Skip to content

Instantly share code, notes, and snippets.

View dizballanze's full-sized avatar

Yurii Shykanov dizballanze

  • Bolt
  • Berlin
View GitHub Profile
"""
>>> a = [1, 2, 5, 12, 44, 83, 301, 404, 589, 700]
>>> binsearch([], 301)
False
>>> binsearch([301], 301)
True
>>> binsearch(a, 301)
True
>>> binsearch(a, 31337)
False
"""
>>> sort([4,2,4,3,6,1])
[1, 2, 4, 4, 6]
"""
def sort(a):
return a
@dizballanze
dizballanze / average.c
Created February 23, 2015 22:35
variable arguments count in C
#include <stdio.h>
#include <stdarg.h>
double average_known_count(int, double, double, ...);
double average_zero_ended(double, double, ...);
int main(void) {
double num1 = 16.6;
CREATE TYPE address AS (country text, city text, zip varchar(6), street text, number text, building text);
CREATE TABLE users (id SERIAL PRIMARY KEY, email text, adresses address[]);
INSERT INTO users(email, adresses) VALUES('user1@example.org', ARRAY[ROW('RU', 'Moscow', '123123', 'Lenina', '5', 'a')::address, ROW('RU', 'SPB', '123456', 'Gagarina', '102', '5')::address]);
SELECT * FROM users;
import subprocess
import argparse
import os
from glob import glob
def _build_wheel(source_dir, destination_dir):
try:
subprocess.check_call(['python', 'setup.py', 'bdist_wheel', '--dist-dir', destination_dir], cwd=source_dir)
except subprocess.CalledProcessError:
@dizballanze
dizballanze / ping.py
Created January 16, 2015 14:15
Check if internet is working
import subprocess
internet = False
while not internet:
try:
subprocess.check_call(["ping", "-c 1", "www.google.ru"])
print("Internet is up again!")
internet = True
except subprocess.CalledProcessError:
print("Internet is still down :(")
@dizballanze
dizballanze / gist:9831063
Last active August 29, 2015 13:57
Debugmail file stracture

Корень файловой системы:

API.md - описание REST Api
app/ - backend приложение
bin/ - скрипты для запуска сервисов
bower_components/ - сюда ставятся фронтенд компоненты из bower
bower.json - зависимости по фронтенду
coffeelint.json - настройки линтера
fapp/ - фронтенд приложение