Skip to content

Instantly share code, notes, and snippets.

View netman92's full-sized avatar

Stanislav Komanec netman92

View GitHub Profile

Keybase proof

I hereby claim:

  • I am netman92 on github.
  • I am netman92 (https://keybase.io/netman92) on keybase.
  • I have a public key whose fingerprint is BAF5 3BAD F692 83F8 EEE0 D538 8E90 5ACC 7160 5676

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am netman92 on github.
  • I am netman92 (https://keybase.io/netman92) on keybase.
  • I have a public key whose fingerprint is BAF5 3BAD F692 83F8 EEE0 D538 8E90 5ACC 7160 5676

To claim this, I am signing this object:

@netman92
netman92 / singleton.py
Last active August 29, 2015 14:26 — forked from 1st/singleton.py
Singleton implantation on Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class Singleton(type):
def __call__(self, *args, **kwargs):
if 'instance' not in self.__dict__:
self.instance = super(Singleton, self).__call__(*args, **kwargs)
return self.instance
@netman92
netman92 / 1
Created April 11, 2015 13:06
codility
#!/usr/bin/python
def solution(X, A):
n = len(A)
right = sum(1 for item in A if item != X)
left = 0
for k, element in enumerate(A, start=1):
if element == X:
left += 1
#!/usr/bin/python
def line_intersection(line1, line2):
xdiff = (line1[0][0] - line1[1][0], line2[0][0] - line2[1][0])
ydiff = (line1[0][1] - line1[1][1], line2[0][1] - line2[1][1])
def det(a, b):
return a[0] * b[1] - a[1] * b[0]
div = det(xdiff, ydiff)
@netman92
netman92 / pq_config.py
Created September 11, 2014 15:59
Compute Postgres config
# -*- coding: utf-8 -*-
ram = raw_input("Ram? [GB] ") or 8
connections = raw_input("Number of expected sim. connections? ") or 1000
ram = float(ram)
connections = int(connections)
shared_buffers = "%0.0fMB" % ((ram*1024)/4)
@netman92
netman92 / maintance.php
Last active December 20, 2015 15:39
Maintance page
<?php
header('HTTP/1.1 503 Service Unavailable');
header('Retry-After: 300'); // 5 minutes in seconds
$site = $_SERVER["HTTP_HOST"];
$language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,5);
switch ($language) {
case "sk-SK":