Skip to content

Instantly share code, notes, and snippets.

View mahendrakalkura's full-sized avatar

Mahendra Kalkura mahendrakalkura

View GitHub Profile
@mahendrakalkura
mahendrakalkura / 1.py
Last active May 20, 2017 05:36
Tell me about the most technically challenging and complicated project that you've worked in the past.
'''
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.
@mahendrakalkura
mahendrakalkura / 1.js
Created February 11, 2017 18:28
Rewrite the bind method from scratch.
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);
@mahendrakalkura
mahendrakalkura / 1.js
Created February 11, 2017 18:24
Write a recursive exponential backoff service (ping) check.
var ping = function() {
// ping...
};
var exponentialBackoff = function(method, currentDelay, maximumDelay) {
var output = method();
if (output) {
return output;
}
@mahendrakalkura
mahendrakalkura / psiupuxa.com.py
Last active April 15, 2017 11:37
psiupuxa.com
# -*- 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
'''
# -*- coding: utf-8 -*-
from grequests import get, map
for response in map(
(
get(
url,
headers={
'X-Requested-With': 'XMLHttpRequest',
'''
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.
# -*- 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`
# -*- 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.
git fsck --unreachable
git reflog expire --expire=0 --all
git repack -a -d -l
git prune
git gc --aggressive
sed -i '{{ number }}d' {{ file }}
Example:
sed -i '1000d' ~/.ssh/known_hosts