Skip to content

Instantly share code, notes, and snippets.

View contracode's full-sized avatar

Jared Contrascere contracode

  • Washington, DC
View GitHub Profile
@gregburek
gregburek / rateLimitDecorator.py
Created December 7, 2011 01:51
Rate limiting function calls with Python Decorators
import time
def RateLimited(maxPerSecond):
minInterval = 1.0 / float(maxPerSecond)
def decorate(func):
lastTimeCalled = [0.0]
def rateLimitedFunction(*args,**kargs):
elapsed = time.clock() - lastTimeCalled[0]
leftToWait = minInterval - elapsed
if leftToWait>0:
@jacksenechal
jacksenechal / readscale.py
Last active January 24, 2019 16:51
Python script to read a USB scale in the Linux
#!/usr/bin/python
import os, time
import usb.core
import usb.util
import pygtk
pygtk.require('2.0')
import gtk
from sys import exit
import math
@RIAEvangelist
RIAEvangelist / Install Cloud9 on local or remote computer, server, or raspberry pi
Last active June 6, 2023 03:37
This gist will help you install Cloud9 on your local or remote computer, server, or even your raspberry pi. Many people are having issues at the time of this Gist's creation.
Complete installation process:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y python-software-properties python make build-essential g++ curl libssl-dev apache2-utils git libxml2-dev
sudo apt-get update
sudo apt-get upgrade
cd ~
mkdir git
cd ~/git
@jrsmith3
jrsmith3 / pdfmod.py
Created April 3, 2014 03:31
Convert specified pages from a PDF to png
"""
This script was used to create the figures for http://jrsmith3.github.io/sample-logs-the-secret-to-managing-multi-person-projects.html from a PDF file containing some old CMU sample logs.
"""
import PyPDF2
from wand.image import Image
import io
import os
@vt0r
vt0r / GnuPG-2.2.md
Last active February 13, 2024 09:03 — forked from mattrude/GnuPG-2.1.md
Build/install instructions for GnuPG 2.2.x on Ubuntu and similar distros (formerly for 2.1.x)

GnuPG 2.2.x Build Instructions

Below are my build instructions for GnuPG 2.2.10, released on August 30th, 2018. These instructions are built for a headless Ubuntu 18.04 LTS server (and have also been tested on Ubuntu 14.04/16.04).

If you prefer, you may use the below install script to install GnuPG 2.2.x by running the following commands:

curl -OL "https://gist.githubusercontent.com/vt0r/a2f8c0bcb1400131ff51/raw/e0d2011d7b89bfe5b83c3f29f21949fb21354dd9/install-gnupg22.sh" && sudo -H bash ./install-gnupg22.sh

Install the needed dependencies

@koliber
koliber / serializers.py
Created September 8, 2015 14:28
`ExtensibleModelSerializer` prototype for rest_framework
class ExtensibleModelSerializer(serializers.ModelSerializer):
"""
Allows for specifying ``non_native_fields`` in the Meta, which allow for custom handling
of some fields, while letting the ``ModelSerializer`` do its magic with the rest of the fields.
For any fields which are not read from or set directly on the model using ``ModelSerializer``'s
logic, you need to provide a mechanism for:
* getting the value from the model
* changing the incoming data to an internal representation (for updates and creates)

Run Jupyterlab on docker

Build starting from a Jupyter 2.x image.

Build

docker build -t jupyterlab .
#!/bin/bash
#
# Blog post @ https://blog.kylemanna.com/sharing/gogo-inflight-wireless-with-openvpn/
#
# Bail on errors
set -e
SERVER_IP=$(host myip.opendns.com. resolver1.opendns.com | awk '/has address/ { print $4 }')
@chunter
chunter / pageant-autoload-keys-at-startup.txt
Created June 20, 2017 10:51
Make Pageant autoload keys at startup
To make Pageant automatically run and load keys at startup:
- Find the location of pageant.exe
- Windows key + R to open the 'run' dialog box
- Type: 'shell:startup' in the dialog box
- Create a shortcut to the pageant.exe and put into this startup folder.
@hughdbrown
hughdbrown / jupyter-lab.sh
Created November 14, 2017 19:47
Set up virtualenv and jupyter kernel to run isolated jupyter lab
#!/bin/sh
# Based on:
# http://anbasile.github.io/programming/2017/06/25/jupyter-venv/
mkvirtualenv --python=`which python3` ADRPython
workon ADRPython
pip3 install \
jupyter jupyterlab jupyterthemes \
scipy \