Skip to content

Instantly share code, notes, and snippets.

View hay's full-sized avatar

Hay Kranen hay

View GitHub Profile
@hay
hay / app.js
Last active December 16, 2016 04:30
Learn Javascript MVC: create a todo list using Stapes.js in less than 100 lines code (part 1) examples
var TodosModel = Stapes.subclass();
var TodosView = Stapes.subclass({
constructor : function(model) {
var self = this;
this.$el = $("#inputform");
this.model = model
var $input = this.$el.find("input");
@hay
hay / WMStats.java
Last active August 30, 2016 11:03
Wikipedia statistics parser comparison
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class WMStats {
private static final String FILE_NAME = "pagecounts-20141029-230000";
@hay
hay / ex4.js
Last active December 11, 2015 01:29
var Module = Stapes.subclass({
sayName : function() {
console.log('i say my name!');
}
});
var BetterModule = Module.subclass({
// Note that this method name is the same as the one in Module
sayName : function() {
BetterModule.parent.sayName.apply(this, arguments);
@hay
hay / ex3.js
Created January 13, 2013 12:02
var Module = Stapes.subclass();
var SubModule = Module.subclass();
var module = new Module();
var submodule = new SubModule();
module instanceof Module; // true
submodule instanceof Module; // true
module instanceof SubModule; // false
@hay
hay / ex2.js
Created January 13, 2013 11:59
var Module = Stapes.subclass({
constructor : function(name) {
this.name = name;
},
sayName : function() {
console.log(this.name);
}
});
@hay
hay / ex1.js
Last active December 11, 2015 00:59
(function() {
var Module = {
create : function() {
return Object.create(this);
}
};
window.Stapes = {
create : function() {
return Object.create(Module);
@hay
hay / has-overflow-scrolling.js
Created November 7, 2012 16:14
Check if a browser supports the overflow-scrolling CSS property, optionally with a prefix
function hasOverflowScrolling() {
var prefixes = ['webkit', 'moz', 'o', 'ms'];
var div = document.createElement('div');
var body = document.getElementsByTagName('body')[0];
var hasIt = false;
body.appendChild(div);
for (var i = 0; i < prefixes.length; i++) {
var prefix = prefixes[i];
@hay
hay / google-plus-clean-gui.user.js
Created September 16, 2012 11:21
Google Plus Clean GUI user script for non-logged in users
// ==UserScript==
// @match *://plus.google.com/*
// ==/UserScript==
[
'#gb',
'#contentPane > div:first-child',
'.l-Ps.Vka',
'.mp.pu',
'.wl.cVa',
'.Uda.NTa.Uua',
{
"70c427d6-3cf1-4a67-b5c7-24b7c8c5ee94" : {
"text" : "spam"
},
"97f6a71d-9696-4977-a0b9-87f3be747a3e" : {
"text" : "eggs"
}
};
@hay
hay / ex1.html
Last active October 7, 2015 09:38
Learn Javascript MVC: create a todo list using Stapes.js in less than 100 lines code (part 2)
<script type="text/html" id="template">
<ul>
{{#todos}}
<li data-id="{{id}}">
<input type="checkbox" class="remove" />
{{text}}
</li>
{{/todos}}
</ul>