Skip to content

Instantly share code, notes, and snippets.

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

Fábio Gomes fabioxgn

🏠
Working from home
  • Leme, SP - Brazil
View GitHub Profile
@fabioxgn
fabioxgn / client.rb
Created June 1, 2021 00:40
Ruby TCP example
require "socket"
socket = TCPSocket.open("localhost", 6666)
loop do
input = gets.chomp #Ask client for command
socket.puts input # Send command to server
line = socket.gets #Get server response
puts line
@fabioxgn
fabioxgn / savon_debug.rb
Created February 10, 2015 16:54
savon with debug
c = Savon.client(wsdl: "WSDL_URL", log: true, log_level: :debug) do
convert_request_keys_to :none
pretty_print_xml :true
end
@fabioxgn
fabioxgn / auth.go
Last active August 29, 2015 14:13 — forked from tristanwietsma/auth.go
package main
import (
"encoding/base64"
"net/http"
"strings"
)
type handler func(w http.ResponseWriter, r *http.Request)
@fabioxgn
fabioxgn / gist:530d0f6ff2a7c791366e
Last active October 1, 2015 19:53
go get usar ssh em vez de https
git config --global url."git@github.com:".insteadOf "https://github.com/"
@fabioxgn
fabioxgn / channels.go
Created May 21, 2014 02:13
First time using channels
func execute(cmd *Cmd, conn ircConnection) {
done := make(chan bool, len(list))
for k, v := range list {
cmdName := k
cmdFunc := v
go func() {
result := cmdFunc(cmd)
conn.Privmsg(cmd.Channel, result)
done <- true
@fabioxgn
fabioxgn / python.py
Created October 29, 2013 18:33
Python
# Rodar CGI - arquivos precisam estar em uma pasta cgi-bin
python -m http.server --cgi
@fabioxgn
fabioxgn / pingar_rede.bat
Created September 4, 2013 19:53
Script para pingar todas as máquinas da rede
@echo off
if %1!==! goto help
if %1!==/?! goto help
echo.
echo Pinging %1.1 - %1.254 (this will take a little time).
echo.
for /l %%p in (1,1,254) do ping %1.%%p -n 1 -w 10 | find /i "resposta"
echo.
echo Done.
echo.
@fabioxgn
fabioxgn / jquery_basics.js
Created March 31, 2013 12:10
Basic examples os jQuery
//execute after the document is loaded
jQuery(document).ready(function() {
$("span").text("$100")
});
//select element by ID
$("#vacati­on");
//select element by class
$(".america");
@fabioxgn
fabioxgn / post.go
Created March 29, 2013 14:18
Simple data validatio in Go When something goes wrong, the errors and the values filled in by the user are returned back to the template.
type Data struct {
Cidade model.Cidade
Erros template.HTML
}
func Handler(w http.ResponseWriter, r *http.Request) {
data := new(Data)
if r.Method == "POST" {
r.ParseForm()
decoder.Decode(&data.Cidade, r.Form)
@fabioxgn
fabioxgn / post.go
Created March 28, 2013 21:40
Posting a form in go and returning errors and the form content
type Data struct {
PostData url.Values
Errors string
}
func Handler(w http.ResponseWriter, r *http.Request) {
data := new(Data)
if r.Method == "POST" {
err := r.ParseForm()
if err != nil {