Skip to content

Instantly share code, notes, and snippets.

William Malo williammalo

Block or report user

Report or block williammalo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
williammalo / calendar.js
Created Jun 25, 2012
Javascript Calendar Maker
View calendar.js
calendar = function(year,month,template,rowStart,rowEnd,cellStart,cellEnd){
var tmpl=function(a,b){return a.replace(/\{\{([^{}]+)}}/g,function(c,d){return typeof b[d]=="function"?b[d]():b[d]})}
return tmpl(template,{
williammalo /
Last active Oct 6, 2015 — forked from 140bytes/LICENSE.txt
get offset of element

recursively checks every parent of the element to get the ABSOLUTE offset of the element.

call it like this:

williammalo /
Last active Oct 7, 2015 — forked from 140bytes/LICENSE.txt
masonry under 140bytes

A minimalist masonry function


Only works with one size of brick.

The only advantage of using this over using inline-block elements is that you can use css transitions.

williammalo /
Last active Oct 8, 2015 — forked from 140bytes/LICENSE.txt
image to 2d array

converts canvas image data to a 2d array of booleans


array[x][y] //gives true or false

very useful for games where you need pixel perfect collision.

Reading an image every time you check for collision is slow. Using a 2d array makes it much faster, and has a very simple syntax (array[x][y]) .


##Object Merger

Recurcively merges two objects.

williammalo / CircleCircleTangents.glsl
Last active Dec 5, 2016
Find Tangents of Two Circles in glsl, useful for calculating soft shadows
View CircleCircleTangents.glsl
//visual basics code from ported to glsl
vec4 FindCircleCircleIntersections(vec2 p0, float r0, vec2 p1, float r1){
vec2 dd = p1-p0;
float d = length(dd);
float a = (r0 * r0 - r1 * r1 + d * d) / (2.0 * d);
float h = sqrt(r0 * r0 - a * a);
williammalo /
Created Mar 10, 2012 — forked from thingsinjars/LICENSE.txt
Chainable DOM Manipulation
williammalo /
Last active Jan 26, 2018 — forked from 140bytes/LICENSE.txt
The cleanest, easiest dom api ever! It will change your life!

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.


<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 /
Last active Jan 27, 2018 — forked from 140bytes/LICENSE.txt
Complete jquery css method clone

A perfect replica (hopefully) of the jQuery .css() method

testNode.css("color","blue")   //use it with two string arguments!

testNode.css({color:"red"})    //use it with an object!

testNode.css("color")          //make it return the value of a property

It's even chainable!

williammalo /
Last active Mar 8, 2018 — forked from 140bytes/LICENSE.txt
get query variable

use like this:


To get variables in urls eg:

If you want to support arrays, check the version by @atk below:

You can’t perform that action at this time.