Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View kennethreitz's full-sized avatar
🐍

Kenneth Reitz kennethreitz

🐍
View GitHub Profile
@kennethreitz
kennethreitz / .htaccess
Created March 29, 2010 04:55
(Passwd) Basic Authentication .htaccess example
Options +Indexes
<Files *>
AuthType Basic
AuthName "Please enter your username and password."
AuthUserFile .htpasswd
Require valid-user
</Files>
@kennethreitz
kennethreitz / 0_urllib2.py
Created May 16, 2011 00:17
urllib2 vs requests
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
gh_url = 'https://api.github.com'
req = urllib2.Request(gh_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
import random
def spiritual_gifts():
# Define the community of believers
believers = []
# Initialize the gifts of the Spirit
possible_gifts = ["Prophecy", "Serving", "Teaching", "Exhortation", "Giving", "Leadership", "Mercy"]
gifts_of_spirit = {}
# The Seven Rays concept from the esoteric teachings of Alice A. Bailey can be described using Python code
# in a metaphorical way. The code will outline each Ray and its associated qualities.
# Define the Seven Rays as a dictionary
seven_rays = {
"1st Ray": {
"Name": "Ray of Will or Power",
"Qualities": ["Power", "Will", "Purpose", "Leadership"],
"Color": "Red"
},
# I Corinthians 13 - ESV, Presented in PEP 8 Style
# Importing essential virtues
from christian_values import love
def chapter_13():
"""
This function describes the characteristics and importance of love,
following the guidelines of I Corinthians 13 in the Bible (ESV).
"""
@kennethreitz
kennethreitz / Documentation.mkd
Created March 31, 2010 16:01
Markdown Documentation template w/ GitHub styling.
<style type="text/css" media="screen"> html{width: 85%; min-width: 600px;margin: 0 auto; font-family: sans-serif;} h1,h2,h3,h4,h5,h6{border:0!important;} h1{font-size:170%!important;border-top:4px solid #aaa!important;padding-top:.5em!important;margin-top:1.5em!important;} h1:first-child{margin-top:0!important;padding-top:.25em!important;border-top:none!important;} h2{font-size:150%!important;margin-top:1.5em!important;border-top:4px solid #e0e0e0!important;padding-top:.5em!important;} h3{margin-top:1em!important;} p{margin:1em 0!important;line-height:1.5em!important;} ul{margin:1em 0 1em 2em!important;}
@kennethreitz
kennethreitz / sentiment_serp_keyword_tracking_ai.py
Last active November 8, 2023 22:11
something I threw together for tracking sentiment of keywords for a company, with the help of ai
import os
import marvin
from serpapi import Client as SerpApi
serpapi = SerpApi(api_key=os.environ['SERPAPI_API_KEY'])
@marvin.ai_fn
def get_suggested_keywords(org_name: str) -> list[str]:
@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

"Other developers are just like us - weird"

"If you ever need to deploy Django, you're good. If you know Capistrano and Unicorn they've got rip-offs of all that stuff."

"I think we should all admit we're horrible coders and move on" "We're all drug addicts - we're fighting methods..."

"It's easy to learn to play the guitar and be able to play Bob Dylan and Weezer and never get better."

"This is basically a talk that was given 30 years ago. We just have to keep giving it every few years because young guys come along and forget it."

@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: