Skip to content

Instantly share code, notes, and snippets.

@Rhomboid
Rhomboid / calckb.txt
Created May 8, 2014 00:13
Windows calc keyboard shortcuts
Atl+1 Switch to Standard mode
Alt+2 Switch to Scientific mode
Alt+3 Switch to Programmer mode
Alt+4 Switch to Statistics mode
Ctrl+E Open date calculations
Ctrl+H Turn calculation history on or off
Ctrl+U Open unit conversion
Alt+C Calculate or solve date calculations and worksheets
F1 Open Calculator Help
Ctrl+Q Press the M- button
@Rhomboid
Rhomboid / bubblesort_lambda.cpp
Last active August 29, 2015 14:03
bubble sort with lambda
#include <vector>
#include <string>
#include <random>
#include <iterator>
#include <iostream>
#include <algorithm>
template<typename T, typename Eng>
std::vector<T> make_random_ints(size_t n, Eng eng, T min, T max)
{
@Rhomboid
Rhomboid / commands.sh
Created July 15, 2014 11:45
Download Weird Al's Tacky with rtmpdump
rtmpdump -o weirdal_tacky.flv -r rtmpe://fms.413C.edgecastcdn.net/00413C/content/ -y 'mp4:conversions/bzmbq0FD/videos/udcyXmsG-3208411.mp4?eee6cc8084bc02b3096443468bd6269a25236a7cc572265bd247c2deec86cc78281f8efc5c11f24dcf4870bc3d93ce2fd5eb2b45776315b6885e4e4f7ce40d249661772ad7f52e90cd98aa89cf5caf5ccd009ea054b841d3938839543b4a455dec905139d42bc43c63ca3340dc6f9209'
# if it doesn't work, fetch http://content.nerdist.com/manifests/udcyXmsG.smil and get the parameters from there
@Rhomboid
Rhomboid / func.cpp
Created August 16, 2014 20:44
ODR and inlining demonstration
#include "func.hpp"
void (*func_ref_func)(void) = &func;
void hidden() {
// stuff
}
@Rhomboid
Rhomboid / gist:fcd11a01934a34365c7b
Created August 26, 2014 13:28
identifiers used in the C++11 standard library
__alignas_is_defined
__bool_true_false_are_defined
_1
_Exit
abort
abs
accumulate
acos
acosh
address
@Rhomboid
Rhomboid / source.c
Last active August 29, 2015 14:07
Scaling 0-255 to 0.00-5.00 for a microcontroller with only 8 bit operations
#include <stdio.h>
#include <string.h>
static const unsigned char lookup[][5] = { { 0, 0, 1, 9, 6 },
{ 0, 0, 3, 9, 2 },
{ 0, 0, 7, 8, 4 },
{ 0, 1, 5, 6, 9 },
{ 0, 3, 1, 3, 7 },
{ 0, 6, 2, 7, 5 },
{ 1, 2, 5, 4, 9 },
@Rhomboid
Rhomboid / bench.py
Last active August 29, 2015 14:08
Python JSON module benchmark (3.x)
from random import randint, random, choice, uniform, seed
from string import ascii_letters
from timeit import repeat
import json
def rand_string():
return ''.join(choice(ascii_letters) for _ in range(randint(3, 24)))
def make_test_data(depth=0):
if random() > 1 - (depth / 9)**3:
@Rhomboid
Rhomboid / string_reverse_msdos.asm
Created March 9, 2015 03:22
MS-DOS string reverse program
.model small
; int 21h functions used:
DOS_PRINTSTR equ 09h ; output a $-terminated string in DS:DX
DOS_INPUT equ 0ah ; read buffered input into structure at DS:DX
DOS_EXIT equ 4ch ; terminate program with exit code in AL
.stack
.data
prompt_text db 'Enter a string: $'
output_text db 0ah, 0dh, 'Your string reversed: $'
@Rhomboid
Rhomboid / swaptest.cpp
Created March 14, 2015 18:51
The stupidity of using XOR to swap integers
#include <iostream>
#include <vector>
#include <random>
#include <iterator>
#include <algorithm>
#include <functional>
#include <chrono>
using test_type = unsigned;
@Rhomboid
Rhomboid / foo.cpp
Created October 10, 2012 21:50
C++11 range based for with containers
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <list>
#include <map>
using namespace std;
int main()
{