Skip to content

Instantly share code, notes, and snippets.

View kunkun-tang's full-sized avatar
🎯
Focusing

Liang Tang kunkun-tang

🎯
Focusing
View GitHub Profile
@ngauthier
ngauthier / timeout_and_tick.go
Created February 10, 2015 18:14
Golang timeout and tick loop
// keepDoingSomething will keep trying to doSomething() until either
// we get a result from doSomething() or the timeout expires
func keepDoingSomething() (bool, error) {
timeout := time.After(5 * time.Second)
tick := time.Tick(500 * time.Millisecond)
// Keep trying until we're timed out or got a result or got an error
for {
select {
// Got a timeout! fail with a timeout error
case <-timeout:
@sednem
sednem / GenericDAO.java
Created December 6, 2012 17:10
DAO Genérico
package br.ufpe.nti.dao;
import java.io.Serializable;
import java.util.List;
public interface GenericDAO<T, I extends Serializable>{
/**
* Persiste um objeto
* @param object