Skip to content

Instantly share code, notes, and snippets.

View mkwiatkowski's full-sized avatar

Michal Kwiatkowski mkwiatkowski

View GitHub Profile
@mkwiatkowski
mkwiatkowski / git-diff-branches.py
Created June 10, 2011 08:58
Shows commits present only in one of the two branches.
#!/usr/bin/python
# Shows commits present only in one of the two branches.
import commands
import sys
def commits_in_branch(branch):
status, output = commands.getstatusoutput("git log --no-color --pretty=oneline %s" % branch)
return set(output.splitlines())
@mkwiatkowski
mkwiatkowski / helloworld.clj
Created September 17, 2011 14:18
Compojure hello world application
(ns helloworld
(:gen-class)
(:use compojure.core
ring.adapter.jetty
clojure.contrib.command-line)
(:require [compojure.route :as route]))
(defroutes main-routes
(GET "/" [] "<h1>Hello World</h1>")
(route/not-found "<h1>Page not found</h1>"))
@mkwiatkowski
mkwiatkowski / Gemfile
Created September 17, 2011 14:29
Rails hello world application
source 'http://rubygems.org'
gem 'rails', '3.1.0'
gem 'sqlite3'
gem 'json'
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
@mkwiatkowski
mkwiatkowski / debugPage.coffee
Created February 17, 2012 13:53
WebPage debugging function for phantomjs
debugPage = (page) =>
console.log(page.evaluate -> window.location.toString())
fs = require('fs')
fs.write('output.html', page.content, 'w')
page.render('output.png')
@mkwiatkowski
mkwiatkowski / gist:2157174
Created March 22, 2012 08:40
phantomjs WebPage calls onLoadFinished two times for iframe
page = new WebPage()
page.onConsoleMessage = (msg) ->
console.log(msg)
page.onLoadStarted = ->
console.log('onLoadStarted')
page.onLoadFinished = (status) ->
isFullyLoaded = page.evaluate ->
class WebRequest
MOBILE_USER_AGENTS = r/palm|blackberry|nokia|phone|midp|mobi|symbian|chtml|ericsson|minimo|audiovox|motorola|samsung|telit|upg1|windows ce|ucweb|astel|plucker|x320|x240|j2me|sgh|portable|sprint|docomo|kddi|softbank|android|mmp|pdxgw|netfront|xiino|vodafone|portalmmm|sagem|mot-|sie-|ipod|up\.b|webos|amoi|novarra|cdm|alcatel|pocket|ipad|iphone|mobileexplorer|mobile/i
attr_reader :time, :ip, :referer, :user_agent
def initialize(time, ip, referer, user_agent)
@time = time
@ip = ip
@referer = referer
@user_agent = user_agent
$ gem install dict
Fetching: dict-0.0.8.gem (100%)
Successfully installed dict-0.0.8
1 gem installed
Installing ri documentation for dict-0.0.8...
Building YARD (yri) index for dict-0.0.8...
Installing RDoc documentation for dict-0.0.8...
$ translate
Please enter the word. (-h for help)
$ rspec
/home/mk/work/dict-gem/lib/dictpl.rb:10:in `initialize': No given word (ArgumentError)
from /home/mk/work/dict-gem/lib/dictpl.rb:53:in `new'
from /home/mk/work/dict-gem/lib/dictpl.rb:53:in `<top (required)>'
from /home/mk/work/dict-gem/spec/lib_dictpl_spec.rb:2:in `require_relative'
from /home/mk/work/dict-gem/spec/lib_dictpl_spec.rb:2:in `<top (required)>'
from /home/mk/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:746:in `load'
from /home/mk/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:746:in `block in load_spec_files'
from /home/mk/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:746:in `map'
from /home/mk/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:746:in `load_spec_files'
rspec spec/
: speck
: specs
: aspect
: respect
: inspect
: suspect
: to inspect
: circumspect
: prospect
$ rspec spec/
............
Finished in 3.7 seconds
12 examples, 0 failures