Skip to content

Instantly share code, notes, and snippets.

View Winchestro's full-sized avatar

Nikita Andrejevich Seredkin Winchestro

View GitHub Profile
@Winchestro
Winchestro / gist:3eb6602ea622610f2994
Created April 28, 2015 21:00
The distribution problem
If you develop native applications you are at the mercy of established and restrictive stores, which are totally overcrowded and/or hard to get into. People generally don't like downloading things unless when it comes to pirating software, which they of course love.
If you develop on the web this problem doesn't really vanish. You still have to pay a lot of attention so the size of your application, you can't just develop software that has to download 5 gig data upfront before it starts running and pretend you develop a native application, like most engines that compile to the web asssume.
The problem is, most established tools are developed under the assumption that the size of your data doesn't really matter, and all data is already on the clients hard drive and relatively cheap to access. It has been optimized for developing applications to be distributed through upfront downloads or CDs/DVDs as a medium. But on the Web you're back to basically floppys that need to carry everything your App needs to *s
/*
assumes you put your constructors for vec2,vec3,etc on your prototype or in global scope
because the Function constructor will move the scope of the getters & setters to the global scope
if you don't care about a bunch of closures you could also just use normal functions.
*/
["x","y","z"].map(function(ex,x,a){
Object.defineProperty(vec3.prototype,a[x],{
get:new Function("return this["+x+"];"),
set:new Function("v","this["+x+"] = v;")
});
@Winchestro
Winchestro / ajaxipedia.js
Last active August 29, 2015 14:07
Bookmarklet to ajax wikipedia links into the page one paragraph at a time
/*
This is a Bookmarklet to make Wikipedia a bit more enjoyable.
1. save the one line of javascript as a bookmark
2. click it on any wikipedia page
3. all links will now load into the page on click
4. click the loaded paragraph again to load the next
5. after reading transforms back to a link, also all links that can't be loaded
6. you have to re-activate the bookmarklet if you navigate away or refresh the page
8. there are empty paragraphs sometimes
@Winchestro
Winchestro / scriptfuck.js
Last active August 29, 2015 14:06
Chaining method calls with getters. Instead chaining someObject.chain.s().o().s(); it allows to write someObject.chain.s.o.s;
/*
This is a little experiment using getters to chain method calls.
First we have the example object
*/
var someObject = {
someMethod:function(){console.log("someMethod called with",arguments);
return this;
},
someValue:0,