Skip to content

Instantly share code, notes, and snippets.

View unimatrixZxero's full-sized avatar
🌱
💎

Sam Figueroa unimatrixZxero

🌱
💎
View GitHub Profile
@mattheworiordan
mattheworiordan / Gemfile
Created September 7, 2011 12:06
Test PDF within Cucumber and Capybara
# normal Gem dependancy declarations
# ...
group :test, :cucumber do
gem 'pdf-reader'
end
@ChristianPeters
ChristianPeters / example_feature_spec.rb
Created June 27, 2014 14:03
Wait longer in Capybara
around { |example| with_wait_time(6) { example.run } }
@internoma
internoma / style-desaturate.css
Created January 6, 2013 11:07
Desaturate & saturate css3
.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 */
}
#!/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.
@paulosborne
paulosborne / gist:7640679
Created November 25, 2013 12:40
Hipster indexOf
var message = "hello, how are you Tal?";
if (~message.indexOf('Tal')) {
console.log('found matching text');
}
@EpokK
EpokK / ngDatePicker.js
Last active December 19, 2015 23:59
ng-datePicker
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) {
# 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|
#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!'
@orend
orend / gist:5134300
Created March 11, 2013 13:40
Streaming with csv, from ruby tapas
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
module ArrayInquirer
def method_missing method, *args
begin
select { |elem| elem.send :"#{method}?", *args }
rescue NoMethodError
super method, *args
end
end
end