Skip to content

Instantly share code, notes, and snippets.

@zef
zef / check_image_dimensions.rb
Created December 3, 2013 18:39
Prints a list of @2x assets that have odd dimensions. Requires imagemagick and the mini_magick gem.
require 'mini_magick'
root_path = '/Users/zef/Dropbox/code/some_project'
local_path = 'some_project/assets'
path = File.join(root_path, local_path, '**.png')
list = []
Dir.glob(path).each do |file|
@zef
zef / gist:4080042
Created November 15, 2012 17:46
Shell commands for seeing space taken by .log files and truncating them.
# how much space is being taken up by .log files?
find . -regex '.*\.log' -exec du -hc {} +
# recursively clear all .log files in current directory
find . -regex '.*\.log' -exec cp /dev/null {} \;
# view .log files sorted by file size
find . -regex '.*\.log' -print0 | xargs -0 du | sort -gr
class CellView < UIView
SIZE = 20
def initWithCell(cell)
if init
self.backgroundColor = UIColor.blackColor
# self.layer.cornerRadius = 4.0
# self.layer.cornerRadius = SIZE/2
self.frame = [[cell.x * SIZE, cell.y * SIZE], [SIZE, SIZE]]
emojify!
@zef
zef / jquery.spin.coffee
Created June 26, 2012 20:33 — forked from innotekservices/jquery.spin.js
jQuery Plugin for Spin.js (Coffescript)
# A jQuery Wrapper around spin.js
# Has sane defaults and uses the color attribute of the target selector
#
# http://fgnass.github.com/spin.js/
#
# preset_name - size of spinner: 'small' or 'large'
# customizations - any option from spin.js
#
# Examples:
#
@zef
zef / coordinates.js
Created September 5, 2011 21:22
Added coordinates for Dvorak for the keyboard heatmap demo here: http://www.patrick-wied.at/projects/heatmap-keyboard/
app.QWERTY_COORDINATES = {
"~": [35, 120],
"`": [35, 120],
"1": [90, 120],
"!": [90, 120],
"2": [144, 120],
"@": [144, 120],
"3": [198, 120],
"#": [198, 120],
"4": [253, 120],
tell application "System Events"
set app_name to name of the first process whose frontmost is true
set visible of process app_name to false
end tell
tell application "Finder"
activate
end tell
@zef
zef / address_book_phone_updater.rb
Created December 3, 2010 21:58
Iterates through Address Book phone numbers so you can change the format programatically.
# Zef Houssney
# http://madebykiwi.com
#
# rb-appscript documentation:
# http://appscript.sourceforge.net/rb-appscript/index.html
#
# Install rb-appscript with:
# sudo gem install rb-appscript
# Make sure to backup your address book before doing this!!!
@zef
zef / gist:631585
Created October 18, 2010 02:01
Example of chord chart formatting
G D/F# Em
She said I don't know if I've ever been good enough
C2 G D/F# Em C2
I'm a little bit rusty, and I think my head is caving in
G D/F# Em
And I don't know if I've ever been really loved
C2 G D/F# Em
By a hand that's touched me, and I feel like somethings gonna give
C2
And I'm a little bit angry
/*
* jQuery UI CSS Framework
* Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.
*/
/* Layout helpers
----------------------------------*/
.ui-helper-hidden { display: none; }
.ui-helper-hidden-accessible { position: absolute; left: -99999999px; }
# This is an incomplete implementation.
module MongoMapper
module NestedAttributes
def self.included(base)
base.extend(ClassMethods)
base.send :include, InstanceMethods
end
module ClassMethods
def accepts_nested_attributes_for(*attr_names)