Skip to content

Instantly share code, notes, and snippets.

View benspaulding's full-sized avatar

Ben Spaulding benspaulding

View GitHub Profile
@nealtodd
nealtodd / deletable_objects_snippet.py
Last active August 10, 2020 06:49
Django helper for showing related objects that would be cascade deleted on deletion of an object.
from django.conf import settings
from django.db.models.deletion import Collector
from django.db.utils import ConnectionRouter
def deletable_objects(obj):
"""
Return a generator that yields (model, instance) tuples
of instances related to obj (including obj itself).
Essentially, programmatic access to the data Django Admin
@vsajip
vsajip / pyvenvex.py
Last active May 18, 2024 23:13
A script which demonstrates how to extend Python 3.3's EnvBuilder, by installing setuptools and pip in created venvs. This functionality is not provided as an integral part of Python 3.3 because, while setuptools and pip are very popular, they are third-party packages.The script needs Python 3.3 or later; invoke it using"python pyvenvex.py -h"fo…
#
# Copyright (C) 2013-2020 Vinay Sajip. New BSD License.
#
import os
import os.path
from subprocess import Popen, PIPE
import sys
from threading import Thread
from urllib.parse import urlparse
from urllib.request import urlretrieve
@iamatypeofwalrus
iamatypeofwalrus / roll_ipython_in_aws.md
Last active January 22, 2024 11:18
Create an iPython HTML Notebook on Amazon's AWS Free Tier from scratch.

What

Roll your own iPython Notebook server with Amazon Web Services (EC2) using their Free Tier.

What are we using? What do you need?

  • An active AWS account. First time sign-ups are eligible for the free tier for a year
  • One Micro Tier EC2 Instance
  • With AWS we will use the stock Ubuntu Server AMI and customize it.
  • Anaconda for Python.
  • Coffee/Beer/Time
@jkocherhans
jkocherhans / gist:5238719
Last active December 15, 2015 09:29
Non-profits for programming education and diversity
http://adainitiative.org
"The Ada Initiative is a non-profit organization supporting women
in open technology and culture. We educate people of all genders
on how to support women in open tech/culture through teaching
workshops, writing policies, guides, and editorials, and speaking."
http://openhatch.org
"OpenHatch is a non-profit that maintains this website, organizes
outreach events to grow the open source community, and brings
diversity to programming groups."
@quchen
quchen / trolling_haskell
Last active February 24, 2024 01:30
Trolling #haskell
13:15 <xQuasar> | HASKELL IS FOR FUCKIN FAGGOTS. YOU'RE ALL A BUNCH OF
| FUCKIN PUSSIES
13:15 <xQuasar> | JAVASCRIPT FOR LIFE FAGS
13:16 <luite> | hello
13:16 <ChongLi> | somebody has a mental illness!
13:16 <merijn> | Wow...I suddenly see the error of my ways and feel
| compelled to write Node.js!
13:16 <genisage> | hi
13:16 <luite> | you might be pleased to learn that you can compile
| haskell to javascript now
import time
import sound
from scene import *
class TeaTimer(Scene):
def setup(self):
self.initial_time = int(60 * 1.5)
self.remaining_time = self.initial_time
self.center_x = self.size.w * 0.5

Guide to how fucked is SSL?

Thanks to Jacob Kaplan-Moss, Donald Stufft, David Reid, Allen Short, Zain Memon, and Chris Armstrong for review.

This is a guide for technical individuals to understand in what circumstances SSL communications are secure against an observer-in-the-middle (for all intents and purposes: the NSA).

@jphalip
jphalip / goto.sh
Created July 10, 2013 16:10
Bash & zshell script for quickly accessing Python packages installed in the current virtualenv. Allows for tab completion. Associated blog post: http://julienphalip.com/post/55092823910/a-script-to-quickly-access-the-source-of-installed
# Author: Julien Phalip
# License: BSD
# Description: Change the current directory to the path of the given Python package.
function goto {
cd `python -c "import pkgutil; print(pkgutil.get_loader('$1').filename)"`
}
function _top_level_packages {
python -c "import pkgutil; print('\n'.join([name for loader, name, ispkg in sorted(pkgutil.iter_modules()) if ispkg]))"
@codysoyland
codysoyland / prime_sieve.py
Last active April 23, 2017 14:24
A prime number generator using Python generators, inspired by concurrent prime sieve at http://play.golang.org/p/9U22NfrXeq
from itertools import count
def filter(input, prime):
for i in input:
if i % prime:
yield i
def get_primes(num):
g = count(2)
for _ in xrange(num):
@arunoda
arunoda / gist:7790979
Last active February 16, 2024 14:05
Installing SSHPass

Installing SSHPASS

SSHPass is a tiny utility, which allows you to provide the ssh password without using the prompt. This will very helpful for scripting. SSHPass is not good to use in multi-user environment. If you use SSHPass on your development machine, it don't do anything evil.

Installing on Ubuntu

apt-get install sshpass

Installing on OS X