Skip to content

Instantly share code, notes, and snippets.

View jvrmaia's full-sized avatar
🤓
bug is feature for hackers

João Maia jvrmaia

🤓
bug is feature for hackers
View GitHub Profile
@jvrmaia
jvrmaia / deriva.pl
Last active October 6, 2015 16:57
Programa em PROLOG para calcular derivada - Parte do trabalho de Linguagens de Programação
/* FUNÇÕES PARA DERIVADA */
/* regras básicas */
deriva(U+V,X,DU+DV):- deriva(U,X,DU), deriva(V,X,DV).
deriva(U-V,X,DU-DV):- deriva(U,X,DU), deriva(V,X,DV).
deriva(U*V,X,DU*V+U*DV):- deriva(U,X,DU), deriva(V,X,DV).
deriva(U/V,X,(DU*V+U*DV)/V^2):- deriva(U,X,DU), deriva(V,X,DV).
/* regra do polinômio */
deriva(U^N,X,N*U^(N-1)*DU):-
@jvrmaia
jvrmaia / hanoi.hs
Created July 14, 2012 18:02
Torre de Hanoi em Haskell
hanoi :: Int -> a -> a -> a -> [(a,a)]
hanoi 1 x y z = [(x,y)]
hanoi n x y z = hanoi (n-1) x y z ++ hanoi 1 x z y ++ hanoi (n-1) y z x
tamhanoi :: Int -> Int
tamhanoi n = 2^n - 1
@jvrmaia
jvrmaia / tmux.md
Created January 19, 2014 20:34
Guia do TMUX

Guia do TMUX

obs.:

  • o guia é baseado nas minhas configurações pessoais do Github
  • C-c significa pressionar a tecla Control e em seguida a tecla c
  • Prefixo + w significa digitar o comando de Prefixo e em seguida apertar w

Linhas de comando

@jvrmaia
jvrmaia / fastfib.py
Created March 26, 2015 13:02
q-matrix <3
import cProfile
def fibonacci(n):
if n < 0:
raise ValueError("Negative arguments not implemented")
print _fib(n)[0]
def _fib(n):
@jvrmaia
jvrmaia / li-ssl-cert.sh
Created April 9, 2015 10:57
ssl manager
#!/usr/bin/env bash
DATE=$(date +%s)
DEFAULT_KEYSTORE_STOREPASS=vmware
KEYSTORE_STOREPASS=`grep keystorePass /usr/lib/loginsight/application/etc/3rd_config/server.xml 2>/dev/null | gawk -F'"' '{print $4}' || echo ${DEFAULT_KEYSTORE_STOREPASS}`
TOMCAT=$(ls /usr/lib/loginsight/application/3rd_party 2>/dev/null | grep tomcat)
[ ! -d "/usr/lib/loginsight/application/3rd_party/${TOMCAT}" ] && \
echo >/dev/stderr "ERROR: Unable to locate Tomcat directory, you must run this on the Log Insight virtual appliance...exiting" && \
exit 255
@jvrmaia
jvrmaia / benchmark-commands.txt
Created November 4, 2016 18:57 — forked from jkreps/benchmark-commands.txt
Kafka Benchmark Commands
Producer
Setup
bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test-rep-one --partitions 6 --replication-factor 1
bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test --partitions 6 --replication-factor 3
Single thread, no replication
bin/kafka-run-class.sh org.apache.kafka.clients.tools.ProducerPerformance test7 50000000 100 -1 acks=1 bootstrap.servers=esv4-hcl198.grid.linkedin.com:9092 buffer.memory=67108864 batch.size=8196
@jvrmaia
jvrmaia / keybase.md
Created October 26, 2017 23:36
keybase.md

Keybase proof

I hereby claim:

  • I am jvrmaia on github.
  • I am jvrmaia (https://keybase.io/jvrmaia) on keybase.
  • I have a public key ASA6QSI2quGUM2deijyUNeLmKG2MwpuwUwwucJMEVuwghAo

To claim this, I am signing this object:

@jvrmaia
jvrmaia / finance.md
Last active September 17, 2023 21:56
finance

patrimômio mínimo de sobrevivência (PMS)

PMS = 6 x [gastos mensais]

patrimônio mínimo recomendado para sua segurança (PMR)

PMR = 12 x [gastos mensais] caso sua empregabilidade seja alta 20 x [gastos mensais] caso sua empregabilidade seja baixa

patrimônio ideal para sua idade e situação de consumo (PI)

Quick Tips for Fast Code on the JVM

I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.

This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea

import re
import random
import time
WORD_LIST = [
'glibc-x86_64.tar.gz',
'rock_pesado.mp3',
'spotify_64bits.tar.gz',
'firefox-x86-64.tar.gz',