Skip to content

Instantly share code, notes, and snippets.

@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
@prashanthrajagopal
prashanthrajagopal / get_url.scpt
Last active January 13, 2024 11:58
AppleScript to get url from Safari, Firefox and Chrome
display dialog "Name of the browser?" default answer "Safari"
set inp to text returned of result
tell application "System Events"
if inp is "Google Chrome" then
tell application "Google Chrome" to return URL of active tab of front window
else if inp is "Safari" then
tell application "Safari" to return URL of front document
else if inp is "Firefox" then
tell application "Firefox" to activate
@tryone144
tryone144 / enct2.py
Created January 29, 2018 20:40
Implementation of the AES protocol as used by https://encipher.it
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# implementation of the AES protocol as used by https://encipher.it
#
# (c) 2018 Bernd Busse
from cryptography.hazmat.primitives.ciphers import Cipher
from cryptography.hazmat.primitives.ciphers.algorithms import AES
from cryptography.hazmat.primitives.ciphers.modes import ECB, CTR
@lightningdb
lightningdb / goodreads-bookmarklet.js
Last active November 22, 2023 17:36
Add to Goodreads from Amazon.com book page bookmarklet
javascript: var asin_elements, asin;asin_elements = document.getElementsByName('ASIN'); if (asin_elements.length == 0) { asin_elements = document.getElementsByName('ASIN.0'); };if (asin_elements.length == 0) { alert('Sorry, this doesn\'t appear to be an Amazon book page.'); }else { asin = asin_elements[0].value; if (asin.match(/\D/) === null) { var x = window.open('http://www.goodreads.com/review/isbn/'+ asin, 'add_review'); } else { var x = window.open('https://www.goodreads.com/search?q='+ asin); } x.focus();}
@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
@ramalho
ramalho / coro_life.py
Last active October 23, 2023 07:21
John Conway's Game of Life implemented with coroutines, by Brett Slatkin
#!/usr/bin/env python3
# Copyright 2014 Brett Slatkin, Pearson Education Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@pkirkovsky
pkirkovsky / yubikey-reset.sh
Last active October 20, 2023 21:57
Utility for resetting a Yubikey to factory defaults using gpg-connect-agent. This will wipe out any stored keys and reset PINs to default values.
# Adapted from https://developers.yubico.com/ykneo-openpgp/ResetApplet.html
gpg-connect-agent <<EOF
/hex
scd serialno
scd apdu 00 20 00 81 08 40 40 40 40 40 40 40 40
scd apdu 00 20 00 81 08 40 40 40 40 40 40 40 40
scd apdu 00 20 00 81 08 40 40 40 40 40 40 40 40
scd apdu 00 20 00 81 08 40 40 40 40 40 40 40 40
scd apdu 00 20 00 83 08 40 40 40 40 40 40 40 40
scd apdu 00 20 00 83 08 40 40 40 40 40 40 40 40
@jsocol
jsocol / data-uri.py
Created July 18, 2011 14:48
Give an image, get a data-uri
#!/usr/bin/env python
"""Command line script to convert a file, usually an image, into a data URI
for use on the web."""
import base64
import mimetypes
import os
import sys
@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
@jmbwell
jmbwell / dreamhost_dns.py
Last active June 14, 2023 07:36
A quick Ansible module for updating DreamHost DNS records.
#!/usr/bin/python
# Copyright: (c) 2022, John Burwell <jmbwell@atatdotdot.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = r'''
---