Skip to content

Instantly share code, notes, and snippets.

@dknecht
dknecht / .aliases
Created February 12, 2010 04:35 — forked from jlong/.aliases
# Console
alias profile="vi ~/.bash_profile"
alias ls="ls -p -G -h"
# Desktop Programs
alias fireworks="open -a '/Applications/Adobe Fireworks CS3/Adobe Fireworks CS3.app'"
alias photoshop="open -a '/Applications/Adobe Photoshop CS4/Adobe Photoshop.app'"
alias illustrator="open -a '/Applications/Adobe Illustrator CS4/Adobe Illustrator.app'"
alias preview="open -a '/Applications/Preview.app'"
alias xcode="open -a '/Developer/Applications/Xcode.app'"
@dknecht
dknecht / fabfile.py
Created February 18, 2010 06:41 — forked from onyxfish/fabfile.py
from fabric.api import *
"""
Base configuration
"""
env.project_name = '$(project)'
env.database_password = '$(db_password)'
env.site_media_prefix = "site_media"
env.admin_media_prefix = "admin_media"
env.newsapps_media_prefix = "na_media"
"""
This fabric file makes setting up and deploying a django application much
easier, but it does make a few assumptions. Namely that you're using Git,
Apache and mod_wsgi and your using Debian or Ubuntu. Also you should have
Django installed on your local machine and SSH installed on both the local
machine and any servers you want to deploy to.
_note that I've used the name project_name throughout this example. Replace
this with whatever your project is called._
from fabric.api import *
"""
Base configuration
"""
env.project_name = '$(project)'
env.database_password = '$(db_password)'
env.site_media_prefix = "site_media"
env.admin_media_prefix = "admin_media"
env.newsapps_media_prefix = "na_media"
Bitly tech talk 4/22/2010
On 4/22 we held a bit.ly tech talk on 'Command Line Fu', where we invited talented hackers to come share their best moves. Please correct my notes and add your fu here!
# @jehiah
# in place file regex replacement
perl -pi -e 's/this/that/g' filename_pattern
# print the last column of a file ($NF stands for 'Number of Fields' or more commonly Last Field).
altscreen on
attrcolor b ".I"
autodetach on
caption always "%?%F%{= Kk}%:%{=u kR}%? %h %-024=%{= Kk} %C%a %D %d %M %Y%{= db}"
defbce "on"
defflow off
defscrollback 10000
defutf8 on
escape ^``
hardstatus alwayslastline "%{= kR} %-Lw%{= Kk} %n%f %t %{-}%+Lw %=%{= dd}"
Bitly tech talk 4/22/2010
On 4/22 we held a bit.ly tech talk on 'Command Line Fu', where we invited talented hackers to come share their best moves. Please correct my notes and add your fu here!
# jehiah
# in place file regex replacement
perl -pi -e 's/this/that/g' filename_pattern
# print the last column
SELECT COUNT(*) FROM "core_account" INNER JOIN "core_account_channels" ON ("core_account"."user_ptr_id" = "core_account_channels"."account_id") INNER JOIN "auth_user" ON ("core_account"."user_ptr_id" = "auth_user"."id") WHERE ("core_account_channels"."channel_id" = E'549eb2b42fd34d57a1aa0437d9a38dab' AND "auth_user"."date_joined" >= E'2010-09-29 00:00:00' AND "auth_user"."date_joined" <= E'2010-09-29 23:59:59' )
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=36305.99..36306.00 rows=1 width=0) (actual time=297.080..297.080 rows=1 loops=1)
-> Nested Loop (cost=19095.19..36305.69 rows=116 width=0) (actual time=182.738..296.900 rows=173 loops=1)
-> Hash Join (cost=19095.19..
EXPLAIN ANALYZE SELECT COUNT(*) FROM "core_voucher" INNER JOIN "core_item" ON ("core_voucher"."item_ptr_id" = "core_item"."id") INNER JOIN "core_transaction" ON ("core_item"."transaction_id" = "core_transaction"."id") WHERE ("core_item"."product_id" = E'5df25690561e4b8c8025e3c87fbc3762' AND NOT ("core_voucher"."status" = E'invalidated' ) AND NOT ("core_transaction"."status" = E'unverified' ));
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=560.36..560.37 rows=1 width=0) (actual time=194.462..194.464 rows=1 loops=1)
-> Nested Loop (cost=2.69..560.23 rows=53 width=0) (actual time=1.596..191.479 rows=1862 loops=1)
-> Nested Loop (cost=2.69..331.67 rows=53 width=33) (actual time=1.423..110.013 rows=1862 loops=1)
<e_item"."product_id" = E'e351ae7f77d04576939d4345756b6d8e' AND NOT ("core_voucher"."status" = E'invalidated' ) AND NOT ("core_transaction"."status" = E'unverified' ));
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=19627.56..19627.57 rows=1 width=0) (actual time=909.937..909.938 rows=1 loops=1)
-> Hash Join (cost=11002.17..19607.04 rows=8206 width=0) (actual time=430.048..903.275 rows=7387 loops=1)
Hash Cond: ((core_item.transaction_id)::text = (core_transaction.id)::text)
-> Hash Join (cost=3594.02..10943.28 rows=8206 width=33) (actual time=38.966..469.332 rows=7387 loops=1)
Hash Cond: ((core_voucher.item_ptr_id)::text = (core_item.id)::text)
-> Seq Scan on co