Skip to content

Instantly share code, notes, and snippets.

View eoinkelly's full-sized avatar

Eoin Kelly eoinkelly

View GitHub Profile
@eoinkelly
eoinkelly / each-with-index-in-ember.md
Last active August 29, 2015 13:59
Iterating over a collection with access to the index in Ember

Iterating over a collection with access to the index in Ember

// within your view/component
collectionWithIndices: function () {
  return this.get('collection').map(function (item, idx) {
    item.index = String(idx); // we need 0 to be "0" or Handlebars will consider it falsy
    return item;
  });
}.property('collection.@each'),
@eoinkelly
eoinkelly / ember-inspector-promises-tab-test.js
Last active August 29, 2015 14:01
A test-drive of the Ember Inspector promises tab
// # How to use this:
//
// 1. Open the Ember Inspector on an Ember app (so Ember is loaded)
// 2. Hit the 'clear' button on the Promises tab to remove any promises from the app itself
// 3. Paste this code into the console and watch how the promises inspector displays it
// 4. Twiddle, Rinse & repeat
// 5. More info at
// * https://github.com/kriskowal/q/blob/v1/design/README.js (great for understanding promises)
// * http://emberjs.com/api/classes/Ember.RSVP.Promise.html (Ember promise implementation specifics)
// I am confused about how you can use `call` without supplying an object for `this`
// The docs don't indicate that you can:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call
var funny = function (a) { return (a + 3); }
funny(3); // 6
funny.call({},3); // 6
funny.call(3); // NaN // (as expected)
var xs = [1,2,3]

Keybase proof

I hereby claim:

  • I am eoinkelly on github.
  • I am eoinkelly (https://keybase.io/eoinkelly) on keybase.
  • I have a public key whose fingerprint is 05FB 2362 B986 574E 8E04 10BD 6491 A52A CC5D AABC

To claim this, I am signing this object:

@eoinkelly
eoinkelly / hybrid-apps-2014.md
Last active August 29, 2015 14:11
A brief overview of Hybrid apps in 2014

Hybrid apps in 2014

  • What is is like to build hybrid apps in 2014?
  • How does it differ from mobile development in 2014?

The tools:

  • Webviews
    • WebView not necessairly the same as the built-in browser on the device.
  • Apache Cordova
@eoinkelly
eoinkelly / pg.sh
Last active August 29, 2015 14:11 — forked from cjolly/pg.sh
newpg=9.3.2
oldpg=9.2.4 # set this to your current PG version
# Stop current Postgres server
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
# Backup current db
mv /usr/local/var/postgres/ /usr/local/var/postgres-$oldpg
# Homebrew
@eoinkelly
eoinkelly / allib-get-image-info.php
Created April 13, 2012 06:40
A simple wrapper function to make retrieving information about a WordPress attachment nicer.
<?php
/* Retrieve information about WordPress images without the chaos.
You have to remember a bunch of different functions to get info about images in the
Media Library so I collected their functionality under one wrapper with a (hopefully)
nice interface. This function tries to avoid fetching unnecessary info whenever it can.
I have limited the granularity of the API to not allow fetching different info
about each available image size. I think that would make using this function
more fiddly without any great benefit.
@eoinkelly
eoinkelly / rubies-on-windows-compared.md
Created October 14, 2012 23:31
Comparing Windows MRI 1.9.3, jRuby 1.7.0 RC, Linux MRI 1.9.3

Test Setup

  • All tests run on same machine: Dell Studio XPS 16 Laptop running Windows 7 x64
  • Same codebase except jRuby does use different sqlite adaptor (you cannot use the standard one with jRuby)
  • Code has 4 unit tests (incl. 21 assertions) that all pass.
  • Code is the example app from Agile Web Development with Rails

Goals

  • I wanted to find the fastest way to run my rails tests on my laptop.

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

##
#
class Connection
def self.create_many(inits)
inits.map { |init| new(init) }
end
def self.for_all(conns, &block)
block.call(conns)
end