Skip to content

Instantly share code, notes, and snippets.

View jumski's full-sized avatar
🐴
For the lack of a nail, throw new HorseshoeNailNotFoundException("no nails!");

Wojtek Majewski jumski

🐴
For the lack of a nail, throw new HorseshoeNailNotFoundException("no nails!");
  • Independent hacker
View GitHub Profile
angular.module('stateMock',[]);
angular.module('stateMock').service("$state", function($q){
this.expectedTransitions = [];
this.transitionTo = function(stateName){
if(this.expectedTransitions.length > 0){
var expectedState = this.expectedTransitions.shift();
if(expectedState !== stateName){
throw Error("Expected transition to state: " + expectedState + " but transitioned to " + stateName );
}
}else{
@jumski
jumski / invalid_json_spec.rb
Last active August 29, 2015 13:56
Sending invalid json in request specs
it 'responds properly when invalid json was sent' do
send method, path, '{invalid_json]',
'CONTENT_TYPE' => 'application/json',
'ACCEPT' => 'application/json'
expect(response.code.to_i).to eq 400
expect(JSON.parse(response.body)).to equal({'message' => 'Problems parsing JSON'})
end
@jumski
jumski / hax
Created February 19, 2014 15:26
Finished in 2.8 seconds
Finished in 3.15 seconds
Finished in 3.18 seconds
Finished in 3.21 seconds
Finished in 3.31 seconds
Finished in 3.34 seconds
Finished in 3.39 seconds
Finished in 3.41 seconds
Finished in 3.57 seconds
Finished in 3.59 seconds
@jumski
jumski / curspec
Created September 10, 2014 12:27
VIM + Rspec : run spec for last cursor save position
#!/bin/bash
[ -S .zeus.sock ] && PREFIX=zeus
COMMAND="$PREFIX rspec `cat .cursor_last_position`"
VERBOSE=false
echo $COMMAND
$COMMAND
@jumski
jumski / README.md
Last active August 29, 2015 14:07
Capistrano crotab tasks for multiple projects deployed from same user

Capistrano + crontab + multiple projects sharing a linux user

  1. put crontab.cap into lib/capistrano/tasks/crontab.cap
  2. create your crontab file (you can use ERB) and put it somewhere
  3. set crontab_template to point to your crontab file, eg:
set :crontab_template, File.expand_path('./crontab.erb', File.dirname(__FILE__))
function! SpecCommandForCurrentFile(alternate_letter)
let basename = expand("%:t:r")
exec ":".a:alternate_letter."spec ".basename."!"
endfunction
cmap A! call SpecCommandForCurrentFile("R")<cr>
cmap V! call SpecCommandForCurrentFile("V")<cr>
cmap S! call SpecCommandForCurrentFile("S")<cr>
cmap T! call SpecCommandForCurrentFile("T")<cr>
(ns reagent-test.core
(:require [reagent.core :as reagent :refer [atom]]
[datascript :as d]
[cljs-uuid-utils :as uuid]))
(enable-console-print!)
(defn bind
([conn q]
(bind conn q (atom nil)))
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
@jumski
jumski / backbone_sync_hack.coffee
Created August 5, 2011 17:10
BackboneJS sync hack to namespace params when saving/updating model
###
Usage:
* add model.name property that will be used as a namespace in the json request
* put this code before your Backbone app code
* use toJSON() as usual (so there is no namespacing in your templates)
* your model's data will be sent under model.name key when calling save()
###
# save reference to Backbone.sync
Backbone.oldSync = Backbone.sync
<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="urn:AllegroWebApi" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="urn:AllegroWebApi"><env:Body><doCheckNewAuctionExt><fields><fid>1</fid><fvalue-string>Pan Tadeusz</fvalue-string><fvalue-int>0</fvalue-int><fvalue-float>0</fvalue-float><fvalue-image> </fvalue-image><fvalue-datetime>0</fvalue-datetime><fvalue-boolean>false</fvalue-boolean></fields><fields><fid>2</fid><fvalue-string>1829</fvalue-string><fvalue-int>0</fvalue-int><fvalue-float>0</fvalue-float><fvalue-image> </fvalue-image><fvalue-datetime>0</fvalue-datetime><fvalue-boolean>false</fvalue-boolean></fields><fields><fid>3</fid><fvalue-string></fvalue-string><fvalue-int>0</fvalue-int><fvalue-float>0</fvalue-float><fvalue-image> </fvalue-image><fvalue-datetime>2011-11-07T21:53:05+01:00</fvalue-datetime><fvalue-boolean>false</fvalue-boolean></fields><fields><fid>4</fid><fvalu