Skip to content

Instantly share code, notes, and snippets.

View mainiak's full-sized avatar

Jakub Viták mainiak

View GitHub Profile
@mainiak
mainiak / timerScopeIssue.coffee
Created December 5, 2012 11:32
nodejs setInterval and setTimeout doesn't persist scope
#!/usr/bin/coffee
###
node v0.8.15
###
# this doesn't work for setInterval either
class Test
constructor: (@text) ->
@mainiak
mainiak / read-file.coffee
Created December 8, 2012 17:31
file seeking in nodejs
#!/usr/bin/env coffee
###
in native fs,
we could set position from where to read,
but we have to track it manually
if run many times with position null,
and once with position=0, it doesn't reset to 0
@mainiak
mainiak / Task.coffee
Last active December 10, 2015 00:59
testing time bending in browser - see http://tryjasmine.com - an nodejs
class Task
constructor: (@text) ->
@intervalId = null
hello: -> window.alert @text
delay: 1000 # 1 sec
timeout: ->
var max = 10,
x = {vs:') versus '};
for (var i=0; i<max; i++) {
console.log('i: ', i);
setTimeout((function(number) { console.log('i(' + i + this.vs + number); }).bind(x), (i * 500), i);
}
@mainiak
mainiak / this.coffee
Created January 24, 2013 14:28
learning callbacks and scopes
#!/usr/bin/env coffee
class Test
constructor: (cb) -> cb(@)
hello: -> console.log 'Hello, World!'
cb = (obj) -> obj.hello()
test = new Test cb
@mainiak
mainiak / clean.sh
Created February 28, 2013 13:48
remove tempory files afer vim editing
#!/bin/sh
find "$(pwd -P)" -type f \( -name "*~" -o -name ".*~" \) -exec rm -vf {} +
#!/usr/bin/env coffee
MAX_CALLS = 10
class Test
constructor: ->
@reset()
run1: (returnFn) ->
@count += 1
console.log 'A| count:', @count
// test page - https://github.com/PlzenskyHackathon2013/
// written on Firefox with FireBug
var teams = [];
$x("//h3/a/text()").forEach(function (item) {
teams.push(item.textContent);
});
console.log(teams);
@mainiak
mainiak / vimrc.md
Last active April 19, 2024 14:22
Vim, vimrc

My .vimrc

# vimtutor
vim ~/.vimrc

in vim