Skip to content

Instantly share code, notes, and snippets.

View jaronwanderley's full-sized avatar

Jaron Wanderley jaronwanderley

View GitHub Profile
@fschr
fschr / main.cpp
Last active September 30, 2025 19:32
SDL2 Hello World | SDL2 Getting Started | SDL | OpenGL
// SDL2 Hello, World!
// This should display a white screen for 2 seconds
// compile with: clang++ main.cpp -o hello_sdl2 -lSDL2
// run with: ./hello_sdl2
#include <SDL2/SDL.h>
#include <stdio.h>
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
@blahah
blahah / README.md
Created April 17, 2016 07:34
Comparison of embedded NoSQL databases that can be emedded in a Node.js - Electron app

Making an Electron app and want to embed a database? Here's a table to help you choose the right database software.

Work in progress

Project Language NPM package? Flat file? In memory? Full-text search? Maturity Embedded size Dependencies
NeDB Javascript Yes Always No High Low Simple
Lunr Javascript No Yes Yes High Tiny None
Search-index Javascript
Sqlite3 C Yes No Yes (fts extens
@paiv
paiv / mathcalc.js
Last active October 29, 2023 11:13
Expression parser in JavaScript
//
// MathCalc: a parser for basic mathematical expressions
// From here: https://paiv.github.io/blog/2016/03/23/js-calc.html
//
//
// Copyright (c) 2016, Pavel Ivashkov, github.com/paiv
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
@william-silversmith
william-silversmith / springfactory.js
Last active August 25, 2023 12:24
Spring Factory
/* springFactory
*
* Generate a physically realistic easing curve for a damped mass-spring system.
*
* Required:
* damping (zeta): [0, 1)
* halfcycles: 0...inf
*
* Optional:
* initial_position: -1..1, default 1
@william-silversmith
william-silversmith / sigmoidfactory.js
Last active October 26, 2021 12:15
An ease-in-out curve that has customizable steepness.
/* sigmoidFactory
*
* Generate an ease-in-out function with desired steepness.
* Accompanying article: https://medium.com/analytic-animations/ease-in-out-the-sigmoid-factory-c5116d8abce9
*
* Required:
* k: (float != 0), sharpness of ease
*
* Return: f(t), t in 0..1
*/
@cauerego
cauerego / IndexedDB101.js
Last active January 13, 2023 22:00 — forked from JamesMessinger/IndexedDB101.js
Very Simple IndexedDB Example
// quite untested, adapted from BigstickCarpet's gist, attempt to make it simpler to use
function openIndexedDB (fileindex) {
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;
var openDB = indexedDB.open("MyDatabase", 1);
openDB.onupgradeneeded = function() {
var db = {}
@william-silversmith
william-silversmith / bouncefactory.js
Last active October 26, 2021 12:11
The Bounce Factory
/* bounceFactory
*
* Consult this article: https://medium.com/@willsilversmith/the-bounce-factory-3498de1e5262#.pn5rcjp15
* The variables below are annotate with comments that reference the article.
*
* Simulate a physical bouncing motion based on physics equations of motion.
*
* We assume mass and gravity = 1 as they are immaterial when we normalize both
* the y and t axis to 1. The length of the animation in msec will determine "gravity"
* and the elasticity will determine the number of bounces.
@SleepWalker
SleepWalker / swipe.js
Created September 30, 2015 04:59
A simple swipe detection on vanilla js
var touchstartX = 0;
var touchstartY = 0;
var touchendX = 0;
var touchendY = 0;
var gesuredZone = document.getElementById('gesuredZone');
gesuredZone.addEventListener('touchstart', function(event) {
touchstartX = event.screenX;
touchstartY = event.screenY;
@wilsonpage
wilsonpage / storage.js
Created September 11, 2015 14:25
Simple localStorage like wrapper around indexeddb
function Storage(name) {
this.ready = new Promise((resolve, reject) => {
var request = window.indexedDB.open(location.origin);
request.onupgradeneeded = e => {
this.db = e.target.result;
this.db.createObjectStore('store');
};
request.onsuccess = e => {
@william-silversmith
william-silversmith / animation.js
Last active October 26, 2021 11:49
Animating an Object
/* Example animation function
*
* Interpolate between a start and end position.
*
* obj.x represents a position parameter (e.g. 12.2)
* end_pos is the value obj.x will have at the end of the animation
* msec is the number of milliseconds we want to run the animation for
* easing is a timing function that accepts a number between 0 to 1
* and returns the proportion of the interpolation between start and end to move the object to.
*