Skip to content

Instantly share code, notes, and snippets.

leandromoreira /
Created Feb 6, 2014
It makes backup and purges it.
set -e
NOW=$(date +"%m-%d-%Y-%H-%M")
## Compacting and making backup
tar -zcf $DEST_FOLDER_BKP/bkp.$NOW.tar.gz $FOLDER_TO_BKP
leandromoreira / gist:9464594
Created Mar 10, 2014
random between 0 and 3
View gist:9464594
mov ax, dx
xor dx, dx
mov cx, 4
div cx ; here dx contains the remainder of the division - from 0 to 3
add dl, '0' ; to ascii from '0' to '3'
import sys
# from original author @jbochi
if len(sys.argv) != 2:
print "Usage: %s <filename>" % sys.argv[0]
with open(sys.argv[1]) as f:
chars =
leandromoreira /
Last active Aug 29, 2015
Speed Run Community Terms or Slangs
WR="world record, of a given game"
PB="personal best, of a given game for the current runner"
PR="personal record, vide PB"
split="sections of a game, how the speed runner tracks his time"
bingo="A run where given sections of a game, mount randomly a (finite) set of objectives"
SRL="the site speedrunlive where lots of speed runners stream"
race="to compete against another runner or team in the same game"
TAS="Tool Assisted Speedrun, usually by using an emulator"
blind="playing a game with no previous training"
urn="run, the run"


Install OpenJDK

sudo apt-get -y install openjdk-7-jdk
sudo mkdir /usr/java
sudo ln -s /usr/lib/jvm/java-7-openjdk-amd64 /usr/java/default

Install Tomcat

leandromoreira / gist:3671392
Created Sep 8, 2012
Use seq instead of empty?
View gist:3671392
(def pack [])
;try to avoid this
(if (not (empty? pack)) (print "something") (print "empty"))
;in favor of this
(if (seq pack) (print "something") (print "empty"))
leandromoreira /
Created Oct 22, 2012
Do something in all subdirectories Unix Shell Terminal Command
$ for dir in *; do echo $dir ; done;
View robot.js
var Robot = function(robot) {
var firstTime = true;
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
var moveAhead = Math.floor(Math.random()*101);
View clappr.html
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Clappr plugin dev tutorial 1 - Hello World</title>
<script type="text/javascript" src=""></script>
<h1>Clappr plugin dev tutorial 1 - Hello World</h1>
View angular_factory.js
.factory('theirTwitterFactory', function($http){
var factory = {};
.success(function(data, status, headers, config) {
factory.tweets = data;
return {
tweets: function(){