Skip to content

Instantly share code, notes, and snippets.

View scottmessinger's full-sized avatar

Scott Ames-Messinger scottmessinger

View GitHub Profile
@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: {
@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;
@konklone
konklone / Dockerfile
Created September 22, 2013 18:17
Dockerfile for installing Ruby 2.0 and RVM
FROM ubuntu
MAINTAINER Eric Mill "eric@konklone.com"
# turn on universe packages
RUN echo "deb http://archive.ubuntu.com/ubuntu raring main universe" > /etc/apt/sources.list
RUN apt-get update
# basics
RUN apt-get install -y nginx openssh-server git-core openssh-client curl
RUN apt-get install -y nano
@sbrin
sbrin / index.html
Last active February 10, 2023 22:23
Paste MS Word Text Jquery plugin
<!DOCTYPE html>
<html>
<body>
<div id="src">Source here...</div>
<div id="editor" contenteditable="true">
<p>Place MS-Word text here...</p>
</div>
</body>
</html>
@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;
@machty
machty / document-title-router.js
Created January 14, 2014 05:12
document.title integration in ember
// Extend Ember.Route to add support for sensible
// document.title integration.
Ember.Route.reopen({
// `titleToken` can either be a static string or a function
// that accepts a model object and returns a string (or array
// of strings if there are multiple tokens).
titleToken: null,
@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
@mikelehen
mikelehen / generate-pushid.js
Created February 11, 2015 17:34
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
require 'date'
class FirebasePush
PUSH_CHARS = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'
def initialize
@prev_ts = 0
@rand_chars = Array.new(12)
end
@code0100fun
code0100fun / tests_acceptance_foo-test.js
Last active July 9, 2018 01:05
Ember CLI QUnit text content helpers
// tests/acceptance/foo-test.js
// Assert that text should be found
assert.hasText('Not Found'); // Error: Could not find text "Not Found" on the page
// Provide custom message
assert.hasText('Not Found', 'Expected to find "Not Found"'); // Error: Expected to find "Not Found"
// Find any number of elements containing the query text
text('Found'); // [<div>Found</div>, <input value="Found">]