Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrey Tatarinov elephantum

View GitHub Profile
View getdoc.js
function GdDocument(name) {
this.name = name;
this.sources = [];
}
function GdProcess(inputs, outputs) {
this.inputs = inputs;
this.outputs = outputs;
for (var i in this.outputs) {
@elephantum
elephantum / .env
Last active Jan 26, 2021
Dask data loss with `.set_index`
View .env
#VERSION=2020.12.0
VERSION=2021.1.1
View gist:6416522
res <- data.frame(session=NA, dt=NA)
for(event_str in unique(summary$event)) {
event_name <- gsub(pattern=' ', replacement='.', x=event_str, )
tmp <- summary[ summary$event == event_str, c('session', 'dt', 'count')]
names(tmp)[3] <- event_name
res <- merge(x=res, y=tmp, by=c('session', 'dt'), all=TRUE)
}
View 1.py
def prepare_data(data):
data['service'] = None
data['service'][data['upstream_addr'] == '-'] = 'static'
data['service'][data['upstream_addr'] == '127.0.0.1:4091'] = 'backend'
data['service'][data['upstream_addr'] == '127.0.0.1:4092'] = 'screenshot'
data['service'][data['upstream_addr'] == '127.0.0.1:9000'] = 'frontend'
data['request_time_xx'] = '-'
data['request_time_xx'][data['request_time'].between(0, 0.5)] = '0-500ms'
data['request_time_xx'][data['request_time'].between(0.5, 1)] = '500ms-1s'
View add_redmine_href.py
import sys
import csv
r = csv.reader(sys.stdin)
data = list(r)
for line in data[1:]: line[-1] += '\n\n http://jira.ent3.ru/issues/%s' % (line[0],)
w = csv.writer(sys.stdout)
w.writerows(data)
View gist:1221744
public class EastActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final EditText username = (EditText)findViewById(R.id.clientid);
final EditText password = (EditText)findViewById(R.id.passwordid);
final Button button = (Button)findViewById(R.id.ok);
final TextView txtResult = (TextView)findViewById(R.id.content);
View xmlrpc_lenta.markdown

Inspired by http://clubs.ya.ru/podpiski/replies.xml?item_no=2

Список постов

get_posts({group_id,md5,url,tag_id}, nav, items_per_page, read_status)

Из group_id, md5, url, tag_id должен быть указан только один. Параметры nav, items_per_page, read_status - необязательные

Содержимое поста

View gist:557195
a = '1.2.3'
b = '1.3.4'
def cmp(a, b):
for (i,j) in zip(a.split('.'), b.split('.')):
if int(i) < int(j):
return False
elif int(i) > int(j):
return True
View profile_httpclient.py
import time
import tornado.ioloop
import tornado.httpclient
import logging
logging.basicConfig(level=logging.DEBUG)
io_loop = tornado.ioloop.IOLoop.instance()
interrupts_count = 0
View parse_log.py
import re, sys, os
from datetime import datetime
from collections import defaultdict
class Request():
def __init__(self, id, start):
self.id = id
self.start = start