Skip to content

Instantly share code, notes, and snippets.

View scottmessinger's full-sized avatar

Scott Ames-Messinger scottmessinger

View GitHub Profile
@jszmajda
jszmajda / dot_notation.rb
Last active August 29, 2015 14:04
Dot Notation
# Simple-ish enumberable-simplifier. Useful for APIs like Twitter, etc
#
# If you have a hash or an array or something that quacks like one, you can do stuff
# example:
# h = {a: {b: {c: [{d: 'hi'}]}}}
# h.extend(DotNotation)
# h.dot('a.b.c.0.d')
# #=> 'hi'
# h.dot('a.b.c.foo.bar.bz.whatever.124.whocares')
# #=> nil
@peterc
peterc / embedded_document_delete.rb
Created March 13, 2010 02:27
MongoMapper to give EmbeddedDocument a "delete" method
# MongoMapper "embedded document delete" plugin
# By Peter Cooper
#
# Got embedded documents you want to delete? You can delete them as if the
# embedded document collection were an array, but then there's no way to get
# a callback (as far as I could tell). This plugin gives you a call back
# (if you want it) and gives a nicer syntax to deleting embedded docs.
#
# Example:
#
@panayi
panayi / gist:2781592
Created May 24, 2012 13:38
Ember.js: Animating view with JQ.Animation mixin
JQ.Animate = Ember.Mixin.create({
cssProperties: ['background', 'backgroundAttachment', 'backgroundColor', 'backgroundImage', 'backgroundPosition',
'backgroundRepeat', 'border', 'borderBottom', 'borderBottomColor', 'borderBottomStyle', 'borderBottomWidth',
'borderColor', 'borderLeft', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', 'borderRight', 'borderRightColor',
'borderRightStyle', 'borderRightWidth', 'borderStyle', 'borderTop', 'borderTopColor', 'borderTopStyle', 'borderTopWidth',
'borderWidth', 'clear', 'clip', 'color', 'cursor', 'display', 'filter', 'font', 'fontFamily', 'fontSize',
'fontVariant', 'fontWeight', 'height', 'left', 'letterSpacing', 'lineHeight', 'listStyle', 'listStyleImage',
'listStylePosition', 'listStyleType', 'margin', 'marginBottom', 'marginLeft', 'marginRight', 'marginTop', 'overflow',
'padding', 'paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop', 'pageBreakAfter', 'pageBreakBefore',
'position', 'styleFloat', 'textAlign', 'textDecoration'
@workmanw
workmanw / Feedback.md
Created July 3, 2012 19:44
Feedback on Ember `VIEW_PRESERVES_CONTEXT`

After a mind numbing week of updating all of the templates in our app and thinking about the implications of this change, I'd like to provide a little bit of feedback on this change.

Overall, I view this change as unfavorable. It's not that I dislike the change, it's that I don't find much value in it and it was a very daunting task to push to Ember users.

Template Simplification

From what I've gathered the purpose of this change is to "significantly reduce the verbosity of templates". I did not find that my templates either grew or shrank in size, they really remained constant. I believe one of the intended ways for reducing size was the elimination for the need of contentBinding="this" on {{view}} helpers. E.g.

{{#each App.photosController}}
@lukemelia
lukemelia / config.ru
Created July 4, 2012 22:06
Example rack app for Ember development
require 'bundler/setup'
require 'sass'
require 'compass'
require 'rake-pipeline'
require 'listen'
require 'rack/lock'
require 'ruby-debug'
require 'securerandom'
require 'ruby_gntp'
@pjlammertyn
pjlammertyn / Ember.Editable.js
Created August 8, 2012 12:51
Ember.Editable mixin
Ember.Editable = Ember.Mixin.create({
_originalPropertyStates: Ember.Map.create(),
_isEditing: false,
willDestroy: function () {
var $this = this;
for (var prop in this.getOwnProperties()) {
Ember.removeBeforeObserver($this, prop, $this, '_beforePropertyChange');
//Ember.removeObserver($this, prop, $this, '_propertyChanged');
}
@go1dfish
go1dfish / array_filter.js
Created October 2, 2012 02:45
Ember.js ArrayProxy based ArrayFilter implementation
Ember.ArrayFilter = Em.ArrayProxy.extend({
init: function() {
this._filterContentDidChange();
this._super();
},
arrangedContent: function() {
var af = this;
return Ember.ArrayFilterSortProxy.create({
arrayFilter: af,
@mmun
mmun / groupBy.js
Last active December 31, 2015 11:39
Computed groupBy
(function() {
var get = Ember.get, set = Ember.set;
function findItemInsertionIndex(group, changeMeta, instanceMeta) {
for (var i = get(group, 'length') - 1; i >= 0; i--) {
var currentItem = group.objectAt(i),
currentIndex = instanceMeta.itemGuidToIndex[Ember.guidFor(currentItem)];
if (currentIndex < changeMeta.index) {
return i + 1;
@lukemelia
lukemelia / buffered_proxy.js
Last active May 5, 2016 20:47
Buffered Proxy, extracted from Yapp codebase
var empty, get, set,
__hasProp = {}.hasOwnProperty;
get = Ember.get;
set = Ember.set;
empty = function(obj) {
var key;
for (key in obj) {
if (!__hasProp.call(obj, key)) continue;
@bravoecho
bravoecho / flattener.rb
Created November 28, 2012 13:16
flatten nested hash - recursive vs non-recursive
require 'pry'
data = {
a: {
alfa: "alfa",
beta: "beta"
},
b: 2,
c: {
alfa: {