Skip to content

Instantly share code, notes, and snippets.

View Chase-san's full-sized avatar

Chase-san

  • Detroit, USA
View GitHub Profile
@Chase-san
Chase-san / gist:703178
Created November 17, 2010 09:12
Look Ma! No hands!
/**
* Recursive with no class level or local variables,
* a single int (the one passed in),
* a single call to print
* a single call to itself
* a single assignment
* a single if() statement (not counting ternaries)
* @param a
*/
public static void rc(int a) {
@Chase-san
Chase-san / Pack.java
Created March 19, 2012 10:16
The Pack Class
package cs.pack;
import java.util.ArrayList;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@Chase-san
Chase-san / Rabbit.java
Last active August 28, 2024 23:57
Rabbit Stream Cipher
package org.csdgn.crypt;
import java.util.Arrays;
/**
* Tested against the actual RFC.
*
* @author Chase (Robert Maupin)
* @see {@link http://tools.ietf.org/rfc/rfc4503.txt}
*/
@Chase-san
Chase-san / index.php
Last active December 12, 2015 02:18
A very tiny image gallery.
<?php /* Copyright(c) 2013 Robert Maupin. Released under the ZLIB License. */
if(count($_FILES) > 0) {
extract($_FILES['file']);
list($w,$h,$type)=getimagesize($tmp_name);
/*see exif-imagetype() documentation :) */
if(!$type||$type>3||filesize($tmp_name)>1024*200)
exit();
$ext=image_type_to_extension($type,false);
$md5=md5_file($tmp_name);
move_uploaded_file($tmp_name,$n="img/$md5.$ext");
@Chase-san
Chase-san / Rabbit.java
Created February 3, 2013 06:47
An implementation of the Rabbit Stream Cipher.
package org.csdgn.crypt;
import java.util.Arrays;
/**
* Tested against the actual RFC.
* This implementation is optimized for code length.
* Please do not use this version in production, use the much faster unrolled version here: https://gist.github.com/2814851
* @author Robert Maupin
* @see {@link http://tools.ietf.org/rfc/rfc4503.txt}
@Chase-san
Chase-san / chibichan.php
Last active December 12, 2015 02:49
A very tiny danbooru style image gallery!
<?php /* Copyright(c) 2013 Robert Maupin. Released under the ZLIB License. */
date_default_timezone_set('GMT');
define('DB','chan.db');
$max_image_size_kb = 1024*1024;
$thumbnail_size = 150;
$thumbnail_quality = 70;
$db = new PDO('sqlite:'.DB, 0, 0, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
function query($sql, $params = NULL) {
global $db;
$s = $db->prepare($sql);
@Chase-san
Chase-san / CSUtil.js
Last active December 12, 2015 08:29
A set of utilities for FightCode.
/* I prefer the singleton class creation method. */
var CSUtil = {
TWO_PI: Math.PI * 2,
TO_DEG: 180/Math.PI,
/**
* Returns the angle from x1y1 to x2y2. This function will accept
* robot.position, scannedRobot.position, and wrap.
*/
angleTo: function(p,q) {
@Chase-san
Chase-san / SkeletonHelper.java
Last active December 29, 2015 00:47
My jpct bones skeleton helper. Now with multiple pose interpolation and blending.
/**
* The MIT License (MIT)
*
* Copyright (c) 2013-2014 Robert Maupin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@Chase-san
Chase-san / rain.cpp
Created May 9, 2013 22:08
Matrix Digital Rain
#include <stdlib.h>
#include <windows.h>
#include <objidl.h>
#include <gdiplus.h>
using namespace Gdiplus;
wchar_t* characters =
//Hiragana
L"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもや"
@Chase-san
Chase-san / hash.go
Created May 10, 2013 18:51
Some basic hash functions for Go. I wrote this as my first attempt at Go.
package hash
type Hasher interface {
Update(uint8)
UpdateArray([]uint8)
Hash() uint32
Reset()
}
const (