This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# normal Gem dependancy declarations | |
# ... | |
group :test, :cucumber do | |
gem 'pdf-reader' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
around { |example| with_wait_time(6) { example.run } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.desaturate { | |
filter: grayscale(100%); /* Current draft standard */ | |
-webkit-filter: grayscale(100%); /* New WebKit */ | |
-moz-filter: grayscale(100%); | |
-ms-filter: grayscale(100%); | |
-o-filter: grayscale(100%); /* Not yet supported in Gecko, Opera or IE */ | |
filter: url(resources.svg#desaturate); /* Gecko */ | |
filter: gray; /* IE */ | |
-webkit-filter: grayscale(1); /* Old WebKit */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# ./sscan.py input.mov rownumber output.png | |
# This is meant to be hyper-simple and makes | |
# some assumptions like: you want a row (not | |
# a column), the video is RGB (not gray), etc. | |
# Bug: frame_count is sometimes fractional. | |
# int() and the "if not okay" are workarounds. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var message = "hello, how are you Tal?"; | |
if (~message.indexOf('Tal')) { | |
console.log('found matching text'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('myApp', []).directive('ngDatePicker', function() { | |
return { | |
require: 'ngModel', | |
link: function(scope, element, attrs, ctrl) { | |
element.datepicker({ | |
changeYear: true, | |
changeMonth: true, | |
appendText: '(yyyy-mm-dd)', | |
dateFormat: 'yy-mm-dd', | |
onSelect: function(dateText, inst) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# scope uses merge which looses conditions when chained on the same attribute | |
# see https://github.com/rails/rails/issues/7365 for the issue | |
# see https://github.com/rails/rails/blob/da5e5c5f779355a2e99e63a90612cbeaeb0fc986/activerecord/lib/active_record/relation/spawn_methods.rb#L35 for an explanation | |
# see https://github.com/rails/rails/commit/cd26b6ae7c1546ef8f38302661bbedf8cb487311 for a fix in Rails 4 | |
# The workaround is to just use class methods - we wrap a dsl around just that | |
# Usage: extend ChainableScope in your ActiveRecord::Base derived class | |
module ChainableScope | |
def chainable_scope name | |
raise 'chainable_scope must be called with a block!' unless block_given? | |
define_singleton_method name do |*args| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#old style | |
a={} | |
a[:test] = {} | |
a[:test][:second_test] = 'Hello hash!' | |
# new style | |
# emulates working with directories | |
b = {} | |
b/:test = {} | |
b/:test/:second_test = 'Hello hash!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
def memstats | |
size = `ps -o size= #{$$}`.strip.to_i | |
end | |
memstats #4900 | |
CSV.open('visitors.csv', headers: true) do |csv| | |
visitors = csv.each # Enumerator | |
memstats # 5164 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ArrayInquirer | |
def method_missing method, *args | |
begin | |
select { |elem| elem.send :"#{method}?", *args } | |
rescue NoMethodError | |
super method, *args | |
end | |
end | |
end |