Skip to content

Instantly share code, notes, and snippets.

Avatar

Bruno Saboia brunosaboia

View GitHub Profile
View ParseError.rs
use std::str::FromStr;
struct ParseError<'a, E> {
error: E,
source: &'a str,
}
fn parse<'a, T: FromStr>(s: &'a str) -> Result<T, ParseError<'a, T::Err>> {
s.parse().map_err(|e| ParseError { error: e, source: s })
}
View poem.txt
Lately having escaped three-kinded death
Not by evasion but by coming through
I celebrate what may be true beginning.
But new begun am most without resource
Stupid and stopped.
How do the newborn grow? I am of them.
Freshness has taken our hearts;
Pain strips us to the source, infants of further life
Waiting for childhood as we wait for form.
@brunosaboia
brunosaboia / clooney.py
Created Jan 5, 2018
Python script to clone all repos from a given Bitbucket team
View clooney.py
# -*- coding: utf-8 -*-
"""
coinify-tools
clooney
~~~~~~~~~~~~
Little script to clone all repos from a given BitBucket team/user.
:author: Bruno Saboia de Albuquerque <bsa@coinify.com>
@brunosaboia
brunosaboia / clone_all_bitbucket.sh
Created Jan 5, 2018
Bash one-liner script to clone all repos from a Bitbucket team
View clone_all_bitbucket.sh
for repo in $(curl -u {username} --raw https://api.bitbucket.org/1.0/users/{team} | sed -r 's/("name": )/\n\1/g' | sed -r 's/"name": "(.*)"/\1/' | sed -e 's/{//' | cut -f1 -d\" | tr '\n' ' '); do git clone git@bitbucket.org:{team}/$repo.git; done
@brunosaboia
brunosaboia / function.r
Created Oct 1, 2015
A function to remove the RF from the Stocks
View function.r
remove_risk_free <- function(stocks, risk_free, rf_col_name) {
if(class(risk_free) != class(timeSeries()) || class(stocks) != class(timeSeries())) {
stop("The two first parameters must be timeSeries objects")
}
if(nrow(risk_free) != nrow(stocks)) {
stop("The two time series must be from the same size")
}
ret <- stocks[,1]
View keybase.md

Keybase proof

I hereby claim:

  • I am brunosaboia on github.
  • I am brunosaboia (https://keybase.io/brunosaboia) on keybase.
  • I have a public key whose fingerprint is E260 F9E5 6381 499E 9FF6 E91D B16A 6870 6E55 31C9

To claim this, I am signing this object:

View gist:7030209
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x84:
base.WndProc(ref m);
if ((int)m.Result == 0x1)
m.Result = (IntPtr)0x2;
return;
}
@brunosaboia
brunosaboia / Post4-3.cs
Created Sep 13, 2013
Salvar o nome no XData
View Post4-3.cs
[CommandMethod("SalvarNome")]
static public void SalvarNome()
{
var documento = Application.DocumentManager.MdiActiveDocument;
var editor = documento.Editor;
var nomeApp = "AppTesteXData";
var opcoesNome = new PromptStringOptions("\nDigite um nome para a entidade: ");
opcoesNome.AllowSpaces = true;
var resultadoNome = editor.GetString(opcoesNome);
@brunosaboia
brunosaboia / Post4-2.cs
Created Sep 13, 2013
Registrando a app na tabela
View Post4-2.cs
static void RegistrarApp(string nome)
{
var documento = Application.DocumentManager.MdiActiveDocument;
var banco = documento.Database;
using (var transacao = documento.TransactionManager.StartTransaction())
{
var tabela = transacao.GetObject(banco.RegAppTableId, OpenMode.ForRead, false) as RegAppTable;
@brunosaboia
brunosaboia / Post4-1.cs
Last active Dec 23, 2015
Ler nome para XData
View Post4-1.cs
[CommandMethod("LerNome")]
public static void LerNome()
{
var documento = Application.DocumentManager.MdiActiveDocument;
var editor = documento.Editor;
var opcoes = new PromptEntityOptions("\nSelecione a entidade: ");
opcoes.SetRejectMessage("\nPor favor, selecione uma reta (Line).");
opcoes.AddAllowedClass(typeof(Line), false);
opcoes.AllowNone = false;