Skip to content

Instantly share code, notes, and snippets.

@PlaidShirtPat
PlaidShirtPat / web-servers.md
Created April 18, 2018 21:38 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@PlaidShirtPat
PlaidShirtPat / thing.ruby
Created February 18, 2016 22:13
_null format
# What your call should look like
AddressModel.formatted
# the definition
my_var = [
address_line1,
address_line2,
address_city,
"#{address_state} #{address_zip}"
].reject(&:blank?).join(", ")
@PlaidShirtPat
PlaidShirtPat / SyncQueue.js
Last active November 16, 2015 03:25
Basic worker queue
//call back should be your getInfo function, which now should look like getInfo(url, callback)
//callback should be some non-blocking async function
function SyncQueue(maxWorkers, callback){
var newQueue = {
"maxWorkers": maxWorkers,
"currentWorkers": 0,
"pendingUrls": [],
//use this to add a url to the queue
@PlaidShirtPat
PlaidShirtPat / version.txt
Created November 14, 2015 01:46
vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 26 2015 17:51:52)
Included patches: 1-761
Compiled by patrick@patrick-linux-dev
Huge version with GTK2 GUI. Features included (+) or not (-):
+acl +farsi +mouse_netterm +syntax
+arabic +file_in_path +mouse_sgr +tag_binary
+autocmd +find_in_path -mouse_sysmouse +tag_old_static
+balloon_eval +float +mouse_urxvt -tag_any_white
+browse +folding +mouse_xterm -tcl
++builtin_terms -footer +multi_byte +terminfo
@PlaidShirtPat
PlaidShirtPat / config.md
Last active October 26, 2015 01:00
ssh config
Host git-account-1
  HostName github.com
  IdentityFile /home/myaccount/.ssh/account1.pem
  User git
  
Host git-account-2
  HostName github.com
  IdentityFile /home/myaccount/.ssh/account2.pem
 User git
= pad_fields.fields_for :icon_pad_names do |pad_name_fields|
- if pad_name_fields.object.language.enabled
.mdl-textfield.mdl-js-textfield.mdl-textfield--floating-label
= pad_name_fields.text_field :name, class: "mdl-textfield__input"
= pad_name_fields.label :name, class: "mdl-textfield__label" do
= pad_name_fields.object.language.name
function generateEveryValidAttributeName();
function toJSONObject(item){
var jsonString = "{";
var everyAttribute =
for(i=0; i<generateEveryValidAttributeName(); i++){
if(item.hasOwnProperty(generateEveryValidAttributeName()[i]){
jsonString = jsonString +
'"' + generateEveryValidAttributeName()[i] + '": ' +
item[generateEveryValidAttributeName()[i]].to_json() + ',';
----- template ------
<my-section>
<header>
{{dirList.length}}
</header>
<section-body>
<my-dir/>
</section-body>
</my-section>
Two tables:
Categories
:id,
:name
Instances
:id,
:category_id,
:another_id,
@PlaidShirtPat
PlaidShirtPat / gist:880165243897586c90c0
Created October 30, 2014 02:10
Attempt at refactoring common pattern in my code
class ApplicationController < ActionController::Base
private
#shared code, called from different controlers to render custom_json
#from their models with optional params
def render_custom_json(model, opts={})
#check if model is a relation and a record and cheat check that it's items
#respond to :custom_json
if((model.is_a?(ActiveRecord::Relation) || model.is_a?(Enumerable)) &&
model.first.respond_to?(:custom_json))