Skip to content

Instantly share code, notes, and snippets.

@bricef
bricef / Sorted.fsx
Last active November 10, 2015 23:24
//#load "Spirograph.fs"
open System.Drawing
//open FSharp.TV.Spirograph
let round (x:float) = int (System.Math.Round (x))
module Seq =
let repeat items =
seq { while true do for item in items do yield item }
@bricef
bricef / FormationController.cs
Last active August 29, 2015 14:21 — forked from Jaandlu/gist:71f1a3f14df43a523dad
Update on boundary code
using UnityEngine;
using System.Collections;
public class FormationController : MonoBehaviour {
public GameObject enemyPrefab;
public float width = 10;
public float height = 5;
public float speed;
public float padding;
using UnityEngine;
using System.Collections;
public class ChangeOnCollision : MonoBehaviour {
private Material myMaterial;
// Use this for initialization
void Start () {
myMaterial = GetComponent<Renderer>().material;
using UnityEngine;
using System.Collections;
public class ChangeOnCollision : MonoBehaviour {
private Material myMaterial;
void Start () {
myMaterial = GetComponent<Renderer>().material;
}
@bricef
bricef / test.js
Last active August 29, 2015 14:05
#pragma strict
var damage = 20;
var vel = Vector2(0,10);
var boom : AudioClip;
function Start () {
rigidbody2D.velocity = vel;
}
@bricef
bricef / smartystring.c
Last active April 15, 2020 06:56
Dynamically growing a string in C.
#include <stdio.h>
#include <stdlib.h>
#define SMARTY_SIZE_INIT 16
typedef struct {
char * str; // a null terminated C string
char * end; // a pointer to the null byte, to be able to repeatedly append
// without using strlen() every time.
size_t size; // currently allocated size for *str, so we know when we
#include <stdio.h>
#if defined(SMALL)
#define SIZE 30
#endif
#if defined(LARGE)
#define SIZE 3000
#endif
/* random.c */
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
void parser(char *input, double particles[][4]){
sscanf(
input,
"p[20] = nullvector(%lf,%lf,%lf,%lf)",
&particles[20][3], &particles[20][0],
@bricef
bricef / gist:2464895
Created April 22, 2012 16:00
Generating an IV in C
int genIV(
void* buffer,
int buffer_len
){
/*
* Note that we propagate the return code from the library called.
*/
#ifndef _WIN32
return RAND_bytes(buffer, buffer_len);
#else
@bricef
bricef / gist:2463908
Created April 22, 2012 12:22
Generating an IV in Java
import java.security.SecureRandom;
public static byte[] genIV(int len) throws Exception{
byte[] arr = new byte[len];
SecureRandom prng = SecureRandom.getInstance("SHA1PRNG");
prng.nextBytes(arr);
return arr;
}