z, ? | toggle help (this) |
space, → | next slide |
shift-space, ← | previous slide |
d | toggle debug mode |
## <ret> | go to slide # |
c, t | table of contents (vi) |
f | toggle footer |
r | reload slides |
n | toggle notes |
p | run preshow |
git checkout -b noʎ_ʞɔnɟ
git svn rebase
and git svn dcommit
git rebase --interactive --autosquash
.$ git init
Initialized empty Git repository in /tmp/world_domination/.git/
$ git commit --message 'git init' --allow-empty
[master (root-commit) a9e1e55] git init
$ cat > README
README-driven development ftw!
^D
$ git add README
$ git commit --message 'I think this is the beginning of a beautiful README'
[master cabba9e] I think this is the beginning of a beautiful README
1 file changed, 1 insertion(+)
create mode 100644 README
$ cat > plans.rb
puts 'Hello, world domination!'
^D
$ git add plans.rb
$ git commit --message 'first working code!'
[master c0def00] first working code!
1 file changed, 1 insertion(+)
create mode 100644 plans.rb
$ git log --oneline --decorate
c0def00 (HEAD, master) first working code!
cabba9e I think this is the beginning of a beautiful README
a9e1e55 git init
$ tr a-z A-Z < README | sponge README
$ cat README
README-DRIVEN DEVELOPMENT FTW!
$ git add README
$ git commit --message 'fixup! cabba9e'
[master 5eaf00d] fixup! cabba9e
1 file changed, 1 insertion(+), 1 deletion(-)
$ git log --decorate --oneline
5eaf00d (HEAD, master) fixup! cabba9e
c0def00 first working code!
cabba9e I think this is the beginning of a beautiful README
a9e1e55 git init
$ git rebase --interactive --autosquash cabba9e^
pick cabba9e I think this is the beginning of a beautiful README
fixup 5eaf00d fixup! cabba9ea1fa1fabaff1edba99a9eba11ad5faded
pick c0def00 first working code!
[detached HEAD badf00d] I think this is the beginning of a beautiful README
1 file changed, 1 insertion(+)
create mode 100644 README
Successfully rebased and updated refs/heads/master.
$ git log --oneline --decorate
bea91e5 (HEAD, master) first working code!
badf00d I think this is the beginning of a beautiful README
a9e1e55 git init
$ cat > .rvmrc
rvm use 1.9.3@world_domination
^D
$ git add .rvmrc
$ git commit --message 'we’re getting serious now'
[master c0ffee5] we’re getting serious now
1 file changed, 1 insertion(+)
create mode 100644 .rvmrc
$ cat >> .rvmrc
bundle
^D
$ git status --short --branch
## master
M .rvmrc
$ git update-index --assume-unchanged .rvmrc
$ git status --short --branch
## master
$ git checkout -b pinky
Switched to a new branch 'pinky'
$ cat > plans.rb
if ENV['USER'] == 'brain'
puts 'Hello, world domination!'
else
puts 'Nice try. You must be Pinky.'
end
^D
$ git diff
diff --git a/plans.rb b/plans.rb
index beefbad..feedba9 100644
--- a/plans.rb
+++ b/plans.rb
@@ -1 +1,5 @@
-puts 'Hello, world domination!'
+if ENV['USER'] == 'brain'
+ puts 'Hello, world domination!'
+else
+ puts 'Nice try. You must be Pinky.'
+end
$ git diff --ignore-all-space
diff --git a/plans.rb b/plans.rb
index beefbad..feedba9 100644
--- a/plans.rb
+++ b/plans.rb
@@ -1 +1,5 @@
+if ENV['USER'] == 'brain'
puts 'Hello, world domination!'
+else
+ puts 'Nice try. You must be Pinky.'
+end
$ git add plans.rb
$ git commit --message 'Pinky-proofing'
[pinky defaced] Pinky-proofing
1 file changed, 5 insertions(+), 1 deletion(-)
$ git checkout -
Switched to branch 'master'
$ git checkout -
Switched to branch 'pinky'
git commit --allow-empty
git rebase -i --autosquash
git update-index --assume-unchanged
git diff -w
git checkout -
git add|checkout|stash -p
$ psql rupy
psql (9.2.1)
Type "help" for help.
# CREATE TYPE track AS ENUM ('1', '2', 'both');
CREATE TYPE
# CREATE TABLE agenda ( \
track track DEFAULT 'both', \
speaker text, title text, abstract text, \
time tstzrange NOT NULL, \
tags text[] \
);
CREATE TABLE
# INSERT INTO agenda (title, time) VALUES \
('Registration', '[2012-11-17 8:45, 2012-11-17 9:30)');
INSERT 0 1
# SELECT track, title, time FROM agenda;
track | title | time
-------+--------------+-----------------------------------------------------
both | Registration | ["2012-11-17 08:45:00+01","2012-11-17 09:30:00+01")
(1 row)
# INSERT INTO agenda (speaker, title, time) VALUES \
('Zed A. Shaw', 'Keynote', '[2012-11-17 9:30, 2012-11-17 10:15)');
INSERT 0 1
# INSERT INTO agenda (track, speaker, title, abstract, time, tags) VALUES \
('1', 'José Valim', 'Elixir', 'In this talk, José Valim will cover…', \
'[2012-11-17 10:15, 2012-11-17 10:45)', '{"Elixir", "Erlang"}');
INSERT 0 1
# INSERT INTO agenda (track, speaker, title, abstract, time, tags) VALUES \
('2', 'Honza Král', 'Extendable Django Apps', 'I will describe how…', \
'[2012-11-17 10:15, 2012-11-17 10:45)', '{"Django", "Python"}');
INSERT 0 1
# SELECT track, speaker, title, tags FROM agenda;
track | speaker | title | tags
-------+-----------------+---------------------------+------------------------
both | | Registration |
both | Zed A. Shaw | Keynote |
1 | José Valim | Elixir | {Elixir,Erlang}
2 | Honza Král | Extendable Django Apps | {Django,Python}
(4 rows)
# INSERT INTO agenda (title, time) VALUES \
('Break', '[2012-11-17 10:45, 2012-11-17 11:00)');
INSERT 0 1
# INSERT INTO agenda (track, speaker, title, abstract, time, tags) VALUES \
('1', 'Igor Minár', 'AngularJS', 'What if you could write modern web…', \
'[2012-11-17 11:00, 2012-11-17 11:30)', '{"AngularJS", "JavaScript"}');
INSERT 0 1
# INSERT INTO agenda (track, speaker, title, abstract, time, tags) VALUES \
('2', 'Olov Lassus', 'JS – from good to great', 'Is it possible to…', \
'[2012-11-17 11:00, 2012-11-17 11:30)', '{"JavaScript"}');
INSERT 0 1
# INSERT INTO agenda (track, speaker, title, time) VALUES \
('1', 'Dr Nic Williams', 'The Future of Deployment', \
'[2012-11-17 11:30, 2012-11-17 12:00)');
INSERT 0 1
# INSERT INTO agenda (track, speaker, title, abstract, time, tags) VALUES \
('2', 'Armin Ronacher', 'Rust from Python and Ruby', 'Rust is a…', \
'[2012-11-17 11:30, 2012-11-17 12:00)', '{"Python", "Ruby", "Erlang"}');
INSERT 0 1
# SELECT track, title, to_char(lower(time), 'HH:MI') AS start, tags FROM agenda;
track | title | start | tags
-------+---------------------------+-------+------------------------
both | Registration | 08:45 |
both | Keynote | 09:30 |
1 | Elixir | 10:15 | {Elixir,Erlang}
2 | Extendable Django Apps | 10:15 | {Django,Python}
both | Break | 10:45 |
1 | AngularJS | 11:00 | {AngularJS,JavaScript}
2 | JS – from good to great | 11:00 | {JavaScript}
1 | The Future of Deployment | 11:30 |
2 | Rust from Python and Ruby | 11:30 | {Python,Ruby,Erlang}
(9 rows)
# SELECT track, speaker, title, to_char(lower(time), 'HH:MI') AS start, tags \
FROM agenda WHERE time @> '2012-11-17 10:20'::timestamptz;
track | speaker | title | start | tags
-------+------------+------------------------+-------+-----------------
1 | José Valim | Elixir | 10:15 | {Elixir,Erlang}
2 | Honza Král | Extendable Django Apps | 10:15 | {Django,Python}
(2 rows)
# SELECT track, speaker, title, to_char(lower(time), 'HH:MI') AS start, tags \
FROM agenda WHERE 'Erlang' = ANY(tags) OR 'JavaScript' = ANY(tags);
track | speaker | title | start | tags
-------+----------------+---------------------------+-------+------------------------
1 | José Valim | Elixir | 10:15 | {Elixir,Erlang}
1 | Igor Minár | AngularJS | 11:00 | {AngularJS,JavaScript}
2 | Olov Lassus | JS – from good to great | 11:00 | {JavaScript}
2 | Armin Ronacher | Rust from Python and Ruby | 11:30 | {Python,Ruby,Erlang}
(4 rows)
# SELECT abstract, abstract::tsvector, to_tsvector('english', abstract) \
FROM agenda WHERE abstract IS NOT NULL;
abstract | abstract | to_tsvector
--------------------------+---------------------------+-----------------------------
In this talk, José Valim…| 'Elixir' 'In' 'José'… | 'also':16 'behind':24…
I… the challenges and… | 'I' 'all'… 'challenges'… | 'base':18 'challeng':22…
What if you could write… | 'As' 'HTML' 'JavaScript.'…| 'app':8 'code':14 'could':4…
Is it possible to make… | 'Is' 'JavaScript' 'Let’s'…| 'care':20 'easier':10…
Rust… wants to rival C++…| 'C++' 'Erlang,' 'Haskell'…| 'bit':23 'c':10 'design':31…
(5 rows)
# SELECT track, speaker, title, lower(time) AS start FROM agenda \
WHERE abstract::tsvector @@ 'Haskell & Ruby'::tsquery;
track | speaker | title | start
-------+----------------+---------------------------+------------------------
2 | Armin Ronacher | Rust from Python and Ruby | 2012-11-17 11:30:00+01
(1 row)
# SELECT track, speaker, title, lower(time) AS start FROM agenda \
WHERE to_tsvector('english', abstract) @@ to_tsquery('challenging:*');
track | speaker | title | start
-------+------------+------------------------+------------------------
2 | Honza Král | Extendable Django Apps | 2012-11-17 10:15:00+01
(1 row)
$ find app/models -name '*.rb'
app/models/foo.rb
app/models/bar.rb
app/models/baz.rb
…
$ find app/models -name '*.rb' | xargs wc -l
43 app/models/foo.rb
2 app/models/bar.rb
83 app/models/baz.rb
…
$ find app/models -name '*.rb' | xargs wc -l | sort -nr
17124 total
3663 app/models/qux.rb
1426 app/models/quux.rb
1240 app/models/corge.rb
953 app/models/grault.rb
… # via Sam Livingston-Gray
$ git log --oneline --name-only
badf00d some commit message
app/models/foo.rb
cafeb01 another commit message
app/controllers/bars_controller.rb
app/views/users/_baz.html.erb
…
$ git log --oneline --name-only | grep '^[^ ]*\.rb$'
app/models/foo.rb
app/controllers/bars_controller.rb
app/views/users/_baz.html.erb
…
$ git log --oneline --name-only | grep '^[^ ]*\.rb$' | sort | uniq -c
4 app/controllers/quxs_controller.rb
183 app/controllers/quuxs_controller.rb
63 app/controllers/corges_controller.rb
…
$ git log --oneline --name-only | grep '^[^ ]*\.rb$' | sort | uniq -c | sort -nr
1096 app/models/foo.rb
325 app/controllers/foos_controller.rb
257 app/models/bar.rb
251 config/routes.rb
248 app/controllers/baz_controller.rb
224 db/schema.rb
… # via Samson Ootoovak/Michael Feathers
$ head mig.log
== AddFooToBar: migrating ===========================
-- add_column(:bars, :foo, :integer)
-> 0.1044s
-- add_column(:bars, :baz, :integer)
-> 0.1144s
…
$ grep ' -> [0-9.]*s' mig.log
-> 0.1044s
-> 0.1144s
…
$ grep ' -> [0-9.]*s' mig.log | cut -d' ' -f5
0.1044s
0.1144s
…
$ grep ' -> [0-9.]*s' mig.log | cut -d' ' -f5 | tr -d s
0.1044
0.1144
…
$ grep ' -> [0-9.]*s' mig.log | cut -d' ' -f5 | tr -d s | xargs
0.1044 0.1144 …
$ grep ' -> [0-9.]*s' mig.log | cut -d' ' -f5 | tr -d s | xargs | tr ' ' +
0.1044+0.1144+…
$ grep ' -> [0-9.]*s' mig.log | cut -d' ' -f5 | tr -d s | xargs | tr ' ' + | bc
4.0230
$ cat db_name.sql | pv | psql db_name
97MB 0:00:12 [28.3MB/s] [ <=> ]
^C
$ pv db_name.sql | psql db_name
97MB 0:00:12 [28.3MB/s] [============> ] 32% ETA 0:00:24
^C
$ pg_dump db_name | pv -s 600m | gzip > db_name.sql.gz
592MB 0:05:09 [1.92MB/s] [=======================================> ] 98%
$ pbpaste | pygmentize -l ruby -f rtf -O style=presentation | pbcopy
* pastes the system clipboard to the command line
* colours it: Ruby syntax, RTF format and presentation-style output
* copies it back to the system clipboard
# via Katrina Owen/Gary Bernhardt
$ diff <(grep -r foo some_dir) <(grep -r foo other_dir)
pgrep
+ pkill
– find and kill processeswatch
– refresh output refreshing every X secondstimeout
– kill a program after X timeparallel
– just… read it (via Lucas di Cioccio)ncdu
– check what takes so much spaceproxylocal
– expose a local port to the publicrmadison
– Debian and Ubuntu versions of a given packagealias computer,='sudo'
computer, apt-get install postgresql
man $(ls /bin /usr/bin | shuf -n 1)