Skip to content

Instantly share code, notes, and snippets.

View KhodeN's full-sized avatar

Artem Berezin KhodeN

View GitHub Profile
@KhodeN
KhodeN / todo_import.py
Last active December 29, 2015 21:49
Import tasks from todolist *.tdl files to YouTrack. Support features and task.
import xml.etree.ElementTree as ET
from youtrack.connection import Connection
class Task(object):
def __init__(self, title, description):
self.title = title.encode('utf-8')
self.description = description.encode('utf-8')
self.feature = False
self.sub_tasks = []
@KhodeN
KhodeN / nginx_codes_stat.py
Last active September 19, 2024 11:54
HTTP-status code statistic from nginx access log
#! /usr/bin/env python
import argparse
import sys
import re
import time
line_nginx_full = re.compile(r"""(?P<ipaddress>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) - - \[(?P<dateandtime>\d{2}\/[a-z]{3}\/\d{4}:\d{2}:\d{2}:\d{2} (\+|\-)\d{4})\] ((\"(GET|POST) )(?P<url>.+)(http\/1\.1")) (?P<statuscode>\d{3}) (?P<bytessent>\d+) (["](?P<refferer>(\-)|(.+))["]) (["](?P<useragent>.+)["])""",
re.IGNORECASE)
line_nginx_onlyStatus = re.compile(r'.+HTTP\/1\.1" (?P<statuscode>\d{3})')
@KhodeN
KhodeN / load_pageant.py
Created June 1, 2014 02:47
Start PAGEANT.EXE (ssh-agent for windows) with all *.ppk, collected recursively
import os
import sys
def get_files(only_ext):
for root, sub_folders, files in os.walk("."):
for file in files:
name, ext = os.path.splitext(file)
if ext == only_ext:
yield os.path.join(root, file)[2:]
@KhodeN
KhodeN / closeDubTabs.js
Created November 13, 2014 00:24
closeDubTabs
var getWindows = new Promise(function(resolve) {
chrome.windows.getAll(function(windows) {
resolve(windows);
});
});
var getTabs = function(window) {
var p = new Promise(function(resolve) {
chrome.tabs.getAllInWindow(window.id, function(tabs) {
@KhodeN
KhodeN / getBoundsWithBreaks.js
Created November 21, 2014 03:45
getBoundsWithBreaks
function getBoundsWithBreaks (text, subString) {
var breaks = [];
_.forEach(text, function (char, index) {
if (char === '\n') {
breaks.push(index);
}
});
var startIndex = text.replace(/\n/g, '').indexOf(subString);
if (startIndex === -1) {
// шлет запрос в сокет
_sendToMediator: function (query) {
var self = this;
return self._getMediator()
.then(function () {
if ( !self.mediator.connected ) {
// пытаемся еще раз подключиться к медиатору
self._getMediator(true);
return self.$q.reject(null);
}
var all_points = [];
var paths = route.getPaths();
var i = 0;
while (paths.get(i) !== null) {
var p = paths.get(i);
var segments = p.getSegments();
$(segments).each(function() {
var pc = this.getCoordinates();
$(pc).each(function() {
all_points.push(this);
@KhodeN
KhodeN / dockfox
Created November 7, 2015 12:03
run firefox in docker
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y firefox
# Replace 1000 with your user / group id
RUN export uid=1000 gid=1000 && \
mkdir -p /home/developer && \
echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
echo "developer:x:${uid}:" >> /etc/group && \
echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
{
"rules": {
"member-access": true,
"member-ordering": [
true,
"public-before-private",
"static-before-instance",
"variables-before-functions"
],
"no-any": false,
@KhodeN
KhodeN / dump.sh
Created January 28, 2016 09:37
dump psql by cron
#!/bin/bash
now=$(date +"%Y-%m-%d_%H:%M")
cd /projects/datamarket
pg_dump -U postgres dm | gzip > backups/dm_dump_$now.sql.gz
# use this row to backup every hour
# crontab -e
# * */1 * * * /projects/datamarket/dump.sh