Skip to content

Instantly share code, notes, and snippets.

View andrerocker's full-sized avatar
🤓
Clojure / SRE

Andre Souza andrerocker

🤓
Clojure / SRE
View GitHub Profile
@andrerocker
andrerocker / Serializer.java
Created September 26, 2014 04:48
Serialize and unserialize any java object to a base46 string
private String serialize(Object object) {
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutputStream output = new ObjectOutputStream(buffer);
output.writeObject(object);
output.flush();
return Base64.encodeBase64String(buffer.toByteArray());
} catch (Exception e) {
@andrerocker
andrerocker / 256color.pl
Created November 21, 2014 04:12
256 color test
#!/usr/bin/perl
# Author: Todd Larason <jtl@molehill.org>
# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.2 2002/03/26 01:46:43 dickey Exp $
# use the resources for colors 0-15 - usually more-or-less a
# reproduction of the standard ANSI colors, but possibly more
# pleasing shades
# colors 16-231 are a 6x6x6 color cube
for ($red = 0; $red < 6; $red++) {
@andrerocker
andrerocker / bt-lockform-frag.js
Created November 7, 2010 17:49
Trecho de implementação - Estado do Formulario
/**
* Retorna estado do Formulario
*/
HTMLFormElement.prototype.isLocked = function()
{
var store = buildStoreForm(this, false);
if(store.length>0)
return store['locked'];
@andrerocker
andrerocker / DateUtil.java
Created November 7, 2010 13:48
Java Encontrar Primeiro e Ultimo Dia de Uma Semana
package com.braincoretechnology.rules.util;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
public class DateUtil
{
public static Date resolvePrimeiroUltimo(Date data, boolean isPrimeiro)
{
@andrerocker
andrerocker / upload.html
Created November 7, 2010 18:14
post blog upload
<form method="post" action="centro.php" enctype="multipart/form-data">
<input type="hidden" name="acao" value="upload-logo">
<input type="file" name="logo">
<input type="submit" value="Enviar">
</form>
@andrerocker
andrerocker / ie6-dynamic-image-change.js
Created November 7, 2010 19:26
Alteração Dinamica de Imagens, Hack para IE6.
function carregarImagem(url, objImgDestino)
{
var img = new Image();
img.onload = function () {
objImgDestino.src=obj.src;
}
img.src = url;
}
@andrerocker
andrerocker / bt-lock-form-frag.js
Created November 7, 2010 17:41
Fragmento bt-lockform
/*
* Bloqueia o Formulario
*/
HTMLFormElement.prototype.lockForm = function()
{
var elmnts = this.elements;
armazenaEstadoFormulario(this);
for(i=0; i<elmnts.length; i++)
habilitaItemForm(elmnts[i], false);
@andrerocker
andrerocker / bt-lockform-frag.js
Created November 7, 2010 17:44
Fragmento de Codigo para Desbloqueio do Formulario
/**
* Desbloqueia o Formulario
*/
HTMLFormElement.prototype.unlockForm = function()
{
var elmnts = this.elements;
var store = buildStoreForm(this, false);
for(i=0; i<elmnts.length; i++)
habilitaItemForm(elmnts[i], !store[i]);
@andrerocker
andrerocker / centro.php
Created November 7, 2010 18:11
post blog upload
<?php
$action = $_REQUEST["acao"];
if($action=="upload-logo")
{
processaLogo();
}
function processaLogo()
{
@andrerocker
andrerocker / upload-frag.php
Created November 7, 2010 18:24
post blog upload frag
<?
function processaUploadLogo($arquivo)
{
$dir = "destino/";
$ale = rand(00,9999);
if (isset($arquivo))
{
$nome = $ale.basename($arquivo["name"]);