Skip to content

Instantly share code, notes, and snippets.

View batter's full-sized avatar

Ben Atkins batter

View GitHub Profile
@WaKeMaTTa
WaKeMaTTa / prototype-to-jquery.md
Last active October 10, 2018 19:27
Converting from Prototype to jQuery (v1)

Converting from Prototype to jQuery

Selecting DOM elements

Prototype’s selector returns DOM elements.

$("element_id");
// return: <div id="element_id"></div>
@JoshCheek
JoshCheek / modulo_arithmetic_1.rb
Last active November 20, 2016 08:28
Playing with Ryan's Graphics lib
# https://vimeo.com/192116528
require "graphics"
class Clock < Graphics::Simulation
def initialize
@radius = 400
@margin = 20
@increment_rate = 0.0009
@num_lines = 1600
@line_width = 2
@brandondurham
brandondurham / styles.less
Last active June 24, 2024 14:48
Using Operator Mono in Atom
/**
* Using Operator Mono in Atom
*
* 1. Open up Atom Preferences.
* 2. Click the “Open Config Folder” button.
* 3. In the new window’s tree view on the left you should see a file called “styles.less”. Open that up.
* 4. Copy and paste the CSS below into that file. As long as you have Operator Mono SSm installed you should be golden!
* 5. Tweak away.
*
* Theme from the screenshot (http://cdn.typography.com/assets/images/blog/operator_ide2.png):
@olivierlacan
olivierlacan / migrate_postgresql_database.md
Last active March 24, 2022 20:30
How to migrate a Homebrew-installed PostgreSQL database to a new major version (9.3 to 9.4) on OS X. See upgraded version of this guide: http://olivierlacan.com/posts/migrating-homebrew-postgres-to-a-new-version/

This guide assumes that you recently run brew upgrade postgresql and discovered to your dismay that you accidentally bumped from one major version to another: say 9.3.x to 9.4.x. Yes, that is a major version bump in PG land.

First let's check something.

brew info postgresql

The top of what gets printed as a result is the most important:

@sebmarkbage
sebmarkbage / Enhance.js
Last active November 7, 2024 13:05
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@dineshrajpurohit
dineshrajpurohit / RootedTreeTraversal.js
Last active September 27, 2018 05:38
Preorder, Postorder,Inorder and Levelorder traversal of rooted trees using Javascript
/**
*
* Dinesh
*
* RootedTreeTraversal
* - Preorder Traversal
* - Postorder Traversal
* - Inorder Traversal
* - Levelorder Traversal
*
@quirkey
quirkey / console_helpers.rb
Last active February 13, 2020 19:57
All the code for the Paperless Profiler
require 'rblineprof'
module Rblineprof
module ConsoleHelpers
include Rblineprof::Helpers
def lineprof_block(options = {}, &block)
profile = lineprof(rblineprof_profiler_regex(options[:lineprofiler])) do
ret = yield
end
json.array! @ranking.results_with_change.each_with_index.to_a do |args|
# We can't unpack the args in the block param because Jbuilder does
# something magic.
(user, player, diff), index = *args
json.rank index+1
json.user user, :id, :facebook_id, :name, :square_avatar
json.score player.r.to_i
json.change_today diff.to_i
@nathany
nathany / config.ru
Last active May 3, 2019 17:10
Magical Unicorn Configuration for Heroku
# add something like this to config.ru
# see https://github.com/kzk/unicorn-worker-killer
if Integer(ENV['UNICORN_KILLER'] || 0) != 0
require 'unicorn/worker_killer'
# Max memory size (RSS) per worker
use Unicorn::WorkerKiller::Oom, (350*(1024**2)), (400*(1024**2)), 30, true
end
@tonycoco
tonycoco / tm2-bundles
Created September 14, 2012 17:01
TextMate 2 Bundles
These are some needed bundles for TM2...
cd ~/Library/Application Support/Avian/Bundles
git clone https://github.com/cucumber/cucumber-tmbundle Cucumber.tmbundle
git clone https://github.com/kuroir/SCSS.tmbundle
git clone https://github.com/mads379/Whitespace.tmbundle
open Cucumber.tmbundle/color_themes/Sunburst.tmTheme