Skip to content

Instantly share code, notes, and snippets.

View panchr's full-sized avatar

Rushy R. Panchal panchr

  • Airbnb
  • New York City
View GitHub Profile
@panchr
panchr / Pipfile
Last active December 25, 2019 19:25
Pipenv issue
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[dev-packages]
django-autofixture = "==0.12.1"
django-nose = "~=1.4.0"
model-mommy = "~=1.5.0"
nose-progressive = "~=1.5.0"
@panchr
panchr / keybase.md
Created November 2, 2016 01:30
keybase.md

Keybase proof

I hereby claim:

  • I am panchr on github.
  • I am panchr (https://keybase.io/panchr) on keybase.
  • I have a public key ASADHO1RTmQpEUNrbuhJ1Kob6gPI_wMsy96DTwMdnMHAUwo

To claim this, I am signing this object:

@panchr
panchr / configure.py
Last active November 15, 2015 21:10
Server initialization script, oriented towards Python servers.
# Rushy Panchal
# configure.py
# Initializes the server
import subprocess
def main():
'''Main process'''
with open("nginx.conf", "w") as nginx_conf:
nginx_conf.write('''{{ nginx_conf }}''')
@panchr
panchr / app.py
Last active August 31, 2015 02:42
Flask Error emails
import logging
from logging.handlers import SMTPHandler
from flask import Flask
app = Flask(__name__) # configure however you normally do
app.debug = False
if not app.debug:
logging.basicConfig(level = logging.INFO)
@panchr
panchr / app.py
Last active August 29, 2015 14:26
Queued (I/O intensive) operations in Python
from queue_db import QueuedWriter
from pymongo import Connection
from flask import Flask
from json import dumps
def main():
'''This is just an example using Flask and MongoDB/pymongo.
Of course, you can use any web server and any database as long as you set up the methods appropriately'''
@panchr
panchr / clean-history
Created July 17, 2015 16:18
Clean Git History
#!/bin/bash
set -o errexit
# Author: David Underhill
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then
exit 0
@panchr
panchr / bitstring.c
Last active August 29, 2015 14:16
Bitstring operations in Python and C
// Rushy Panchal
// bitstring.c
// Provides bitstring operations in C
#include <math.h>
unsigned int countBits(unsigned int n);
unsigned int not(unsigned int n);
unsigned int rcirc(unsigned int x, unsigned int n);
unsigned int lcirc(unsigned int x, unsigned int n);
@panchr
panchr / stringFilter.py
Last active August 29, 2015 14:13
Python string filtering
import re
FILTER_WORDS = ["spam", "morespam", "blahblah"] # and so forth
FILTER = re.compile("|".join(FILTER_WORDS))
def phrasePassesFilter(word):
'''Checks if the phrase passes the filter'''
return not bool(FILTER.match(word)) # if there are no matches, FILTER.match --> None, so it passes the filter
@panchr
panchr / repositories.js
Last active August 29, 2015 14:13
GitHub repository sorting
/*
repositories is a list of repository objects, in the form of
[
{name: "repo A", description: "my first repository!"},
{name: "repo B", description: "my second repository!"}
]
This is the same form as returned by the GitHub API: https://api.github.com/users/panchr/repos
query is just the search query as a string, such as "repo python my first"
*/
@panchr
panchr / anchorScroll.js
Created January 3, 2015 18:03
A small jQuery-driven script to smooth-scroll to anchors
jQuery.fn.smoothScroll = function(options) {
var options = jQuery.extend({offset: 0, duration: 900, easing: "swing"}, options);
$('html, body').stop().animate({'scrollTop': this.offset().top + options.offset}, options.duration, options.easing);
}
function anchorLinkSmoothScroll() {
// Smooth scroll to any clicked anchor link
$("a[href^=#]").click(function (event) {
event.preventDefault();
var anchorLink = this.href.replace(this.baseURI, "");