Skip to content

Instantly share code, notes, and snippets.

View dariusk's full-sized avatar

Darius Kazemi dariusk

View GitHub Profile
@dariusk
dariusk / signed-integers.md
Created January 12, 2016 15:10
Brief description of signed integers for IntermezzOS book

Signed integers exist because we need some way to store negative numbers in a computer. Imagine you have 32 bits of storage and you want to put data in there. We could put in 0x00000001 and say that represents 1 in decimal, as you might expect. If we subtract 1 from that, we get 0x00000000, which represents 0. But if we subtract 1 from 0, the bits "wrap around" and we get 0xFFFFFFFF -- this happens on the hardware level! The internal counter has nowhere to go so it wraps around to the top of the range of representable bits.

If we'd been representing this number as an unsigned integer, 0xFFFFFFFF would represent 4,294,967,295. This is the number you'd normally expect if you started from 0x00000000 and kept counting up until you got to 0xFFFFFFFF. So when we have an unsigned integer, 0 - 1 = 4,294,967,295. Which is weird and probably not what we want! A signed integer is just a convention that reserv

var src = window.getDraggedFile() || "/timbre.js/misc/audio/amen.wav";
Array.prototype.pick = function() {
return this[Math.floor(Math.random()*this.length)];
}
T("audio").load(src, function() {
function slice(that, start) {
var len = 450;
return that.slice(start, start+len).set({bang:false});
@dariusk
dariusk / 433.js
Created November 19, 2015 03:52
John Cage's 4'33" in the Web Audio API.
// John Cage's 4'33" with the Web Audio API
function makeSilence(e) {
var buflen = e.outputBuffer.length;
var dataL = e.outputBuffer.getChannelData(0);
var dataR = e.outputBuffer.getChannelData(1);
dataL.fill(0);
dataR.fill(0);
}
function InitAudio() {
{
"topics": [
{
"name": "Labor Day",
"text": "WESTVILLE, Ill. -- A van struck a crowd of people gathered for a Labor Day parade in a small eastern Illinois community, injuring nine people."
},
{
"name": "François Hollande",
"text": "PARIS - Citing the need to act “without calculation or delay,” French President François Hollande said Monday that Paris would accept the 24,000 refugees it could be assigned under a new European Union plan, and insisted that any solution to the ..."
},
@dariusk
dariusk / census_aliases.js
Last active September 23, 2020 01:50
census_aliases.js
var census_aliases = {
//Economic Variables
"income":{
"api":"acs",
"variable":"B19013_001E",
"description":"Median household income in the past 12 months (in 2013 inflation-adjusted dollars)",
"text":"median household income",
"unit":"dollars"
},
"income_per_capita":{
int maxParticles = 100; ArrayList <Particle> particles = new ArrayList <Particle> (); int drawMode = 0; color BACKGROUND_COLOR = color(255); color PGRAPHICS_COLOR = color(0); PGraphics pg; void setup() { size(1280, 720, P2D); smooth(16); pg = createGraphics(width, height, JAVA2D); pg.beginDraw(); pg.textSize(500); pg.textAlign(CENTER, CENTER); pg.fill(PGRAPHICS_COLOR); pg.text("TYPE", pg.width/2, pg.height/2); pg.endDraw(); background(BACKGROUND_COLOR); } void draw() { addRemoveParticles(); for (Particle p : particles) { p.update(); p.display(); } } void mousePressed() { drawMode = ++drawMode%4; background(BACKGROUND_COLOR); if (drawMode == 2) image(pg, 0, 0); particles.clear(); } void addRemoveParticles() { if (drawMode >= 1) { for (int i=particles.size()-1; i>=0; i--) { Particle p = particles.get(i); if (p.life <= 0) { particles.remove(i); } } } while (particles.size () < maxParticles) { particles.add(new Particle()); } } class Particle { PVector loc, vel; float radius = 10; float life = 1; float lifeRate =

meats, and vegetables ham or other mushrooms and cheese, usually topped with or other bread A halved baguette shōga, with mayonnaise such as beni topped with pickles, fried noodles, frequently bun stuffed with A hot dog to add flavor. butter is added or sausage. Sometimes of lunch meat with thin slices German sandwich prepared simple and common vary widely A bundle, fillings can form a neat tucked in to with the ends the sandwich filling tightly wrapped around (often a tortilla) toast. Flat bread accompanied by the in a bowl may be served hot cheese sauce bread. Or the pieces) of toasted slices (or other sauce, poured over hot melted cheese vegetable sandwiches. A used to prepare of vegetables are pastries. Many types a filling for as well as and cracker biscuits sandwiches, toast, crumpets a spread for additives. It is wheat and spice manufacturing, various vegetables, by-product of beer yeast extract, a from used brewers' food paste made dark brown Australian Vegemite is a in a bun savory donkey meat Choppe

@dariusk
dariusk / couplets.js
Created April 13, 2015 16:15
Generating rhyming couplets
var _ = require('underscore');
var RiTa = require('rita');
var lexicon = new RiTa.RiLexicon();
var rita = RiTa.RiTa;
var animals = require('./animals.json').animals;
Array.prototype.pick = function() {
return this[Math.floor(Math.random()*this.length)];
};
animals = _.map(animals, function(animal) {
var EdgeGrid = require('edgegrid');
var client_token = 'akab-xxxxxx',
client_secret = 'xxxxxxxx',
access_token = 'akab-xxxxxx',
baseUri = 'https://akaa-xxxxxxx.luna.akamaiapis.net/';
eg.auth({
'path': 'diagnostic-tools/v1/dig?hostname=developer.akamai.com&queryType=A&location=Philadelphia,United States',
'method': 'GET',
@dariusk
dariusk / joeks.txt
Created February 3, 2015 21:02
#ReplaceALetterRuinATvShow
9fto 5
18 to kife
101 Dabmatians: The Series
$1u98 Beauty Show
1 vs. r00
2gBroke Girls
2DqV
Thb 20th Century
20/2w
21 Jimp Street