Skip to content

Instantly share code, notes, and snippets.

View Paratron's full-sized avatar
🧙
Web Wizardry

Christian Engel Paratron

🧙
Web Wizardry
View GitHub Profile
@Paratron
Paratron / gist:3027785
Created July 1, 2012 10:05
Suggestion for basic AppJS structure.
//Previously, you first required appjs, then called appjs.init(), which returns an app object. We can merge that into just one step.
var app = require('appjs');
//This is the basic way to call a window. You pass either a string with the URL of the window content, or you pass a full object, if you want to set more options.
var main_window = app.createWindow({
url: 'http://appjs/main.html',
width: 640,
height: 480,
maximizable: false
@Paratron
Paratron / gist:3236143
Created August 2, 2012 10:33
Get id attribute of all elements with a certain class.
//Without jQuery
var elements = document.getElementsByClassName('clicked'), //Be careful: won't work in IE 6,7,8
ids = [];
for(var i = 0; i < elements.length; i++){
ids.push(elements[i].id);
}
console.log(ids);

Two jQuery Plugins for you

Hey, I wanted to share two jQuery Plugins we created for the promotional website for Spritepad. We needded two things there:

###Displacement The starscape background and some elements of the page should scroll at a different speed as the page, to achieve a fake 3D effect.

###Reaction on user scrolling We wanted some elements to appear on screen at the moment the user scrolls far enough that they have moved into the view area.

/**
* Short Countdown
* ===============
* This is my try of a short JavaScript Countdown.
* Line breaks and identation added for better reading.
* Line 2 could be boiled down to:
* e = +new d()+36E5;
* But the way it is right now makes it much easier to tweak the duration.
*
* Character count with whitespace trimmed: 178.
//Cargo Asset Loader
//===================
//This file defines the API for a HTML5 asset loader that is mainly designed to be used for games
//but could be used for any kind of HTML5 application that requires some kind of asset management.
//@version: 1 (April 1st, 2013)
//@author: Christian Engel <[email protected]>
//The Cargo asset loader should deliver the following number of features:
@Paratron
Paratron / raf-polyfill.js
Created April 29, 2013 11:17
A Polyfill for window.requestAnimationFrame()
(function() {
var lastTime = 0;
var vendors = ['webkit', 'moz'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame =
window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame)
@Paratron
Paratron / undo_redo.js
Created July 31, 2013 15:51
Easy undo/redo with backbone
this.on('change', function(){
changes.push(this.previousAttributes());
});
undo: function(){
undone.push(this.toJSON());
this.set(changes.pop());
}
redo: function(){
@Paratron
Paratron / agents.md
Last active February 26, 2024 12:28
Social Network Crawler User Agents

#Social Network Crawler User Agents Users can post URLs on a lot of different platforms nowadays. Most of those platforms will send a request to that URL to generate some preview data from it.

These are a couple of user agents I quickly tested out.

##Facebook

facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)
@Paratron
Paratron / isofix.js
Last active August 29, 2015 14:00
Iso fix
/**
* Renders the tiles to the layer canvas and pushes to the display.
* @method Phaser.TilemapLayer#render
* @memberof Phaser.TilemapLayer
*/
Phaser.TilemapLayer.prototype.render = function () {
if (this.layer.dirty)
{
this.dirty = true;
@Paratron
Paratron / twig_init.php
Created August 7, 2014 20:29
Twig Template Engine Bootstrap
require('lib/php/Twig/Autoloader.php');
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem('lib/templates');
$twig = new Twig_Environment($loader);