Skip to content

Instantly share code, notes, and snippets.

@Cergoo
Cergoo / tailwind.itermcolors
Created November 10, 2018 08:11 — forked from stidges/tailwind.itermcolors
An iTerm2 color scheme based on the Tailwind CSS color scheme (https://tailwindcss.com/docs/colors)
<?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>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.18431372940540314</real>
@Cergoo
Cergoo / public_key_decrypt_gpg_base64.go
Created October 20, 2018 16:59 — forked from jyap808/public_key_decrypt_gpg_base64.go
Decrypting a base64 GPG public key encrypted string using a passphrase protected private key in ASCII armor format
package main
import (
"bytes"
"code.google.com/p/go.crypto/openpgp"
"encoding/base64"
"fmt"
"io/ioutil"
"log"
)
https://wiki.archlinux.org/index.php/Tmux_(%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9)
http://gimmor.blogspot.ru/2012/10/tmux.html
Очень хороший способ запустить tmux:
tmux attach || tmux new — делая так, вы сперва пытаетесь подключиться к уже существующему серверу tmux, если он существует; если такого ещё нет — создаёте новый.
После этого вы попадаете в полноценную консоль.
Ctrl+b d — отключиться. (Точно так же вы отключитесь, если прервётся соединение. Как подключиться обратно и продолжить работу — см. выше.)
@Cergoo
Cergoo / other
Last active January 2, 2016 07:09
func (s *Store) openOrCreate(file string) (*os.File, error) {
fname := fmt.Sprintf("%s/%s", s.RootDir, file)
f, e := os.OpenFile(fname, os.O_RDWR^os.O_SYNC^os.O_CREATE, 0600)
if e != nil {
return nil, reterr("openOrCreate", e)
}
return f, nil
}
// truncate a filename extension
@Cergoo
Cergoo / byte_to_int
Created December 20, 2013 05:01
[]byte to int
func read_int32(data []byte) int32 {
return int32(uint32(data[0]) + uint32(data[1])<<8 + uint32(data[2])<<16 + uint32(data[3])<<24)
}
@Cergoo
Cergoo / iota
Created December 17, 2013 17:55
iota example
type ByteSize float64
const (
_ = iota // ignore first value by assigning to blank identifier
KB ByteSize = 1<<(10*iota)
MB
GB
TB
PB
EB
ZB
for x := range container.Iter() { ...
func (c *container) Iter () <-chan item {
ch := make(chan item);
go func () {
for i := 0; i < c.size; i++ {
ch <- c.items[i]
@Cergoo
Cergoo / copyobj.go
Last active December 29, 2015 08:29
package main
import (
"encoding/json"
"fmt"
"reflect"
)
type M map[string]interface{} // just an alias
package main
import (
"bufio"
"net"
)
type Client struct {
incoming chan string
outgoing chan string
package main
import "fmt"
func collect(vals []int, f func(int) int) []int {
length := len(vals)
newVals := make([]int, length, length)
for i, val := range vals {
newVals[i] = f(val)