Skip to content

Instantly share code, notes, and snippets.

View thluiz's full-sized avatar

Thiago Luiz Silva thluiz

View GitHub Profile
@thluiz
thluiz / shellNode.js
Created October 4, 2012 00:08
Run shell commands via NodeJS
var exec = require('child_process').exec;
var child = exec("echo 'teste'",
function (error, stdout, stderr) {
if(stdout!==''){
console.log('---------stdout: ---------\n' + stdout);
}
if(stderr!==''){
console.log('---------stderr: ---------\n' + stderr);
@thluiz
thluiz / file_encoder.py
Last active April 28, 2024 06:51
Just a short python script to convert a file from one encoding to another
# coding=utf-8
"""
Convert a file from one encoder to another
usage: python file_encoder.py 'source encode', 'target encode',
'source file', 'target'
example: python file_encoder.py 'iso8859-1', 'utf-8', 'file.html',
'file-utf8.html'
"""
import sys
@thluiz
thluiz / httpoison_post_request.ex
Last active August 29, 2015 14:14
Making a HTTPoison post request in Elixir
case HTTPoison.post(url, body, headers) do
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
body
{:ok, %HTTPoison.Response{status_code: 404}} ->
"Not found :("
{:error, %HTTPoison.Error{reason: reason}} ->
reason
end
@thluiz
thluiz / httpoison_post_form_request.ex
Created February 1, 2015 21:51
HTTPoison post url encoded form
headers = [
{"Content-Type", "application/x-www-form-urlencoded"},
{"Accept", "text/html"}
]
encoded_text = URI.encode_www_form(text)
body = "text=#{encoded_text}"
case HTTPoison.post(url, body, headers) do
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
@thluiz
thluiz / fibonacci.ex
Created February 2, 2015 09:45
The simplest fibonacci implementation
defmodule Fibonacci do
def calc(0), do: 1
def calc(1), do: 1
def calc(n) when n > 0, do: calc(n-2) + calc(n-1)
end
@thluiz
thluiz / f#_convert_UInt32_to_binary
Last active December 12, 2016 15:11
Convert a UInt32 (Unsigned Integer) to Binary in F#
let rec to_binary(value: UInt32)=
if value < 2u then
value.ToString()
else
let divisor = value/2u
let remainder = (value % 2u).ToString()
to_binary(divisor) + remainder
@thluiz
thluiz / sql-server-row-number-performance.sql
Last active February 14, 2018 14:31
Trying to compare multiple implementations of dynamic ordering in sql server
create table #test_data(col1 varchar(100), col2 varchar(100))
declare @i int = 0
while (@i < 1000000)
begin
insert into #test_data(col1, col2)
values ('col1_' + right('00000000' + cast(@i as varchar(9)), 9), CONVERT(varchar(255), NEWID()))
set @i = @i + 1
end
{"lastUpload":"2021-07-10T03:58:02.482Z","extensionVersion":"v3.4.3"}
@thluiz
thluiz / ChocolateyMinimalPackages.ps
Last active May 2, 2020 15:31
Chocolatey minimal packages
choco install -y irfanview 7zip.install checksum firacode slack paint.net inkscape gimp irfanview-shellextension irfanviewplugins spotify nuget.commandline soapui pencil krita windirstat ngrok
choco install -y archive archiver grepwin procexp winmerge vim bat powertoys evernote nodejs.install audacity zoom-client powershell-core sql-server-management-studio zoomit visualstudio2019community
choco install visualstudiocode-insiders --pre -y
@thluiz
thluiz / download-images-loop.ps1
Created November 13, 2019 09:21
Powershell script for download images in a range
$wc = New-Object System.Net.WebClient
For ($i=1; $i -le 100; $i++) {
$url = "https://membros.myvtmi.im/qrcode/http/cerimonias.myvtmi.im/cerimonia-$i"
$wc.DownloadFile($url, "c:\tmp\cerimonia-$i.png")
}