Skip to content

Instantly share code, notes, and snippets.

View avivbeeri's full-sized avatar

Aviv Beeri avivbeeri

View GitHub Profile
#include <stdio.h>
#include "wren.h"
char* script = " class Colored { \n"
" foreign static point(a, b)\n"
" }\n"
" class App { \n"
" \n"
" static update() {\n"
" var red = [1, 0, 0, 1]\n"
@avivbeeri
avivbeeri / test.c
Last active October 24, 2019 08:18
Minimal case for foreign allocate issue with wrenEnsureSlot
#include <stdio.h>
#include "wren.h"
void TEST_allocate(WrenVM* vm) {
// HERE:
// Changing the number of slots to be n + 2 where n is the number of arguments
// for the foreign class constructor causes an error to occur.
// It looks like Wren get's confused about what the return value
// is supposed to be.
wrenEnsureSlots(vm, 2);
@avivbeeri
avivbeeri / playwav.c
Created July 13, 2018 21:00 — forked from armornick/playwav.c
Play a sound with SDL2 (no SDL_Mixer)
#include <SDL2/SDL.h>
#define MUS_PATH "Roland-GR-1-Trumpet-C5.wav"
// prototype for our audio callback
// see the implementation for more information
void my_audio_callback(void *userdata, Uint8 *stream, int len);
// variable declarations
static Uint8 *audio_pos; // global pointer to the audio buffer to be played
@avivbeeri
avivbeeri / prng.js
Created July 11, 2018 12:01 — forked from blixt/prng.js
A very simple, seedable JavaScript PRNG.
/**
* Creates a pseudo-random value generator. The seed must be an integer.
*
* Uses an optimized version of the Park-Miller PRNG.
* http://www.firstpr.com.au/dsp/rand31/
*/
function Random(seed) {
this._seed = seed % 2147483647;
if (this._seed <= 0) this._seed += 2147483646;
}
@avivbeeri
avivbeeri / random.js
Created July 11, 2018 12:00 — forked from kerimdzhanov/random.js
JavaScript: get a random number from a specific range
/**
* Get a random floating point number between `min` and `max`.
*
* @param {number} min - min number
* @param {number} max - max number
* @return {number} a random floating point number
*/
function getRandomFloat(min, max) {
return Math.random() * (max - min) + min;
}
@avivbeeri
avivbeeri / index.html
Created December 22, 2015 14:30
Paste to canvas demo
<body>
<canvas id="canvas"></canvas>
<div style="width: 200px; height: 200px; background: grey" id="pasteTarget">
Click and paste here.
</div>
</body>