Skip to content

Instantly share code, notes, and snippets.

<?php
$elements = array(1, 2, 3);
// array_map
// (PHP 4 >= 4.0.6, PHP 5)
$mappedElements = array_map(
function($element) {
return 2 * $element;
},
sudo vi /etc/php.ini
sudo /sbin/service httpd restart
@trikitrok
trikitrok / intallNFS.sh
Created May 12, 2014 13:28
Install nfs on Ubuntu
sudo apt-get install nfs-kernel-server
(defn fizz-buzz [coll]
(clojure.string/join
\space
(map #(let [s (str %2 %3) ]
(if (seq s)
s
(str %)))
coll
(cycle [ "" "" "Fizz" ])
(cycle [ "" "" "" "" "Buzz" ]))))
@trikitrok
trikitrok / 0_reuse_code.js
Created June 17, 2014 18:03
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@trikitrok
trikitrok / deleteAllMp4WithSpacesInNames.sh
Created June 17, 2014 18:29
It deletes all the mp4 files found under the current folder. -print0 and -0 to avoid that a space in a filename is used as a delimiter -> Explained in http://stackoverflow.com/questions/16758525/how-to-use-xargs-with-filenames-containing-whitespaces
find . -name *.mp4 -print0 | xargs -0 rm
@trikitrok
trikitrok / deleteBranch.sh
Created June 18, 2014 11:06
Deleting a remote branch
git push origin --delete <branch-name>
@trikitrok
trikitrok / Rock-paper-scissorsKata.md
Last active August 29, 2015 14:08
Unconditional Rock-paper-scissors kata

In this kata we'll use TDD to develop an object-oriented solution for the Rock-paper-scissors game.

The catch is that we can't use any conditionals, that is, if, switch, ternary operator or any other type of conditionals are not allowed.

It's an introductory kata which will help you to hone your OO skills.

This would be the initial code in Ruby:

class RockPaperScissors
(ns bowling-game.core-test
(:use midje.sweet)
(:use [bowling-game.core]))
(def a-gutter-game (repeat 20 0))
(def a-no-spares-no-strikes-game
(concat [1 6 4 5 3 1] (repeat 14 0)))
(def a-game-with-spares
(concat [4 6 4 5 3 1] (repeat 14 0)))
(def a-game-with-strikes
; ...
(defn num-neighbors-being-a-cell [cell cells]
(count (filter (neighbors cell) cells)))
(defn has-cell? [loc cells]
(= loc (some #{loc} cells)))
(defn will-have-a-cell? [loc cells]
(let [num-neighbors (num-neighbors-being-a-cell loc cells)]