Skip to content

Instantly share code, notes, and snippets.

View MitMaro's full-sized avatar
🦀
Rewritten in Rust

Tim Oram MitMaro

🦀
Rewritten in Rust
View GitHub Profile
@MitMaro
MitMaro / gist:959013
Created May 6, 2011 14:08
Doctrine 2 Remove Bug
<?php
require_once 'library/Doctrine/Common/ClassLoader.php';
$classLoader = new Doctrine\Common\ClassLoader('Doctrine', 'library/');
$classLoader->register();
// Set up caches
$config = new Doctrine\ORM\Configuration;
$cache = new Doctrine\Common\Cache\ArrayCache;
@MitMaro
MitMaro / gist:1054156
Created June 29, 2011 15:57
Doctrine Join Table Filter
/**
* @Entity
*/
class User {
// ...
}
/**
* @Entity
@MitMaro
MitMaro / gist:1677024
Created January 25, 2012 16:16
RoboDonna
import Chalkboard;
import Mouth;
import java.io.IOException;
import java.io.InputStream;
import java.io.File;
import UnknownEmotion;
public class RoboDonna {
public static void main(String [] args) {
RoboDonna donna = new RoboDonna();
@MitMaro
MitMaro / gist:2941752
Created June 16, 2012 15:51
PHP Cache Example
<?php
define("CACHE_FILE_NAME", "cache.html");
define("CACHE_TIME", 1 * 60 * 60);
// timeout cache (you can also delete the file on update to page and check for existing file only or combination of both)
if (filemtime(CACHE_FILE_NAME) + CACHE_TIME >= time() ) {
echo file_get_contents(CACHE_FILE_NAME);
return;
}
@MitMaro
MitMaro / gist:3691466
Created September 10, 2012 15:19
Why you need symbol concat in macro
/* If you had this it would break */
#define SWAP(x, y, T) do { T temp = x; x = y; y = temp; } while (0)
int main(void) {
int temp;
int a = 1;
int b = 2;
invert (unsigned x, int p, int n){
p = specified starting position, n = how many to change, x = number being altered;
while (p <= n){
change the 0 or 1 at p to the opposite;
n++;
}
}
@MitMaro
MitMaro / cs3710a1q1.c
Created September 15, 2012 20:06
cs3710a1q1
/*Question 1: Bitwise operators*/
#define INT_SIZE (sizeof(int) * 8)
#include <stdio.h>
/* Helper function to print a binary representation of an unsigned integer */
void print_int_as_binary_string(unsigned int b) {
int i;
char buffer[INT_SIZE + 1];
@MitMaro
MitMaro / gist:3729657
Created September 15, 2012 20:42
Swap Macro
/* If you have this it would not break */
#define SWAP(x, y, T) do { T temp##x##y = x; x = y; y = temp##x##y; } while (0)
int main(void) {
int temp;
int a = 1;
int b = 2;
@MitMaro
MitMaro / build.xml
Created November 14, 2012 13:51
Ant Build File Tempate
<?xml version="1.0"?>
<project name="Clue" default="main" basedir=".">
<property name="src.dir" location="src" />
<property name="build.dir" location="build" />
<property name="dist.jar" location="clue.jar" />
<property name="libs.dir" location="jars" />
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${dist.jar}" />
@MitMaro
MitMaro / script.js
Created December 24, 2012 04:37
Google Docs - Duplicate Row Down Script
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [ {name: "Duplicate Selected Row Down", functionName: "duplicate_row_down"},];
ss.addMenu("Utilities",menuEntries);
}
function duplicate_row_down (){
var sh = SpreadsheetApp.getActiveSheet();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var d = ss.getActiveSelection();