Skip to content

Instantly share code, notes, and snippets.

View elado's full-sized avatar
👨‍💻

Elad Ossadon elado

👨‍💻
View GitHub Profile
app = angular.module 'checkboxListApp'
app.directive 'checkboxList', ->
restrict: 'AE'
replace: true
scope:
list: '='
model: '=ngModel'
@elado
elado / eo-keepratio.coffee
Created May 20, 2014 19:32
Responsive Boxes: Keep Ratio of Width and Height
# By Elad Ossadon
app = angular.module 'eo-keepratio'
SPACERS =
'1:1': "R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
'16:10': "R0lGODlhEAAKAIAAAP///wAAACH5BAEAAAAALAAAAAAQAAoAAAILhI+py+0Po5y0rgIAOw=="
'16:9': "R0lGODlhEAAJAIAAAP///wAAACH5BAEAAAAALAAAAAAQAAkAAAIKhI+py+0Po5yUFQA7"
'4:3': "R0lGODlhBAADAIAAAP///wAAACH5BAEAAAAALAAAAAAEAAMAAAIDhI9WADs="
'3:1': "R0lGODlhAwABAIAAAP///wAAACH5BAEAAAAALAAAAAADAAEAAAIChAsAOw=="
@elado
elado / app.coffee
Last active August 29, 2015 14:05
Angular Resource - Share all instances of a query across entire app
app = angular.module 'my-app', ['eo-cached-resource-action']
app.factory 'Category', ($resource, cachedResourceAction) ->
Category = $resource "/categories/:id/:action", {id: '@id'}, {
query: { method: 'GET', cache: true, isArray: true }
}
Category.query = cachedResourceAction.wrapArrayAction(Category.query)
Category
@elado
elado / grape-encoding_spec.rb
Created October 22, 2014 20:05
Grape Encoding Test (currently fails)
# -*- encoding : utf-8 -*-
require 'spec_helper'
require 'shared/versioning_examples'
describe Grape::API do
module EncodingSpec
class API < Grape::API
params do
requires :a
@elado
elado / gulp-sass-parallel.js
Last active August 29, 2015 14:20
gulp-sass-parallel
function sass(path) {
var cssFilter = $.filter('**/*.css');
return gulp.src(path, { base: 'app', dot: true })
.pipe($.changed($.config.tmp, {extension: '.css'}))
.pipe($.plumber())
.pipe($.rubySass({
container: path.replace(/[\*\/]/g, "_")
}))
@elado
elado / slug_rack_app.rb
Last active August 29, 2015 14:23
Rails conditional controller
# routes.rb (very bottom route):
match '*path' => SlugRackApp
# slug_rack_app.rb
class SlugRackApp
def self.call(env)
path = env["action_dispatch.request.path_parameters"][:path]
@elado
elado / proxy-server.js
Created September 11, 2015 16:09
Proxy all requests to another server, add Access-Control headers
var http = require('http'),
httpProxy = require('http-proxy');
var proxy = httpProxy.createProxyServer({});
var server = http.createServer(function (req, res) {
console.log(req.url, req.method);
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Request-Method', '*');
@elado
elado / gist:979577
Created May 18, 2011 21:14
Blocks with closures errors in Obj-C
@interface TestClass : NSObject {
#if NS_BLOCKS_AVAILABLE
void (^blk)(void);
#endif
}
- (id)initWithBlock:(void (^)(void))block;
- (void)exec;
@end
@implementation TestClass
@elado
elado / Rakefile
Created May 21, 2011 18:13
Fix Rails with Rake 0.9
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'rake'
################################
# fixes rake 0.9 bug w/ rails
################################
module ::RailsAppNameHere
@elado
elado / gist:1004030
Created June 2, 2011 06:40
Date Regexp Validator
^((29\/0?2(?=\/(\d{2}(0[48]|[13579][26]|[2468][048])|
([13579][26]|[2468][048])00))|([01]?\d|2[0-8])\/(0?\d|1[0-2])|
(29|30)\/(0?[13-9]|1[0-2])|31\/(0?[13578]|1[02]))\/\d{4})$