Apenas faça um acesso http na url:
http://tinyurl.com/api-create.php?url=http://URL_PARA_REDUZIREle retorna apenas a tiny-url gerada, sem html nem nada, mais simples impossível ;)
http://tinyurl.com/api-create.php?url=http://URL_PARA_REDUZIR
#!ruby
require 'rubygems'
gem 'win32console', '>= 1.2.0'
require 'Win32/Console/ANSI'
puts `/xampp/php/php5.3.0beta2/php.exe #{$*.join ' '}`
class A
{
public static function metodo()
{
return self::outro_metodo();
}
public static function outro_metodo()
{
return "classe A chamando";
}
}
class B
{
public static function outro_metodo()
{
return "classe B sobreescreveu";
}
}
echo B::metodo();
class A
{
public static function metodo()
{
return static::outro_metodo();
}
public static function outro_metodo()
{
return "classe A chamando";
}
}
class B
{
public static function outro_metodo()
{
return "classe B sobreescreveu";
}
}
echo B::metodo();
use MeuNamespace\A;
use MeuNamespace\B;
$a = new A();
$b = new B();
use MeuNamespace;
$a = new A();
$b = new B();
use MeuNamespace\SubNamespace;
use MeuNamespace as MN;
$a = new MN\A();
$b = new MN\B();
$c = SubNamespace\C();
namespace MeuNamespace; //informa o namespace do arquivo
class A
{
public function __construct($a)
{
$a = \trim($a);
}
}
class ArrayData implements IteratorAggregate
{
private $data;
public function __construct($data = array())
{
$this->data = $data;
}
public function getIterator()
{
return new ArrayIterator($this->data);
}
public function push()
{
$args = func_get_args();
foreach ($args as $arg) {
array_push($this->data, $arg);
}
}
public function each($block)
{
foreach ($this as $value) {
$block($value);
}
}
public function map($block)
{
return new static(array_map($block, $this->data));
}
public function inject($base, $block)
{
$this->each(function($value) use (&$base, $block) {
$base = $block($base, $value);
});
return $base;
}
public function reject($block)
{
$new_data = new static;
$this->each(function($value) use ($block, $new_data) {
if (!$block($value)) $new_data->push($value);
});
return $new_data;
}
}
$data = new ArrayData(array(1, 2, 3));
$data->push(4, 5);
$data->map(function($value) {
return $value * 2;
})->reject(function($value) {
return $value > 5;
})->each(function($value) {
echo "$value
";
});
echo $data->inject(0, function($sum, $value) {
return $sum + $value;
});
function beenchmark($block)
{
$start = microtime(true);
$block();
echo "
Executed in " . (microtime(true) - $start);
}
$a = range(0, 100000);
$b = new ArrayData($a);
beenchmark(function() use ($a) {
$s = 0;
foreach ($a as $value) {
$s += $value;
}
});
beenchmark(function() use ($b) {
$s = 0;
$b->each(function($value) use (&$s) {
$s += $value;
});
});
beenchmark(function() use ($b) {
$b->inject(0, function($s, $value) {
return $s + $value;
});
});
Executed in 0.0579040050507
Executed in 0.131916046143
Executed in 0.254753112793
class A
{
public function my_method()
{
return "ok, reach here";
}
public function inner_lambda()
{
$proc = function() {
return $this->my_method();
};
return $proc();
}
}
$a = new A();
echo $a->inner_lambda();
module StateMachine
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
# aqui vem os métodos da classe
end
end
00000000
01111111
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Conversor de UTF-8</title>
<script type="text/javascript" charset="utf-8">
get = function(id) {
return document.getElementById(id);
};
UTF8 = {
encode: function(content) {
return content;
},
decode: function(content) {
return content;
}
}
encodeFromTo = function(source, destiny, method) {
var value = get(source).value;
get(destiny).value = method(value);
};
window.onload = function() {
get('encode_button').onclick = function() {
encodeFromTo('original_area', 'encoded_area', UTF8.encode);
};
get('decode_button').onclick = function() {
encodeFromTo('encoded_area', 'original_area', UTF8.decode);
};
};
</script>
<style type="text/css" media="screen">
textarea {
width: 300px;
height: 200px;
}
</style>
</head>
<body>
<textarea id="original_area"></textarea><br />
<button type="button" id="encode_button">Codificar para UTF-8</button>
<button type="button" id="decode_button">Decodificar de UTF-8</button><br />
<textarea id="encoded_area"></textarea>
</body>
</html>
1000000011000010 100000001 byte - 0xxxxxxx
2 bytes - 110xxxxx 10xxxxxx
3 bytes - 1110xxxx 10xxxxxx 10xxxxxx
4 bytes - 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
var encoded = ''; //iniciamos com uma string vazia
for (var i = 0; i < content.length; i++) { //iniciando uma iteracao sobre cada caractere da string
var c = content.charCodeAt(i); //pegando o codigo do caractere na posicao atual
//verificando numero de bytes
if (c < 128) { //1 byte
encoded += String.fromCharCode(c); //simplesmente recolocamos o caractere sem modificações
} else if (c < 2048) { //2 bytes
encoded += String.fromCharCode((c >> 6) | 0xC0); //primeiro caractere
encoded += String.fromCharCode((c & 0x3F) | 0x80); //segundo caractere
} else if (c < 65536) { //3 bytes
encoded += String.fromCharCode((c >> 12) | 0xE0); //primeiro caractere
encoded += String.fromCharCode(((c >> 6) & 0x3F) | 0x80); //segundo caractere
encoded += String.fromCharCode((c & 0x3F) | 0x80); //terceiro caractere
} else { //4 bytes
encoded += String.fromCharCode((c >> 18) | 0xF0); //primeiro caractere
encoded += String.fromCharCode(((c >> 12) & 0x3F) | 0x80); //segundo caractere
encoded += String.fromCharCode(((c >> 6) & 0x3F) | 0x80); //terceiro caractere
encoded += String.fromCharCode((c & 0x3F) | 0x80); //quarto caractere
}
}
return encoded;
00011000 >> 2
resulta em: 00000110
01101110 >> 3
resulta em: 00001101
00110111
& 01100010
----------
00100010
01111000
& 00111110
----------
00111000
00110101
| 11100001
----------
11110101
var decoded = ''; //string vazia
var i = 0; //iterador
var n = c1 = c2 = c3 = c4 = 0; //buffers
while (i < content.length) {
c1 = content.charCodeAt(i);
if (c1 < 128) { //1 byte
decoded += String.fromCharCode(c1); //sem conversão, padrão ASCII
i++; //proximo byte
} else if (!(c1 & 0x20)) { //2 bytes
c2 = content.charCodeAt(i + 1);
decoded += String.fromCharCode(((c1 & 0x1F) << 6) | (c2 & 0x3F));
i += 2; //pular 2 bytes
} else if (!(c1 & 0x10)) { //3 bytes
c2 = content.charCodeAt(i + 1);
c3 = content.charCodeAt(i + 2);
decoded += String.fromCharCode(((c1 & 0xF) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));
i += 3; //pular 3 bytes
} else if (!(c1 & 0x8)) { //4 bytes
c2 = content.charCodeAt(i + 1);
c3 = content.charCodeAt(i + 2);
c4 = content.charCodeAt(i + 3);
decoded += String.fromCharCode(((c1 & 0x7) << 18) | ((c2 & 0x3F) << 12) | ((c3 & 0x3F) << 6) | (c4 & 0x3F));
i += 4; //pular 4 bytes
}
}
return decoded;