This file contains hidden or 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
""" | |
Usage: | |
cat '1234567890123456' > secret.key | |
echo "hello world" | python encdec.py | python encdec.py -d | |
""" | |
import sys | |
import base64 | |
import getopt |
This file contains hidden or 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
var i interface{} | |
b := []byte(json_data) | |
json.Unmarshal(b, &i) | |
v := i.(map[string]interface{}) | |
data := v["data"].(string) | |
fmt.Printf("data = %v\n", data) |
This file contains hidden or 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, sys | |
import fnmatch | |
import subprocess | |
import multiprocessing | |
from multiprocessing.pool import ThreadPool | |
def iter_files(root, pattern): | |
for root, dirs, files in os.walk(root): | |
for f in files: | |
if not fnmatch.fnmatch(f, pattern): continue |
This file contains hidden or 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 unittest | |
import oslo_cache.core as cache | |
from oslo_config import cfg | |
CONF = cfg.CONF | |
class CacheTest(unittest.TestCase): | |
def get_client(self): | |
cache.configure(CONF) |
This file contains hidden or 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 | |
if [ "`cat /sys/kernel/mm/ksm/run`" -ne 1 ] ; then | |
echo 'KSM is not enabled. Run echo 1 > /sys/kernel/mm/ksm/run' to enable it. | |
exit 1 | |
fi | |
echo Shared memory is $((`cat /sys/kernel/mm/ksm/pages_shared`*`getconf PAGE_SIZE`/1024/1024)) MB | |
echo Saved memory is $((`cat /sys/kernel/mm/ksm/pages_sharing`*`getconf PAGE_SIZE`/1024/1024)) MB | |
if ! `type bc &>/dev/null` ; then | |
echo "bc is missing or not in path, skipping ratio calculation" | |
exit 1 |
This file contains hidden or 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 | |
swap_file=/swap0 | |
usage(){ | |
echo "Usage:" | |
echo " $0 0 disable swap file" | |
echo " $0 size create swap file" | |
} | |
make_swap(){ |
This file contains hidden or 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
// tested flink 0.9.1 | |
object Job { | |
def main(args: Array[String]) { | |
// set up the execution environment | |
val env = StreamExecutionEnvironment.getExecutionEnvironment | |
val properties = new Properties | |
var bootstrap_servers = "<kafka-server>:9092" | |
properties.setProperty("bootstrap.servers", bootstrap_servers) | |
properties.setProperty("zookeeper.connect", "<zookeeper-server>:2181") |
This file contains hidden or 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
# dev | |
.git | |
**/*.sw* | |
**/tags | |
*.sublime* | |
# docker | |
Dockerfile* | |
.dockerignore | |
docker-compose.yml |
This file contains hidden or 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
def get_servers(opts={}): | |
limit = 500 | |
marker = None | |
opts['limit'] = limit | |
while True: | |
servers = client.servers.list(search_opts=opts, marker=marker) | |
for server in servers: |
This file contains hidden or 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 urlparse import urlsplit, urlunsplit | |
def url_path_join(*parts): | |
"""Join and normalize url path parts with a slash.""" | |
schemes, netlocs, paths, queries, fragments = \ | |
zip(*(urlsplit(part) for part in parts)) | |
scheme = next((x for x in schemes if x), '') | |
netloc = next((x for x in netlocs if x), '') |