Skip to content

Instantly share code, notes, and snippets.

View searls's full-sized avatar
💚

Justin Searls searls

💚
View GitHub Profile
interestingMessageReceivedAts: Ember.arrayComputed "messages",
addedItem: (array, message, changeMeta, instanceMeta) ->
console.log 'added', message.get('id')
array
removedItem: (array, message, changeMeta, instanceMeta) ->
console.log 'removed', message.get('id')
array
@searls
searls / grunt-debug
Last active August 29, 2015 13:58
debugging node apps
#!/bin/bash
node --debug-brk $(which grunt) "$@"

123-456-7890

@searls
searls / instructions.md
Created May 2, 2014 12:05
Creating a USB install disk of OS X Mavericks

Apple has changed how it distributes OS X Mavericks since its initial release in October 2013. This note was written on May 2, 2014. This affects the instructions you'll find online for how to make a bootable OS X installer.

It used to be that when you downloaded OS X from the App Store, the entire 5GB installer was placed in /Applications/Install OS X Mavericks.app. Now, there is a simple shortcut program placed in /Applications/OS X Mavericks.app. The app file is immediately removed in the event of an error or a successful post-install launch. When the download succeeds, the app file is launched which brings up the traditional install wizard, but this time mounted to /Volumes/Install OS X Mavericks.

I actually discovered this because if you already have a volume mounted of the same name (which I did, because I was trying to update my existing USB installer), the App Store download promptly fails right after finishing its download.

So if you have an empty disk you'd like to use as an installer that'

@searls
searls / gist:9f1e0f471317811df48d
Last active August 29, 2015 14:01
extract async behavior into mixins
class Foo
constructor: ->
Mixin.callMeAfterRenderHappens(this)
rendered: ->
#do stuff
new MyView(foo).render() #=> Foo#rendered is eventually called
App.Conversation = DS.Model.extend
messages: DS.hasMany('message')
myMessages: (->
@store.filter 'message', (message) =>
message.get('conversation') == this
).property()
@searls
searls / null_client.rb
Last active August 29, 2015 14:04
NullObject for an ActiveRecord object
class NullClient < Client #<-- subclass b/c otherwise form helpers, other things, explode
def _create_record
end
def _update_record
end
def name
end
end
@searls
searls / postgres-regexp_replace.md
Created August 20, 2014 20:01
regex find-and-replace in Postgresql queries

Regex replacements in postgres

I had to make a simple change to all the strings in a table, and I was dreading having to load them into memory, iterate over them, searching for the string, and updating replacements. So instead, I learned that postgresql can actually do regex replacements in an update statement.

For example, if I have a links table with a url column with a bunch of URLs erroneously ending in "?":

Link.where("long_url like '%?'").count #=> 487185
@searls
searls / heroku-set-cedar
Last active August 29, 2015 14:05
Blindly upgrade from Heroku's Bamboo stack to Cedar stack
#!/bin/bash -e
PREV_PWD=`pwd`
mkdir -p "$HOME/tmp"
cd "$HOME/tmp"
echo "-----> Cloning into $1"
heroku git:clone -a $1
cd $1
echo "-----> Setting stack to cedar"
@searls
searls / layout.html.erb
Created August 27, 2014 18:50
Delay implementing a PDF rendering feature by beating Chrome into submission instead
<%= stylesheet_link_tag "application", :media => "screen,print" %>