git fsck --unreachable
git reflog expire --expire=0 --all
git repack -a -d -l
git prune
git gc --aggressive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
I faced this problem when developing tweet.tv. | |
Steps | |
===== | |
1. Gather tweets from twitter.com using end-user supplied query. | |
Example: tom brady nfl | |
twitter.com translates this to "tom AND brady AND nfl". | |
2. Store the tweets in a PostgreSQL database. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bind = function(context) { | |
var bindee = this; | |
var parameters = Array.prototype.slice.call(arguments, 1); | |
parameters = parameters.concat(Array.prototype.slice.call(arguments)); | |
var noop = function() {}; | |
var method = function() { | |
return bindee.apply(this instanceof noop? this: context, parameters); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ping = function() { | |
// ping... | |
}; | |
var exponentialBackoff = function(method, currentDelay, maximumDelay) { | |
var output = method(); | |
if (output) { | |
return output; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
''' | |
$ mkvirtualenv psiupuxa.com | |
$ workon psiupuxa.com | |
$ pip install grequests | |
$ pip install scrapy | |
$ python psiupuxa.com.py > psiupuxa.com.txt | |
$ xargs -P 64 wget < psiupuxa.com.txt | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from grequests import get, map | |
for response in map( | |
( | |
get( | |
url, | |
headers={ | |
'X-Requested-With': 'XMLHttpRequest', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
I faced this problem when developing tweet.tv. | |
Steps | |
===== | |
1. Gather tweets from twitter.com using end-user supplied query. | |
Example: tom brady nfl | |
twitter.com translates this to "tom AND brady AND nfl". | |
2. Store the tweets in a PostgreSQL database. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
''' | |
This module converts search engine queries into PostgreSQL native full-text queries. | |
Examples: | |
1. `one two three` becomes `one & two & three` | |
2. `one OR two OR three` becomes `one | two | three` | |
3. `(one two) three` becomes `(one & two) | three` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
''' | |
Method 1 | |
======== | |
(as implemented below) | |
Reason: "The line will be at most 1000 characters long." | |
i.e.: We will always have enough memory to slice and dice the list normally. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sed -i '{{ number }}d' {{ file }} | |
Example: | |
sed -i '1000d' ~/.ssh/known_hosts |
NewerOlder