Skip to content

Instantly share code, notes, and snippets.

View mingrammer's full-sized avatar
🧗
learn, code, and grow

MinJae Kwon (Miti) mingrammer

🧗
learn, code, and grow
View GitHub Profile
@mingrammer
mingrammer / keybase.md
Created October 10, 2018 09:14
Keybase proof

Keybase proof

I hereby claim:

  • I am mingrammer on github.
  • I am mingrammer (https://keybase.io/mingrammer) on keybase.
  • I have a public key ASCozwJWH7JP75YzsTAPDo-5h-mAz5CqxIhs-TVmQU--xgo

To claim this, I am signing this object:

@mingrammer
mingrammer / turn.py
Last active August 18, 2018 23:41
pycon-2018-banksalad-holdem
from typing import List
from .core.cards import Card
from .core.madehands import evaluate
from .player import Other
def bet(
my_chips: int,
my_cards: List[Card],
@mingrammer
mingrammer / download-csv-from-browser.js
Last active June 14, 2023 04:16
Download CSV files directly from your browser
function createCSV(data) {
var lineDelimiter = '\n';
var csv = {
'title': '',
'head': '',
'body': ''
};
csv.title = 'csv-title.csv';
csv.head = '...'; // make your own csv head
@mingrammer
mingrammer / seoul-metro-max-min-in-out-elasticsearch.py
Last active January 23, 2018 02:55
Get the maximum and minimum numbers of people in/out for seoul metro using elasticsearch
import math
from pprint import pprint
import elasticsearch as es
import numpy as np
# Constants
INDEX_NAME = 'seoul-metro-2014'
THRESHOLD = 10
CHUNK_SIZE = 5000
@mingrammer
mingrammer / two-ways-of-if-statement.py
Created May 25, 2017 09:24
Two styles of writing 'if' statement
### without elif, else
if cond == 'one':
# something
return # or break
if cond == 'two':
# something
return # or break
# something
return # or break
numbers = [1, 2, 3, 4, 5, 6]
# The left side of unpacking should be list or tuple.
*a, = numbers
# a = [1, 2, 3, 4, 5, 6]
*a, b = numbers
# a = [1, 2, 3, 4, 5]
# b = 6
headers = {
'Accept': 'text/plain',
'Content-Length': 348,
'Host': 'http://mingrammer.com'
}
def pre_process(**headers):
content_length = headers['Content-Length']
print('content length: ', content_length)
from functools import reduce
primes = [2, 3, 5, 7, 11, 13]
def product(*numbers):
p = reduce(lambda x, y: x * y, numbers)
return p
product(*primes)
# 30030
def save_ranking(**kwargs, *args):
...
def save_ranking(*args, **kwargs):
print(args)
print(kwargs)
save_ranking('ming', 'alice', 'tom', fourth='wilson', fifth='roy')
# ('ming', 'alice', 'tom')
# {'fourth': 'wilson', 'fifth': 'roy'}