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 sys | |
import json | |
import xgboost as xgb | |
if len(sys.argv) < 2: | |
print(f'Usage: {sys.argv[0]} <model-file>') | |
exit(1) | |
loaded_model = xgb.Booster() | |
loaded_model.load_model(sys.argv[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
from multiprocessing import Process, Queue | |
from queue import Empty | |
import os | |
from time import sleep | |
def fun(q, timeout): | |
while True: | |
try: | |
item = q.get(timeout=timeout) | |
print(item, os.getpid()) |
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 __future__ import print_function | |
from datetime import datetime | |
import asyncore | |
from smtpd import SMTPServer | |
class EmlServer(SMTPServer): | |
no = 0 | |
def process_message(self, peer, mailfrom, rcpttos, data, mail_options=None, | |
rcpt_options=None): | |
filename = '%s-%d.eml' % (datetime.now().strftime('%Y%m%d%H%M%S'), |
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 __future__ import print_function | |
import sys | |
import re | |
if len(sys.argv) < 3: | |
print('{} <input-file> <line-seq-file><replace-lines-file>'.format(sys.argv[0])) | |
sys.exit(1) | |
input_lines = [] | |
line_seq = [] |
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 json | |
from elasticsearch import Elasticsearch | |
try: | |
es = Elasticsearch(['127.0.0.1:9200']) | |
indexes = es.indices.get_alias('*') | |
index_list = [] | |
for idx in indexes: | |
print 'Index ' + idx | |
index_list.append(idx) |
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
package main | |
import ( | |
"fmt" | |
"time" | |
"github.com/go-kit/kit/log" | |
"github.com/prometheus/tsdb" | |
"github.com/prometheus/tsdb/labels" | |
) |
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 multiprocessing import Process, Lock | |
from time import sleep | |
def f(name, l, shouldsleep): | |
i = 1 | |
while i < 30: | |
l.acquire() | |
print 'Myself', name, 'The lock', l | |
if shouldsleep: | |
print name, 'will sleep for 10 secs, others have to wait' |
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
package main | |
import ( | |
"crypto/md5" | |
"encoding/json" | |
"flag" | |
"fmt" | |
"github.com/hashicorp/consul/api" | |
"io/ioutil" | |
"os" |
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 threading import Thread, Lock | |
from time import sleep, time | |
from datetime import datetime | |
from pymongo import MongoClient | |
from uuid import uuid1 | |
import atexit | |
class DistLockMongo(Thread): | |
def __init__(self, host='localhost', port=27017, db='lockdb'): |
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 my_binary_search(lst, val, start, end): | |
if start == end: | |
if val == lst[start]: | |
return start | |
return -1 | |
if val < lst[start] or val > lst[end]: | |
return -1 | |
if val > lst[end]: | |
if val == lst[end]: | |
return end |
NewerOlder