Skip to content

Instantly share code, notes, and snippets.

View a1tus's full-sized avatar

ILYA a1tus

  • Russia, Moscow
View GitHub Profile
@montanaflynn
montanaflynn / pget.go
Last active October 21, 2023 06:12
Bounded Parallel Get Requests in Golang
package main
import (
"fmt"
"net/http"
"sort"
"time"
)
// a struct to hold the result from each request including an index
@tebeka
tebeka / server_test.go
Created April 16, 2016 04:36
Wait for HTTP server to Start
func waitForServer(URL string, timeout time.Duration) error {
ch := make(chan bool)
go func() {
for {
_, err := http.Get(URL)
if err == nil {
ch <- true
}
time.Sleep(10 * time.Millisecond)
}
@luke
luke / bulkupsert.py
Last active March 17, 2023 19:30
I needed to upsert (insert or update) bajillions of records into postgresql. After trying various libs including upsert (which was slow as hell) I ended up doing a bit of research and trying 3 different methods. This one won. While I'm manually building the sql string no user data is passed in. Its loaded via the copy from statement as CSV. Call…
import logging
import cStringIO
import csv
DEBUG = False
def data2csv(data):
si = cStringIO.StringIO()
cw = csv.writer(si, delimiter='\t',lineterminator="\n")
for row in data: