Skip to content

Instantly share code, notes, and snippets.

@tomask-de
tomask-de / main.go
Created February 24, 2024 09:14 — forked from tangledbytes/main.go
1brc-go-sol
package main
import (
"bytes"
"fmt"
"math"
"os"
"os/signal"
"runtime"
"runtime/pprof"
@tomask-de
tomask-de / main.go
Created August 18, 2023 11:57
tbtest 10k/1mio
package main
import (
"fmt"
"log"
"os"
"reflect"
"time"
tb "github.com/tigerbeetle/tigerbeetle-go"
@tomask-de
tomask-de / far.sh
Created April 25, 2018 07:30
find and replace oneliner
for f in `find . -name "*.go" | xargs grep -l "<OLD>"`; do sed -i -e 's/<OLD>/<NEW>/g' $f; done
@tomask-de
tomask-de / locations.sql
Created April 11, 2018 14:14
opengeodb locations incl. location id, zip code, location name, region (federal state), lon and lat
CREATE TABLE locations
(
id INT AUTO_INCREMENT PRIMARY KEY,
loc_id INT NOT NULL,
zip VARCHAR(10) NOT NULL,
location_name VARCHAR(255) NOT NULL,
region VARCHAR(255) NOT NULL,
lat DOUBLE NOT NULL,
lon DOUBLE NOT NULL
) ENGINE = InnoDB;
@tomask-de
tomask-de / zipcode-radius-search-with-federal-state.sql
Last active April 11, 2018 13:54
opengeodb search by zip code and radius incl. the federal state in result
SELECT
dest.zc_loc_id AS ID,
dest.zc_zip AS PLZ,
dest.zc_location_name AS ORT,
ACOS(
SIN(RADIANS(src.zc_lat)) * SIN(RADIANS(dest.zc_lat))
+ COS(RADIANS(src.zc_lat)) * COS(RADIANS(dest.zc_lat))
* COS(RADIANS(src.zc_lon) - RADIANS(dest.zc_lon))
) * 6380 AS Entfernung,
t5.text_val AS Bundesland
@tomask-de
tomask-de / place-zip-state.sql
Created April 10, 2018 16:09
opengeodb select place, zip/postal code, federal state
SELECT
t1.loc_id, t1.text_val AS Ort, t2.text_val AS PLZ, t5.text_val AS Bundesland
FROM geodb_textdata t1, geodb_textdata t2, geodb_textdata t3, geodb_textdata t4, geodb_textdata t5
WHERE t2.text_val = '08060'
AND t1.loc_id = t2.loc_id
AND t2.text_type = '500300000' /* PLZ */
AND t3.loc_id = t1.loc_id
AND t3.text_type = '500600000' /* Amtlicher Gemeindeschlüsssel */
AND t4.text_type = '500600000'
AND t4.text_val = SUBSTR(t3.text_val,1,2)
@tomask-de
tomask-de / go-static.sh
Created April 22, 2016 14:17
build a statically linked executable with go
#!/bin/bash
go build -installsuffix netgo -tags netgo -a -ldflags "-s -X main.version=${VERDSION}"
@tomask-de
tomask-de / like.js
Created April 21, 2016 10:52
react like
/** @jsx React.DOM */
var React = require('react');
var Ausgabe = React.createClass({
getInitialState: function() {
return {
gefaelltmir: false
};
},
handleClick: function(e) {
@tomask-de
tomask-de / java-ts-to-date-from-oracle-number.sql
Last active April 21, 2016 10:55
Convert a Java timestamp (long value) saved in an Oracle database as NUMBER(16) into a readable string
-- 2177452800000000 = diff from 01.01.1970 00:00:00.000000 to 01.01.1901 00:00:00.000000
select timestamp '1970-01-01 00:00:00' + numtodsinterval((STAMP - 2177452800000000)/1000/1000,'SECOND') from DUAL;
@tomask-de
tomask-de / phpunit2mvnrepo
Last active April 21, 2016 09:38
Install specified PHPUnit version to local Maven repository
mvn install:install-file -Dfile=phpunit-4.3.phar \
-DgroupId=de.phpunit \
-DartifactId=PHPUnit \
-Dversion=4.3 \
-Dpackaging=phar \
-DgeneratePom=true \
-DcreateChecksum=true \
(-DlocalRepositoryPath=<path-to-repo>)