Skip to content

Instantly share code, notes, and snippets.

View mickey's full-sized avatar

Michael Bensoussan mickey

View GitHub Profile
<html>
<head>
<script src="processing.js"></script>
</head>
<h1>Processing.js</h1>
<h2>Simple processing.js via JavaScript</h2>
<p>Clock</p>
<p><canvas id="canvas1" width="200" height="200"></canvas></p>
# The search is performed half a second after the most recent event in order to prevent the search hapenning on every keypress.
# Each of the event handlers simply marks the time of the most recent event and a timer periodically executes doSearch
class HighlightCurrentWord(sublime_plugin.EventListener):
def __init__(self):
self.previousRegion = sublime.Region(0, 0)
sublime.set_timeout(self.on_timer, 50)
def on_timer(self):
sublime.set_timeout(self.on_timer, 50)
self.doSearch(sublime.active_window().active_view(), False)
require 'base58'
class ShortsController < ApplicationController
def self.short_url_for url
s = Short.find_by_url(url)
if s
s.nb_reqs += 1
else
s = Short.new
s.url = url
@mickey
mickey / gist:970493
Created May 13, 2011 13:04
deploy multiple applications running on the same Engine Yard server
require 'rubygems'
require 'clamp'
class LicCommand < Clamp::Command
option "--[no-]migrate", :flag, "don't run migrations", :default => true
option "--disable", :flag, "disable the apps during the deployment", :default => false
option ["-e", "--environment"], "ENVIRONMENT", "the environment to which you want this application to deploy"
option ["-r", "--ref"], "REF", "branch|tag|ref - default is master", :default => "master"
# encoding: utf-8
class Redirect
def initialize(app)
@app = app
end
def call(env)
redirects = get_redirects
locale = env['rack.session']['locale']
redirects.each do |r|
namespace :assets do
desc "Crush png images"
task :crush_pngs do
Dir['public/**/*.png'].each do |file|
`pngcrush -rem alla -reduce -brute "#{file}" "#{file}.crushing"`
`mv "#{file}.crushing" "#{file}"`
end
end
require 'rubygems'
require 'benchmark'
require 'active_support/all'
n = 50000
Benchmark.bm do |x|
x.report { n.times do ; Date.tomorrow; end }
x.report { n.times do ; Date.today.next; end }
x.report { n.times do ; Date.today.advance(:days => 1); end }
import android.app.Activity
import android.app.ListActivity
import android.widget.TextView
import android.widget.ListView
import android.widget.ArrayAdapter
import android.os.Bundle
class Start < ListActivity
def onCreate(state:Bundle)
super(state)
configure: error: Incorrect libnet version. libnet >= 1.1.2.1 required
Error: #<BuildError: Failed executing: ./configure --disable-debug --disable-dependency-tracking --prefix=/usr/local/Cellar/ettercap-ng/0.7.3 --mandir=/usr/local/Cellar/ettercap-ng/0.7.3/share/man --infodir=/usr/local/Cellar/ettercap-ng/0.7.3/share/info --disable-gtk --disable-plugins --with-openssl=/usr --with-libpcap=/usr --with-libncurses=/usr --with-libpcre=/usr/local --with-libnet=/usr/local>
/usr/local/Library/Homebrew/formula.rb:469:in `system'
/usr/local/Library/Formula/ettercap-ng.rb:33:in `install'
/usr/local/Library/Homebrew/install.rb:92:in `install'
/usr/local/Library/Homebrew/formula.rb:246:in `brew'
/usr/local/Library/Homebrew/formula.rb:530:in `stage'
/usr/local/Library/Homebrew/formula.rb:489:in `mktemp'
/usr/local/Library/Homebrew/formula.rb:528:in `stage'
/usr/local/Library/Homebrew/formula.rb:241:in `brew'
Your OS X is ripe for brewing.
Any troubles you may be experiencing are likely purely psychosomatic.