Skip to content

Instantly share code, notes, and snippets.

View azm-gh's full-sized avatar

Jakub azm-gh

  • Prague
  • 16:32 (UTC -12:00)
View GitHub Profile
export default function Counter() {
const [count, setCount] = useState(0);
function handleClick() {
setCount(count +1);
}
return (
<button onClick = {handleClick}>
You pressed me {count} times
@azm-gh
azm-gh / working-with-files-in-python.py
Created January 27, 2019 22:03
working-with-files-in-python
import os
from pathlib import Path
with open('data.txt', 'w') as f:
data = 'some data to be written in a file'
f.write(data)
with open('data.txt', 'r') as f:
data = f.read()
@azm-gh
azm-gh / methodTypes.py
Created January 25, 2019 11:43
Python's Instance, Class, and Static Methods Demystified
import math
class MyClass:
def method(self):
return 'instance method called', self
@classmethod
def classmethod(cls):
return 'class method called',cls
import time
def speed_test(func):
def wrapper(*args, **kwargs):
t1 = time.time()
for x in xrange(5000):
results = func(*args, **kwargs)
t2 = time.time()
print '%s took %0.3f ms' % (func.func_name, (t2-t1)*1000.0)
return results