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 / trollsort.c
Created December 28, 2013 13:44
Very stupid sort (trolling homework)
/* http://codegolf.stackexchange.com/questions/16226/trolling-homework-questions-sorting */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
void read_some_doubles(double **data, size_t *size)
{
char buf[512], *endptr;
@Rhomboid
Rhomboid / example.py
Created December 22, 2013 06:41
Python itertools.groupby example with US state capitals
from itertools import groupby
state_capitals = ['Montgomery', 'Juneau', 'Phoenix', 'Little Rock', 'Sacramento', 'Denver',
'Hartford', 'Dover', 'Tallahassee', 'Atlanta', 'Honolulu', 'Boise', 'Springfield',
'Indianapolis', 'Des Moines', 'Topeka', 'Frankfort', 'Baton Rouge', 'Augusta',
'Annapolis', 'Boston', 'Lansing', 'Saint Paul', 'Jackson', 'Jefferson City',
'Helena', 'Lincoln', 'Carson City', 'Concord', 'Trenton', 'Santa Fe', 'Albany',
'Raleigh', 'Bismarck', 'Columbus', 'Oklahoma City', 'Salem', 'Harrisburg',
'Providence', 'Columbia', 'Pierre', 'Nashville', 'Austin', 'Salt Lake City',
'Montpelier', 'Richmond', 'Olympia', 'Charleston', 'Madison', 'Cheyenne']
@Rhomboid
Rhomboid / inordertree.c
Created December 18, 2013 09:35
Recursive stack blowout demonstration
#include <stdio.h>
#include <stdbool.h>
struct node {
void *val;
struct node *left, *right;
};
void in_order_traverse(const struct node *n, void (*callback)(const void *), size_t depth)
{
@Rhomboid
Rhomboid / superbowl.cpp
Created December 5, 2013 08:42
C++11 homework example (Superbowl scores)
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <string>
#include <limits>
#include <iterator>
#include <algorithm>
#include <utility>
using namespace std;
@Rhomboid
Rhomboid / urls.txt
Created December 2, 2013 19:34
Web scraping example
This file has been truncated, but you can view the full file.
http://databases.lovd.nl/shared/genes/A1BG
http://proteomics.bio21.unimelb.edu.au/lovd/genes/A1BG
http://databases.lovd.nl/shared/genes/A1BG-AS1
http://proteomics.bio21.unimelb.edu.au/lovd/genes/A1BG-AS1
http://databases.lovd.nl/shared/genes/A1CF
http://proteomics.bio21.unimelb.edu.au/lovd/genes/A1CF
http://databases.lovd.nl/shared/genes/A2LD1
http://databases.lovd.nl/shared/genes/A2M
http://proteomics.bio21.unimelb.edu.au/lovd/genes/A2M
http://databases.lovd.nl/shared/genes/A2M-AS1
@Rhomboid
Rhomboid / eulersieve.py
Created November 30, 2013 08:45
Python number sieve performance comparison
# http://projecteuler.net/problem=7 (should print 104743)
from operator import itemgetter
from timeit import repeat
def ver1(n):
'''Original, baseline version that uses a dict'''
eratosthenes = dict.fromkeys(range(2, n), True)
for i in range(2, n):
if eratosthenes[i]:
@Rhomboid
Rhomboid / cachesize.cpp
Created November 29, 2013 05:01
Simplistic cache size measurement (C++11)
#include <iostream>
#include <sstream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
using namespace std;
using namespace std::chrono;
int main()
@Rhomboid
Rhomboid / foo.c
Created September 3, 2013 02:37
Interesting integer signed overflow testcase
#include <stdio.h>
#include <string.h>
int main(void)
{
char t[] = "abcdefghijklmnopqrstuvwxyz";
for (int i = 0, n = strlen(t); i < n; i++)
{
if (t[i] >= 'a' && t[i] <= 'z')
{
@Rhomboid
Rhomboid / gist:6185478
Created August 8, 2013 15:13
Chromium Blink license analysis
bsd_2clause_ish AbstractDatabaseServer.h
bsd_2clause_ish AbstractSQLStatementBackend.h
bsd_2clause_ish AbstractSQLStatement.h
bsd_2clause_ish AbstractSQLTransactionBackend.h
bsd_2clause_ish AbstractSQLTransaction.h
bsd_2clause_ish AccessibilityMockObject.cpp
bsd_2clause_ish AccessibilityMockObject.h
lgpl AccessibilityProgressIndicator.cpp
lgpl AccessibilityProgressIndicator.h
bsd_2clause_ish AccessibilityScrollView.cpp