Skip to content

Instantly share code, notes, and snippets.

@nvgoldin
nvgoldin / asyncio_shutdown_loop.py
Created July 27, 2016 13:34
Python 3.5 asyncio - shutdown all tasks safely using signal handler
import signal
import functools
async def looping_task(loop, task_num):
try:
while True:
print('{0}:in looping_task'.format(task_num))
await asyncio.sleep(5.0, loop=loop)
except asyncio.CancelledError:
return "{0}: I was cancelled!".format(task_num)
@remojansen
remojansen / class_decorator.ts
Last active September 14, 2023 14:54
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
@akagisho
akagisho / gitlab_installer.sh
Last active February 9, 2017 05:44
GitLab installer for CentOS 6.4 (64bit)
#!/usr/bin/env bash
# GitLab installer for CentOS 6.4 (64bit)
if [ $(whoami) != "root" ]; then
echo "You must be root to do!" 1>&2
exit 1
fi
[[ "$MYSQL_PASSWORD" == "" ]] && MYSQL_PASSWORD="Myp@ssword"