Skip to content

Instantly share code, notes, and snippets.

// Fibonacci
// Loop
var first = 0,
second = 1,
total = 0;
for (var x = 1; x <= 8; x++) {
first = second;
second = total;
total = first + second;
}
@lucian303
lucian303 / factorial.js
Last active August 29, 2015 14:16
Factorial
// Factorial
// Reduce
var number = 7;
arr = [];
for (var x = 1; x <= number; x++) {
arr.push(x);
}
alert(arr.reduce(function (a, x) {
@lucian303
lucian303 / bind_and_curry.js
Created January 28, 2015 23:03
Manual bind and curry examples in JS
function mul(x, y) {
if (Number(x) && Number(y)) {
return x * y;
} else if (Number(x)) {
return function (z) {
return x * z;
}
}
}
@lucian303
lucian303 / .zshrc
Created March 20, 2014 19:01
Cygwin / windows .zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="tjkirch"
# Example aliases
<?php
/**
* A simple quicksort implementation for exercise purposes
*/
function quicksort($list)
{
$listLength = count($list);
if ($listLength <= 1) {
return $list;
@lucian303
lucian303 / my-osx.sh
Created September 23, 2013 18:53
osx settings
#!/usr/bin/env bash
# ~/.osx — http://mths.be/osx
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
@lucian303
lucian303 / unicode_char.php
Created June 11, 2013 01:03
Get a unicode char in PHP fast and clean with just plain PHP.
$unicodeChar = '\u2191'; // up arrow
$upArrow = json_decode('"' . $unicodeChar . '"');
@lucian303
lucian303 / forin.js
Created May 17, 2013 08:58
proper for in iteration js
for (name in obj) {
if (typeof obj[name] !== 'function') {
console.log(name + ': ' + obj[name]);
}
}
@lucian303
lucian303 / proto_inherit.js
Created May 17, 2013 08:54
prototypical inheritance in js
if (typeof Object.create !== 'function') {
Object.create = function (o) {
var F = function () {};
F.prototype = o;
return new F();
};
}
@lucian303
lucian303 / .zshrc
Last active December 17, 2015 09:48
mac .zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="af-magic"
# Example aliases