Skip to content

Instantly share code, notes, and snippets.

View viebig's full-sized avatar

Guilherme Viebig viebig

View GitHub Profile
@viebig
viebig / gist:246bdc5970eedc95c02d
Created May 8, 2015 20:55
DDD Geolocalização Latitude/Longitude
var dddGeo = [];
dddGeo[11] = {
latitude: -23.547778,
longitude: -46.635833
}; // | São Paulo | Região Metropolitana de São Paulo.
dddGeo[12] = {
latitude: -23.203416,
longitude: -45.890627
}; // | São Paulo | São José dos Campos e Região.
@viebig
viebig / gist:a4b7be13a18f8a889252
Created August 20, 2015 14:44
Mysql Group Contact
SET group_concat_max_len = 204800;
SELECT id, GROUP_CONCAT(message SEPARATOR ', ')
FROM messages
@viebig
viebig / gist:ff3d5911623fad0ed3bc
Created October 2, 2015 15:46
Vftpd Amazon Ami Virtual Users not pam_pwdfile.so
Security groups
21-22
1024-1048
/etc/vsftpd/vsftpd.conf
listen=YES
anonymous_enable=NO
local_enable=YES
@viebig
viebig / sigep.php
Created January 1, 2016 18:34
Exemplo de requisição para geração de etiquetas do correios
<?php
$usuario = 'sigep';
$senha = 'n5f9t8';
$contrato = '9912208555';
$cartao = '0057018901';
$context = stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
@viebig
viebig / mogrify.sh
Created January 4, 2016 16:18
Mogrify optimize/compress/resize JPG close to photoshop, fireworks
mogrify -resize 50% -unsharp 0.25x0.25+8+0.065 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off *.jpg
To search scripts, stylesheets and snippets by filename you can use:
* Ctrl + O (Windows)
* Cmd + O (Mac OSX)
To perform a text search within the current file you can use:
* Ctrl + F (Windows)
* Cmd + F (Mac OSX)
@viebig
viebig / ec2hostname.rb
Created January 27, 2016 12:03 — forked from kixorz/ec2hostname.rb
EC2 Instance Route53 Hostname registration init.d script. Instance needs to have the attached IAM instance role policy applied.
#!/usr/bin/ruby
# chkconfig: 35 99 01
# description: EC2 DNS registration
# processname: ec2hostname
require 'aws-sdk'
require 'net/http'
`touch /var/lock/subsys/ec2hostname`
@viebig
viebig / docker.bash
Created January 28, 2016 22:28
Sample docker deploy script, using bash ssh rsync
#!/bin/bash
appname="my-docker-app"
if [ $1 == "deploy" ]
then
host="ec2-user@ec2"
ssh -tt $host "mkdir $appname && cd $appname && sudo chmod 777 * -R"
rsync --progress --exclude-from 'deploy.exclude' -avz -e "ssh" . $host:$appname
ssh -tt $host "cd $appname && docker build -t $appname ."
ssh -tt $host "cd $appname && docker ps -q --filter='image=$appname' | xargs docker stop"
@viebig
viebig / reflect.py
Created March 16, 2016 20:08 — forked from huyng/reflect.py
A simple echo server to inspect http web requests
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
@viebig
viebig / server.php
Created March 18, 2016 18:02
Simple HTTP echo server (Generic TCP)
<?php
//
// By: Spicer Matthews <spicer@cloudmanic.com>
// Company: Cloudmanic Labs, LLC
// Date: 5/19/2011
// Description: This is an echo server. It will read any messages sent in and then echo them back out.
//
$hostname = "127.0.0.1";
$portno = "7834";
ob_implicit_flush();