Skip to content

Instantly share code, notes, and snippets.

View ConnorAtherton's full-sized avatar
🏠
In the trees 🌲 🌲

Connor Atherton ConnorAtherton

🏠
In the trees 🌲 🌲
View GitHub Profile
@ConnorAtherton
ConnorAtherton / Node.md
Created September 21, 2015 02:34
Node tidbits

Node

From the v8 source

There are three flags available for js: global, ignorecase, and multiline.

/**
* Regular expression flag bits. They can be or'ed to enable a set
* of flags.
def port_open?(ip, port, timeout = 3)
Timeout::timeout(timeout) do
begin
TCPSocket.new(ip, port).close
{open: true}
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
{open: false}
end
end
rescue Timeout::Error
@ConnorAtherton
ConnorAtherton / lint.rb
Created July 16, 2015 02:26
Add this in .git/hooks/pre-commit to check for lint offenses before checking anything in.
#!/usr/bin/env ruby
require 'rubocop'
ADDED_OR_MODIFIED = /A|AM|^M/.freeze
changed_files = `git status --porcelain`
.split(/\n/)
.select { |file| file =~ ADDED_OR_MODIFIED }
.map { |file| file.split(' ')[1] }
@ConnorAtherton
ConnorAtherton / random.rb
Last active August 29, 2015 14:24
Random Ruby
#
# Shorthands
#
%w() # word array delimited by spaces
%r() # is another way to write a regular expression.
%q() # is another way to write a single-quoted string (and can be multi-line, which is useful)
%Q() # gives a double-quoted string
%x() # shell command
%i() # an array of symbols
@ConnorAtherton
ConnorAtherton / gist:dd42f37525af2c403894
Created March 19, 2015 11:34
Helpful linux commands
find_users: cat /etc/passwd | grep "/home" | cut -d: -f1
@ConnorAtherton
ConnorAtherton / gist:cc844309a5a9268f5d52
Created January 25, 2015 01:29
Rails critical css inline
Generates a new stylesheet for each active view helper function called in the view.
- Names it according to the route because we know it is going to be unique.
- Also tried to optimize head links as much as possible for rails apps.
HOWTO
- know which styles are in the head of the document. Maybe using something like capybara?
@ConnorAtherton
ConnorAtherton / gist:1bf40d07198962847ae4
Created December 29, 2014 07:58
Thoughts on a framework..
/config
-> Specify path to folder (intended as a construct your own framework approach)
-> Should be extendable so if we want to add a new concept we can specify it then access it through the app object
/router
-> the router just passes it to the object (controller?) where the method name is the http method type
e.g get("/connor", "connor") would look for just a get method in "ControllerDir"/connor.js.get(req, res);
get("/connor") default to a formatting of the route name (/connor/horse-foot) = connorHorseFoot.js unless name passed in
route("/connor") doesn't care about the method, will pass in and try use method name from the object (throws 404|500 if not found)
resource("/connor") for REST
sockets("/connor") for sockets -> decide on some kind of protocal for message passing. The arguments passed to the controller callback will be different.
@ConnorAtherton
ConnorAtherton / alumni.yml
Last active August 29, 2015 14:06
Alumni 2013
- name:
twitter:
bio: **optional** Max 200 chars
@ConnorAtherton
ConnorAtherton / alumni.yml
Created September 25, 2014 04:39
Alumni 2014
- name: Connor Atherton
twitter: ConnorAtherton6
bio: **optional** max 200 chars
- name:
twitter:
bio: