Skip to content

Instantly share code, notes, and snippets.

View newnewcoder's full-sized avatar
🐌
On vacation

newnewcoder newnewcoder

🐌
On vacation
  • Taiwan Taipei
View GitHub Profile
sudo curl -sSL https://get.docker.com/ | sh
sudo usermod -aG docker $(whoami)
sudo curl -L "https://github.com/docker/compose/releases/download/1.16.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo apt-get install -y bash-completion
@newnewcoder
newnewcoder / generate_secret_key.py
Created March 11, 2018 03:14
generate flask secret key
import os
from base64 import b64encode
random_bytes = os.urandom(24)
print(b64encode(random_bytes).decode('utf-8'))
sudo lsof -i -n -P | grep LISTEN
@newnewcoder
newnewcoder / mysql-docker.sh
Created October 9, 2018 12:09 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@newnewcoder
newnewcoder / learn_simple_lru.md
Created December 9, 2018 09:28
learn simple LRU

LRU Cache 學習

LRU是在一個有限大小的快取空間,保持最近使用過的資料的一種快取機制,可以透過getter、setter方法搭配一個有序字典物件來實現

import collections


class LRUCache(object):
 """ Simple LRU Cache
@newnewcoder
newnewcoder / ipython_notebook_in_git.md
Created January 16, 2019 07:03 — forked from pbugnion/ ipython_notebook_in_git.md
Keeping IPython notebooks under Git version control

This gist lets you keep IPython notebooks in git repositories. It tells git to ignore prompt numbers and program outputs when checking that a file has changed.

To use the script, follow the instructions given in the script's docstring.

For further details, read this blogpost.

The procedure outlined here is inspired by this answer on Stack Overflow.

<!DOCTYPE html>
<html>
<body>
<div id="container"></div>
<script>
var node1 = document.createElement("p");
var txt1 = document.createTextNode("This is 1 ");
node1.appendChild(txt1);
find $(pwd) -name "*.sql" -type f -mtime +30 -exec rm -f {} \;
@newnewcoder
newnewcoder / httpd.py
Created April 12, 2020 03:23 — forked from daimatz/httpd.py
SimpleHTTPServer with custom headers
#!/usr/bin/env python
import SimpleHTTPServer
import BaseHTTPServer
import sys
"""
Usage:
python httpd.py [port] [additional headers ...]
@newnewcoder
newnewcoder / tmux-cheatsheet.markdown
Created May 15, 2020 02:12 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname