Skip to content

Instantly share code, notes, and snippets.

View rafaelrinaldi's full-sized avatar

Rafael Rinaldi rafaelrinaldi

View GitHub Profile
@rafaelrinaldi
rafaelrinaldi / maxValue.as
Created April 19, 2011 21:57
Getting the max and the min value of an array.
public function maxValue( p_array : Array ) : Number {
var max : Number = 0;
for each(var number : Number in p_array) {
if(number > max) {
max = number;
}
}
@rafaelrinaldi
rafaelrinaldi / popup.js
Created April 26, 2011 14:32
A script that shows a popup in the middle of the screen.
function popup(p_url, p_title, p_width, p_height) {
var left = (screen.width * .5) - (p_width * .5);
var top = (screen.height * .5) - (p_height * .5);
var target = window.open(p_url, p_title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=' + p_width + ', height=' + p_height + ', top=' + top + ', left=' + left);
}
@rafaelrinaldi
rafaelrinaldi / facebook_share.js
Created May 12, 2011 20:52
Easy way to share a Facebook page and a tweet on Twitter.
/*
Tricky way to share a Facebook page. Tested in Google Chrome, Firefox and Safari. Works pretty well.
I don't know the author, found this script lost on internet. I just updated a few things, add small features and did a cleaning in the code.
*/
function shareFacebook( p_width, p_height ){
@rafaelrinaldi
rafaelrinaldi / CloneVector.as
Created May 27, 2011 00:55
Tricky way to clone a Vector in ActionScript.
var vec1 : Vector.<String> = new <String>["blue", "gray", "orange"];
var vec2 : Vector.<String> = vec1.concat();
vec1[0] = "foo";
trace(vec1); // foo,gray,orange
trace(vec2); // blue,gray,orange
@rafaelrinaldi
rafaelrinaldi / randomString.as
Created May 30, 2011 00:46
Get a random string with alphanumeric and numeric characters.
package tea.string
{
/**
*
* Get a random string with alphanumeric and numeric characters.
*
* @param p_length String length.
*
* @author Rafael Rinaldi (rafaelrinaldi.com)
* @since May 29, 2011
@rafaelrinaldi
rafaelrinaldi / getChildren.as
Created June 10, 2011 17:54
Return an Array with the children of any container.
package tea.display
{
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
/**
*
* Return an <code>Array</code> with the children of any container.
*
* @param p_target The container you want.
*
@rafaelrinaldi
rafaelrinaldi / repeat.as
Created July 23, 2011 05:37
Repeat a String how many times you want.
/**
*
* @param p_string String to be repeated.
* @param p_times How many times the string will be repeated.
*
* @return A new instance with the string repeated.
*
* @author Rafael Rinaldi (rafaelrinaldi.com)
* @since 25/03/2011
*
@rafaelrinaldi
rafaelrinaldi / mergeArray.as
Created July 26, 2011 19:39
Merge arrays.
// Thanks to Grant Skinner (gskinner.com)
var arr : Array = [1,2,3];
var arr2 : Array = [4,5,6];
arr.push.apply(arr, arr2);
trace(arr); // 1,2,3,4,5,6
@rafaelrinaldi
rafaelrinaldi / get_params.sh
Created August 4, 2011 18:53
Easy (maybe dumb also?) way to get short and long parameters of a Shell script.
# author: Rafael Rinaldi (rafaelrinaldi.com)
# since: Aug 3, 2011
# license: WTFPL
# A string with available options
options=$@
# Options converted to an array
arguments=($options)
@rafaelrinaldi
rafaelrinaldi / getPropertyStack.as
Created August 9, 2011 15:17
List all properties and values from a object.
package com.rafaelrinaldi.string
{
import flash.utils.describeType;
/**
*
* List all properties and values from a object.
*
* @author Rafael Rinaldi (rafaelrinaldi.com)
* @since Aug 9, 2011
*