Skip to content

Instantly share code, notes, and snippets.

View eduan's full-sized avatar
🏠
Working from home

.Eduan eduan

🏠
Working from home
View GitHub Profile
@eduan
eduan / cipher
Last active August 29, 2015 14:17
Cipher
function VigenèreAutokeyCipher(key, abc) {
this.keyStore = '';
this.encode = function (str) {
var box = [abc];
this.keyStore = key;
for(var k in str){
this.keyStore += abc.indexOf(str[k]) < 0 ? '' : str[k];
}
for(var i in abc){
box.push(abc.split(abc[i])[1] + abc.split(abc[i])[0] + abc[i]);
var Cromossomo = function(genes){
if(genes)
this.genes = genes;
this.custo = 10000;
};
Cromossomo.prototype.genes = '';
Cromossomo.prototype.random = function(tamanho){
this.genes = '';
var MORSE_CODE = {'\.-' : 'A', '-\.\.\.' : 'B', '-\.-\.' : 'C', '-\.\.' : 'D', '\.' : 'E', '\.\.-\.' : 'F', '--\.' : 'G', '\.\.\.\.' : 'H', '\.\.' : 'I', '\.---' : 'J', '-\.-' : 'K', '\.-\.\.' : 'L', '--' : 'M', '-\.' : 'N', '---' : 'O', '\.--\.' : 'P', '--\.-' : 'Q', '\.-\.' : 'R', '\.\.\.' : 'S', '-' : 'T', '\.\.-' : 'U', '\.\.\.-' : 'V', '\.--' : 'W', '-\.\.-' : 'X', '-\.--' : 'Y', '--\.\.' : 'Z', '\.-\.-' : 'Ä', '\.--\.-' : 'Á', '\.--\.-' : 'Å', '\.\.-\.\.' : 'É', '--\.--' : 'Ñ', '---\.' : 'Ö', '\.\.--' : 'Ü', '-----' : '0', '\.----' : '1', '\.\.---' : '2', '\.\.\.--' : '3', '\.\.\.\.-' : '4', '\.\.\.\.\.' : '5', '-\.\.\.\.' : '6', '--\.\.\.' : '7', '---\.\.' : '8', '----\.' : '9', }
var decodeBits = function(bits){
var morse = [], bits = bits.split(''), last = '', trecho = '', frequency = {};
for (var i = bits.length - 1; i >= 0; i--) {
if(last.length > 0 && last != bits[i]){
var obj = frequency[last] ? frequency[last] : {};
obj[trecho.length] = trecho
frequency[last] = obj;
@eduan
eduan / gist:bde28b986a4a8f50cd34
Last active August 29, 2015 14:22
install django
#Necessário ter python, apache e banco instalados
#Depois é preciso baixar pip
#Instalar o pip
wget https://bootstrap.pypa.io/get-pip.py
pyhton get-pip.py
sudo pip install Django
sudo pip install MySQL-python
sudo pip install django-input-mask
@eduan
eduan / gist:32dbe30d8174f4e2c5dc
Created January 4, 2016 17:00
verificando se processo já existe antes de executá-lo
if ((`pgrep pavucontrol` > 0)); then echo 'ja existe'; else pavucontrol; fi
@eduan
eduan / gist:ab145d4563f4f60ec726
Created January 11, 2016 16:40
top 10 arquivos/diretórios
du -a /var | sort -n -r | head -n 10
$client = new SoapClient('http://www.dominio.com.br/api/v2_soap/?wsdl');
$session = $client->login('usuario', '123456789senha');
$result = $client->salesOrderInfo($session, '123132131');
var_dump($result);
@eduan
eduan / branchswithcer.sh
Last active May 11, 2016 14:38
Magento branch switcher
#/bin/bash
if [[ "$1" == "-h" || "$1" == "-help" ]]; then
echo "Script de deploy";
echo "./deploy [dir] [branch]";
exit;
fi
if [[ "$1" == "-b" ]]; then
echo "Branch atuais:";
for D in `ls -d $2*/`
#awesome command
( zcat $( ls -tr /var/log/apt/history.log*.gz ) ; cat /var/log/apt/history.log ) | egrep '^(Start-Date:|Commandline:)' | grep -v aptdaemon | egrep '^Commandline:'
@eduan
eduan / 0_reuse_code.js
Created August 22, 2017 13:33
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console