Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am nzaillian on github.
  • I am nzaillian (https://keybase.io/nzaillian) on keybase.
  • I have a public key whose fingerprint is 8FD2 A81C 5FC8 8010 2AF0 70CD 4580 1CED AC00 074C

To claim this, I am signing this object:

@nzaillian
nzaillian / cache_digests.rake
Last active December 20, 2015 11:59
cache_digests dependency dump rake task updated for Rails 4
# The functionality from the cache_digests gem (https://github.com/rails/cache_digests)
# has been merged into actionpack for Rails 4,
# but the handy rake task to dump the template dependency hierarchy for a given template
# to the console didn't. Here's the rake task from DHH's cache_digests project tree, updated
# for ActionView in Rails 4. Copy it to your project's lib/tasks directory as "cache_digests.rake"
namespace :cache_digests do
desc 'Lookup nested dependencies for TEMPLATE (like messages/show or comments/_comment.html)'
task :nested_dependencies => :environment do
raise 'You must provide TEMPLATE for the task to run' unless ENV['TEMPLATE'].present?
@nzaillian
nzaillian / configuration
Last active December 19, 2015 10:59
My personal pattern for storing configuration info
# The personal pattern I've devised for storing module or app-wide configuration
# info in ruby projects
require 'ostruct'
module SomeApp
class Configuration
def self.method_missing(*args)
config.send *args
@nzaillian
nzaillian / gist:5461534
Created April 25, 2013 17:28
Sublime Text SASS block commenting fix
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<!-- <dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>source.sass</string>
<key>settings</key>
<dict>
@nzaillian
nzaillian / serialized_attr_accessor.rb
Created March 27, 2012 17:10
A Rails initializer to patch dedicated accessors/mutator methods for the keys of serialized hash properties onto model instances
# A Rails initializer that adds accessor/mutator methods
# of the form "instance.property_key" for any serialized (hash) attribute
# of your models. Stick contents in a file called serialized_attr_accessor.rb
# or similar and place it in your config/initializers directory.
#
# usage:
#
# class MyModel < ActiveRecord::Base
#
# # your model has a serialized hash attribute "settings"
@nzaillian
nzaillian / gist:746853
Created December 18, 2010 20:27
open new tab to current working directory in Mac OS X's Terminal.app
#!/bin/bash
#place this somewhere in Bash's $PATH and chmod +x it....
working_dir=$PWD
/usr/bin/osascript<<END
on run
tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
tell application "Terminal" to do script "cd $working_dir" in front window
end run
END
@nzaillian
nzaillian / Issuing queries against Flickr's REST API using AS3
Created November 26, 2010 20:29
Issuing queries against Flickr's REST API from AS3
/*
Example usage:
var fj:FlickrJSON = new FlickrJSON(YOUR_API_KEY);
fj.loader.addEventListener(Event.COMPLETE, YOUR_LOAD_COMPLETE_CALLBACK_FUNCTION);
fj.doCall(FLICKR_API_METHOD_AS_STRING, {PARAM_1_NAME_AS_STRING : PARAM_1_VALUE_AS_STRING, ...});
you will want to convert the response string that you get in your callback to a native Object. To do this, simply use the
static method FlickrJSON.objectFromResponse.
"""Found myself needing to emulate key presses in an application on OS X. The solution was the following:"""
import os
def press_key(key):
cmd = "osascript -e 'tell application \"System Events\" to keystroke \"" + key + "\"'"
os.system(cmd)