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 / test_fizzbuzz.py
Last active December 16, 2018 01:48
FizzBuzz test using Pytest
class FizzBuzz:
def say(self, number):
  if number % 3 == 0 and number % 5 == 0:
  return 'FizzBuzz'
  elif number % 3 == 0:
  return 'Fizz'
  elif number % 5 == 0:
  return 'Buzz'
  else:
  return number
@zkan
zkan / test_fizzbuzz.py
Created December 16, 2018 01:30
FizzBuzz test using unittest
import unittest
class FizzBuzz:
def say(self, number):
if number % 3 == 0 and number % 5 == 0:
return 'FizzBuzz'
elif number % 3 == 0:
return 'Fizz'
elif number % 5 == 0:
# ---- 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
object HelloWorld {
def main(args: Array[String]): Unit = {
println("From Zero to Hello World!")
}
}
@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__.
"""
import cv2
image = cv2.imread('simplesat.png')
print(type(image)) # <class 'numpy.ndarray'>
print(image.shape) # (224, 224, 3)
b, g, r = image[46, 46]
print(b, g, r) # 152 222 148
@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 / second_gist
Created June 17, 2018 05:12
Add a gist using tavern
Woohoo I added a gist using tavern!
@zkan
zkan / tavern_workshop_at_pycon_thailand_2018
Last active June 17, 2018 04:58
tavern_workshop_at_pycon_thailand_2018
Hello
import time
from celery import Celery
app = Celery('tasks', broker='redis://localhost:6379')
@app.task
def hello(name):