Skip to content

Instantly share code, notes, and snippets.

@sunary
sunary / common-cmd.sh
Last active May 12, 2020 21:02
usually commands
# rsync
rsync -rzvh --exclude='*.git' --exclude='*.pyc' -e 'ssh -p PORT' SRC [USER@]HOST:/home/user/
rsync -r ~/Music/iTunes/iTunes\ Media/Music ~/Documents/OneDrive/
# Start mongo
mongod --config /usr/local/etc/mongod.conf --fork
# supervisord
supervisord.conf /etc/supervisor/conf.d/supervisord.conf
@sunary
sunary / tips.sql
Last active July 25, 2017 05:06
mysql postgreSQL utils (python)
## Create table
id int(11) NOT NULL AUTO_INCREMENT
elements integer[4]
title TEXT CHARACTER SET utf8 NOT NULL
source VARCHAR(100) CHARACTER SET utf8 NOT NULL
doc_id INT REFERENCES documents ON DELETE CASCADE
review set('positive', 'negative', 'neutral') COMMENT '",".join(data) when query'
@sunary
sunary / crypto400.py
Last active December 25, 2015 02:09
crypto400.py
from sympy import *
from sympy import pdiv, prem
from sympy.abc import x
from random import random, choice, randint
from string import ascii_letters, digits
import sys
import os
import binascii
import threading
import Queue
@sunary
sunary / docker.sh
Last active December 24, 2017 05:32
docker tips
# build
docker build -t=image_name .
# start
docker run -d -p PORT:PORT image_name
# exec
docker exec -it container_name /bin/bash
# tag
@sunary
sunary / dot.vn
Last active May 10, 2017 09:18
3 letters dot .vn domain avaliable
aae
aah
aai
aaj
aan
aao
aap
aaq
aax
aay
@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
@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 / 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 / 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 / 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" ]