Skip to content

Instantly share code, notes, and snippets.

@lucian303
lucian303 / silexDbFetch.php
Created May 15, 2013 23:14
silexDbFetch.php
<?php
/** @var $db Doctrine\DBAL\Connection */
$db = $app['db'];
$sql = "select * from users";
var_dump($db->fetchAll($sql, array())); die;
@lucian303
lucian303 / aliases.sh
Last active December 17, 2015 09:39
linux aliases
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# Comment in the above and uncomment this below for a color prompt
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u @ \h \[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(parse_git_branch)$ '
EDITOR='nano'
export EDITOR
@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
@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 / 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 / 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 / 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 &
<?php
/**
* A simple quicksort implementation for exercise purposes
*/
function quicksort($list)
{
$listLength = count($list);
if ($listLength <= 1) {
return $list;
@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
@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;
}
}
}