most of these require logout/restart to take effect
# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false
# Set a shorter Delay until key repeat
;; This is at: https://gist.github.com/8655399 | |
;; So we want a rhyming dictionary in Clojure. Jack Rusher put up | |
;; this code here: | |
;; | |
;; https://gist.github.com/jackrusher/8640437 | |
;; | |
;; I'm going to study this code and learn as I go. | |
;; | |
;; First I put it in a namespace. |
#!/usr/bin/env bash | |
###############FUNCTIONS############ | |
function prepare { | |
#optimize the index | |
echo -n "Optimizing index $INDEX_NAME..." | |
curl -XPOST "$ADDRESS/$INDEX_NAME/_optimize" 2>/dev/null| grep 'failed":0' >/dev/null | |
if [ $? -eq 0 ]; then | |
echo "done" |
class Organization | |
def to_param | |
"42" | |
end | |
def saved? | |
rand > 0.5 | |
end | |
end |
module CustomValidationMatcher | |
class IsValid | |
def matches?(target) | |
@target = target | |
@target.valid? | |
end | |
def failure_message | |
"expected #{ @target.class.name } to be in valid, errors were: #{ @target.errors.full_messages.inspect }" |
/* Simple producer-consumer example using coroutines */ | |
// Our counter | |
counter := 0 | |
// Indicate we're done | |
done := false | |
// Increment a counter by n up to y | |
produce := method(n, y, | |
loop( |
Gemfile.lock |
class MyMigration < Veritas::Migration | |
def call | |
# Transformations | |
# --------------- | |
# 1) remove all columns except id, name and email | |
# 2) rename user_id to id | |
# 3) add a boolean active column, setting the default to false | |
# 4) add a constraint on name where it must be between 1 and 100 characters |
rvm use @$(basename `pwd`) --create |
# This example is an alternative to implementing polymorphic associations | |
# using an ActiveRecord-esque 'type' column. In this model, there are many | |
# 'units.' Unit is an abstract supertype. Descendants are modeled referencing | |
# a unit by 'unit_id', a foreign key to the primary key in the units model. | |
# Note: This approach maintains referential integrity in the database via | |
# descendants' FK to unit.id; however, it is the application's responsibility | |
# to ensure that no two descendants reference the same unit. This is an | |
# intrinsic limitation of the "Class Table Inheritance" approach, but it's | |
# a lot better than maintaining "type" data that is opaque to the data store. |