This file contains 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
const Hooks = { ViewportResizeHooks} | |
const connectLiveSocket = () => { | |
const csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute('content') | |
const liveSocket = new LiveSocket('/my_app/live', Socket, { | |
params: { | |
_csrf_token: csrfToken, | |
viewport: { | |
width: window.innerWidth, | |
height: window.innerHeight |
This file contains 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
"Turn off any hacks vim does to be vi backwards-compatible | |
set nocompatible | |
"Set Mapleader | |
let mapleader = "," | |
let g:mapleader = "," | |
"Use pathogen to manage plugin bundles | |
"See http://www.vim.org/scripts/script.php?script_id=2332 | |
filetype off |
This file contains 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 table pantry(name varchar(50), quantity int); | |
insert into pantry values('soup', 10), ('celery', 5), ('crackers', 2); | |
create temporary table shopping_list(name varchar(50)); | |
insert into shopping_list values ('soup'), ('onion'), ('celery'); | |
select a.name, ifnull(b.quantity, 0) as quantity | |
from shopping_list a |
This file contains 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
ls *.tar | xargs -i tar xf {} |
This file contains 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
# Hash keyed by y to speed to_s | |
def to_h | |
hash_with_default = Hash.new {|hash,key| hash[key] = []} | |
@points.inject(hash_with_default) { |hash, point| h[point.y] << point.x; hash } | |
end |
This file contains 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
1. Install lib event from source http://libevent.org/ | |
2. Install tmux from source with: | |
.configure LDFLAGS="-L/usr/local/lib" |
This file contains 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
SELECT TABLE_NAME, table_rows, data_length, index_length, round(((data_length + index_length) / 1024 / 1024),2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "my_database_name"; |
This file contains 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
# One-liner based on an image a friend sent in an email... | |
(1..9).inject("") { |s,i| s+=i.to_s; puts "#{s.to_i}*8+#{i} = #{s.to_i*8+i}".center(25); s } | |
This file contains 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
# Disable the MySQL binary log while restoring data from mysqldump | |
(echo "set session sql_log_bin=0;"; cat some_dump.sql) | mysql ... |
This file contains 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 Tumblr slidedeck "Massively Sharded MySQL" (http://assets.en.oreilly.com/1/event/74/Massively%20Sharded%20MySQL%20at%20Tumblr%20Presentation.pdf): | |
Our shard-split process relies on creating new slaves quickly, which involves copying around very large data sets. | |
For compression we use pigz (parallel gzip), but there are other alternatives. | |
On destination box: | |
$ nc -l [port] | pigz -d | tar xvf - |
NewerOlder