Skip to content

Instantly share code, notes, and snippets.

View adituv's full-sized avatar

Iris Ward adituv

View GitHub Profile
@adituv
adituv / input.cc
Last active August 29, 2015 13:56
C++ space-delimited inputs
#include <iostream>
#include <fstream>
#include <limits>
using namespace std;
int main() {
float val1, val2;
int line = 0;
ifstream file("temp.txt", ifstream::in);
@adituv
adituv / .vimrc
Created November 5, 2014 01:01
I had to recreate my vimrc. Based heavily on http://statico.github.io/vim.html
"BEGIN Vundle stuff
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'kien/ctrlp.vim'
@adituv
adituv / Main.hs
Last active August 29, 2015 14:15
Qualified Record Pun
{-# LANGUAGE NamedFieldPuns #-}
module Main where
import qualified MyRecord as M
someFunction :: M.MyRecordType -> Int
someFunction (MyRecordType { M.someVal }) = M.someVal * M.someVal
main :: IO ()
main = print . someFunction . MyRecordType $ 3
@adituv
adituv / CList.hs
Created June 22, 2015 04:48
Constrained heterogeneous list
{-# LANGUAGE ConstraintKinds, GADTs, RankNTypes #-}
module CList where
infixr 5 :>
data CList c where
Nil :: CList c
(:>) :: forall c t. (c t) => t -> CList c -> CList c
-- "Monomorphic map instance" (ish) for CList. Converts to normal list.
@adituv
adituv / AutoVersion.md
Last active August 29, 2015 14:27
Visual Studio 2012 - Automatically incrementing version for C#

This requires Microsoft Visual Studio 2012 SDK and Microsoft Visual Studio 2012 Visualization & Modeling SDK, which come separately from Visual Studio 2012. Other version combinations are probably possible, and maybe compatible, but untested. The core of the method is this:

  • Add AssemblyInfo.tt to MyProject\Properties, filling out the "Your xxxxxx" sections.
  • Open up the project file (e.g. MyProject.csproj) in a text editor (e.g. Notepad++), and locate the line that defines the build targets for the language ("import project... microsoft.csharp.targets")
  • Insert the contents of MyProject.csproj there
  • Finally, if you build the AssemblyInfo.tt template within Visual Studio, make sure to set AssemblyInfo1.cs to Build Action: None in the File Properties window. This will fix any errors about duplicate definitions.
@adituv
adituv / keybase.md
Created September 13, 2015 22:34
keybase.md

Keybase proof

I hereby claim:

  • I am adituv on github.
  • I am adituv (https://keybase.io/adituv) on keybase.
  • I have a public key whose fingerprint is 798A 393A 8BE6 7A6C 060D 8D06 86D6 0E51 3A2B 000F

To claim this, I am signing this object:

@adituv
adituv / denki.lua
Last active October 17, 2015 15:33
Denki Blocks Lua
--[[
Denki Blocks - BizHawk Lua Overlay
Version 1.0.0
Contributions by AdituV
You may use, edit, and redistribute this file under the
condition that this notice is left intact, and attribution
is provided for all contributions as above.
]]
@adituv
adituv / Khinchin.py
Last active December 20, 2015 03:49
A demonstration of Khinchin's constant for the continued fraction expansion of the number pi. Obviously as python has finite precision floating point, this is only an approximation, and is likely to approach an incorrect result as a grows larger.
#!/usr/bin/python3
from math import floor
from math import pi
def getExpansion(y):
x = y
while True:
z = floor(x)
yield z
@adituv
adituv / dotprod.c
Last active December 20, 2015 04:58
OpenCL pseudocode to demonstrate the usual pattern of calling OpenCL
//The code that runs on the graphics card is included in the program here as a plaintext string
//It's also possible to include it as a binary, but I don't know how to do that.
const char* source=
"__kernel \n"
"void sum(__global float* source, __global float* dest, uint n) \n"
" int idx = get_global_id(0); \n"
" int iter = 2; \n"
" \n"
" while(iter < n && idx % iter == 0) { \n"
" dest[min(iter*idx,n)] = source[min(iter*idx,n)] + source[(iter-1)*idx]; \n"
@adituv
adituv / point_of_no_return.sound
Last active December 26, 2015 15:38
Very simple converter from list of frequencies and durations to output sound wave on stdout. Pipe it through e.g. /dev/audio or aplay to actually create sound.
1.25@130.8127827
0.25@174.6141157
0.25@164.8137785
0.25@174.6141157
0.75@195.9977180
0.25@207.6523488
1.00@195.9977180
1.25@0
0.25@174.6141157
0.25@195.9977180