Skip to content

Instantly share code, notes, and snippets.

View vanclist's full-sized avatar

Viacheslav Artemchuk vanclist

View GitHub Profile
@vanclist
vanclist / list_js_i18n.py
Last active April 5, 2018 07:38
List all i18n-ed strings in *.js files
from pprint import pprint
import subprocess
from bs4 import BeautifulSoup
def parse(document):
soup = BeautifulSoup(document, 'lxml')
return [text for text in soup.stripped_strings if text.startswith("<%= i18n")]
@vanclist
vanclist / icecast-multi-restream.liq
Last active June 10, 2017 15:20
Restream one icecast-compatible stream to multiple streams (can be used for testing purposes)
#!/usr/bin/env liquidsoap
set("harbor.bind_addr", "0.0.0.0")
live = input.harbor("/", port=8008, icy=true, buffer=0.0, user="source", password="root")
files = mksafe(playlist(mode="normal", "jingle.txt"))
radio = fallback(track_sensitive=false, [live,files])
ports = [
@vanclist
vanclist / GatlingLoadTest.scala
Created March 31, 2017 16:54
Gatling tests setup for common tasks
package com.example.loadtest
import io.gatling.core.Predef._
import io.gatling.core.controller.inject.InjectionStep
import io.gatling.http.Predef._
import scala.concurrent.duration._
sealed trait CommonVars {
val nominalResponseTime = Integer.getInteger("nominalResponseTime", 1200).toInt
val partDuration = Integer.getInteger("partDuration", 60).toInt seconds
class Mappable:
def __init__(self, items): self.items = items
def map(self, func):
return self.__class__(map(func, self.items))
class Filterable:
def __init__(self, items): self.items = items
def filter(self, func):
return self.__class__(filter(func, self.items))
@vanclist
vanclist / wrk-html-report.sh
Last active March 31, 2017 16:23
wrk result to HTML on Teamcity
#!/usr/bin/env bash
PROJECTS=(%projects%)
USER_NAME=root
SERVER_PATH=/opt/some-server/
CONNECTIONS=(1 4 16 64 256 1024)
BOOTSTRAP='<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">'
JS_LIBS='<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>'
# clean up working directory
@vanclist
vanclist / gatling-cluster-teamcity.sh
Last active July 24, 2017 03:24
Gatling cluster with Teamcity
#!/usr/bin/env bash
#Assuming same user name for all hosts
USER_NAME='gatling'
#Remote hosts list
HOSTS=(node1-load.some.host node2-load.some.host node3-load.some.host node4-load.some.host)
#Assuming all Gatling installation in same path (with write permissions)
GATLING_HOME=/opt/loadtest/
#No need to change this
REMOTE_REPORT_DIR=/opt/loadtest/target/gatling/
#!/bin/bash
AGENT="AudioAddict-di/1.4.7 iOS/8.1"
COOKIES="./cookies.txt"
AUTH="ephemeron:dayeiph0ne@pp"
DOMAIN=gmail.com
PLAYLISTDI="di.fm.m3u"
PLAYLISTSKY="sky.fm.m3u"
PLAYLISTJAZZ="jazzradio.m3u"
PLAYLISTROCK="rockradio.m3u"
JSONDI="http://listen.di.fm/premium_high.json"
@vanclist
vanclist / polish_to_unicode.py
Last active March 29, 2017 11:10
Polish chars to unicode
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unicodedata
text = u"Dzień dobry! Wczoraj wysłałem ogłoszenia kolega to mieszkanie. I przypomniałem sobie, " +
"że nie przedłużył umowy najmu. Dlatego pytam Pan przygotować nową umowę najmu. " +
"Również poprosić o wypłatę przyjechać do dnia 9 lutego, bo Ja idę w podróży służbowej."
print unicodedata.normalize('NFD', text).encode('ascii', 'replace')
POLISH_CHARACTERS = {