This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tuple # typing.Tuple | |
list # typing.List | |
dict # typing.Dict | |
set # typing.Set | |
frozenset # typing.FrozenSet | |
type # typing.Type | |
collections.deque | |
collections.defaultdict | |
collections.OrderedDict | |
collections.Counter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function arrGet($arr, $key, $default = null) | |
{ | |
return isset($arr[$key]) ? $arr[$key] : $default; | |
} | |
function arrAny() | |
{ | |
foreach (func_get_args() as $arg) { | |
if ($arg) return $arg; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function realIntVal($s, $onEmptyStr=null, $onNonNumeric=null) { | |
if ($s === '') return $onEmptyStr; | |
return is_numeric($s) ? intval($s) : $onNonNumeric; | |
} | |
function testRealIntVal() { | |
$arr = ['', '0', '1', 'a', 'a123', '123a', null]; | |
$res = []; | |
foreach ($arr as $v) { | |
$res[$v] = realIntVal($v); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
ini_set('display_errors', 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame as pg | |
FPS = 30 | |
WW = 800 | |
WH = 600 | |
BLUE = (0, 0, 255) | |
BLACK = (0, 0, 0) | |
WHITE = (255, 255, 255) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pygame | |
#pycairo | |
p5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def s_ring(r1, r2): | |
pi = 3.1415 | |
s1 = pi * (r1 ** 2) | |
s2 = pi * (r2 ** 2) | |
s = s2 - s1 | |
return s | |
def hyp(a, b): | |
return (a ** 2 + b ** 2) ** 0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hr(): | |
print('--------------------------------') | |
def equ2(a, b, c): | |
d = b * b - 4 * a * c | |
print('D =', d) | |
aa = a * 2 | |
d_sqrt = d ** 0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import datetime | |
import json | |
####################################################################################################################### | |
def replace_suffix(s, suffix, replace): | |
""" | |
replace suffix if exists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
def fn_none(): | |
""" | |
>>> fn_none() is None | |
True | |
""" | |
return None |
OlderNewer