Skip to content

Instantly share code, notes, and snippets.

@leandromoreira
leandromoreira / bkp_purge.sh
Created Feb 6, 2014
It makes backup and purges it.
View bkp_purge.sh
#!/bin/bash
set -e
NOW=$(date +"%m-%d-%Y-%H-%M")
SOURCE_FOLDER_BKP=$1
DEST_FOLDER_BKP=$2
## Compacting and making backup
tar -zcf $DEST_FOLDER_BKP/bkp.$NOW.tar.gz $FOLDER_TO_BKP
@leandromoreira
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'
View hexdump.py
import sys
# from original author @jbochi https://gist.github.com/jbochi
if len(sys.argv) != 2:
print "Usage: %s <filename>" % sys.argv[0]
sys.exit(1)
with open(sys.argv[1]) as f:
chars = f.read()
@leandromoreira
leandromoreira / speed_run_terms.py
Last active Aug 29, 2015
Speed Run Community Terms or Slangs
View speed_run_terms.py
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"
View instructions.md

Instructions

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
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
leandromoreira / do_something_all_subdirectoreis.sh
Created Oct 22, 2012
Do something in all subdirectories Unix Shell Terminal Command
View do_something_all_subdirectoreis.sh
$ 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);
robot.ahead(moveAhead);
View clappr.html
<!DOCTYPE html>
<html>
<head>
<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="http://cdn.clappr.io/latest/clappr.min.js"></script>
</head>
<body>
<h1>Clappr plugin dev tutorial 1 - Hello World</h1>
View angular_factory.js
angular.module('twitter')
.factory('theirTwitterFactory', function($http){
var factory = {};
$http.get('/data/theirs.json')
.success(function(data, status, headers, config) {
factory.tweets = data;
});
return {
tweets: function(){