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())
@fabiomcosta
fabiomcosta / sync-settimout-snippet.js
Created August 26, 2011 21:06
Mocks the setTimeout function with jasmine, making setTimeout dependent tests synchronous and easier to test.
// inside your beforeEach hook
spyOn(window, 'setTimeout').andCallFake(function(fn){
fn.apply(null, [].slice.call(arguments, 2));
return +new Date;
});
...
@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 / 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')
@dchelimsky
dchelimsky / output.txt
Created March 16, 2012 15:28
RSpec is not the reason your rails test suite is slow
[david: compare]$ # at this point we have a stock rails app with no minitest tests and one pending rspec example
[david: compare]$
[david: compare]$ time rake test
Run options:
# Running tests:
Finished tests in 0.030419s, 0.0000 tests/s, 0.0000 assertions/s.
@roberto
roberto / _flash_messages.html.erb
Created August 13, 2012 22:47
Rails flash messages using Twitter Bootstrap
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
@eethann
eethann / _.objMapFunctions.js
Created August 23, 2012 01:05
Underscore mixin with common iterator functions adapted to work with objects and maintain key/val pairs.
_.mixin({
// ### _.objMap
// _.map for objects, keeps key/value associations
objMap: function (input, mapper, context) {
return _.reduce(input, function (obj, v, k) {
obj[k] = mapper.call(context, v, k, input);
return obj;
}, {}, context);
},
// ### _.objFilter
@jrmoran
jrmoran / controllers.coffee
Created November 28, 2012 18:43
AngularJS Testing Controllers with Testacular & Testem
# = require '../components/jquery/jquery'
# = require '../components/angular-complete/angular'
Controllers = angular.module 'controllers', []
Controllers.controller 'PhoneListCtrl', ['$scope', ($scope)->
$scope.phones = [
{name: "Nexus S", snippet: "Fast just got faster with Nexus S."},
@ayamomiji
ayamomiji / gist:4736614
Last active November 10, 2017 11:16
turbolinks + angularjs
bootstrapAngular = ->
$('[ng-app]').each ->
module = $(this).attr('ng-app')
angular.bootstrap(this, [module])
$(document).on('page:load', bootstrapAngular)
@dorkalev
dorkalev / a start
Last active December 23, 2015 08:29
sentence = "there is a wild rose"
letters = sentence.gsub(' ','').split(//)