Skip to content

Instantly share code, notes, and snippets.

View altherlex's full-sized avatar

Alther Alves altherlex

View GitHub Profile
@altherlex
altherlex / clisoap-qualitor.rb
Last active May 4, 2018 12:41
How to consuming a Qualitor WebService
# Calling into cmd line (ShellScipt or PowerShell):
# ./clisoap-qualitor.rb config-file.yml
require 'savon'
require 'yaml'
config = YAML::load( File.open(ARGV[0]) )
conn = Savon.client(wsdl:config["url"])
auth = conn.call(:login, message:{login:config["login"], passwd:config["passwd"], company:config["company"]})
# TIP: HOW TO KEEP SESSION WHEN CONSUMING A SOAPCLIENT WITH SAVON v.2
# It's necessary to maintain the session with option: "cookies:auth.http.cookies"
r = conn.call(config["method"].to_sym, message: {auth:auth.body[:login_response][:result], xmlValue:config["xml"]}, cookies:auth.http.cookies)
@altherlex
altherlex / forwarding.conf
Last active April 12, 2017 11:40
By mining your nginx log with LOGSTASH (you'll need ELASTICSEARCH for database and KIBANA for see information)
# into Nginx server
# how install: https://github.com/elastic/logstash-forwarder#building-it
# git clone git://github.com/elasticsearch/logstash-forwarder.git
# cd logstash-forwarder
# go build // it's necessary to install go interpreter
# vi forwarding.conf
# cmd to start service> ./logstash-forwarder -config forwarding.conf
#### ATTENTION when you generate the certificate
# the name on CN flag into comand openssl will be the same of servers configuration into file
@altherlex
altherlex / salmpe+html.md
Created March 23, 2015 16:24
Sampe html code for initial course
@altherlex
altherlex / combine_anagrams.rb
Created March 24, 2015 18:58
Exercise solve for ruby beginners
# encoding: UTF-8
# Exercise description: http://goo.gl/2XsKhW
require 'minitest'
require "minitest/autorun"
############### Exercise 3 ##############
class Array
def combine_anagrams
self.group_by{|el| el.downcase.chars.sort}.values
end
@altherlex
altherlex / test_watir-gem.rb
Created March 27, 2015 10:53
Gem Watir for automating test
# encoding: UTF-8
#http://watir.com/
#https://github.com/watir/watir/
require 'rubygems'
require "watir"
teste_site = "http://blogsearch.google.com.br/"
browser = Watir::IE.new
browser.goto teste_site
@altherlex
altherlex / my_comands.MD
Created April 9, 2015 18:38
my comands

h1. Meus comandos

for i in $(find -name '.');do file $i;done |grep UTF

#!/bin/bash
for i in $(find -name '*.*');do iconv -f iso-8859-1 -t UTF-8 -o $i $i;done
#do encoding=$(file -bi $i | sed -e 's/.*[ ]charset=//');
do iconv -f iso-8859-1 -t UTF-8 -o $i $i;done
-----------------------------------------
@altherlex
altherlex / Malha-Logistica.md
Last active August 29, 2015 14:19
Malha-Logistica
@altherlex
altherlex / nodejs_benchmark.rb
Created May 3, 2015 05:20
Nodejs benchmark
# Testing Scaling
require 'benchmark'
n = 10000
result = Benchmark.bm do |x|
x.report { for i in 1..n; Thread.new {`curl -XGET http://localhost:3000`}; end }
end
@altherlex
altherlex / test_spec.rb
Created May 4, 2015 18:24
subject, specify, let
#http://stackoverflow.com/questions/9778657/why-does-this-simple-rspec-string-equality-spec-fail
describe First do
specify { First.new.to_s.should == "Hello World" }
end
describe First do
describe "#to_s" do
subject { First.new.to_s }
it { should == "Hello World" }
end
@altherlex
altherlex / cmd_nodejs.js
Last active August 29, 2015 14:20
cmds nodejs
//Automatic re-running with nodemon and npm server
nodemon -x 'npm start'
//or
node app.js
//Start mongodb
mongod --dbpath C:\mongodb\data\db