Skip to content

Instantly share code, notes, and snippets.

var util = require("util");
var obj1 = function () {
this.color = "green";
this.type = "suv";
};
obj1.prototype.demo = 123;
var obj2 = function () {
@mrkaspa
mrkaspa / tailSum
Last active August 29, 2015 14:17
object RecursiveSum extends App {
println(sum(List(1, 2, 3, 10)))
def sum(nums: List[Int]): Int = {
@tailrec
def sumTail(x: Int, xs: List[Int]): Int = xs match {
case Nil => x
case y :: ys => sumTail(x + y, ys)
}
sumTail(0, nums)
@user = self
template = Tilt::ERBTemplate.new("#{Padrino.root}/api/views/mailers/welcome.erb").render(@user)
@mrkaspa
mrkaspa / ycombinator.js
Created May 27, 2015 20:48
Y Combinator JS and Recursive Calls
var trampoline = function (f) {
while (f && f instanceof Function) {
f = f.apply(f.context, f.args);
}
return f;
}
var thunk = function (fn) {
return function () {
var args = Array.prototype.slice.apply(arguments);
@mrkaspa
mrkaspa / bilby_rec.coffee
Created May 27, 2015 21:05
Tail recursion con bilby
bilby = require('bilby')
loop1 = (n) ->
inner = (acc, i) ->
if(i is 0)
bilby.done(acc)
else
bilby.cont( ->
inner(acc + i, i - 1)
)
@mrkaspa
mrkaspa / gulpfile.js
Created June 28, 2015 04:11
Setting Gulp for Sass, Coffee y Browserify
var gulp = require('gulp');
var gutil = require('gulp-util');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var coffee = require('gulp-coffee');
var browserify = require('gulp-browserify')
var paths = {
@mrkaspa
mrkaspa / sgit
Last active August 29, 2015 14:24
No more large commits
#!/bin/bash
ARGSI="${#}"
if [ $ARGSI == "1" ]; then
git add -A && git commit -m "$1" && git push origin master
else
if [ $ARGSI == "2" ]; then
git add -A && git commit -m "$1" && git push origin $2
else
if [ $ARGSI == "3" ]; then
function toon {
echo -n "λ>"
}
get_git_dirty() {
git diff --quiet || echo '*'
}
autoload -Uz vcs_info
zstyle ':vcs_info:*' check-for-changes true
@mrkaspa
mrkaspa / onchange.sh
Last active August 29, 2015 14:25 — forked from evgenius/onchange.sh
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <[email protected]>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@mrkaspa
mrkaspa / y-combinator.go
Last active August 29, 2015 14:27 — forked from wancw/y-combinator.go
Y combinator in Go, runable example: http://play.golang.org/p/xVHw0zoaWX
package main
import "fmt"
type (
tF func(int) int
tRF func(tF) tF
tX func(tX) tF
)