Skip to content

Instantly share code, notes, and snippets.

View gleicon's full-sized avatar

Gleicon Moraes gleicon

View GitHub Profile

Keybase proof

I hereby claim:

  • I am gleicon on github.
  • I am gleicon (https://keybase.io/gleicon) on keybase.
  • I have a public key whose fingerprint is C6CC 3FB6 16AE 0EFA 74E1 D749 E45A 2482 12B7 5B5B

To claim this, I am signing this object:

@gleicon
gleicon / stats.py
Created September 10, 2016 19:15 — forked from lucindo/stats.py
# Helper class for statistics
# see: http://www.johndcook.com/blog/standard_deviation/
class Stats:
""" Uses Welford's method to calculate stats.
Assumes positive values.
It's not thread safe
stats = Stats("ConnectionTimeStats")
stats.add(0.223)
stats.add(1.343)
package main
import (
"bufio"
"fmt"
"strings"
"github.com/dgryski/go-simstore/simhash"
)
@gleicon
gleicon / Readme.md
Created August 17, 2016 00:54 — forked from eduardompinto/Readme.md
Criando uma cara para contar relações de quem fez X, também fez X

Relacionamento de quem fez X, também fez X

O objetivo aqui é pegar uma entrada composta por um csv com: produto, sessão. E considerando que a ação X foi aplicada a ele criar um cara que pega as relações por sessão.

Exemplo de entrada:

1231312124,cb808cb9-3bfd-4c0c-ad20-2e181b9b3a93
1231212124,cb808cb9-3bfd-4c0c-ad20-2e181b9b3a93
1231112124,cb808cb9-3bfd-4c0c-ad20-2e181b9b3a93
1231762124,cb808cb9-3bfd-4c0c-ad20-2e181b9b3a93
@gleicon
gleicon / histogram.rb
Last active May 1, 2016 00:37
pre-historic 2006 code for my post graduation studies using ruby and imagemagick. fepo.
# This routine needs the color_histogram method
# from either ImageMagick 6.0.0 or GraphicsMagick 1.1
# Specify an image filename as an argument.
require 'RMagick'
class PixelColumn < Array
def initialize(size)
super
fill {Magick::Pixel.new}
# Protection from SYN flood attack.
net.ipv4.tcp_syncookies = 1
# Martians? Don't care.
net.ipv4.conf.all.log_martians = 0
# Discourage Linux from swapping idle server processes to disk (default = 60)
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
@gleicon
gleicon / tail.py
Created February 16, 2016 00:38
tail in python
import sys
import time
def tail(tfile):
with open(tfile, 'r') as fp:
while True:
ll = fp.readline()
if ll:
print ll
else:
package main
import "fmt"
// this is the intro to tutorial challenges from hackerrang in Go.
func findArrElement(arr []uint64, arrLen, value int) int {
for i:=0; i < arrLen; i++ {
if arr[i] == uint64(value) {
return i
}
}
@gleicon
gleicon / gist:8a41cb86e87b8becf178
Created February 4, 2016 19:37 — forked from ysimonson/gist:5877284
LinkedIn OAuth2 authentication over tornado
from tornado import auth, httpclient, httputil, escape
import urllib
import functools
class LinkedInMixin(auth.OAuth2Mixin):
"""
LinkedIn authentication using OAuth2.
Example usage::
import requests
import smtplib
user = "yourusername"
password = "yourpass"
fromaddr = "user@gmail.com"
toaddr = "sysadmin@gmail.com"
smtpserver = "smtp.server"
port = 587