Skip to content

Instantly share code, notes, and snippets.

View chanshik's full-sized avatar

Chanshik Lim chanshik

View GitHub Profile
@chanshik
chanshik / serialize-numpy-array.py
Created December 21, 2017 06:48 — forked from alexland/serialize-numpy-array.py
serialize, persist, retrieve, and de-serialize a NumPy array as a binary string (any dimension, any dtype); exemplary use case: a web app calculates some result--eg, from a Machine Learning algorithm, using NumPy and the result is a NumPy array; it is efficient to just return that result to rather than persist the array then retrieve it via query
import time
import numpy as NP
from redis import StrictRedis as redis
# a 2D array to serialize
A = 10 * NP.random.randn(10000).reshape(1000, 10)
# flatten the 2D NumPy array and save it as a binary string
array_dtype = str(A.dtype)
@chanshik
chanshik / loop.ex
Created April 2, 2017 18:56 — forked from nanne007/loop.ex
loop, while,break construct in elixir
defmodule Loop do
defmacro while(predicate, do: block) do
quote do
try do
for _ <- Stream.cycle([:ok]) do
if unquote(predicate) do
unquote(block)
else
throw :break
end
#!/usr/bin/env python
#
# Converts any integer into a base [BASE] number. I have chosen 62
# as it is meant to represent the integers using all the alphanumeric
# characters, [no special characters] = {0..9}, {A..Z}, {a..z}
#
# I plan on using this to shorten the representation of possibly long ids,
# a la url shortenters
#
@chanshik
chanshik / quiz.py
Created December 21, 2016 07:46
SynapSoft Quiz
"""
SynapSoft Quiz
http://www.synapsoft.co.kr/jsp/recruit/1611.html
1/N 모양의 분수를 소수로 나타내어 봅시다.
1/2 = 0.5
1/3 = 0.333333...
1/4 = 0.25
1/5 = 0.2
1/6 = 0.166666...
@chanshik
chanshik / benchmark+go+nginx.md
Created September 12, 2016 08:57 — forked from hgfischer/benchmark+go+nginx.md
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
@chanshik
chanshik / introrx.md
Created July 20, 2016 10:23 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@chanshik
chanshik / playbook.yml
Created March 2, 2016 01:52 — forked from hostmaster/playbook.yml
ansible playbook choose APT or YUM for package installation
- name: Install wget package (Debian based)
  action: apt pkg='wget' state=installed
  only_if: "'$ansible_pkg_mgr' == 'apt'"
 
- name: Install wget package (RedHat based)
  action: yum name='wget' state=installed
  only_if: "'$ansible_pkg_mgr' == 'yum'"
@chanshik
chanshik / springer-free-maths-books.md
Created December 30, 2015 03:59 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of books available for free, here are the direct links
[Unit]
Description=App Redis Sidekick
Requires=docker.service
Requires=etcd.service
After=docker.service
After=etcd.service
After=app-redis.service
BindsTo=app-redis.service