Skip to content

Instantly share code, notes, and snippets.

View montague's full-sized avatar

Ian Asaff montague

  • Outside Boston
View GitHub Profile
iex(26)> [head | tail] = [1,2,3]
[1, 2, 3]
iex(27)> head
1
iex(28)> tail
[2, 3]
iex(29)> [tail | head]
[[2, 3] | 1]
iex(30)> [head | tail]
[1, 2, 3]
@montague
montague / gist:147dffb9bf3163d96b45
Created April 2, 2015 19:59
Create "card" example for stripe API v1
using System;
using System.Net;
using System.IO;
using System.Text;
namespace stripe_example
{
class MainClass
{
public static void Main (string[] args)
image = Image.new([[1, 1, 0, 0],
[0, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]])
Test.assert_equals(Person.new("ian").greet("sam"), "Hi sam, my name is ian")
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev libffi-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p195.tar.gz
tar -xvzf ruby-2.0.0-p195.tar.gz
cd ruby-2.0.0-p195/
./configure --prefix=/usr/local
make
make install
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
# see this http://stackoverflow.com/questions/357754/can-i-traverse-symlinked-directories-in-ruby-with-a-glob
Dir[Rails.root.join("spec/support/**{,/*/**}/*.rb")].each {|f| require f}
@montague
montague / gist:3209712
Created July 30, 2012 20:04
bash prompt
#shows ruby version, current dir, current branch
export PS1="\[\e[0m\][\$(~/.rvm/bin/rvm-prompt i v g)]\[\e[1;36m\]\$(parse_git_branch)\[\e[0m\]:\W$ \[\e[0;91m\]"
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
<html>
<head>
<script type="text/javascript" charset="utf-8">
$(function(){
$('#submit_button').click(function(){
var url = "/post/to/this/url";
$.post(url, $('form').serialize(), function(responseData, ajaxStatus){
//this is the callback function that fires upon completion of the ajax post request
//the 'data' parameter holds whatever the server returned in response to to the post request
//here, i am assuming the server returns a message that is intended to be displayed to the user ("missing data", "info submitted", etc)