Skip to content

Instantly share code, notes, and snippets.

View soundmasteraj's full-sized avatar

AJW soundmasteraj

  • Orbiting a virtual particle
View GitHub Profile
@soundmasteraj
soundmasteraj / CircularBuffer.h
Created April 28, 2016 09:07 — forked from yagihiro/CircularBuffer.h
circular buffer library for Arduino (C++)
/*
CircularBuffer.h - circular buffer library for Arduino.
Copyright (c) 2009 Hiroki Yagita.
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
@soundmasteraj
soundmasteraj / 577457-a-star-shortest-path-algorithm
Created May 17, 2016 00:19
Implementing some of the other commenter's helpful code revisions
Hey, I incorporated some of these helpful comments from other users, this compiles on Dev C++ and now runs without causing abnormal termination on Windows 10
Thanks everybody! Hope this is helpful in some way. :)
https://code.activestate.com/recipes/users/4192555/
https://code.activestate.com/recipes/users/4180055/
// Astar.cpp
// http://en.wikipedia.org/wiki/A*// Compiler: Dev-C++ 4.9.9.2// FB - 201012256
#include <cstdlib> // new
@soundmasteraj
soundmasteraj / gist:31016c9043fcd22de90ed003a42d3a61
Created February 19, 2018 21:41 — forked from borismus/gist:1032746
Convert a base64 string into a binary Uint8 Array
var BASE64_MARKER = ';base64,';
function convertDataURIToBinary(dataURI) {
var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
var base64 = dataURI.substring(base64Index);
var raw = window.atob(base64);
var rawLength = raw.length;
var array = new Uint8Array(new ArrayBuffer(rawLength));
for(i = 0; i < rawLength; i++) {
@soundmasteraj
soundmasteraj / short_version.py
Last active March 13, 2018 15:55 — forked from miloharper/short_version.py
A neural network in 9 lines of Python code.
from numpy import exp, array, random, dot
training_set_inputs = array([[0, 0, 1], [1, 1, 1], [1, 0, 1], [0, 1, 1]])
training_set_outputs = array([[0, 1, 1, 0]]).T
random.seed(1)
synaptic_weights = 2 * random.random((3, 1)) - 1
for iteration in xrange(10000):
output = 1 / (1 + exp(-(dot(training_set_inputs, synaptic_weights))))
synaptic_weights += dot(training_set_inputs.T, (training_set_outputs - output) * output * (1 - output))
print 1 / (1 + exp(-(dot(array([1, 0, 0]), synaptic_weights))))
/*
* OpenSimplex Noise in Java.
* by Kurt Spencer
*
* v1.1 (October 5, 2014)
* - Added 2D and 4D implementations.
* - Proper gradient sets for all dimensions, from a
* dimensionally-generalizable scheme with an actual
* rhyme and reason behind it.
* - Removed default permutation array in favor of
OpenSimplexNoise noise;
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
int numFrames = 100;
PVector field(float x,float y){
float amount = 2.5;
float scale = 0.03;
float radius = 0.45;
double value1 = 400.0*noise.eval(scale*x,scale*y,radius*cos(TWO_PI*1.0*(frameCount-1)/numFrames),radius*sin(TWO_PI*1.0*(frameCount-1)/numFrames));
double value2 = 400.0*noise.eval(1000+scale*x,scale*y,radius*cos(TWO_PI*1.0*(frameCount-1)/numFrames),radius*sin(TWO_PI*1.0*(frameCount-1)/numFrames));
//int value2 = (int) Math.round(value);
float parameter1 = (int) Math.round(value1)/100.0;
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
if (p < 0.5)
return 0.5 * pow(2*p, g);
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
if (p < 0.5)
return 0.5 * pow(2*p, g);
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
if (p < 0.5)
return 0.5 * pow(2*p, g);