Skip to content

Instantly share code, notes, and snippets.

@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(); ?>
// 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 / 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>
@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 / 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 / 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 / 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 / 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 / calculate-total.js
Created July 5, 2012 20:11
Calculate Total
function calculateTotal(boxes, total) {
boxes.find('option:selected').each(function() {
var m = /\[\+ \$(\d+\.\d+)\]/.exec(this.value);
if(m !== null) {
total += +m[1];
}
});
var decimalPart = (total - Math.floor(total)) * 100;
@minitech
minitech / ruby.c
Created July 1, 2012 17:14
Fake Ruby
// This C is pretending to be Ruby.
// Yeah, I know the ifs aren't quite right. Oh well.
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#define puts );printf("%s\n",
#define gets _gets()
#define if );if(