Skip to content

Instantly share code, notes, and snippets.

-- A simple test for index-function generalization across a for loop
-- ==
-- input { [0, 1000, 42, 1001, 50000] }
-- output { 52043i32 }
-- structure gpu { Copy 0 }
let main [n] (a: [n]i32): i32 =
let b = loop xs = a[1:] for i < n / 2 - 2 do
xs[i:] -- This will result in a copy, but it needn't
in reduce (+) 0 b
f :: [a] -> [a]
f (x:x':xs) = x':x:xs
f xs = xs
import Data.List
import Text.Printf
type Point = (Int, Int)
ccw :: Point -> Point -> Point -> Int
ccw p1 p2 p3 = (fst p2 - fst p1) * (snd p3 - snd p1)
- (snd p2 - snd p1) * (fst p3 - fst p1)
#![feature(no_std)]
#![no_std]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate "std" as std;
fn main() {
let v =
<[_] as
::std::slice::SliceExt>::into_vec(::std::boxed::Box::new([1, 2]));
#!/bin/env python2
import urllib2
def main():
f = open('fil', 'r')
out = open('out', 'w')
for line in f:
h = urllib2.urlopen(line)
out.write(h.read())
### Keybase proof
I hereby claim:
* I am Munksgaard on github.
* I am munksgaard (https://keybase.io/munksgaard) on keybase.
* I have a public key whose fingerprint is A8DB 29FF 0D46 722B EC5F 536A 9F88 3D7F D6D9 3E64
To claim this, I am signing this object:
@Munksgaard
Munksgaard / wakeup
Created January 4, 2015 21:16
A script to wake you up by playing some music.
#!/bin/bash
#
# Wakeup
# Author: Philip Munksgaard
# Description: Suspends the computer and wakes up at a specified
# time and starts playing a song.
# Note: does not ensure that sound is on and high enough!
wakeuptime=$1
shift
@Munksgaard
Munksgaard / rndphrase.c
Last active August 29, 2015 14:12
A very simple implementation of rndphrase in C
/* rndphrase.c
*
* Author: Philip Munksgaard <pmunksgaard@gmail.com>
* Date: 2014-12-29
*
* This whole thing is pretty much a direct port of the implementation from
* brinchj's original rndphrase.js:
* https://github.com/brinchj/rndphrase
*/
$ cargo run
Compiling cube v0.0.0 (file:///home/munksgaard/src/piston-examples/gfx_cube)
src/main.rs:51:29: 51:50 error: wrong number of lifetime parameters: expected 1, found 0 [E0107]
src/main.rs:51 static VERTEX_SRC: &'static gfx::ShaderSource<u8> = shaders! {
^~~~~~~~~~~~~~~~~~~~~
src/main.rs:51:29: 51:50 error: wrong number of type arguments: expected 0, found 1
src/main.rs:51 static VERTEX_SRC: &'static gfx::ShaderSource<u8> = shaders! {
@Munksgaard
Munksgaard / plade.js
Created March 21, 2014 14:51
Bankopladegenerator
var count = 0;
function nextrow(row) {
var i,j;
for (i = 0; i < 5; i++) {
if (i == 4 && row[i] == 8) {
return null;
} else if (i == 4 || row[i] < row[i+1] - 1) {
row[i]++;
for (j=0; j<i; j++) row[j] = j;