Skip to content

Instantly share code, notes, and snippets.

View Sonique's full-sized avatar

Vitaly Larchenkov Sonique

View GitHub Profile
@Sonique
Sonique / shri.js
Last active August 29, 2015 14:26 — forked from verkholantsev/shri.js
/**
* Реализация API, не изменяйте ее
* @param {string} url
* @param {function} callback
*/
function getData(url, callback) {
var RESPONSES = {
'/countries': [
{name: 'Cameroon', continent: 'Africa'},
{name :'Fiji Islands', continent: 'Oceania'},
@Sonique
Sonique / executor-shutdown.java
Created April 24, 2017 10:02
Java Executor proper shutdown
try {
System.out.println("attempt to shutdown executor");
executor.shutdown();
executor.awaitTermination(5, TimeUnit.SECONDS);
}
catch (InterruptedException e) {
System.err.println("tasks interrupted");
}
finally {
if (!executor.isTerminated()) {
@Sonique
Sonique / hosts.ini
Created July 23, 2018 12:25
Ansible: use any python version for ansible_python_interpreter
[nodes:vars]
ansible_python_interpreter = ls /usr/bin/ | grep -E "^python([2-3](.[0-9])?)?$" | head -n 1
@Sonique
Sonique / utils.py
Created August 10, 2018 10:49 — forked from jossef/utils.py
python different ways to import external modules (from cdn / memory string / file path / plugin directory)
import imp
import importlib
import inspect
import glob
import requests
import os
def import_from_string(content, module_name, file_name=None):
if not file_name:
file_name = '{0}.py'.format(module_name)