Skip to content

Instantly share code, notes, and snippets.

View mikz's full-sized avatar

Michal Cichra mikz

View GitHub Profile
@kenichi
kenichi / wsd.rb
Last active September 8, 2015 20:49
WebSocket::Driver client example with Celluloid::IO
require 'websocket/driver'
require 'socket'
require 'forwardable'
require 'celluloid/io'
class WSDTester
include Celluloid::IO
include Celluloid::Logger
extend Forwardable
#!/usr/bin/env macruby
# encoding: utf-8
CALENDARS = ['Michal Cichra', 'Calendar'] # Set names of calendars to show
before = 3 # days to show before today
after = 10 # days to show after today
today = 'dnes'
@scottmessinger
scottmessinger / gist:1018177
Created June 10, 2011 03:15
Model has no method '_configure'
Relevant Code:::
var Course = Backbone.Model.extend({
url : function(){
var base = 'courses'
if (this.isNew()) return base;
return base + (base.charAt(base.length-1) == '/'?'' : '/') + this.id;
}
})
@shaneog
shaneog / gist:1198248
Created September 6, 2011 17:12
elasticsearch ubuntu 11.04
cd ~
# Install the required JDK
sudo apt-get install openjdk-6-jre-headless
# Download, extract and move ElasticSearch
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.17.6.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
@mikz
mikz / gist:1337933
Created November 3, 2011 22:07
Rate current song in iTunes - Alfred Extension - requires macruby
read -s -r -d '' SCRIPT <<"EOF"
framework 'ScriptingBridge'
rating = ARGV.pop
itunes = SBApplication.applicationWithBundleIdentifier("com.apple.itunes")
track = itunes.currentTrack
track.rating = rating.to_f*20
puts "#{track.artist} - #{track.name} rated #{rating} stars"
EOF
@mikz
mikz / unicorn.rb
Created April 2, 2012 13:59
unicorn config
preload_app true
worker_processes 2
listen 3000
before_fork do |server, worker|
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
@jalberto
jalberto / remote_cache_with_project_root_strategy.rb
Created May 6, 2014 14:17
Capistrano 3.1.x Strategy to deploy git projects with subdirectories
# Usage:
# 1. Drop this file into lib/capistrano/remote_cache_with_project_root_strategy.rb
# 2. Add the following to your Capfile:
# require 'capistrano/git'
# require './lib/capistrano/remote_cache_with_project_root_strategy'
# 3. Add the following to your config/deploy.rb
# set :git_strategy, RemoteCacheWithProjectRootStrategy
# set :project_root, 'subdir/path'
# Define a new SCM strategy, so we can deploy only a subdirectory of our repo.
BARE_EDITOR="/home/rgrau/programmingStuff/emacs-snapshot/bin/emacsclient"
function elm {
last_mig=$(ls -tr db/migrate | tail -n1)
$BARE_EDITOR -n db/migrate/$last_mig
}
@mikz
mikz / alias.sh
Created November 15, 2012 16:21
Tiny script to run ruby files or run all files in directory (usefull for tests)
alias rt="ruby -Itest -I. -e \"alias rt="ruby -Itest -I. -e \"require'pathname';P=Pathname;ARGV.map{|a|p=P.new(a);next unless p.exist?;p.directory?? P.glob(p.join('**/*.rb')):p}.flatten.compact.uniq.each{|p|require p.expand_path}\""\""
@rmoriz
rmoriz / 1.md
Last active December 14, 2015 19:49
RubyMotion + Philips Hue SDK