Skip to content

Instantly share code, notes, and snippets.

View rsgrafx's full-sized avatar
🏠
Working from home

Orion Engleton rsgrafx

🏠
Working from home
View GitHub Profile
@rsgrafx
rsgrafx / gist:9862471
Created March 29, 2014 20:37
I started using Enumerable#detect. Decided to have a little fun with procs.
#!/Users/orionengleton/.rvm/rubies/ruby-2.1.1/bin/ruby
log = [
{time: 201201, x: 2},{time: 201201, y: 7},{time: 201201, z: 2},
{time: 201202, a: 3},{time: 201202, b: 4},{time: 201202, c: 0}
]
# Required - Results.
required_result = [{:time=>201201, :x=>2, :y=>7, :z=>2}, {:time=>201202, :a=>3, :b=>4, :c=>0}]
# Using global variables * and #Procs
@rsgrafx
rsgrafx / gist:9846923
Last active August 29, 2015 13:57
Angular Directive to embed gists by using url passed in as attribute.
Usage:
// <show-code url='https://gist.github.com/your-user-name/XXXXX.js'></show-code>
angular.module('yourAppName')
.directive('showCode', function () {
return {
restrict: 'E',
transclude: true,
scope: {
url: '@url'
angular.module('cardUiApp')
.directive('card', function () {
return {
template: ' content',
restrict: 'AE',
scope: {
name: '@',
amount: '=',
save: '&'
},
@rsgrafx
rsgrafx / gist:5436732
Last active December 16, 2015 12:48
Brain dump ... Using singletons, forwardable, delegation. - Commented out code - the non ruby way. After several months of objective c development you tend to forget the elegance of Ruby. but thankfully I found my way back.
puts "#{ENV['RUBY_VERSION']}"
require 'rubygems'
require 'httparty'
require 'forwardable'
module Rulers
module Model
module HttpModel
@rsgrafx
rsgrafx / gist:2320717
Created April 6, 2012 15:19
Is this Good Practice? Storing in outside Objects accessed by a constant.
#!/usr/bin/env ruby
OUTSIDE_STATE = true
NAMES = {:objects => []}
module CheckSelf
module ClassMethods
def self.inherited(child)
::NAMES[:objects] << child
end