Skip to content

Instantly share code, notes, and snippets.

@sunary
sunary / pusher_client.md
Last active July 28, 2018 06:00
pusher websocket
@sunary
sunary / decorator.ts
Created June 11, 2018 10:28
ts decorator
export function NeedAuthorization() {
return (target, key, descriptor) => {
if (descriptor === undefined) {
descriptor = Object.getOwnPropertyDescriptor(target, key);
}
const originalMethod = descriptor.value;
descriptor.value = function(...args) {
if (args.length >= 3) {
const context = args[2];
if (!context || !context.user) {
@sunary
sunary / tips.md
Created June 4, 2018 03:35
mac tips

disable builtin keyboard:

sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext

enable builtin keyboard:

sudo kextload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext
@sunary
sunary / name.service
Last active April 9, 2018 07:06
systemd
sudo vi /etc/systemd/system/name.service
`
[Unit]
Description = ...
After = network.target
[Service]
WorkingDirectory = /home/sunary/dir
ExecStart = /usr/bin/python /home/sunary/dir/run.py
User = sunary
Restart = always
@sunary
sunary / Dockerfile
Created December 27, 2017 09:30
Nodejs Docker
FROM node:7.6.0
ADD package.json /tmp/package.json
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
ADD . /usr/src/app
RUN npm rebuild node-sass
@sunary
sunary / Dockerfile
Last active December 27, 2017 09:33
Flask docker
FROM python:2.7
RUN pip install Flask==0.11 requests==2.9.1
WORKDIR /
COPY . /
EXPOSE 8072
CMD [ "python", "run.py" ]
@sunary
sunary / ank.md
Last active May 18, 2017 05:12
ank - python Microservices

ank Microservice framework

Source: https://github.com/sunary/ank

Giới thiệu

Thực sự thì mình khá thích ý tưởng chia bài toán ra các processor nhỏ hơn, và có thể hoạt động độc lập mà không ảnh hưởng/phụ thuộc vào môi trường. Các processor này sẽ được ghép nối với nhau dựa trên yêu cầu của bài toán, và có thể dễ dàng thay thế chỉnh sửa từng proccesor mà không ảnh hường đến các processor khác.

ank ra đời là vì vậy, ank giúp các bạn viết các app độc lập và hổ trợ lắp ghép với nhau (pipeline và braching) mà không làm mất đi sự trong sáng của chương trình.

Xin nói qua 1 chút ưu/nhược điểm để các bạn có thể hình dung:

@sunary
sunary / moveset.py
Last active September 29, 2016 08:41
list moveset in pokemon go
__author__ = 'sunary'
list_moves = {
0: '',
1: 'Thunder Shock',
2: 'Quick Attack',
3: 'Scratch',
4: 'Ember',
5: 'Vine Whip',
@sunary
sunary / ES.md
Last active December 15, 2016 04:32
elasticsearch tips and tricks

order:

index > type > documents

filter vs query

  • filter: boolean, exactly value, no score, cached, faster
  • query: relevent, full text, score, not cached, slower

term vs match

  • term: analyzed
  • match: not analyzed, date, integer
@sunary
sunary / register_pypi.sh
Last active December 21, 2017 04:47
upload to pypi
~/.pypirc
[distutils]
index-servers =
pypi
[pypi]
repository:https://upload.pypi.org/legacy/
username:username
password:password