Skip to content

Instantly share code, notes, and snippets.

View yv84's full-sized avatar
๐Ÿ’
Focusing

Vladimir Yudintsev yv84

๐Ÿ’
Focusing
View GitHub Profile
@yv84
yv84 / test_asyncio_mosk.py
Last active August 29, 2015 14:01 — forked from trecouvr/Mockin' asyncio coroutine
Mockin' asyncio coroutine
import asyncio
import unittest
import unittest.mock
class MyClass:
@asyncio.coroutine
def coro1(self):
g = yield from self.coro2()
@yv84
yv84 / gist:0cdbe77b29743b8ac8f1
Last active August 29, 2015 14:01
mastering_regular_expressions_third_edition
def f(text, pattern):
match = None
for match in re.finditer(pattern, text):
s = match.start()
e = match.end()
print('Found "%s" at %d:%d' % (text[s:e], s, e))
if match: print(match.groups())
r = lambda text, pattern, repl : re.compile(pattern).sub(repl, text)
@yv84
yv84 / loan.py
Last active June 8, 2017 03:33
loan
def differ(loan, rate, t, accuracy=2):
list_pay_per_month = []
body_of_loan = loan
month_count = t * 12
body_per_month = loan / month_count
sum = 0
for _ in range(month_count):
interest = body_of_loan * rate / 12
pay_per_month = interest + body_per_month
# https://company.yandex.ru/job/vacancies/dev_pyth_transport.xml
from itertools import chain
def f(l1, l2):
def gen():
while True:
yield None
return dict(zip(l1, chain(l2, gen())))
assert(f([1,2,3,4,5,6],['a','b','c']) ==
@yv84
yv84 / app.py
Last active August 29, 2015 14:05 — forked from tistaharahap/app.py
assets = Environment(app)
assets.url = '/static'
assets.directory = app.config['ASSETS_DEST']
coffee = Bundle(
'coffee/models.coffee',
'coffee/app.coffee',
filters='coffeescript',
output='js/app.js'
)
@yv84
yv84 / cleanDirectory.java
Last active June 8, 2018 14:58
remove directories older than
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Arrays;
import java.util.Calendar;
@yv84
yv84 / replacer.py
Last active February 19, 2018 10:02 — forked from meddulla/replacer.py
Script to recursively replace string in filename and contents
"""
Usage: python script.py search_string replace_string dir
Eg. python batchreplace.py galleries productions /Sites/cjc/application/modules/productions/
And it will search recursively in dir
and replace search_string in contents
and in filenames.
Case-sensitive
"""
from sys import argv
#[root@localhost share]# cat ~/.bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
var RunAsUtil = {
execute: function(workFunction, runAsUser) {
Packages.org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(new Packages.org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork()
{
doWork: workFunction
}, runAsUser);
},
doInTransaction: function(workFunction) {
var txs = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext().getBean("TransactionService");
var th = txs.getRetryingTransactionHelper();
@yv84
yv84 / YUI-dojo events.js
Created July 29, 2016 13:07
YUI-dojo events.js
require(["dojo/_base/connect"], function(connect){
connect.subscribe("handleFieldChange", function(event, message){
console.log("dojo_subscribe->" + event.x);
debugger;
});
});
YAHOO.Bubbling.on("handleFieldChange", function(e, param) {
console.log("YAHOO_on->" + e + param[1].x);
debugger;