This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <errno.h> | |
#include <semaphore.h> | |
#include <time.h> | |
#include <unistd.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import anushri | |
OUTPUT_CLIENT = 20 | |
BPM = 70 | |
BEAT_LENGTH = 60 / BPM | |
WHOLE_LENGTH = BEAT_LENGTH * 4 | |
NOTE_16 = WHOLE_LENGTH / 16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# This code demonstrates a code sequence that will cause the Python sqlite | |
# to immediately generate a "database is locked" exception, even with a large | |
# timeout | |
import sqlite3 | |
import time | |
import threading |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
for a in /dev/sd*1 | |
do | |
SECTORS=$(/sbin/blockdev --getsize $a) | |
SECTOR=$(python -c "import random; print random.randint(0, $SECTORS - 1);") | |
dd if=$a of=/dev/null iflag=direct skip=${SECTOR} bs=512 count=1 2>/dev/null & | |
done | |
wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import queue | |
import os | |
import pyudev | |
import urwid | |
text = urwid.Text("") | |
loop = urwid.MainLoop(urwid.Filler(text)) | |
inter_thread_queue = queue.Queue() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is the header that does all the heavy-lifting | |
// NB: lots of boilerplate | |
// runtime function table | |
struct FrobableTable { | |
int (*frob)(const void *ptr); | |
}; | |
// forward declaration of the implementation | |
template<class FrobableImplType> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This benchmark shows how indirect function calls have nearly | |
the same overhead costs as direct function calls. | |
This is comparing apples to apples, factoring out the savings | |
due to inlining optimizations that direct calls usually afford. | |
From this, it seems that inlining and other generic interprocedual | |
optimizations are the main drivers of direct function call optimization, | |
not the direct call itself. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
#include <cstring> | |
#include <cstdio> | |
template <size_t N> | |
class StaticallySizedString { | |
char _str[N + 1]; | |
public: |