Skip to content

Instantly share code, notes, and snippets.

@marcan
marcan / linux.sh
Last active December 1, 2023 15:18
Linux kernel initialization, translated to bash
#!/boot/bzImage
# Linux kernel userspace initialization code, translated to bash
# (Minus floppy disk handling, because seriously, it's 2017.)
# Not 100% accurate, but gives you a good idea of how kernel init works
# GPLv2, Copyright 2017 Hector Martin <marcan@marcan.st>
# Based on Linux 4.10-rc2.
# Note: pretend chroot is a builtin and affects the current process
# Note: kernel actually uses major/minor device numbers instead of device name
colors = {
'deep pink 1':(255, 20, 147),
'peacock':(51, 161, 201),
'deep pink 3':(205, 16, 118),
'deep pink 2':(238, 18, 137),
'deep pink 4':(139, 10, 80),
'medium violet red':(199, 21, 133),
'sea shell':(255, 245, 238),
'pale goldenrod':(238, 232, 170),
'yellow':(255, 255, 0),
@Enkerli
Enkerli / spi_midi_wx11.txt
Last active April 9, 2016 06:46
Quick Sonic Pi script using MIDI in from a WX11 wind controller to control amplitude. Based on Robin Newman’s blogpost: https://rbnrpi.wordpress.com/2016/04/01/a-completely-different-way-to-use-sonic-pi-with-a-midi-controller/
require 'drb/drb'
DRB_URI="drbunix:/var/tmp/sonic-pi-midiconnector"
@midi = DRbObject.new_with_uri(DRB_URI)
use_bpm 240
use_synth :dtri
note_node=play 60, release: 100, attack: 1
live_loop :ctl do
control note_node, amp: @midi.k2/127.0
# Alexandre rANGEL
# "ascension hill" (v14)
# www.quasecinema.org
# 26-Mar-2016
# Sonic Pi 2.9
myBPM = 144
bpmDivider = 2
use_bpm myBPM
set_volume! 1.0 # the age of
@scshepard
scshepard / readme.md
Last active August 29, 2015 14:21 — forked from max-mapper/readme.md

experimental zip stream parsing

using punzip, which uses mount-url and yauzl

problem: theres a 500mb ZIP with a few CSVs in it, but you only care about one of the files and dont want to download the whole thing and have to unzip the whole zip just to get the one file

  1. brew install osxfuse (or however you install fuse on your OS)
  2. npm install punzip csv-parser -g
  3. punzip http://download.cms.gov/Research-Statistics-Data-and-Systems/Statistics-Trends-and-Reports/Medicare-Provider-Charge-Data/Downloads/PartD_Prescriber_PUF_NPI_DRUG_13.zip --entry=2 | csv-parser --separator=$'\t'

Git Cheat Sheet

Commands

Getting Started

git init

or

import numpy as np
import pandas as pd
from bs4 import BeautifulSoup, element
import urllib2, re
# Read the HTML from the webpage on Wikipedia stats and convert to soup
soup = BeautifulSoup(urllib2.urlopen('http://stats.wikimedia.org/EN/TablesWikipediaEN.htm').read())
# Look for all the paragraphs with 2014
_p = soup.findAll('b',text=re.compile('2014'))
@scshepard
scshepard / use_git.md
Last active August 29, 2015 14:11 — forked from amandabee/use_git.md

Git is a version control system. Github is a proprietary hosting service that manages central git repositories. A git repository doesn't have to be public, but there are some great free hosts available if you do want to make your work available. Github, obviously, or Gitorious, especially if you're offended by github's ugly gender politics. Github's GUI is much nicer than any generalized Git GUI's I've seen, which is a vote for using Github, but it really doesn't matter.

So here are a few good reasons you should use git to manage teaching materials:

  • Greg Wilson explains it pretty well to a Python conference. You have to listen to him talk about a few other things first, but the whole talk is interesting so go ahead.

Any newsroom with an