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
@juanplopes
juanplopes / DefaultSchedulerContext.java
Created March 26, 2015 14:02
QConSP 2015: TaskScheduler
import com.google.common.collect.Lists;
import com.google.common.collect.Queues;
import com.google.common.primitives.Ints;
import com.google.common.primitives.Longs;
import java.util.List;
import java.util.PriorityQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
#include <iostream>
#include <queue>
#include <cmath>
using namespace std;
priority_queue<int> Q, T;
int main() {
int test=0, tests; cin >> tests;
int D;
@juanplopes
juanplopes / keygen.py
Last active August 29, 2015 14:21
Simple Python script to help using GitHub pages as a Maven private repository
#!/usr/bin/env python
"""
GitHub keygen
Creates an OAuth2 token and adds a server entry at ~/.m2/settings.xml.
Makes it easy to either use a github private repository as a maven repository,
and to deploy artifacts to a private or public repository using github site
plugin.
"""
def is_change_possible(coins, change):
if change==0: return True
if change<0 or len(coins)==0: return False
return (is_change_possible(coins[1:], change) or
is_change_possible(coins[1:], change-coins[0]))
print is_change_possible([1, 2, 5], 8)
print is_change_possible([1, 2, 5], 4)
print is_change_possible([1]*2000, 2000)
let rec enumerateSquares (x: uint64) = seq {
if x<>0UL then
yield x &&& (~~~x+1UL)
yield! enumerateSquares(x &&& (x - 1UL))
}
let enumerateSquares (bitboard: uint64) =
bitboard
|> Seq.unfold(fun x ->
if x = 0UL then None
else Some(x &&& (~~~x + 1UL), x &&& (x - 1UL)))
@juanplopes
juanplopes / rainbow.py
Last active August 29, 2015 14:23
Python script to put a rainbow overlay in an image
#!/usr/bin/env python
import Image, colorsys, sys
if len(sys.argv) < 2:
print 'usage: {} <file> [<output>]'.format(sys.argv[0])
sys.exit(0)
img = Image.open(sys.argv[1])
width, height = img.size
# -*- coding: utf-8 -*-
from __future__ import print_function
import timeit, random, sys
if sys.version_info >= (3, ): xrange=range
def partition(data, begin, end):
value = data[end-1]
pivot = begin

Discussão iniciada no grupo tdd-no-mundo-real

Pessoal, desculpe a resposta longa mas esse assunto é muito interessante. Quem hoje em dia, pode acompanhar uma discussão entre grandes pioneiros de sua área que com certeza entrarão para a história da Engenharia de Software nos séculos seguintes? Somos muito afortunados quanto a isso.

Tenho acompanhado essas discussões pelos blogs do DHH e do Uncle Bob.

Achei que deveriam ter incluído o Uncle Bob no hangout. Como disseram que fariam outros episódios, creio que ele deve participar no próximo.

Resumindo o que tirei das opiniões deles:

Remember

This is ok:

for(int i = 1; i <= floor(sqrt(n)); i++) {
    //code
}