๐
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import unittest | |
import unittest.mock | |
class MyClass: | |
@asyncio.coroutine | |
def coro1(self): | |
g = yield from self.coro2() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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']) == |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
OlderNewer