Skip to content

Instantly share code, notes, and snippets.

View sylr's full-sized avatar

Sylvain Rabot sylr

View GitHub Profile
@sylr
sylr / prometeus.pprof
Last active January 10, 2019 15:28
prometheus azure sd stuck
goroutine 1516690 [running]:
runtime/pprof.writeGoroutineStacks(0x7fcfd86e2b90, 0xc09997ee60, 0x40bb2f, 0xc0d9689c50)
/usr/local/go/src/runtime/pprof/pprof.go:678 +0xa7
runtime/pprof.writeGoroutine(0x7fcfd86e2b90, 0xc09997ee60, 0x2, 0xc00033e700, 0x0)
/usr/local/go/src/runtime/pprof/pprof.go:667 +0x44
runtime/pprof.(*Profile).WriteTo(0x2e6eb80, 0x7fcfd86e2b90, 0xc09997ee60, 0x2, 0xc09997ee60, 0xc041252e80)
/usr/local/go/src/runtime/pprof/pprof.go:328 +0x3e4
net/http/pprof.handler.ServeHTTP(0xc07fd206cd, 0x9, 0x7fcfd86e2b60, 0xc09997ee60, 0xc0b4f3aa00)
/usr/local/go/src/net/http/pprof/pprof.go:245 +0x210
net/http/pprof.Index(0x7fcfd86e2b60, 0xc09997ee60, 0xc0b4f3aa00)
@sylr
sylr / functions_test.go
Created October 24, 2018 15:08
prometheus functions_test.go
// Copyright 2015 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmDnsName": {
"type": "string",
"metadata": {
"description": "DNS name for the VM"
}
},
@sylr
sylr / hash-lev.go
Last active July 22, 2017 09:59
Generate array of hashes and compute levenshtein distances of hashes
package main
import (
"fmt"
"sync"
"time"
"strconv"
"math/rand"
"crypto/md5"
"encoding/hex"
@sylr
sylr / postgres-9.5-sharding.sh
Last active June 11, 2019 21:23
Postgresql 9.5 sharding example
echo master shard_{0,1,2,3} | xargs -n1 /usr/local/bin/dropdb -p 6432 -h /tmp -U postgres
echo master shard_{0,1,2,3} | xargs -n1 /usr/local/bin/createdb -p 6432 -h /tmp -U postgres
for a in {0..3}; do
echo "
CREATE TABLE users (id serial PRIMARY KEY, username TEXT NOT NULL);
ALTER SEQUENCE users_id_seq INCREMENT BY 4 RESTART WITH $a;
" | /usr/local/bin/psql -p 6432 -h /tmp -U postgres -d shard_$a;
done
@sylr
sylr / .bashrc
Created July 25, 2012 09:33
SSH agent tweak for screen
# SSH agent tweak for screen
export SSH_AUTH_SOCK_TMP=/tmp/$LOGNAME-ssh-agent.sock
# test link reference
if [ ! -e "$SSH_AUTH_SOCK_TMP" ]; then
# test that link exists
if [ -L "$SSH_AUTH_SOCK_TMP" ]; then
unlink $SSH_AUTH_SOCK_TMP
fi
#!/usr/bin/env sh
if test -f ~/.evolution/.running; then
echo >&2 "evolution is running, close it before running this script"
exit 1
fi
for file in $(find ~/.evolution/ -type f -name \*.db);
do
mime=$(file $file | grep -i "SQLite")
# command line can be amazing and so simple ( just a terminal! ) at the same time
# Show apps that use internet connection at the moment
lsof -P -i -n
# all parameters from latest command
!*
#edit current command line in your editor
<ctrl-x> <ctrl-e>
#!/bin/sh
tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"
location ~ ^/php-fpm-(status|ping)$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/php-fpm-status;
include fastcgi_params;
}