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 java.util.List; | |
public class KahendpisteMeetod { | |
/** | |
* Sorteerida List kahendpistemeetodil. | |
* @param massiiv sorteeritav list. | |
* @param vasak_piirik Positsioon kust alates sorteerida | |
* @param parem_piirik Positsioon milleni sorteerida, välja arvatud | |
*/ | |
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
-- Protsent kõikide päringute mahust | |
SELECT substring(query, 1, 50) AS short_query, | |
round(total_time::numeric, 2) AS total_time, | |
calls, round((total_time / calls)::numeric, 2) AS mean, | |
round((100 * total_time / sum(total_time::numeric) | |
OVER ())::numeric, 2) AS percentage_overall | |
FROM pg_stat_statements | |
ORDER BY total_time DESC | |
LIMIT 20; |
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, struct, re | |
def cached_property(accessor): | |
cache_name = '_cached_%s' % accessor.__name__ | |
def property_cacher(obj): | |
try: | |
return getattr(obj, cache_name) | |
except AttributeError: | |
value = accessor(obj) | |
setattr(obj, cache_name, value) |
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
from threading import RLock, Thread | |
import time | |
running = True | |
def long_lock_loop(mutex): | |
while running: | |
mutex.acquire() | |
print "Long acquired" | |
time.sleep(3) |
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
gistup |
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
// In main part of the application | |
db, err := sql.Open("postgres", connectString) | |
defer db.Close() | |
checkErr(err) | |
// In single request | |
tx, err := db.BeginTx(context.TODO(), TxOptions{sql.LevelRepeatableRead}) // Gets a single connection from pool and start transaction | |
checkErr(err) |
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
CREATE TABLE data (id serial primary key, name text, data jsonb); | |
INSERT INTO data (name, data) VALUES ('testing', '{"foo": 1, "bar": 2}'); | |
INSERT INTO data (name, data) DEFAULT VALUES; |
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
diff --git a/patroni/dcs/kubernetes.py b/patroni/dcs/kubernetes.py | |
index ade15ff..9fbd9e7 100644 | |
--- a/patroni/dcs/kubernetes.py | |
+++ b/patroni/dcs/kubernetes.py | |
@@ -107,7 +107,8 @@ class Kubernetes(AbstractDCS): | |
try: | |
return func(*args, **kwargs) | |
except (RetryFailedError, k8s_client.rest.ApiException, | |
- HTTPException, HTTPError, socket.error, socket.timeout): | |
+ HTTPException, HTTPError, socket.error, socket.timeout) as e: |
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
#!/bin/sh | |
if [ -z "$1" ]; then | |
(>&2 echo "Usage: $0 \"host=.. user=.. dbname=..\"") | |
exit 1 | |
fi | |
CONNSTRING=$1 | |
cat - <<PRELUDE |
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
#!/bin/bash | |
PID=$1 | |
function curtime() { | |
date "+[%H:%M:%S]" | |
} | |
function check() { | |
curl -vk https://localhost:8008/ 2>&1 | grep -q $1 |
OlderNewer