Skip to content

Instantly share code, notes, and snippets.

View rafaelrinaldi's full-sized avatar

Rafael Rinaldi rafaelrinaldi

View GitHub Profile
@rafaelrinaldi
rafaelrinaldi / QueryStringDecoder.js
Last active September 25, 2015 06:17
JavaScript query string decoder.
/**
* Simple query string decoder.
*/
var QueryStringDecoder = (function() {
return {
decode: function(url) {
var decoded = {},
count = 0,
pairs = url.slice(url.indexOf('?') + 1).split("&"),
pair;
@rafaelrinaldi
rafaelrinaldi / EmbeddedXMLTest.as
Created March 23, 2011 19:37
A test showing how to use embedded XML files in ActionScript.
package {
import flash.utils.ByteArray;
import flash.display.Sprite;
/**
*
* @author Rafael Rinaldi (rafaelrinaldi.com)
* @since 23/02/2011
*
@rafaelrinaldi
rafaelrinaldi / git-push.sh
Created March 24, 2011 04:31
Easy way to push changes to your GitHub repositories.
github_user="your-user-goes-here"
git-push() {
git push `printf git@github.com:$github_user/%s.git $1`
}
@rafaelrinaldi
rafaelrinaldi / SmartDisplayObjectContainer.as
Created March 25, 2011 06:56
Simple way to avoid null childs inside a DisplayObjectContainer.
package {
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
/**
*
* @author Rafael Rinaldi (rafaelrinaldi.com)
* @since 25/03/2011
*
@rafaelrinaldi
rafaelrinaldi / glade.as
Created March 28, 2011 14:03
Glade formula written in ActionScript.
//
// Don't poop in your workplace.
//
// @author Rafael Rinaldi (rafaelrinaldi.com)
//
var glade : String = Bath.get().split(Fragrances.SHIT).join(Fragrances.SPRING);
@rafaelrinaldi
rafaelrinaldi / random.sh
Created March 29, 2011 22:23
Return a string with a random numeric value and you can specify the length.
random() {
value=$RANDOM
length=$1
if [[ ! $length ]]; then
length=5
fi
echo ${value:0:$length}
}
@rafaelrinaldi
rafaelrinaldi / repeat.sh
Created March 29, 2011 22:45
Repeats a character how many times you want.
#
# Repeats a character how many times you want.
#
# $1 The character you want.
# $2 How many times you want.
#
repeat() {
character=$1
times=$2
string=$(printf "%""$times""s")
@rafaelrinaldi
rafaelrinaldi / how_to_use_fdb.txt
Created April 6, 2011 21:17
Using fdb to debug.
1) Execute 'fdb'
2) Initialize a session typing 'run'
3) When you open the SWF file fdb will output this:
Player connected; session starting.
Set breakpoints and then type 'continue' to resume the session.
[SWF] path:file.swf - N bytes after decompression
(fdb)
4) Then you set your breakpoints. E.g: To set a breakpoint in the line 100 of your Main.as class, you will use:
@rafaelrinaldi
rafaelrinaldi / get_file_extension.sh
Created April 15, 2011 16:03
Return the file extension.
# Return the file extension.
get_file_extension() {
echo $1 | awk -F . '{print $NF}'
}
@rafaelrinaldi
rafaelrinaldi / rename-files.sh
Created April 15, 2011 16:16
Helpful for when you want to change the name of a sequence of images at the same time.
# /bin/bash
#
# Helpful for when you want to change the name of a sequence of images at the same time.
#
# Author: Rafael Rinaldi (rafaelrinaldi.com)
# Since: 15/04/2011
#
path=$1