Skip to content

Instantly share code, notes, and snippets.

int max_rand_step = 5;
int frame_num = 0;
int shape_opacity = 20;
int num_of_rects = 40;
void setup(){
size(displayWidth, displayHeight);
frameRate(40);
}
@bgrayburn
bgrayburn / localStorageArrays.coffee
Last active September 1, 2015 13:55
Functions to utilize localStorage as arrays of json objects
initLocalStorageArray = (name)->
if (localStorage.getItem(name)==null)||(localStorage.getItem(name)[0]!='[')
localStorage.setItem(name,'[]')
offlineArrays = ['array1','array2']
offlineArrays.forEach (n)->initLocalStorageArray(n)
clearArrays = ->
offlineArrays.forEach (n)->localStorage.setItem(n,'[]')
@bgrayburn
bgrayburn / wordWrap
Last active May 30, 2022 15:37
A javascript function to word wrap given a long string and a max line length
var wordwrap = function(long_string, max_char){
var sum_length_of_words = function(word_array){
var out = 0;
if (word_array.length!=0){
for (var i=0; i<word_array.length; i++){
var word = word_array[i];
out = out + word.length;
}
};