Skip to content

Instantly share code, notes, and snippets.

View apolev's full-sized avatar

Alexey Polev apolev

View GitHub Profile
@apolev
apolev / cast_test.go
Created May 26, 2019 10:52
test_casting_optimization
package main
import (
"bytes"
"testing"
)
type A struct {
b interface{}
}
def print_ledder (step, max_number ):
if step > max_number:
return
bound = step + 1
print (' '.join(str(x) for x in list(range(1, bound))))
print_ledder(bound, max_number)
n = int(input())
print_ledder(1, n)
@apolev
apolev / assignment.py
Created September 25, 2017 09:36
Assignment
import math
def square():
n = int(input())
if n!= 0:
square()
if round(math.sqrt(n)) == math.sqrt(n):
print(n)
def read_float():
return float(input())
a = read_float()
b = read_float()
c = read_float()
d = read_float()
e = read_float()
f = read_float()
@apolev
apolev / sister.py
Created August 31, 2017 19:56
Sister
while True:
try:
count = int(input('Please enter count: '))
if count > 10:
print('What\'s wrong with you? This is too much!')
continue
if count < 1:
print('I can\'t count something less than one time.')
continue
except ValueError:
@apolev
apolev / foobar.java
Last active August 29, 2015 14:25
Alexei Zhiryakov как вариант решения проблемы
public class Handler {
// all stuff for establishing and reloading connection go here
private ConnectionManager manager;
private void handle() throws UnreachableServerException {
connection = manager.getConnection("someId");
// Here we are using 100% good connection
}
}
@apolev
apolev / gist:f345ada8066a95a3319a
Last active August 29, 2015 14:19
Example for #190 pdepend issue
<?php
namespace Just\A\Test;
trait A {
public function speakA() {
return true;
}
}

Code style

Общие правила

Присвоение сравнений: скобки не ставим, если там один оператор, иначе ставим.

$hasOrders  = count($orders) > 0;
$isSuperman = (count($orders) > 0 && $user->canFly());
@apolev
apolev / class.php
Created December 23, 2013 06:39
Test class
<?php
class StaticClass {
public static function modifySubscriber ($number){
echo 'Hello-world';
if ($number < 400000
|| ($number >= 404000 && $number < 404999)
|| $number >= 406000) {
throw new Exception('invalid phone number');