Skip to content

Instantly share code, notes, and snippets.

View frostney's full-sized avatar
🐢

Johannes Stein frostney

🐢
View GitHub Profile
@frostney
frostney / gist:2638923
Created May 8, 2012 20:09
jQuery-like each function for node.js
function each(object, callback) {
Object.keys(object).forEach(function(key) {
var value = object[key];
callback(key, value);
});
}
@frostney
frostney / index.html
Created June 18, 2012 20:17
Proof-of-concept for an iOS-like slider ui element in CSS3 with pseudo-selector to be used in a single div element. Works only in Webkit browsers. Demo here: http://jsfiddle.net/Stoney/Xsx9W/
<!doctype html>
<html>
<head>
<title>CSS Magic</title>
<style>
.switch:before, .switch.off:before {
content: "";
@frostney
frostney / Utils.hx
Created October 27, 2012 18:56
jQuery-like extend and each functions for HaXe
package ;
class Utils
{
public static function extend(obj1: Dynamic, obj2: Dynamic): Dynamic {
var keys = Reflect.fields(obj2);
for (k in keys) {
@frostney
frostney / gist:4114006
Created November 19, 2012 21:19
HTML5 Boilerplate plugins.js in Coffeescript
do ->
noop = ->
methods = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
'timeStamp', 'trace', 'warn']
console = (window.console or= {})
@frostney
frostney / gist:4144734
Created November 25, 2012 18:39
My .gitignore for web projects
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
@frostney
frostney / gist:4144754
Created November 25, 2012 18:43
My .gitignore for delphi/freepascal projects
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.ppu
*.dcu
*.so
@frostney
frostney / gist:4144794
Last active October 13, 2015 05:17
Properties in CoffeeScript classes: Not completely my code, but I found it extremely useful
Function::property = (prop, desc) ->
Object.defineProperty @prototype, prop, desc
Function::staticProperty = (prop, desc) ->
Object.defineProperty @, prop, desc
class MyClass
privateVar = 5
testVar = 10
@frostney
frostney / gist:4165353
Created November 28, 2012 22:56
Walking through folder recursively async (node.js): includes option to filter elements, hidden dot files and filenames with trailing underscore. (walkFiles function taken from http://stackoverflow.com/questions/7041638/walking-a-directory-with-node-js)
var path = require('path');
var fs = require('fs');
var es6shim = require('es6-shim');
/**
* dir: path to the directory to explore
* action(file, stat): called on each file or until an error occurs. file: path to the file. stat: stat of the file (retrived by fs.stat)
* done(err): called one time when the process is complete. err is undifined is everything was ok. the error that stopped the process otherwise
*/
var walkFiles = function(dir, action, done) {
@frostney
frostney / gist:4171169
Created November 29, 2012 19:07
jQuery-like extend in Coffeescript
extend = (target, objects...) ->
for obj in objects
for key, value of obj
target[key] = value
target
# One object
a = extend {}, {test: 5}
alert JSON.stringify(a)
@frostney
frostney / collection.coffee
Created December 2, 2012 17:01
Collection class in Coffeescript including proxies (e.g. adding function to when a key is changed like triggering a redraw of the UI).
class Collection
data =
collection: {}
state: {}
proxies:
handler: {}
keyHandler: {}
contructor: (content) ->
if content