Skip to content

Instantly share code, notes, and snippets.

View alexrothenberg's full-sized avatar

Alex Rothenberg alexrothenberg

View GitHub Profile
#!/usr/bin/env ruby
require 'fileutils'
def analyze
Dir.glob("public/dist/**/*.{js,css}").reduce({}) do |hash, filename|
filename =~ /public\/dist\/([^-]*)(-.{10})?\.(.*)/
name = "#{$1}.#{$3}"
# puts name
hash[name] = File.new(filename).size
signups = cuco_session.course_signups.includes(:course_role, :course).where(person: family.people)
count = signups.where(person_id: person.id).joins(:course).where(courses: { period_id: period.id }).count
##
x = cuco_session.course_signups
y = x.includes(:course_role, :course)
signups = y.where(person: family.people)
a = signups.where(person_id: person.id)
// What should we call the things under each day?
// Its kinda like a recurring event but not quite
// "WeeklyScheduleEventThingy"? We can do better!
// http://delorean/schedules?staff_member_uid=asdfasdfasfd
// create, update, index, show
{
"schedule": {
"start_date": "2016-01-01",
'use strict';
describe('Offers : controller', function(){
beforeEach(module('client'));
var $scope,
genericService;
@alexrothenberg
alexrothenberg / gist:8d50d3302ebe234e94cf
Created December 19, 2014 16:24
Simple caching for angular.js
"use strict";
angular.module('gatewayApp')
.factory('Cache', [function(){
var cache = {};
var _get = function(key) {
var cacheHit = cache[key];
if (_exists(cacheHit) && _notExpired(cacheHit)) {
return cacheHit.value;
} else {
### Keybase proof
I hereby claim:
* I am alexrothenberg on github.
* I am alexrothenberg (https://keybase.io/alexrothenberg) on keybase.
* I have a public key whose fingerprint is BD37 11A2 4CA9 9DC3 FE1F 1F4B E978 24DB 3CDB 639F
To claim this, I am signing this object:
@alexrothenberg
alexrothenberg / Rakefile
Created March 19, 2014 14:10
stub api calls for rubymotion calabash tests
Motion::Project::App.setup do |app|
app.info_plist['API_BASE_URL'] = ENV['API_BASE_URL'] || 'http://api.myserver.com'
end
task :cucumber => [:stub, :'build:simulator', :'calabash:run']
task :stub do
ENV['API_BASE_URL'] = 'http://stub.example.com'
end
@alexrothenberg
alexrothenberg / gist:9393607
Created March 6, 2014 16:31
MRI/JRuby/Rubinius discrepency
MRI - detect with a lambda complains about 2 parameters but map works
$ irb
2.1.1 :001 > lambda = ->(word, index) { word.length == 3 }
=> #<Proc:0x007fb52d00ab38@(irb):1 (lambda)>
2.1.1 :002 > %w(Hi there how are you).each_with_index.detect &lambda
ArgumentError: wrong number of arguments (1 for 2)
from (irb):1:in `block in irb_binding'
from (irb):2:in `each'
from (irb):2:in `each_with_index'
-(void)someBigMethod {
// create a screenshot
CALayer * screenLayer = [[[[[UIApplication sharedApplication] keyWindow] rootViewController] view] layer];
CGFloat const shotScale = ([[UIScreen mainScreen] scale] / 2.0);
UIGraphicsBeginImageContextWithOptions(screenLayer.bounds.size, YES, shotScale);
[screenLayer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// put the screenshot in a layer