Skip to content

Instantly share code, notes, and snippets.

View MarkBennett's full-sized avatar

Mark Bennett MarkBennett

View GitHub Profile
@MarkBennett
MarkBennett / gist:775636
Created January 12, 2011 03:14
tmux-session.sh
#!/bin/sh
#
# window 0 = irc
# window 1 = development server
# window 2 = vim w/ autotest split
# window 3 = console
# window 4 = remote server
tmux new-session -s litdistco -n irc \; new-window -n server \; new-window -n vim \; split-window -d -p 30 \; new-window -n console \; new-window -n remote
function Human(name, age) {
this.name = name;
this.age = age;
}
bob = new Human("bob", 30);
bob.name; // "bob"
bob.age; // 30
@MarkBennett
MarkBennett / importer.rb
Created February 13, 2011 01:28
Simple CSV importer
module PublisherImporter
extend self
# Import a csv given it's full path
def import(csv_path)
CSV.foreach(csv_path, :headers => true) do |row|
import_row(row)
end
end
##BEGIN - Hug##
___ ____ ___
____( \ .-' `-. / )____
(____ \_____ / (O O) \ _____/ ____)
(____ `-----( ) )-----' ____)
(____ _____________\ .____. /_____________ ____)
(______/ `-.____.-' \______)
##END##
@MarkBennett
MarkBennett / tmux-session.sh
Created April 7, 2011 21:02
A newer version of a tmux session script
#!/bin/sh
tmux new-session -s migration -n irc -d
tmux new-window -n migration
tmux new-window -n log1
tmux split-window -d -p 30
tmux new-window -n log2
tmux new-window -n log3
tmux new-window -n log4
tmux attach
@MarkBennett
MarkBennett / beta.js
Created April 13, 2011 19:06
One way to write the BetaHandler
function countletters(event){
var max=jQuery(this).attr('maxlength');
var valLen=jQuery(this).val().length;
if(valLen > max) {
jQuery(this).val(jQuery(this).val().substring(0, max));
valLen=max;
}
jQuery("div.counter").text( valLen+'/'+max);
}
@MarkBennett
MarkBennett / Vagrantfile
Created May 2, 2011 20:24
Chef / Vagrant setup
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "base"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
@MarkBennett
MarkBennett / hello_jello.js
Created June 20, 2011 21:38
How would you improve this code?
function say_hello(name) {
msg = "Hello, " + name + "!"
alert(msg);
};
say_hello("Jello")
@MarkBennett
MarkBennett / gist:1061159
Created July 2, 2011 16:41
Google+ Share HTTP Request
Request URL:https://plus.google.com/u/0/_/sharebox/post/?_reqid=632995&rt=j
Request Method:POST
Status Code:200 OK
Query String Parametersview URL encoded
_reqid:632995
rt:j
Request Payload
spar=%5B%22Testing%20to%20see%20what%20kind%20of%20XHR%20requests%20are%20made%20when%20I%20share%20something%20on%20Google%2B.%20Can't%20find%20a%20good%20Chrome%20extenstion%20to%20share%20so%20thinking%20I%20might%20hack%20a%20quick%20one%20if%20it's%20not%20to%20hard.%22%2C%22oz%3A104431949275766772757.130eb661e76.0%22%2Cnull%2Cnull%2Cnull%2Cnull%2C%22%5B%5C%22%5Bnull%2Cnull%2Cnull%2C%5C%5C%5C%22share%20on%20google%2B%20-%20Chrome%20Web%20Store%5C%5C%5C%22%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%5B%5D%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%5C%5C%5C%22Find%20great%20apps%2C%20extensions%20and%20themes%20about%20share%20on%20google%2B%20in%20the%20Chrome%20Web%20Store.%5C%5C%5C%22%2Cnull%2Cnull%2C%5Bnull%2C%5C%5C%5C%22https%3A%2F%2Fchrome.google.com%2Fwebstore%2Fsearch%3Fhl%3Den-US%
@MarkBennett
MarkBennett / rspec_matcher_be_indexed_on.rb
Created July 11, 2011 18:45
RSpec matcher for table indexes
# Playlist.should be_indexed_on([:name])
RSpec::Matchers.define :be_indexed_on do |expected|
match do |actual|
indexes = ActiveRecord::Base.connection.indexes(actual.table_name)
expected.map!(&:to_s)
indexes.map { |index| index.columns.map(&:to_s) }.include?(expected)
end
end