Skip to content

Instantly share code, notes, and snippets.

View madis's full-sized avatar
🧑‍💻
code mode

Madis Nõmme madis

🧑‍💻
code mode
View GitHub Profile
@madis
madis / gist:4650014
Created January 27, 2013 19:40
Testing CORS OPTIONS request with curl
curl \
--verbose \
--request OPTIONS \
http://localhost:3001/api/configuration/visitor \
--header 'Origin: http://localhost:9292' \
--header 'Access-Control-Request-Headers: Origin, Accept, Content-Type' \
--header 'Access-Control-Request-Method: GET'
# http://nils-blum-oeste.net/cors-api-with-oauth2-authentication-using-rails-and-angularjs/#.UQJeLkp4ZyE
@madis
madis / javascript_debugging.js
Created February 12, 2013 16:56
Javascript debugging
// Creating a script tag & adding it to page
jCookie=document.createElement('script');
jCookie.type = 'text/javascript';
jCookie.src = "https://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js";
$('body').append(jCookie)
@madis
madis / useful_postgres_snippets.md
Last active December 13, 2015 21:48
Postgres administration & other useful snippets
@madis
madis / coffeescript_inheritance.coffee
Created March 11, 2013 21:45
Playing with coffeescript inheritance
class Base
@doSomething: (@origin) ->
console.log "Base.doSomething called"
@showSomething: ->
console.log "Showing something", @things
@createSomething: (something) ->
new @
@madis
madis / install_ruby_2.0.0.sh
Created July 20, 2013 12:56
Installing Ruby 2 with openssl libraries linking issue
# Will get you past the ssl library linking issue
rvm pkg install openssl
rvm install --autolibs=packages --with-openssl-dir=$HOME/.rvm/usr 2.0.0
@madis
madis / install_rails_from_master.sh
Created July 20, 2013 17:12
Creating new rails app from rails/rails master
# Some info
# http://www.drurly.com/blog/2012/09/08/create-a-rails-4-project/
# http://stackoverflow.com/questions/12333726/how-to-create-a-rails-project-using-rails-master-beta-4-0-0
git clone https://github.com/rails/rails.git
ruby rails/railties/bin/rails new fooapp --dev
rails -v # => Rails 4.0.0.beta
@madis
madis / useful_ruby_rails_snippets.rb
Created August 4, 2013 11:09
Useful Ruby & Rails snippets
# Running only fast tests on command line
`zeus test -t ~slow spec`
# Getting the profiling information for RSpec runs
`echo "--profile">> .rspec`
@madis
madis / postgres_setup.md
Last active December 21, 2015 03:18
OS X installing postgres. Setting up postgres roles and database
# Install postgres
brew install postgres

# Create folder for logs
mkdir -p /usr/local/var/postgres/

# Set permissions
chmod 700 /usr/local/var/postgres
@madis
madis / option_arrow_bash.md
Last active July 18, 2016 12:21
Use [option] + [arrow] on OS X iterm2 to move and delete by word
  1. in ~/.inputrc:
"\M-d": backward-kill-word
"\e[1;5C": forward-word
"\e[1;5D": backward-word
  1. iTerm2 preferences: Profiles -> Keys
@madis
madis / for_1.9.3.c
Last active December 23, 2015 12:19
Compiling geoip-c for ruby 2.0.0 vs 1.9.3 mkmf error
// Compile with:
// export RUBY_DIR=$HOME/.rvm/rubies/ruby-1.9.3-p448
// gcc-4.6 -o for_1.9.3 -I$RUBY_DIR/include/ruby-1.9.1/x86_64-darwin12.4.1 -I$RUBY_DIR/include/ruby-1.9.1/ruby/backward -I$RUBY_DIR/include/ruby-1.9.1 -Iext/geoip -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fno-common -pipe for_1.9.3.c -L. -L$RUBY_DIR/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -liconv -lruby.1.9.1 -lGeoIP -liconv -lpthread -ldl -lobjc
#include "ruby.h"
int t() { GeoIP_record_by_ipnum(); return 0