Skip to content

Instantly share code, notes, and snippets.

View artyom's full-sized avatar

Artyom Pervukhin artyom

View GitHub Profile
@artyom
artyom / noautosave.patch
Created June 5, 2017 16:07
Patch for https://github.com/Doist/bitmapist-server/ allowing one to disable autmated periodic saving and initiate save by SIGUSR2
diff --git i/bitmapist.go w/bitmapist.go
index 0e22f2c..345ae31 100644
--- i/bitmapist.go
+++ w/bitmapist.go
@@ -18,10 +18,11 @@ import (
func main() {
args := struct {
- Addr string `flag:"addr,address to listen"`
- File string `flag:"db,path to database file"`
~ ¶ cat .bin/org.acme.kill_distnoted.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.acme.kill_distnoted</string>
<key>Program</key>
<string>/Users/artyom/.bin/checkdistnoted</string>
<key>ProgramArguments</key>
@artyom
artyom / ssh-mux.go
Created February 25, 2017 17:26
Example ssh server with both interactive terminal & sftp support
package main
import (
"bufio"
"bytes"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
@artyom
artyom / bashrc-snippet.bash
Created November 18, 2016 09:47
Show gopher when current working directory is under GOPATH
__pschar () {
IFS=':' read -ra PDIRS <<< "$GOPATH"
for P in "${PDIRS[@]}" ; do
test "${1#$P}" = "$1" || {
printf ""
return
}
done
printf "¶"
}
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 63
model name : Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
stepping : 2
microcode : 0x25
cpu MHz : 2400.078
cache size : 30720 KB
physical id : 0
@artyom
artyom / ping.go
Last active November 9, 2016 07:32
package main
import (
"fmt"
"net"
"os"
"time"
"golang.org/x/net/icmp"
"golang.org/x/net/ipv4"
@artyom
artyom / fields.go
Last active September 12, 2016 19:52
package rest
import (
"flag"
"io/ioutil"
"net/url"
"github.com/artyom/autoflags"
)
@artyom
artyom / gpg-encrypt.go
Created April 27, 2016 17:10
Encrypt file using OpenPGP
package main
import (
"flag"
"io"
"log"
"os"
"github.com/artyom/autoflags"
@artyom
artyom / redis-zram.txt
Created April 12, 2016 10:31
Fat redis on a 8 Gb instance
admin@ip-172-16-38-251:~$ free -h
total used free shared buffers cached
Mem: 7.8G 7.7G 132M 284K 788K 10M
-/+ buffers/cache: 7.7G 143M
Swap: 49G 40G 9.3G
admin@ip-172-16-38-251:~$ redis-cli
127.0.0.1:6379> info memory
# Memory
used_memory:48507306184
used_memory_human:45.18G
@artyom
artyom / deps-update.sh
Last active March 29, 2016 11:58
Manage dependencies with git subtrees
#!/bin/sh -eu
deps () {
# format is "key path repo branch"
cat <<-"EOF"
dep1 libs/dep1 git@github.com:User/lib1.git master
EOF
}
SEL=${1:-}