Skip to content

Instantly share code, notes, and snippets.

@minitech
minitech / alternative-looping.cs
Created July 9, 2012 14:25
Another way to loop
// Alternative looping.
// I wouldn't do this using a foreach loop, but it is much nicer than
// the original here: http://stackoverflow.com/a/11367974/707111
public int getNthIndex(string str, char c, int n)
{
int index = 0;
int count = 0;
if(n == 0)
@minitech
minitech / else.ismeta
Created July 10, 2012 21:03
ISMETA: else implementation
def else (Block b) (Block k = Block.empty) {
(Condition c) {
Condition r = if not c b
k r
}
}
@minitech
minitech / dabblet.css
Created July 17, 2012 21:12
A functional door.
/**
* A functional door.
*/
#wall {
background-color: #eee;
bottom: 0;
left: 0;
position: absolute;
right: 0;
@minitech
minitech / dabblet.css
Created July 17, 2012 21:14
A functional door.
/**
* A functional door.
*/
#wall {
background-color: #eee;
bottom: 0;
left: 0;
position: absolute;
right: 0;
@minitech
minitech / server.c
Created July 25, 2012 00:37
My prototype webserver-thing
#include "xeric-utils.h"
/* The main method. */
int main(int argc, char * argv[]) {
int i;
int port = 80;
struct in_addr address = {0};
/* Parse the arguments: */
for(i = 1; i < argc; i++) {
@minitech
minitech / xeric-utils.h
Created July 25, 2012 01:24
The missing header file.
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
// In regards to
// http://stackoverflow.com/questions/11679116/creating-a-dynamic-binding-in-javascript
for(var i = 0; i < info.length; i++){
var temp = [
parseInt(info[i].site_id),
info[i].site,
info[i].site_code,
processArray(info[i].tc10),
processArray(info[i].tc9x_test),
@minitech
minitech / gist:3314755
Created August 10, 2012 14:50
I never even thought to do this before

Globals, schmobals.

<?php function header($navigation) { ?>
<header id="header">
    Some amazing title
</header>

<?php $navigation(); ?>
@minitech
minitech / ball.js
Created August 11, 2012 00:52
Ball bashing head against ceiling
// A failed attempt
function animate() {
g.clearRect(0, 0, 32, 32);
var t = (new Date().getTime() - start) / 1000;
var circlePosition = Math.min(1, Math.abs(Math.tan(t * Math.PI) / Math.PI));
g.beginPath();
g.arc(16 + Math.cos(circlePosition * Math.PI) * 8, 16 + Math.sin(circlePosition * Math.PI) * 8, 2.5, 0, Math.PI * 2);
// Some code I found from 2009 :)
function isNullOrUndefined(o) {
if(o === null) {
return true;
}
if(typeof o === "undefined") {
return true;
}
if(o === undefined) {