Skip to content

Instantly share code, notes, and snippets.

View martinisoft's full-sized avatar
🏠
Coding from home

Aaron Kalin martinisoft

🏠
Coding from home
View GitHub Profile
@martinisoft
martinisoft / gistie.rb
Created September 23, 2008 06:29 — forked from pieter/gistie.rb
command-line posting to gist
#!/usr/bin/env ruby
# Made by Pieter de Bie <frimmirf@gmail.com>
# Based on a "Pastie" task by someone
require "tempfile"
GIST_URL = 'http://gist.github.com/gists'
GIST_LOGIN_URL = 'https://gist.github.com/session'
USERNAME = "martinisoft"
TOKEN = "6ef8395fecf207165f1a82178ae1b984"
@martinisoft
martinisoft / main.cpp
Created June 8, 2009 04:58
List files in directory recursively
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
// getdir - returns vector of files in all directories of directory
@martinisoft
martinisoft / kick_safari.sh
Created November 12, 2009 05:47
kick Safari when you edit html files for instant previews
kicker -e "osascript -e 'tell application \"Safari\" to do JavaScript \"window.location.reload();\" in first document'" index.html
require "pty"
require "expect"
STDOUT.sync = true
STDERR.sync = true
$expect_verbose = true
prompt_pat = %r/^[\s]{1}/
PTY.spawn("/home/martinisoft/srcds/orangebox/srcds_run -game tf +ip 192.168.1.8 +maxplayers 8 +map ctf_2fort") do |output, input, pid|
input.sync = true
require 'eventmachine'
module EventMachine
module Protocols
class SRCDS < Connection
include EventMachine::Deferrable
def initialize
@authed = false
@commands = { "exec" => 2, "auth" => 3 }
@martinisoft
martinisoft / jquery_setup.rake
Created July 6, 2010 01:24
Rake task to setup a Rails 3 app for jQuery instead of Prototype
# Rails 3 jQuery Install Rakefile
# by Aaron Kalin
# Compiled from http://www.railsinside.com/tips/451-howto-unobtrusive-javascript-with-rails-3.html
#
# Note: this assumes you use git, if not then use the optional usage
#
# Usage: rake install_query
#
# Optional usage: rake install_jquery[nogit]
#
@martinisoft
martinisoft / tpl-cukeapp.rb
Created October 24, 2010 04:35
Rails 3, RSpec, Cucumber, Factory_Girl, HAML, SASS, Devise, Formtastic Template
## Rails App Template
## Updated for Rails 3.0.1
## Created on 10/23/10
## Updated on 11/4/10
## Run using $ rails new [appname] -JT -m tpl-cukeapp.rb
## Gems
# Warden and Devise for security
gem 'warden', '0.10.7'
run("echo group :test, :development do >> Gemfile;")
run("echo gem \\'rspec-rails\\', \\'\\>\\= 2.3.0\\' >> Gemfile;")
run("echo gem \\'capybara\\', \\'0.3.9\\' >> Gemfile;")
run("echo gem \\'database_cleaner\\' >> Gemfile;")
run("echo gem \\'cucumber-rails\\' >> Gemfile;")
run("echo gem \\'launchy\\' >> Gemfile;")
run("echo end >> Gemfile;")
run("bundle install")
@martinisoft
martinisoft / regext.txt
Created August 23, 2011 02:35 — forked from jt/regext.txt
Regular expression notes
- any character you use it will literally match it except special characters
^ $ ? . / \ [ ] { } ( ) + * - all the special characters that will need escaping if you don't want them to be special
// - regexp ruby class
Common Patterns (I authored)
/[\w+\.~-]+@[\w~-]+.[\w\.]+/ - match emails, conforms to RFC 3986 section 3.3
/\+?(\d)?[-|\.|\s]?\(?(\d{3})\)?[-|\.|\s]?(\d{3})[-|\.|\s]?(\d{4})/ - match phone numbers, https://gist.github.com/1009331
Strategies
@martinisoft
martinisoft / gist:1235506
Created September 22, 2011 18:04
rbx build fail log
gort:~ martinisoft$ rvm install -n 1.9 rbx -- --default-version=1.9rbx-head-1.9 installing #dependencies Pulling from origin master
Copying from repo to source...
rbx-head-1.9 - #configuring
rbx-head-1.9 - #compiling
rbx-head-1.9 - adjusting #shebangs for (erb ri rdoc).
rbx-head-1.9 - #importing default gemsets (/Users/martinisoft/.rvm/gemsets/)
WARN: rbx rbx-1.9-head-1.9 is not installed.
To install do: 'rvm install rbx-1.9-head-1.9'
gort:~ martinisoft$ rvm list