Skip to content

Instantly share code, notes, and snippets.

View juanplopes's full-sized avatar
🌲
Is that a Segment Tree problem?

Juan Lopes juanplopes

🌲
Is that a Segment Tree problem?
View GitHub Profile
import static java.lang.System.exit;
import static java.lang.System.out;
public class Dafuq {
/**
* This does not do what you think it does.
* <p>
* You think code is documentation? No! Documentation is code!
\u002a\u002f
@SingingBush
SingingBush / JavaBluetooth.md
Last active October 22, 2024 09:13
A short article about the lack a standard API for Bluetooth in Java SE

Bluetooth (or the lack of) on Java

Java SE has never had support for bluetooth, the closest thing to a standard is JABWT (Java APIs for Bluetooth Wireless Technology) defined in JSR-82 which is actually for Java ME (Micro Edition).

JSR-82 provides the specification for the javax.bluetooth and javax.obex packages and would allow for code somewhat like:

import javax.bluetooth.BluetoothStateException;
import javax.bluetooth.DeviceClass;
@luzfcb
luzfcb / resposta_aos_novatos.md
Last active March 13, 2024 21:20
resposta aos iniciantes novatos pythonbrasil

Olá, seja bem vindo ao grupo Python-Brasil.

  • Insira aqui o pedido de mais informações ou possivel solução a pergunta feita

Dito isto, aqui nós possuímos algumas regras que ajudam a manter essa lista útil e agradável para os participantes

Antes de mandar as suas próximas perguntas, pedimos para que leia o texto:

@juanplopes
juanplopes / pave.md
Last active August 29, 2015 14:05
Candidato, é pavê ou pra comê? (texto de @kramercarlos)

Texto criado pelo amigo Carlos Krämer (github . twitter . facebook) lá no Facebook, reproduzido aqui com a permissão dele.

Jornalista: Candidato, é pavê ou pra comê?

Dilma: Veja bem, nunca foi tanto pra comê quanto no meu governo. Há um ditado.... eu digo, editaram quando eu era o cachorro atrás de uma criança ... que diz que todo mundo que insere, ou melhor, ingere o que é pavê, tem uma satisfação imensa de... como dizem... dobrar a esquina. Mas nós precisamos continuar mudando, meu governo foi ótimo, eu fui eleita para dar prosseguimento ao governo Lula, Lula, LULA. Mas ninguém está mais insatisfeita com ele, digo, com o governo, não com o Lula, do que eu, mas os pessimistas é que estão tornando tudo ruim.

Marina: Eu não acho que é pavê nem pra comê. Nós precisamos aprender a reunir o que é bom em tudo, as melhores

import logging
import sys
from graph import *
from residual import *
from dijkstras import Dijkstra
first_from_set = lambda s: list(s)[0]
excess_criteria = lambda x: x.supply > 0
deficit_criteria = lambda x: x.supply < 0
@juanplopes
juanplopes / gist:178060e556e68421a8c5
Last active August 29, 2015 14:02
Ford-Fulkerson example for presentation: http://goo.gl/DizfF7
from collections import defaultdict
def add(network, a, b, capacity):
network[a][b] = network[b][a] = capacity
def send(network, a, b, V, minimum=1000000):
V.add(a)
if a == b:
print '-> path', a
return minimum
@juanplopes
juanplopes / convexhull01.html
Last active August 29, 2015 13:56
Revised @ElemarJR's Convex Hull (using Monotone Chain)
<!doctype html>
<html>
<head>
<title>ConvexHull 01</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
@juanplopes
juanplopes / Main.java
Created January 22, 2014 13:41
Using Count-Min Sketch to find stream's quantiles with small memory footprint.
QuantileSketch sketch = new QuantileSketch();
for (int i = 0; i < 100000000; i++) {
double x1 = Math.random();
double x2 = Math.random();
//random normal distribution with mean=0 and stdev=1
sketch.offer(abs(sqrt(-2 * log(x1)) * cos(2 * Math.PI * x2)));
}
for (int i = 0; i <= 100; i++) {
@debasishg
debasishg / gist:8172796
Last active November 23, 2024 12:32
A collection of links for streaming algorithms and data structures

General Background and Overview

  1. Probabilistic Data Structures for Web Analytics and Data Mining : A great overview of the space of probabilistic data structures and how they are used in approximation algorithm implementation.
  2. Models and Issues in Data Stream Systems
  3. Philippe Flajolet’s contribution to streaming algorithms : A presentation by Jérémie Lumbroso that visits some of the hostorical perspectives and how it all began with Flajolet
  4. Approximate Frequency Counts over Data Streams by Gurmeet Singh Manku & Rajeev Motwani : One of the early papers on the subject.
  5. [Methods for Finding Frequent Items in Data Streams](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.187.9800&amp;rep=rep1&amp;t
@juanplopes
juanplopes / rsa.py
Last active July 14, 2023 17:35
RSA by example
from random import randint
#----Step 1
# First, choose two random primes.
# In real world, they should be really big primes (hundreds of digits).
p, q = 41, 47
#----Step 2
# From them we have n=p*q and phi(n)=(p-1)*(q-1).