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)
--------------------------------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=13740.85..13740.86 rows=1 width=0) (actual time=152.590..152.591 rows=1 loops=1)
-> Nested Loop (cost=46.63..13736.22 rows=1852 width=0) (actual time=0.906..146.770 rows=1869 loops=1)
-> Nested Loop (cost=46.63..7977.58 rows=1852 width=33) (actual time=0.815..78.919 rows=1869 loops=1)
-> Bitmap Heap Scan on core_item (cost=46.63..1978.16 rows=1852 width=66) (actual time=0.751..5.526 rows=1881 loops=1)
Recheck Cond: ((product_id)::text = '5df25690561e4b8c8025e3c87fbc3762'::text)
-> Bitmap Index Scan on core_item_product_id (cost=0.00..46.17 rows=1852 width=0) (actual time=0.716..0.716 rows=1898 loops=1)
Index Cond: ((product_id)::text = '5df25690561e4b8c8025e3c87fbc3762'::text)
-> Index Scan using core_voucher_pkey on core_v