This file contains hidden or 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
// BEGIN kbob | |
// This is identical to https://vulkan-tutorial.com/Drawing_a_triangle/Swap_chain_recreation | |
// as of 2018-06-13 except for code between the "BEGIN kbob" and "END kbob" comments. | |
// The original code is still there but commented out with "//-". | |
// | |
// Built with MoltenVK 1.1.73 and GLFW 20180519 for MacOS, the original never recreated | |
// the swap chain. It continued to draw at the original 800 by 600 resolution and scaled | |
// the result to fit the resized window. | |
// | |
// Also, according to GLFW doc, the glfwGetWindowSize() is not the right function to call. |
This file contains hidden or 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
// Ask Hackaday: How do you DIY a Top-Octave Generator? | |
// https://hackaday.com/2018/05/24/ask-hackaday-diy-top-octave-generator/?utm_source=feedburner | |
// Target Arduino Mega. | |
// N.B., Timer 1 has highest interrupt priority, so | |
// use it for the highest frequency oscillators. | |
// Note Comp Port/Pin Arduino Pin | |
// C OC1A PB5 pin 11 | |
// B OC1B PB6 pin 12 |
This file contains hidden or 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
#define EXPECT | |
#include <assert.h> | |
#include <math.h> | |
#include <stdbool.h> | |
#include <stddef.h> | |
#include <stdio.h> |
This file contains hidden or 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 <assert.h> | |
#include <stdint.h> | |
#include <unistd.h> | |
/* print nine digit positive */ | |
char *p9dp(uint32_t n, char *p) | |
{ | |
uint32_t a = n % 10; | |
n /= 10; | |
if (n) { |
This file contains hidden or 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
struct TrieNode { | |
is_terminal: bool, | |
children: [Option<Box<TrieNode>>; 256], | |
} | |
impl TrieNode { | |
fn new() -> TrieNode { | |
let mem : TrieNode = unsafe { std::mem::zeroed() }; | |
mem | |
} |
This file contains hidden or 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
// Polyphase decimation filter. | |
// | |
// Convert an oversampled audio stream to non-oversampled. Uses a | |
// windowed sinc FIR filter w/ Blackman window to control aliasing. | |
// Christian Floisand's 'blog explains it very well. | |
// | |
// This version has a very simple main processing loop (the decimate | |
// method) which vectorizes easily. | |
// | |
// Refs: |
This file contains hidden or 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 itertools | |
def infinite_combinations(n, iterator): | |
seen = [] | |
for item in iterator: | |
for subset in itertools.combinations(seen, n - 1): | |
yield subset + (item,) | |
seen.append(item) |
This file contains hidden or 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/python | |
from itertools import count | |
def ramanujan_number(): | |
cubes = (i**3 for i in count(1)) | |
smaller_cubes = [] | |
sums = {} | |
for n in cubes: | |
for m in smaller_cubes: |
This file contains hidden or 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/python | |
# https://plus.google.com/u/0/114070220225686847236/posts/d7xrq9ph7WJ | |
# There are no repeated digits, and no adjacent digits with a | |
# difference of one, in the number 13524. How many such arrangements | |
# of 5 digits are there? What's the shortest program you can write to | |
# find out? | |
import itertools |
This file contains hidden or 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/python | |
from itertools import count, cycle, islice, izip, repeat | |
def fizzbuzz(n): | |
class d(int): __add__ = lambda self, other: other | |
def i(x): return x | |
def f(x): return x + 'Fizz' | |
def b(x): return x + 'Buzz' | |
def p(x): print x |