Skip to content

Instantly share code, notes, and snippets.

William Malo williammalo

View GitHub Profile
@williammalo
williammalo / Readme.md
Created Mar 10, 2012 — forked from thingsinjars/LICENSE.txt
Chainable DOM Manipulation
View Readme.md
@williammalo
williammalo / LICENSE.txt
Created Mar 22, 2012 — forked from tsaniel/LICENSE.txt
Fisher–Yates shuffle
View LICENSE.txt
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@williammalo
williammalo / README.md
Created Mar 23, 2012
Determine if a value is in a array
View README.md

This is a fork of a function by MathRobin. It's a bit longer, but it's made to work in older browsers that don't support indexOf.

@williammalo
williammalo / README.md
Last active Oct 2, 2015 — forked from 140bytes/LICENSE.txt
vendorPrefixr
View README.md

Adds vendor prefix when needed.

Thanks to Evghenusi for minification tips

@williammalo
williammalo / README.md
Last active Jan 26, 2018 — forked from 140bytes/LICENSE.txt
The cleanest, easiest dom api ever! It will change your life!
View README.md

I always thought there was a better way to access the dom. This is a tool that allows you to use extremely simple syntax to access dom elements. It makes an object with the name of your choice (I chose "$") that contains a reference to all elements that have an id.

example:

<script> $.foo.innerHTML = "Hello world" </script>

You can even choose to use an object that already exists (I chose "document" because it makes sense)

@williammalo
williammalo / README.md
Last active Oct 2, 2015 — forked from 140bytes/LICENSE.txt
MathGlobalizr
View README.md

A function to get rid of the stupid "Math" object once and for all!

It allows this sort of syntax:

 myVariable = floor(myVariable)
 myOtherVariable = random()
@williammalo
williammalo / README.md
Last active Oct 2, 2015 — forked from 140bytes/LICENSE.txt
file Size Unit Calculator
View README.md

This is a function to calculate the appropriate unit to describe a file size. If you want a fancier function, try this function: https://gist.github.com/2202887 by @vitronprince

Thanks to maettig for minification tips.

@williammalo
williammalo / index.html
Created Mar 29, 2012
easy pixel perfect collision engine demo canvas/javascript
View index.html
<!DOCTYPE html>
<title>terrain test</title>
<body onkeydown=keys(1,event) onkeyup=keys(0,event)>
<script>
var CANVAS_WIDTH=480, CANVAS_HEIGHT=320, FPS = 30;
var keydownleft=0, keydownright=0 ,keydownspace=0 ,keydownup=0 ,keydowndown=0;
//mathglobalizr: https://gist.github.com/2221488
@williammalo
williammalo / README.md
Last active Oct 2, 2015 — forked from 140bytes/LICENSE.txt
Check if canvas pixel is black
View README.md

This function checks if a canvas pixel is black.

This is very useful for making pixel-perfect collisions in a javascript game.

argument x and y are for the coordinates of said pixel.

argument c is for the canvas context.

@williammalo
williammalo / README.md
Last active Mar 8, 2018 — forked from 140bytes/LICENSE.txt
BoxCollisionCheck
View README.md

Function to check if 2 objects collide. Very useful for games.

arguments:

a: object 1 x

b: object 1 y

You can’t perform that action at this time.