import code; code.interact(local=locals())IPython with embed()
| license: mit |
| -- Table information like sortkeys, unsorted percentage | |
| -- see http://docs.aws.amazon.com/redshift/latest/dg/r_SVV_TABLE_INFO.html | |
| SELECT * FROM svv_table_info; | |
| -- Table sizes in GB | |
| SELECT t.name, COUNT(tbl) / 1000.0 AS gb | |
| FROM ( | |
| SELECT DISTINCT datname, id, name | |
| FROM stv_tbl_perm | |
| JOIN pg_database ON pg_database.oid = db_id |
Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.
| # Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key | |
| # that enables you to choose a character from a menu of options. If you are on Lion | |
| # try it by pressing and holding down 'e' in any app that uses the default NSTextField | |
| # for input. | |
| # | |
| # It's a nice feature and continues the blending of Mac OS X and iOS features. However, | |
| # it's a nightmare to deal with in Atom if you're running vim mode, | |
| # as it means you cannot press and hold h/j/k/l to move through your file. You have | |
| # to repeatedly press the keys to navigate. |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| var obj = { | |
| id: 1, | |
| whoami: function() { | |
| return this.id; | |
| } | |
| }; | |
| function callExternally(callback) { | |
| this.id = 99; | |
| return callback(); |
| # gap.py | |
| # (c) 2013 Mikael Vejdemo-Johansson | |
| # BSD License | |
| # | |
| # SciPy function to compute the gap statistic for evaluating k-means clustering. | |
| # Gap statistic defined in | |
| # Tibshirani, Walther, Hastie: | |
| # Estimating the number of clusters in a data set via the gap statistic | |
| # J. R. Statist. Soc. B (2001) 63, Part 2, pp 411-423 |
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
| var list = $$("#item-page-wrapper .list-items table tbody .lineItemMainInfo .lineItemPart strong"); | |
| var total=0; | |
| for(i=0; i<list.length;i++){ | |
| total += parseFloat(list[i].innerText.replace("$","")); | |
| } | |
| alert(list.length+" items for a total of: $"+total.toFixed(2)); |