Skip to content

Instantly share code, notes, and snippets.

require 'prawn'
Prawn::Document.generate('crop-marks.pdf') do
spacing = 12
margin = 100
canvas do
# topleft corner
stroke_line [bounds.left + spacing, bounds.top - margin],
[bounds.left + margin - spacing, bounds.top - margin]
$(document).ready(function(){
$("a.tab").live('click', function () {
$(".content").hide();
$("ul.tabs .active").removeClass("active");
$(this).addClass("active");
$("#" + $(this).attr("title")).show();
});
@remear
remear / face_detector.rb
Created December 7, 2011 22:16 — forked from mattetti/face_detector.rb
Macruby Face Detection in Mac OS X Lion. Usage: $ macruby face_detector.rb or $ macruby face_detector.rb image_url
framework 'Cocoa'
class NSColor
def toCGColor
color_RGB = colorUsingColorSpaceName(NSCalibratedRGBColorSpace)
## approach #1
# components = Array.new(4){Pointer.new(:double)}
# color_RGB.getRed(components[0],
# green: components[1],
# blue: components[2],
@remear
remear / gist:1672746
Created January 24, 2012 21:13 — forked from seanlilmateus/gist:1536136
macruby core animation Fireworks, have a nice macruby new year
#!/usr/local/bin/macruby
framework 'Cocoa'
framework 'QuartzCore'
class FireworkDelegate
attr_accessor :window
def initWithURL(url)
case url
when String
@firework_photo_url = NSURL.URLWithString(url)
@remear
remear / gist:1724911
Created February 2, 2012 18:09 — forked from akitaonrails/gist:1724673
Fixing Apachebench on OS X Lion
# If you're getting this error trying to use ApacheBench on OS X Lion:
# Benchmarking mwmanning.com (be patient)...apr_socket_recv: Connection reset by peer (54)
#
# You need to download the latest beta version of Apache and rebuild ab.
# Here's how (assuming you have homebrew installed).
# Install Homebrew (https://github.com/mxcl/homebrew) and then the Perl Regex support
brew install pcre
# Download the latest from http://httpd.apache.org/download.cgi, then decompress and compile it
@remear
remear / eunic
Created February 9, 2012 23:10 — forked from pjammer/eunic
i put this into /usr/local/bin/eunic and you can your server using eunic -s && eunic -N
#!/bin/bash
set -u
set -e
#change this below to your actual path. If you another environemnt like staging, fucking change N to -e staging instead.
APP_PATH=/youpath/to/app/root
PID=$APP_PATH/tmp/pids/unicorn.pid
OLD_PID=$APP_PATH/tmp/pids/unicorn.pid.oldbin
UNICORN_COMMAND="unicorn_rails -c $APP_PATH/config/unicorn.rb -D"
while getopts ":nsNr" opt; do
@remear
remear / gist:4003564
Created November 2, 2012 18:52 — forked from dumindu/gist:3359218
How to target mobile devices with CSS Media Queries
@media only screen and (-webkit-device-pixel-ratio: .75) {
/* CSS for Low-density Android screens goes here *
* Ex: HTC Evo, HTC Incredible, Nexus One */
}
@media only screen and (-webkit-device-pixel-ratio: 1) and (max-device-width: 768px) {
/* CSS for Medium-density Android screens goes here *
* Ex: Samsung Ace, Kindle Fire, Macbook Pro *
* max-device-width added so you don't target laptops and desktops */
}
@remear
remear / ajax-form.js
Created February 25, 2013 02:20 — forked from havvg/ajax-form.js
jQuery(function($) {
$('form[data-async]').live('submit', function(event) {
var $form = $(this);
var $target = $($form.attr('data-target'));
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),
@remear
remear / .zshrc
Created February 27, 2013 21:55 — forked from SlexAxton/.zshrc
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else

Install Python

$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7

Symlinks...