Skip to content

Instantly share code, notes, and snippets.

View thoth-ky's full-sized avatar
👨‍💻
Code.Eat.Watch

Mutuku Kyalo thoth-ky

👨‍💻
Code.Eat.Watch
View GitHub Profile
@jbesw
jbesw / gist:f9401b4c52a7446ef1bb71ceea8cc3e8
Created August 4, 2020 11:39
AWS CloudFormation template to create public/private subnets in a VPC with a NAT Gateway.
# This creates a VPC with two public subnets and two private subnets in two Availability Zones,
# together with a NAT Gateway and associated routing. Change the Availability Zone locations as needed.
# Important: this configures various AWS services and there are costs associated with these services after the Free Tier usage.
# Please see the AWS Pricing pages for details. You are responsible for any AWS costs incurred.
# No warranty is implied in this example.
# Usage from command line:
# aws cloudformation --region <<YOUR-REGION>> create-stack --stack-name vpc- --template-body file://vpc-setup.yaml
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
class RedisSessionStore(SessionStore):
def __init__(self, expire = 1800, key_prefix=''):
SessionStore.__init__(self)
self.redis = redis.Redis(tools.config.get('redis_host', 'localhost'),
int(tools.config.get('redis_port', 6379)),
int(tools.config.get('redis_dbindex', 1)),
password=tools.config.get('redis_pass', None))
self.path = session_path()
self.expire = expire
self.key_prefix = key_prefix
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active March 27, 2024 19:48
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'