Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrey Tatarinov elephantum

View GitHub Profile
@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 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 gist:0de68436eae6cbe7ca18
<p
data-style-tablet_portrait="font-size: 37px; line-height: 46px; padding-right: 0px;"
data-style-phone_portrait="font-size: 28px; line-height: 35px; padding-right: 0px;"
data-class-tablet_portrait="empty"
data-class-phone_portrait="empty"
data-size-leading-linked-tablet_portrait="true"
data-size-leading-linked-phone_portrait="true"
data-size-leading-ratio-tablet_portrait="1.25"
data-size-leading-ratio-phone_portrait="1.25"
style="font-size: 31px; line-height: 39px; padding-right: 0px;"
View gist:e606715054078a008400
ideas <- function(x) {
Sys.sleep(1)
re_coordinates = 'shadow%3Afalse%7C(\\d+\\.\\d+)%2C(\\d+\\.\\d+)'
url <- paste('http://moscowidea.ru/ideas/', x, sep="")
read_data <- function(){
thepage = readLines(url)
coord_page <- thepage[grep(re_coordinates, thepage)]
mypattern_in = 'part_idea__summary__suggestion'
mypattern_out = 'part_idea__summary__purpose'
sugg_start = grep(mypattern_in, thepage) + 2
View gist:8953132
log_format jsonlog '{'
'"time_local": "$time_local", '
'"request": "$request", '
'"msec": "$msec", '
'"status": "$status", '
'"body_bytes_sent": "$body_bytes_sent", '
'"request_time": "$request_time", '
'"remote_addr": "$remote_addr", '
'"remote_user": "$remote_user", '
View gist:8932295
# -*- coding: utf-8 -*-
# apt-get install python-pandas python-boto
AWS_ACCESS_KEY_ID =
AWS_SECRET_ACCESS_KEY =
import datetime
import gzip
import json
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 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 - необязательные

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