Skip to content

Instantly share code, notes, and snippets.

View ahvonenj's full-sized avatar
🐢
${framework} solves everything!

Jonah ahvonenj

🐢
${framework} solves everything!
View GitHub Profile
@ahvonenj
ahvonenj / lerp.js
Last active December 17, 2015 14:21
Perfect JavaScript function lerper
var CLerp =
{
time: 0, // Program / game elapsed time
lerps: [],
doLerp: function(v0, v1, t, f, id)
{
var self = this;
var id = id || null;
@ahvonenj
ahvonenj / loop.js
Last active October 9, 2018 13:24
Perfect JavaScript update loop with requestAnimationFrame
function timestamp()
{
return window.performance && window.performance.now ? window.performance.now() : new Date().getTime();
}
this.t =
{
now: null,
acc: 0,
@ahvonenj
ahvonenj / srcbuster
Created October 19, 2015 12:55
Invalid src buster
// Scans through whole HTML document and tries to find src or css url-rules that are faulty
// These faulty / empty rules can cause Google Chrome to load a webpage multiple times
// First run this whole script in developer console and then print out contents of bustedNullSrcs array
// The array contents give hints as to what might cause the Chrome multiple page load bug
var bustedNullSrcs = [];
(function($)
{
bustedNullSrcs.length = 0;
@ahvonenj
ahvonenj / php-dependency-sniffer.js
Last active December 16, 2015 09:51
PHP dependency sniffer
/*******************************************************************************
* Script: PHP dependency sniffer
* Description: Figures out to which PHP scripts the page contacts during use
* Date: 15.10.2015
* Comments
* It is not perfect, but at least gives some idea which PHP files some page uses
*
* Include this script on the page you want to sniff for PHP file usage and
* use the page normally, as in go through page's controls of which you think
@ahvonenj
ahvonenj / svgviewer.html
Created October 7, 2015 09:47
Simple svg / image drag and drop viewer
<!doctype html>
<html>
<head>
<title>svgviewer</title>
<style>
*
{
margin: 0;
padding: 0;
@ahvonenj
ahvonenj / chromwebstore.js
Created August 26, 2015 15:20
Chrome web store download
/*
* @title crx DL link
* @description prompt crx download-link on Chrome Web Store
* @include https://chrome.google.com/webstore/detail/*
* @contributor taizooo http://let.hatelabo.jp/taizooo/let/gYC-x-e5r_G0bw (Fork of)
* @contributor noromanba http://let.hatelabo.jp/noromanba/let/hLHX5-ST-aMn
* @license MIT License http://opensource.org/licenses/MIT
* @javascript_url
*/
@ahvonenj
ahvonenj / catchajax.js
Created August 10, 2015 09:01
Catch AJAX event / request
$(document).ajaxSend(function(event, request, settings)
{
console.log('Caught AJAX request!');
console.log(event);
console.log(request);
console.log(settings);
});
@ahvonenj
ahvonenj / keycode.js
Last active December 20, 2015 18:44
JavaScript keypress / keycode
$(document).on('keypress', function(e)
{
// Evaluate keycode into a lowercase human-readable letter
var key = String.fromCharCode(e.charCode).toLowerCase();
// Figure what to do with each key
switch(key)
{
case 'a':
console.log('a pressed');
@ahvonenj
ahvonenj / sineball.js
Last active August 29, 2015 14:25
Sine ball
this.position = Victor.fromObject(
{
x: self.vpc.x + Math.cos(time * 0.002) * self.helpers.sineBetween(-100, 100, time * 0.0002),
y: self.vpc.y + Math.sin(time * 0.002) * self.helpers.sineBetween(100, 100, time * 0.002)
});
@ahvonenj
ahvonenj / sineheart.js
Last active August 29, 2015 14:25
Sine heart
this.position = Victor.fromObject(
{
x: self.vpc.x + Math.cos(time * 0.002) * self.helpers.sineBetween(10, 250, time * 0.002),
y: self.vpc.y + Math.sin(time * 0.002) * self.helpers.sineBetween(-100, 250, time * 0.002)
});