I hereby claim:
- I am nguyendv on github.
- I am dvnguyen (https://keybase.io/dvnguyen) on keybase.
- I have a public key ASBse3cu58LtPrbtHJgEZgDbg3ZAZmVE0oIRLDHo8NPwVgo
To claim this, I am signing this object:
// Generators are denoted using `function*` syntax | |
const myGenerator = function* () { | |
console.log("a"); | |
} | |
const iterator = myGenerator(); | |
iterator.next(); // execute the generator's body, which displays "a" | |
// a generator that generates numbers | |
const numberGenerator = function* () { |
I hereby claim:
To claim this, I am signing this object:
import time, asyncio | |
def stuff(arg1, arg2): | |
# Doing IO | |
pass | |
async def async_stuff(): | |
loop = asyncio.get_event_loop() # get the default event loop | |
loop.run_in_executor(None, stuff, param1, param2) | |
import logging | |
from logging.handlers import RotatingFileHandler | |
def setup_logger(): | |
MAX_BYTES = 10000000 # Maximum size for a log file | |
BACKUP_COUNT = 9 # Maximum number of old log files | |
# The name should be unique, so you can get in in other places | |
# by calling `logger = logging.getLogger('com.dvnguyen.logger.example') | |
logger = logging.getLogger('com.dvnguyen.logger.example') |
@pytest.fixture | |
def db_conn(): | |
psycopg2.connect("dbname=test user=postgres") | |
yield conn | |
# start cleaning up | |
conn.close() | |
def test_foo(db_conn): | |
result = db_conn.execute(a_sql_statement) | |
assert result == expected_value |
@pytest.fixture | |
def db_conn(): | |
conn = psycopg2.connect("dbname=test user=postgres") | |
return conn | |
def test_foo(db_conn): | |
result = db_conn.execute(a_sql_statement) | |
assert result == expected_value |
class Car { | |
private var color: Color | |
init { ... } | |
} |
# Terminate instance | |
instance = ec2.Instance(instances_id) | |
instance.terminate() | |
# delete sec group | |
sec_group2 = ec2.SecurityGroup(sec_group_id) | |
sec_group2.delete() | |
# delete subnet | |
subnet2 = ec2.Subnet(subnet_id) |
import boto3 | |
# http://boto3.readthedocs.io/en/latest/reference/services/ec2.html#service-resource | |
ec2 = boto3.resource('ec2', aws_access_key_id='AWS_ACCESS_KEY_ID', | |
aws_secret_access_key='AWS_SECRET_ACCESS_KEY', | |
region_name='us-west-2') | |
# create VPC | |
vpc = ec2.create_vpc(CidrBlock='192.168.0.0/16') |