Skip to content

Instantly share code, notes, and snippets.

@richieforeman
richieforeman / makeauthority.sh
Created July 23, 2012 21:38
Issue Your Own Self-Signed S/MIME Certs with OpenSSL
# Run this once
openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
@briancavalier
briancavalier / promise-monad-proof.js
Created August 8, 2012 15:57
A proof that Promises/A is a Monad
//-------------------------------------------------------------
//
// Hypothesis:
//
// Promises/A is a Monad
//
// To be a Monad, it must provide at least:
// - A unit (aka return or mreturn) operation that creates a corresponding
// monadic value from a non-monadic value.
// - A bind operation that applies a function to a monadic value
@jlicht
jlicht / gist:4046626
Created November 9, 2012 16:21
Data in the DPLA Repository - by Collection
The 'value' is the number of documents. To search for documents within a particular collection:
http://api.dp.la/v1/items?isPartOf=Albert%20Gore%20Sr.%20Senate%20Collection
{"rows":[
{"key":"Digital Library of Georgia,","value":379},
{"key":"Digital Library of Georgia,\"Integrated in all respects\": Ed Friend's Highlander Folk School films and the politics of segregation","value":8},
{"key":"Digital Library of Georgia,\"Thar's gold in them thar hills\": Gold and gold mining in Georgia, 1830s-1940s","value":174},
{"key":"Digital Library of Georgia,1968 sanitation workers strike","value":150},
{"key":"Digital Library of Georgia,A Thousand wheels are set in motion: the buildings of Georgia Tech at the turn of the 20th century, 1888-1908","value":2},
@edsu
edsu / pizza.txt
Last active February 3, 2018 21:31
An example of looking up Pizza in Wikidata, to see the equivalent entities on other Wikipedias using the wggetentities call in the Wikidata API http://wikidata.org/w/api.php. The use of python as a filter on the end of curl is just to pretty print the JSON. You can obviously leave it off if you don't have Python available. In response to https:/…
curl "https://www.wikidata.org/w/api.php?action=wbgetentities&sites=itwiki&titles=Pizza&format=json" | python -mjson.tool
{
"entities": {
"q177": {
"descriptions": {
"de": {
"language": "de",
"value": "Gericht"
},
"en": {
@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
@damianavila
damianavila / remove_output.py
Created April 3, 2013 22:05
Remove output from IPython notebook from the command line (dev version 1.0)
"""
Usage: python remove_output.py notebook.ipynb [ > without_output.ipynb ]
Modified from remove_output by Minrk
"""
import sys
import io
import os
from IPython.nbformat.current import read, write
@zacharyvoase
zacharyvoase / README.md
Last active May 21, 2020 06:19
A li’l class for data URI manipulation in Python.

DataURI.py

Data URI manipulation made easy.

This isn't very robust, and will reject a number of valid data URIs. However, it meets the most useful case: a mimetype, a charset, and the base64 flag.

Parsing

@paulmwatson
paulmwatson / maps.google.com.new.lat.lng.js
Created May 17, 2013 09:28
Bookmarklet for getting the latitude and longitude of the center of the map in new Google Maps (which has lost the What's Here? feature which got the lat/lng easily.)
javascript:var d=document,w=window,l=d.location.href;lats=l.indexOf('!2d')+3;late=l.indexOf('!3d',lats);lat=l.substring(lats,late);lngs=l.indexOf('!3d')+3;lnge=l.indexOf('!',lngs);lnge==-1?lnge=l.length:lnge=lnge;lng=l.substring(lngs,lnge);w.location='http://maps.google.com?q='+lng+','+lat;
@tknerr
tknerr / Vagrantfile
Last active January 28, 2024 09:12
Sample Vagrantfile that works with all providers (virtualbox, aws, managed) and in combination with the vagrant-omnibus plugin
#
# Vagrantfile for testing
#
Vagrant::configure("2") do |config|
# the Chef version to use
config.omnibus.chef_version = "11.4.4"
def configure_vbox_provider(config, name, ip, memory = 384)
config.vm.provider :virtualbox do |vbox, override|
@rwjblue
rwjblue / rsa_decrypt.rb
Last active March 16, 2016 16:18
Public-key encryption with Ruby.
require 'openssl'
require 'base64'
ciphertext = Base64.decode64("CIPHERTEXT GOES HERE")
passphrase = ENV['PRIVATE_KEY_PASSPHRASE'] # read in from environment
private_key = OpenSSL::PKey::RSA.new(File.read('path/to/private_key.pem'), passphrase)
plaintext = private_key.private_decrypt(ciphertext, OpenSSL::PKey::RSA::PKCS1_PADDING)
puts "Plain text is: " + plaintext