Skip to content

Instantly share code, notes, and snippets.

View z4y4ts's full-sized avatar
🎯
Focusing

Alexander Zayats z4y4ts

🎯
Focusing
View GitHub Profile
@z4y4ts
z4y4ts / lucid-custom.css
Created June 16, 2013 22:08
WP Lucid theme tweaks
.home .thumb { display: none; }
.comment-reply-link {
background: url(/wp-content/themes/Lucid/images/more-arrow.png) no-repeat center right;
}
.article { padding: 14px; }
.post_content { padding: 36px 14px 30px 14px; }
#main-area .container { width: 1000px; }
#left-area { width: 670px; }
.flexslider img { width: 1000px; }
@z4y4ts
z4y4ts / trace.sh
Last active October 12, 2015 20:58
web2py trace
function trace() {
local DEV_ROOT=~/dev/branch
local dir=$DEV_ROOT/booking/gui/applications/${1:-booking}/errors/
local ticket=`ls -1t ${dir} | head -1`
python -c "import cPickle as pickle; print pickle.load(open('${dir}/${ticket}', 'r')).get('traceback')"
}
@z4y4ts
z4y4ts / gist:3302920
Created August 9, 2012 10:08
SQL complex query with aggregation in web2py DAL way

Raw SQL

query = '''SELECT COALESCE(SUM(imp), 0) AS imps,
                  COALESCE(SUM(click), 0) AS clicks
           FROM logCuDate
           WHERE id=%s
               AND date >= %s
               AND date <= %s'''
res = db.executesql(query, args, as_dict=True)
@z4y4ts
z4y4ts / gist:3181380
Created July 26, 2012 10:23
OS X Mountain Lion virtualenvwrapper fix
Install XCode & Command Line Tools
curl -O http://python-distribute.org/distribute_setup.py
sudo python distribute_setup.py
sudo easy_install pip
sudo pip install virtualenvwrapper
@z4y4ts
z4y4ts / .zshrc
Created April 28, 2012 14:27
Color prompt with time
# Prompt setup (c) smax 2002, adapted for zsh (c) piranha 2004
# 0-black, 1-red, 2-green, 3-yellow, 4-blue, 5-magenta 6-cyan, 7-white
Cr() { echo '%{\033[3'$1'm%}'; }
hc=`Cr 6`; wc=`Cr 3`; tc=`Cr 7`; w=`Cr 7`; n=`Cr 9`; r=`Cr 1`; y=`Cr 6`; gr=`Cr 2`
[ $UID = 0 ] && at=$r%B'#'%b || at=$w'@'
PW_LEN=25
PS1="$wc%n$at$hc%m $wc%$PW_LEN<..<%~$w>$n"
export RPROMPT=$(echo "$gr%T$n")
unset n b Cr uc hc wc tc tty at r y gr
@z4y4ts
z4y4ts / gist:1691021
Created January 27, 2012 21:31
How to join tables on regex — performance test
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Nested Loop (cost=0.00..6275.34 rows=882 width=163) (actual time=0.448..1058.363 rows=75615 loops=1)
Join Filter: (((msg.src_addr)::text ~~ (('380'::text || (mnc.code)::text) || '%'::text)) OR ((msg.dst_addr)::text ~~ (('380'::text || (mnc.code)::text) ||
-> Seq Scan on sms_mobilenetworkcode mnc (cost=0.00..1.18 rows=1 width=7) (actual time=0.014..0.042 rows=12 loops=1)
Filter: (length((code)::text) = 2)
-> Seq Scan on messages msg (cost=0.00..4064.76 rows=88376 width=159) (actual time=0.005..16.282 rows=88382 loops=12)
Total runtime: 1064.521 ms
(6 rows)