Skip to content

Instantly share code, notes, and snippets.

View zkan's full-sized avatar
🐻
Stay Hungry. Stay Foolish.

Kan Ouivirach zkan

🐻
Stay Hungry. Stay Foolish.
View GitHub Profile
@zkan
zkan / SNSTopic.py
Created February 16, 2017 23:51 — forked from stuartmyles/SNSTopic.py
A complete example of how to use Amazon Web Services Simple Notification Services from Python. This code uses the boto library https://github.com/boto/boto to create a topic, wait for a confirmation and then send a success message. Simply plug in your AWS access and secret keys, plus your email and mobile phone number.
# An example of how to use AWS SNS with Python's boto
# By Stuart Myles @smyles
# http://aws.amazon.com/sns/
# https://github.com/boto/boto
#
# Inspired by parts of the Ruby SWF SNS tutorial http://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-sns-tutorial-implementing-activities-poller.html
# And the Python SNS code in http://blog.coredumped.org/2010/04/amazon-announces-simple-notification.html and http://awsadvent.tumblr.com/post/37531769345/simple-notification-service-sns
import boto.sns as sns
import json
@zkan
zkan / download_anonymous_icons_from_drive.rb
Created August 1, 2017 00:11 — forked from rockwotj/download_anonymous_icons_from_drive.rb
Downloads all of the icons of anonymous animals from Google Drive
#!/usr/bin/env ruby
icon_list = "alligator, anteater, armadillo, auroch, axolotl, badger, bat, beaver, buffalo, camel, chameleon, cheetah, chipmunk, chinchilla, chupacabra, cormorant, coyote, crow, dingo, dinosaur, dolphin, duck, elephant, ferret, fox, frog, giraffe, gopher, grizzly, hedgehog, hippo, hyena, jackal, ibex, ifrit, iguana, koala, kraken, lemur, leopard, liger, llama, manatee, mink, monkey, narwhal, nyan cat, orangutan, otter, panda, penguin, platypus, python, pumpkin, quagga, rabbit, raccoon, rhino, sheep, shrew, skunk, slow loris, squirrel, turtle, walrus, wolf, wolverine, wombat"
for icon in icon_list.split ', ' do
element = icon.sub ' ', ''
`curl https://ssl.gstatic.com/docs/common/profile/#{element}_lg.png -o icons/#{element}.png`
end

Effective Engineer - Notes

What's an Effective Engineer?

  • They are the people who get things done. Effective Engineers produce results.

Adopt the Right Mindsets

@zkan
zkan / __init__.py
Created July 4, 2018 00:45 — forked from timsavage/__init__.py
Customising Django Auth username length for Django 1.8+
default_app_config = 'myapp.auth.apps.MyAuthAppConfig'
@zkan
zkan / life.py
Created August 4, 2018 00:22 — forked from jasonkeene/life.py
Python implementation of Conway's Game of Life
"""Python implementation of Conway's Game of Life
Somewhat inspired by Jack Diederich's talk `Stop Writing Classes`
http://pyvideo.org/video/880/stop-writing-classes
Ironically, as I extended the functionality of this module it seems obvious
that the next step would be to refactor board into a class with advance and
constrain as methods and print_board as __str__.
"""
# ---- Base python ----
FROM python:3.6 AS base
# Create app directory
WORKDIR /app
# ---- Dependencies ----
FROM base AS dependencies
COPY gunicorn_app/requirements.txt ./
# install app dependencies
RUN pip install -r requirements.txt
@zkan
zkan / jinja2_file_less.py
Created January 27, 2019 13:16 — forked from wrunk/jinja2_file_less.py
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#

Kafka 0.11.0.0 (Confluent 3.3.0) added support to manipulate offsets for a consumer group via cli kafka-consumer-groups command.

  1. List the topics to which the group is subscribed
kafka-consumer-groups --bootstrap-server <kafkahost:port> --group <group_id> --describe

Note the values under "CURRENT-OFFSET" and "LOG-END-OFFSET". "CURRENT-OFFSET" is the offset where this consumer group is currently at in each of the partitions.

  1. Reset the consumer offset for a topic (preview)
@zkan
zkan / heart.py
Last active February 14, 2021 15:38 — forked from gatukgl/heart.py
Drawing heart with turtle in Python
import turtle
turtle.pensize(3)
def draw_heart_curve():
for i in range(200):
turtle.right(1)
turtle.forward(1)
turtle.color("pink", "pink")
@zkan
zkan / datasourcetocsv_operator.py
Created February 21, 2021 09:03 — forked from ganapathichidambaram/datasourcetocsv_operator.py
Airflow - Postgresql DataSource to CSV export
from airflow.hooks.postgres_hook import PostgresHook
from airflow.models import BaseOperator
from airflow.utils.decorators import apply_defaults
from datetime import datetime, timedelta
from os import environ
import csv
class DataSourceToCsvOperator(BaseOperator):
"""