Skip to content

Instantly share code, notes, and snippets.

/**
* NEVER BLOCKING LOOP : implementation of the infamous setTimeout 0 hack, with time checking in order to guarantee fluidity without sacrificing execution speed.
*
* USAGE :
* var array = ["a way too big array that is heavy to process"]
* optimizedFor({
* nbIterations: array.length,
* each:function( index ) {
* doSomethingUsefulWith( array[ index ] );
* },
@Aymkdn
Aymkdn / Run a web page from a Github project in one click.md
Last active December 10, 2015 18:48
Run a web page from a Github project in one click. See README below.

When you visit a Github project with, for example, a demo.html page you can simply click on the "Run" button and the page will be loaded directly into your browser without the need to download the full git project in the correct directory and play with your browser to find where you downloaded it.

Instructions :

  1. Store the below PHP file to your web server;
  2. Edit the below Greasemonkey file with the URL of your webserver;
  3. Load the Greasemonkey script into your web browser;
  4. Go to any file stored on Github and you'll see a "Run" button just after the "History" button.

Once you did all the steps then you can try it. For example go to https://github.com/prezjordan/dynamo.js/blob/master/test/test.html and you should see the Run button:

@Aymkdn
Aymkdn / bookmarklet
Created October 24, 2012 14:22
Bookmarklet to show all the JS scripts into a page
javascript:(function(){function ajax(b){if(typeof XMLHttpRequest==="undefined"){XMLHttpRequest=function(){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(c){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(c){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(c){}throw new Error("This browser does not support XMLHttpRequest.")}}var a=new XMLHttpRequest();if(!b.url){throw new Error("You must define 'url'")}a.open("GET",b.url);a.onreadystatechange=function(){if(a.readyState===4){if(a.status===200){var c=(a.responseXML?a.responseXML:a.responseText);if(typeof b.success==="function"){b.success(c,b)}}if(typeof b.after==="function"){b.after()}}};a.send()}var s=document.getElementsByTagName("SCRIPT"),tx="",sr=[],i,t;for(i=0;i<s.length;i++){with(s.item(i)){t=text;if(t){tx+=t}else{sr.push(src)}}}var __loadedScript=sr.length;with(window.open()){document.write('<textarea id="t">'+tx+"</textarea>");for(var i=0;i<sr.length;i++){ajax({url:sr[i],success:function(a,b){document.getElementById("t").value+="
@Aymkdn
Aymkdn / spservices-startworkflow.js
Created October 11, 2012 15:22
Start a workflow with Sharepoint (JavaScript)
/**
* Start a workflow
*
* @param {Object} params
* @param {String} params.listName The name of the list
* @param {Number} params.itemID The item ID
* @param {String} params.workflowName The name of the workflow
* @param {Array|Object} [params.parameters] An array of object with {Name:"Name of the parameter", Value:"Value of the parameter"}
* @param {Function} [params.after] Callback after the request is done
*/
@Aymkdn
Aymkdn / LICENSE.txt
Created July 29, 2011 17:29 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
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