Skip to content

Instantly share code, notes, and snippets.

View kennethreitz's full-sized avatar
🐍

Kenneth Reitz kennethreitz

🐍
View GitHub Profile
# encoding: utf8 1,1 Top# encoding: utf8
import argparse
from datetime import datetime
import json
from random import randint
import requests
import sys
from time import sleep
@kennethreitz
kennethreitz / reddit.py
Created March 1, 2018 18:15 — forked from alexritter96/reddit.py
dumb reddit scraping
import json
import praw
reddit = praw.Reddit(
client_id='',
client_secret='',
password='',
user_agent='',
username=''
)
@kennethreitz
kennethreitz / ugly.py
Last active September 6, 2018 14:39 — forked from j00bar/ugly.py
for foo in bar:
if not condition_one:
win_the_points()
else:
if check_the_thing():
continue
else:
if do_some_stuff():
do_the_thing()
else:
@kennethreitz
kennethreitz / phabricator_readme.md
Last active December 10, 2021 16:45 — forked from sparrc/phabricator_readme.md
Phabricator Ubuntu Installation Guide

Phabricator Ubuntu 16.04 Installation Guide (Updated)

This is a supplement to the official Phabricator Installation Guide, because their guide will leave you with all kinds of permission and config errors and ~15,000 setup issues on startup.

Install Apache and php7.1

$ apt install apache2

$ sudo apt-get install -y python-software-properties

@kennethreitz
kennethreitz / queries.py
Created January 17, 2017 20:04
Django Queryset Coding Convention
q = Employee.objects.filter(name='test', id=5).select_related('tasks')
q = q.order_by('first_name', 'last_name')
Top 20 Downloaded Projects on PyPI
==================================
#1 lxml ........ 4890886 downloads
#2 setuptools .. 4243069 downloads
#3 distribute .. 3880163 downloads
#4 zc.buildout . 3090694 downloads
#5 pip ......... 2695166 downloads
#6 boto ........ 2463436 downloads
#7 simplejson .. 2364527 downloads
@kennethreitz
kennethreitz / pr.md
Created September 12, 2012 20:56 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@kennethreitz
kennethreitz / hstore.py
Created July 6, 2012 08:41
PostgreSQL hstore + SQLAlchemy
import collections
import sqlalchemy.types
class Hstore(sqlalchemy.types.UserDefinedType, sqlalchemy.types.MutableType):
"""The ``hstore`` type that stores a dictionary. It can take an any
instance of :class:`collections.Mapping`.
It can be extended to store other types than string e.g.::
@kennethreitz
kennethreitz / gist:2899598
Created June 9, 2012 05:17 — forked from brosner/gist:2899595
S3 eventlet backend for django-ajax-uploader
"""
This file provides an eventlet based S3 uploader for django-ajax-uploader. It
supports chunk retry and chunk parallelism for efficient uploads.
This backend will only work with the forked django-ajax-uploader from my
multipart-post branch which adds some efficiencies to file upload.
django-ajax-uploader: https://github.com/brosner/django-ajax-uploader/tree/multipart-post
Author: Brian Rosner <brosner@gmail.com>
@kennethreitz
kennethreitz / mongo.py
Created March 13, 2012 22:54 — forked from lstoll/mongo.py
MongoHQ w/ pymongo on Heroku
import os
import pymongo
MONGO_URL = os.environ.get('MONGOHQ_URL')
if MONGO_URL:
# Get a connection
conn = pymongo.Connection(MONGO_URL)
# Get the database