This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
tc.constraint_name, | |
tc.table_schema, | |
tc.table_name, | |
kcu.column_name | |
FROM | |
information_schema.table_constraints tc | |
JOIN information_schema.key_column_usage kcu | |
ON tc.constraint_name = kcu.constraint_name | |
AND tc.table_schema = kcu.table_schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func insert(num int, pos int, dst []int) []int { | |
if len(dst) == 0 { | |
dst = append(dst, num) | |
return dst | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// Работает не совсем правильно, над поправить | |
import ( | |
"bufio" | |
"flag" | |
"fmt" | |
"os" | |
"regexp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// JSON filter | |
// Stdin: json objects separated by new line | |
// Stdout: valid json objects | |
// Use case: I had a service with logs in json format. | |
// But due unknown reason sometimes one or two lines in logs corrupted. | |
// I needed an utility which filters valid json from invalid json. | |
// Example: cat my-service-logs.json | json_validator | cat > processed-logs.json | |
import ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"fmt" | |
"os" | |
"github.com/shelomentsevd/mtproto" | |
"time" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type Box struct { | |
ID string | |
} | |
type BoxContainter struct { | |
box Box |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"sync/atomic" | |
"fmt" | |
) | |
type Increment struct { | |
count uint32 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Store struct { | |
mutex sync.RWMutex | |
data map[string]int | |
} | |
func (s * Store) Read(key string) int, error { | |
// ... | |
defer s.mutex.RUnlock() | |
s.mutex.RLock() | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os" | |
"os/signal" | |
"syscall" | |
"fmt" | |
"time" | |
"reflect" | |
"mtproto" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from os import listdir | |
from os.path import dirname, realpath, isfile, isdir, isabs, join | |
def get_filenames(path): | |
if isabs(path): | |
dir_path = path | |
else: | |
dir_path = join( dirname(realpath(__file__)), path ) |
NewerOlder