Skip to content

Instantly share code, notes, and snippets.

Casey Watson watsoncj

Block or report user

Report or block watsoncj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jsmpereira
jsmpereira / gist:1094024
Created Jul 19, 2011
Padrino pagination
View gist:1094024
#
# Adapted from http://pastebin.com/FL5KeQQH
#
# As mentioned on the link above put this on app/helpers/pagination.rb
# and you can use in your view
#
# =will_paginate @posts
#
# I'm also using this https://gist.github.com/837683
#
@daveaugustine
daveaugustine / Inside_your_router.coffee
Created Feb 8, 2012
Super simple Google Analytics page tracking with backbone
View Inside_your_router.coffee
initialize: ->
@bind 'all', @_trackPageview
_trackPageview: ->
url = Backbone.history.getFragment()
_gaq.push(['_trackPageview', "/#{url}"])
@jowl
jowl / gitshot
Created Sep 17, 2012
Take photo automatically after every git commit. Run `gitshot --enable` in project base dir to enable.
View gitshot
#!/usr/bin/env ruby
require 'fileutils'
APP = __FILE__.split('/').last
pwd = Dir.pwd
if ARGV.include? '--enable'
post_commit = File.join(pwd,'.git/hooks/post-commit')
abort('post commit hook already exist!') if File.exists?(post_commit)
View .phoenix.js
// Key combinations
var hyper = ['ctrl','alt','cmd','shift'];
var mash = ['ctrl','alt','cmd'];
// Screen placement movement
api.bind('h', mash, function() { to_left(1, 2); }); // left
api.bind('l', mash, function() { to_right(1, 2); }); // right
api.bind('k', mash, function() { to_top(1, 2); }); // up
api.bind('j', mash, function() { to_bottom(1, 2); }); // down
api.bind('.', mash, function() { to_bottom_right(1, 2); }); // bottom-right
View Why Hypermedia Matters.md

So the brilliance of hypermedia is that it's a protocol programming language: the client is the generic execution environment, and the server is the "programmer" which sends tiny little chunks of programs down to the client to dictate what actions may be taken next, given its context.

The fact that the client also builds a UI is irrelevant to this power. The power is in creating a dynamic, custom protocol by choosing for the client which message structures that will be sent from the client, which is done using merely the tools of hypermedia. The protocol between a client and server is then codified in the hypermedia (e.g. HTML) part of the code which uses links and forms to document the various messages which may pass between client and server, and the client states in which either may be used.

Armstrong's formula for a good protocol:

Client-State, Client-Message => Server-State, Server-Response-Message

But in hypermedia, the server's response dictate's the client state:

@ryanray
ryanray / deploy.rb
Created Nov 21, 2013
I couldn't find a quick example of how to deploy a node.js app using Capistrano 3. This gist assumes you are using Capistrano 3, Upstart, Forever, ssh/forward agent, and an unprivileged user named 'deploy'. Hopefully this simple setup will help to get you started.
View deploy.rb
# config/deploy.rb
# probably a lot of ways to improve this...
set :application, 'my_app'
set :repo_url, 'git@github.com:USERNAME/my_app.git'
# should set up a deploy user
set :user, 'deploy'
set :deploy_to, '/var/www/my_app'
set :scm, :git
@ScottPolhemus
ScottPolhemus / mixins.less
Last active Aug 12, 2018
A collection of LESS mixins.
View mixins.less
//
// LESS Utility Mixins
// -------------------
// Fill the parent element
.fill(@spacing: 0) {
position: absolute;
top: @spacing; bottom: @spacing;
left: @spacing; right: @spacing;
}
@thlorenz
thlorenz / .generating-xcode-via-gyp.md
Last active Aug 26, 2018
Generating Xcode projects from Node.js binding repos via gyp
View .generating-xcode-via-gyp.md

This is specifically tailored to Node.js binding projects in which case the C++ layer is always a library.

Clone gyp:

git clone --depth 1 https://chromium.googlesource.com/external/gyp.git gyp

Add the below common.gypi file in the root of the project.

@joeytwiddle
joeytwiddle / asyncWrappers.js
Last active Jul 1, 2019
Helper to use promises in restify (might also work for express)
View asyncWrappers.js
/**
* Use restify with promises
*
* Restify middleware and route handlers are passed a callback function `next`
* which must be called on success, or on an error.
*
* But you may prefer to define your middleware and routes using promises or
* async functions instead of using callbacks.
*
* To achieve that, simply wrap your middleware functions in `middleware()` and
@mauvm
mauvm / Jasmine-and-Babel6.md
Created Nov 12, 2015
Jasmine ES6 run script for use with Babel 6
View Jasmine-and-Babel6.md
$ npm install --save babel-cli babel-preset-es2015
$ npm install --save-dev jasmine

.babelrc:

{
  "presets": ["es2015"]
You can’t perform that action at this time.