This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
import redis | |
import random | |
import pylibmc | |
import sys | |
r = redis.Redis(host = 'localhost', port = 6389) | |
mc = pylibmc.Client(['localhost:11222']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[clojure.java.classpath :as cp]) | |
(cp/classpath-directories) | |
;; => | |
;; (#object[java.io.File 0x49d2af93 "/Users/rcanepa/Development/colossus/simpleclerk_v2/scv2backend/test"] | |
;; #object[java.io.File 0x5ad1f78e "/Users/rcanepa/Development/colossus/simpleclerk_v2/scv2backend/dev"] | |
;; #object[java.io.File 0x15548223 "/Users/rcanepa/Development/colossus/simpleclerk_v2/scv2backend/dev-resources"] | |
;; #object[java.io.File 0x40ec6a80 "/Users/rcanepa/Development/colossus/simpleclerk_v2/scv2backend/src"] | |
;; #object[java.io.File 0x698fb58a "/Users/rcanepa/Development/colossus/simpleclerk_v2/scv2backend/resources"] | |
;; #object[java.io.File 0x44b0d626 "/Users/rcanepa/Development/colossus/simpleclerk_v2/scv2backend/target/base+system+user+dev+dev/classes"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------ | |
From psql | |
------------------ | |
- Check all database sizes | |
\l+ | |
- Connect to database DBNAME | |
\connect DBNAME | |
- Check the table sizes from database DBNAME |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------ | |
OSX | |
------------------ | |
- Install redis via homebrew | |
homebrew install redis | |
- Tap services to start/stop services | |
brew tap homebrew/services | |
- Start, stop or restart redis |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Checking types | |
Object.prototype.toString.call([]); // [object Array] | |
Object.prototype.toString.call({}); // [object Object] | |
Object.prototype.toString.call(''); // [object String] | |
Object.prototype.toString.call(new Date()); // [object Date] | |
Object.prototype.toString.call(1); // [object Number] | |
Object.prototype.toString.call(function () {}); // [object Function] | |
Object.prototype.toString.call(/test/i); // [object RegExp] | |
Object.prototype.toString.call(true); // [object Boolean] | |
Object.prototype.toString.call(null); // [object Null] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Starting data: 2 reserves on two different meeting rooms. | |
M1: Meeting Room 1 | |
M2: Meeting Room 2 | |
M1 M2 | |
07 | |
08 | |
09 x | |
10 x x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add office- prefix to all files on a directory | |
ls | xargs -I {} mv {} office-{} | |
# Add office- prefix to all .js files on a directory | |
ls | grep .js | xargs -I {} mv {} office-{} | |
More information: | |
http://stackoverflow.com/questions/6329505/how-to-rename-all-file-in-a-folder-with-a-prefix-in-a-single-unix-command |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE EXTENSION btree_gist; | |
CREATE TABLE room_reservations ( | |
room_id integer, | |
reserved_at timestamptz, | |
reserved_until timestamptz, | |
canceled boolean DEFAULT false, | |
EXCLUDE USING gist ( | |
room_id WITH =, tstzrange(reserved_at, reserved_until) WITH && | |
) WHERE (not canceled) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn str->pg-enum | |
"Convert a string value into an enum-compatible object." | |
[enum-type s] | |
(doto (org.postgresql.util.PGobject.) | |
(.setType enum-type) | |
(.setValue s))) | |
(def str->status | |
"Convert a string status into a something_status enum object" | |
(partial string->pg-enum "something_status")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[schema.core :as s]) | |
(require '[schema.coerce :as coerce]) | |
(require '[schema.utils :as utils]) | |
(defn filter-schema-keys | |
[m schema-keys extra-keys-walker] | |
(reduce-kv (fn [m k v] | |
(if (or (contains? schema-keys k) | |
(and extra-keys-walker | |
(not (utils/error? (extra-keys-walker k))))) |