Skip to content

Instantly share code, notes, and snippets.

View adilsoncarvalho's full-sized avatar

Adilson Carvalho adilsoncarvalho

View GitHub Profile
@adilsoncarvalho
adilsoncarvalho / simple_list.cpp
Created April 16, 2014 13:13
Simple list study on C++
#include <iostream>
#include <list>
using namespace std;
int main()
{
list<int> numeros;
list<int>::iterator item;
@adilsoncarvalho
adilsoncarvalho / assignment-4-sort-1.rb
Last active August 29, 2015 14:01
On Strategy: What Managers Can Learn form The Great Philosophers
#!/usr/bin/env ruby
require 'yaml'
DOUBLED = /aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq|rr|ss|tt|uu|vv|ww|xx|yy|zz/i
names = [
"Aber&Crombie", "Apple", "BMW", "Boss", "Burger King", "Carlsberg", "Caterpillar",
"Coca-cola", "Dior", "Disney", "Ebay", "Emirates", "Google", "IBM", "Ikea", "Kodak",
"Lacoste", "Lenovo", "Levi’s", "L’oréal", "Michelin", "Mittal", "Monsanto", "Nestlé", "Nike",
"Nikon", "Nutella", "Pampers", "Pfizer", "Philips", "Procter&Gamble", "Redbull",
@adilsoncarvalho
adilsoncarvalho / file.sh
Created July 28, 2014 12:25
Enviando arquivos para um ftp
#!/bin/sh
USERNAME="username"
PASSWORD="password"
SERVER="hostname or ip here"
# Directory where file is located
DIR="/some/directory"
# Filename of backup file to be transfered
FILE="filename"
# login to ftp server and transfer file
cd $DIR
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="mcorp template" />
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
@adilsoncarvalho
adilsoncarvalho / gist:2882336171a8b131ce8c
Created September 5, 2014 13:57
Conversa com o Léo e o Otaviano
// BASE
- Addict ... add<IParceiro>() : where new()
public T FindBy<T>(int id) where T : IParceiro {
var p = Addict.Create<T>() { .... props .... }
return p
}
# This file should be placed at /etc/logrotate.d/
/srv/*/shared/log/*.log {
daily
missingok
dateext
rotate 30 # amount of days to keep compressed logs (you should backup it up externally)
compress
delaycompress
notifempty
@adilsoncarvalho
adilsoncarvalho / gist:5b978e2d55985d91adf7
Last active August 29, 2015 14:06
Showing Dialogs in STA (very useful when dealing with SAP forms)
public static class FileDialogExtension
{
internal class SapMainWindow : IWin32Window
{
[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();
public IntPtr Handle { get { return GetForegroundWindow(); } }
}
@adilsoncarvalho
adilsoncarvalho / gist:a431adaa93aeff4aef6c
Created June 1, 2015 11:05
Run rubocop just for the modified files
git diff --diff-filter=AM --name-only origin/master |grep '\.rb' |xargs --no-run-if-empty bundle exec rubocop
@adilsoncarvalho
adilsoncarvalho / sorting.rb
Created July 24, 2015 18:43
Ordenando valores usando um dicionário de apoio
elementos = %w(sub_grupo loja setor grupo fornecedor)
# => ["sub_grupo", "loja", "setor", "grupo", "fornecedor"]
elementos.sort
# => ["fornecedor", "grupo", "loja", "setor", "sub_grupo"]
indice = { loja: 0, fornecedor: 1, setor: 2, grupo: 3, sub_grupo: 4 }
# => {:loja=>0, :fornecedor=>1, :setor=>2, :grupo=>3, :sub_grupo=>4}
elementos.sort{|a,b| indice[a.to_sym] <=> indice[b.to_sym] }
@adilsoncarvalho
adilsoncarvalho / Lambdas in BOO.boo
Created October 15, 2010 11:37
How to write lambdas in boo
#
# Thanks to Glauco Vinicius who teached this to me
#
#
# our little lambda that evaluates if a number is even or odd
#
IsEven = { x | (x % 2) == 0 }
#