Skip to content

Instantly share code, notes, and snippets.

View mrbanzai's full-sized avatar

Michael Porter mrbanzai

  • Lightning Source, LLC
  • Raleigh, NC
View GitHub Profile
(function ($) {
function autoSubmitHandler ($input, $button) {
var self = this;
this.$input = this;
this.$button = $button;
this.$input.on('keydown', function (e) { self.handleInputKeydown(e); });
this.$input.on('blur', function (e) { self.handleInputBlur(e); });
@ccashwell
ccashwell / github_ssh.sh
Created November 8, 2012 22:29
Bash Scripting: OAUTH2 Authorization, Generating SSH keys and Adding Keys to GitHub
#!/bin/bash
# This is an example of OAUTH2 authorization via GitHub and adding a new (optionally generated) SSH key to your account.
# If generated, the key is put in the default location with no password. Security is obviously relaxed for brevity's sake. Enjoy.
read -p "GitHub Username: " uname
read -s -p "GitHub Password: " passwd
if [[ "$uname" == "" || "$passwd" == "" ]]; then
echo -e "\n\nCan't set up your GitHub SSH keys without authorization. You're on your own now, champ."
exit 1
fi
@domenic
domenic / promises.md
Last active March 31, 2024 14:07
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@wilmoore
wilmoore / readme.md
Last active February 11, 2024 22:32
UMD-inspired Module Boilerplate

UMD-Inspired JS Module Boilerplate

This is the module format you don't know you need until you need it. Write your module once and have it work in a CJS/NodeJs, AMD, YUI (v3+), or Browser Global environment.

Best Used When...

  • You are migrating from namespaced (err, globals) code to either AMD or CJS modules or both.
  • You can't yet factor out browser globals but also need to test your code via NodeJS (e.g. Mocha).

Benefits & Trade-offs

@mklnz
mklnz / capistrano_sudo_helpers.rb
Created April 17, 2012 18:12
Sudo put and template methods for Capistrano
# I got tired of uploading to /tmp then moving to the correct location, so these two convenience methods will save you a lot of time in the long run.
# Helper method to upload to /tmp then use sudo to move to correct location.
def put_sudo(data, to)
filename = File.basename(to)
to_directory = File.dirname(to)
put data, "/tmp/#{filename}"
run "#{sudo} mv /tmp/#{filename} #{to_directory}"
end
@sbusso
sbusso / simple_ruby_daemon.rb
Created March 5, 2012 13:50 — forked from mynameisrufus/.gitignore
Simple ruby daemon
#!/usr/bin/env ruby
# == Simple Daemon
#
# A simple ruby daemon that you copy and change as needed.
#
# === How does it work?
#
# All this program does is fork the current process (creates a copy of
# itself) then exits, the fork (child process) then goes on to run your
# daemon code. In this example we are just running a while loop with a
@nesquena
nesquena / linode_fog.rb
Created October 28, 2011 09:24
Linode and Fog Samples
## DNS
@dns = Fog::DNS.new(:provider => 'Linode', :linode_api_key => LINODE_KEY)
if @zone = @dns.zones.all.find { |z| z.domain == ZONE }
puts "Found zone #{@zone.inspect}"
else
@zone = @dns.zones.create(:domain => ZONE, :email => ZONE_EMAIL)
puts "Creating zone #{@zone.inspect}"
end
@karmi
karmi / workers.rake
Created July 22, 2010 15:58
Rake taks to launch multiple Resque workers in development/production with simple management included
# Rake task to launch multiple Resque workers in development/production with simple management included
require 'resque/tasks' # Require Resque tasks
namespace :workers do
# = $ rake workers:start
#
# Launch multiple Resque workers with the Rails environment loaded,
# so they have access to your models, etc.