Skip to content

Instantly share code, notes, and snippets.

View jclem's full-sized avatar
🪄

Jonathan Clem jclem

🪄
View GitHub Profile
@jclem
jclem / gifify.sh
Last active December 11, 2015 16:19
Shell script for turning .mov files into .gifs and posting to Cloudapp
#!/bin/bash
function printHelpAndExit {
echo 'Usage:'
echo ' gifify -coux filename'
echo ''
echo 'Options: (all optional)'
echo ' c CROP: The x and y crops, from the top left of the image, i.e. 640:480'
echo ' o OUTPUT: The basename of the file to be output (default "output")'
echo ' u: Upload the resulting image to CloudApp'
@jclem
jclem / gifify_alfred.sh
Last active December 12, 2015 07:29
Shell script for starting the Gifify process from Alfred
name=gifify_`date +%s`
echo -ne $name | pbcopy
osascript <<EOF
tell application "System Events"
set visible of process "Terminal" to false
end tell
tell application "QuickTime Player"
activate
GIT
remote: git://github.com/searls/jasmine-rails.git
revision: 1f7991488103d58b927b1736394afedb21c7aede
specs:
jasmine-rails (0.3.2)
jasmine (~> 1.3)
jasmine-headless-webkit
rails (>= 3.1.0)
GEM
alive_sec = (Time.now - start_time).to_i
worker_pid = Process.pid
@@kill_attempts ||= 0
sig = :QUIT
sig = :TERM if @@kill_attempts > configuration.max_quit
sig = :KILL if @@kill_attempts > configuration.max_term
logger.warn "#{self} send SIG#{sig} (pid: #{worker_pid}) alive: #{alive_sec} sec (trial #{i})"
Process.kill sig, worker_pid
def self.kill_self(logger, start_time)
alive_sec = (Time.now - start_time).to_i
worker_pid = Process.pid
@@kill_attempts ||= 0
sig = :QUIT
sig = :TERM if @@kill_attempts > configuration.max_quit
sig = :KILL if @@kill_attempts > configuration.max_term
logger.warn "#{self} send SIG#{sig} (pid: #{worker_pid}) alive: #{alive_sec} sec (trial #{i})"
def self.kill_self(logger, start_time)
alive_sec = (Time.now - start_time).to_i
worker_pid = Process.pid
@@kill_attempts ||= 0
@@kill_attempts += 1
sig = :QUIT
sig = :TERM if @@kill_attempts > configuration.max_quit
sig = :KILL if @@kill_attempts > configuration.max_term
@jclem
jclem / myFunction.js.coffee
Created March 17, 2013 00:23
DOM ready binding for Rails 4 turbolinks. DOM ready functions need to be rebound after clicking a Turbolinks link. so use something like this to ensure that your DOM ready events still get bound properly.
$.turbobind ->
$('.element').on 'click', (e) ->
console.log('woohoo!')
class Pet < ActiveRecord::Base
belongs_to :person
end
class Person < ActiveRecord::Base
has_many :pets do
def names
collect(&:name)
end
end
#!/bin/bash
function printHelpAndExit {
echo 'Usage:'
echo ' gifify -conx filename'
echo ''
echo 'Options: (all optional)'
echo ' c CROP: The x and y crops, from the top left of the image, i.e. 640:480'
echo ' o OUTPUT: The basename of the file to be output (default "output")'
echo ' n: Do not upload the resulting image to CloudApp'
$ ->
$('img[data-retina]').each ->
if window.devicePixelRatio > 1
src = $(this).attr('src')
retinaSrc = src.replace /(\.[a-z]+$)/, "@2x$1"
$(this).attr('src', retinaSrc)