Skip to content

Instantly share code, notes, and snippets.

/* Function: al_transform_rotation
*/
void al_transform_rotation(const ALLEGRO_TRANSFORM *trans, float* rotation)
{
float t = *rotation;
*rotation = t - atan2f(trans->m[0][1], trans->m[0][0]);
}
static void bitmap_source_release_content(ALLEGRO_GC_BITMAPSOURCE *bitmap_source)
{
if ( bitmap_source->type == BS_NORMAL )
{
if ( bitmap_source->name_to_bitmap )
{
/* free string key */
AL_AATREE_ITERATOR* iterator = al_aa_begin(bitmap_source->name_to_bitmap);
while (iterator && al_aa_next(iterator))
http://pin.it/zuSovQT
@fengye
fengye / new_gist_file.js
Last active January 20, 2016 14:59
How JavaScript closure works
//From http://stackoverflow.com/questions/111102/how-do-javascript-closures-work
function sayHello2(name) {
var text = 'Hello ' + name; // Local variable
var say = function() { console.log(text); }
return say;
}
var say2 = sayHello2('Bob');
say2(); // logs "Hello Bob"
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaFormat;
import android.util.Log;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@fengye
fengye / octavetest
Last active January 21, 2017 02:16
if (midiNote > 0)
{
int octave = midiNote / 12;
int noteNum = midiNote % 12;
int normalizedNote;
if (octave % 2 == 0)
{
normalizedNote = noteNum;
}
#!/bin/bash
find -maxdepth 1 -type d | while read -r dir; do printf "%s:\t" "$dir"; find "$dir" -type f | wc -l; done
@fengye
fengye / min-char-rnn.py
Last active February 11, 2017 06:38 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@fengye
fengye / TestBehaviour.cs
Last active February 18, 2018 01:03
A study on MonoBehaviour's behaviour in the game and in Unity editor.
using UnityEngine;
using System.Collections;
public class TestBehaviour : MonoBehaviour {
TestBehaviour()
{
// Will be called in Editor(play in game view, stop and back to scene) and Game.
// Will also be called when script get recompiled.
Debug.Log("TestBehaviour ctor: " + System.DateTime.Now.Ticks);