Skip to content

Instantly share code, notes, and snippets.

View alexandre's full-sized avatar
🎯
Focusing

Alexandre Souza alexandre

🎯
Focusing
View GitHub Profile
str_1 = 'this is a test'
str_2 = 'wokka wokka!!!'
dist = 0
for x,y in zip(str_1, str_2):
val = ord(x) ^ ord(y)
while val != 0:
dist += 1
val &= val -1
@alexandre
alexandre / distância_de_mahalanobis.md
Last active August 29, 2015 14:09
um cenário envolvendo distância de Mahalanobis. By @rittersport3.

o pai tem 1.80... O primeiro irmão tem 1.75 e o outro 1.83 O pai calça 42. O primeiro calça 41 e o segundo 44 Quem é mais parecido com o Pai?

+--------|Altura|Calçado+
|Pai     |1.80  |  42   |
|Filho[0]|1.75  |  41   |
|Filho[1]|1.83  |  44   |
+-----------------------+
@alexandre
alexandre / nn_or_ifelse.py
Created November 27, 2014 01:53
not_not and if_else
>>> def not_not(x):
... return not(not x)
...
>>> def if_else(x):
... return True if x else False
...
>>> import dis
>>> dis.dis(not_not)
2 0 LOAD_FAST 0 (x)
3 UNARY_NOT

Keybase proof

I hereby claim:

  • I am alexandre on github.
  • I am ubbersith (https://keybase.io/ubbersith) on keybase.
  • I have a public key whose fingerprint is 9239 1566 BB34 30BE 2EF8 31FD C2E6 08F9 327E 2AB3

To claim this, I am signing this object:

@alexandre
alexandre / slack_tip.txt
Created January 5, 2015 06:54
Oracle Jdk Slackware64 14.1
$ tar -xzvf jdk*linux-*.tar.gz
$ rm jdk*linux.tar.gz
# mkdir /opt/java
# mv jdk.... /opt/java/
# cd /opt/java
# ln -s jdk1.7.0_03 jdk
# vim /etc/profile
export JAVA_HOME="/opt/java/jdk"
@alexandre
alexandre / fix_term.md
Last active January 18, 2018 01:45
"Terminal entry not found in terminfo" - corrigindo o problema

Depois de instalar o ubuntu (quando a máquina não é minha não adianta falar "coloca slack!") em uma máquina, umas das primeiras coisas que eu faço é instalar o terminator[0]. Ok, seguindo o processo normal, instalei o git e comecei a puxar as minhas configurações; umas delas é o vim_conf[1] - um repositório com meu vimrc, baseado no vimbootstrap[2], e outros arquivos relacionados.

Depois de preparar os arquivos, eu me deparei com o erro abaixo:

alexandre@alexandre ~ $ vim .bashrc 

E558: Terminal entry not found in terminfo
'gnome-256color' not known. Available builtin terminals are:
    builtin_gui
 builtin_amiga
@alexandre
alexandre / foo.py
Last active August 29, 2015 14:14
a question in pocoo channel...
{% extends "base.html" %}
{% block content %}
<h1>simple tool</h1>
<br>
<p>Click <a href="/logout">here </a>to logout</p>
<br>
<br>
<table>
<caption align="left">HMCs:</caption>
@alexandre
alexandre / quora_tips_better_dev.md
Last active August 29, 2015 14:16
learning how to be a better programmer

What are the minimum set of required computer science skills for a web developer who does not have a CS degree to be a good programmer?

The absolute minimum probably would be learning about the basic data structures:

  • Hash map: if you only learn one, this is the one you should learn.
  • Lists: linked single vs double, head node vs head-less and also array lists. Learn how they relate to stacks and queues.
  • Binary search tree/Quad tree/Oct tree: learn why they are important, and how they are maintained balanced.
  • Trie: if you have extra time, these are very important for string searching.
  • Graphs/Networks: these are more specialized, but I wouldn't consider a programmer as advanced unless they were very comfortable with these.
@alexandre
alexandre / recursao.clj
Last active August 29, 2015 14:16
testando recursão e avaliação preguiçosa...se é que eu entendi...
(comment
Tentando onseguir o mesmo resultado em clojure:
#Python3
>>> x = [1, 2, 3]
>>> x.append(x)
>>> x[3][3][3] == x
True
)
user=> (def x (list 1 2 3))
#'user/x
@alexandre
alexandre / recur.md
Created March 10, 2015 02:08
tests with Python and Haskell...
>>>x = [1, 2]
>>> x.append(x)
>>> x[2][2][2][2] ==x
True
let x = [1, 2]
let x = x ++ x
x !! 2 == x