Skip to content

Instantly share code, notes, and snippets.

class List
def initialize
@list = Hash.new(0)
end
def add_item(item)
@list[item] += 1
end
end
@elektronaut
elektronaut / gist:4717588
Last active December 12, 2015 04:49
Processing save frames
boolean output = true;
int frameNumber = 0;
void setup() {
smooth();
size(1280, 720, P3D);
fill(0);
}
void draw() {
default_run_options[:pty] = true
# Name of application
set :application, "yourapp"
# Your username on the server
set :user, "app"
set :runner, user
# Use sudo?
@elektronaut
elektronaut / gist:3483910
Created August 26, 2012 22:21
adaptive.scss
$font-size: 16;
$line-height: $font-size * 1.5;
$column-width: 60;
$gutter-width: 16;
$rem: $font-size / 1rem;
@mixin font-size($size: $font-size) {
font-size: $size + px;
font-size: $size / $rem;
}
# Model
class Foo < ActiveRecord::Base
class << self
def fetch_bar(bar)
self.create({
:bar => open("http://bar.com/#{bar}").read
})
end
end
end
class Numeric
def percent
self.to_f / 100.0
end
end
class Float
def chance?
rand < self
end
// General rich textarea
function jRichTextArea(textArea, options) {
this.textArea = textArea;
// Default options
settings = jQuery.extend({
className: "richTextToolbar"
}, options);
this.toolbar = {
#!/usr/bin/env ruby
# Usage:
#
# Create a list of installed gems:
# $ gem list > my_gems.txt
#
# Copy my_gems.txt to your target and pipe it through this script:
# $ cat my_gems.txt | ./install_gems.rb
tell application "System Events"
set theProcess to "something"
if (get name of processes contains theProcess) then
if (get visible of process theProcess) then
set visible of process theProcess to false
else
set visible of process theProcess to true
activate application theProcess
end if
else
color 1: #E29C17
color 2: #009914
color 1 in decimal: rgb(226, 156, 23)
color 2 in decimal: rgb(0, 153, 20)
colors blended:
rgb((226+0)/2, (156+153)/2, (23+20)/2)
= rgb(113, 154.5, 21.5)