Skip to content

Instantly share code, notes, and snippets.

View phuong's full-sized avatar
🏠
Working from home

Phuong phuong

🏠
Working from home
View GitHub Profile
<!-- I am ready now, click one of the buttons! -->
<svg><image id="v-146" width="500" height="500" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="data:image/svg+xml;utf8,%3Csvg%20viewBox%3D%220%200%20100%20100%22%20height%3D%22100%22%20width%3D%22100%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20data-name%3D%22Layer%201%22%20id%3D%22Layer_1%22%3E%0A%20%20%3Ctitle%3ECompute%3C%2Ftitle%3E%0A%20%20%3Cg%3E%0A%20%20%20%20%3Crect%20fill%3D%22%239d5025%22%20ry%3D%229.12%22%20rx%3D%229.12%22%20height%3D%2253%22%20width%3D%2253%22%20y%3D%2224.74%22%20x%3D%2223.5%22%3E%3C%2Frect%3E%0A%20%20%20%20%3Crect%20fill%3D%22%23f58536%22%20ry%3D%229.12%22%20rx%3D%229.12%22%20height%3D%2253%22%20width%3D%2253%22%20y%3D%2222.26%22%20x%3D%2223.5%22%3E%3C%2Frect%3E%0A%20%20%3C%2Fg%3E%0A%3C%2Fsvg%3E" preserveratio="true" style="border-color: rgb(51, 51, 51); box-sizing: border-box; color: rgb(51, 51, 51); cursor: move; font-family: sans-serif; font-size: 14px; line-height: 20px; outline-color: rgb(51, 51, 51); tex
@phuong
phuong / git-mv-with-history
Created September 3, 2021 02:31 — forked from emiller/git-mv-with-history
git utility to move/rename file or folder and retain history with it.
#!/bin/bash
#
# git-mv-with-history -- move/rename file or folder, with history.
#
# Moving a file in git doesn't track history, so the purpose of this
# utility is best explained from the kernel wiki:
#
# Git has a rename command git mv, but that is just for convenience.
# The effect is indistinguishable from removing the file and adding another
# with different name and the same content.
const fs = require('fs')
const JSONC = require('jsoncomp')
const perf = require('execution-time')
const sizeof = require('object-sizeof')
const _ = require('lodash')
const CJSON = require('compress-json')
const file = './june.loc.json'
let data = fs.readFileSync(file, 'utf-8')
data = JSON.parse(data)
data = {
"windows": [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/_kit_ (KHTML, like Gecko) Chrome/_chrome_ _render_",
"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/_kit_ (KHTML, like Gecko) Chrome/_chrome_ _render_",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/_kit_ (KHTML, like Gecko) Chrome/_chrome_ _render_",
"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/_kit_ (KHTML, like Gecko) Chrome/_chrome_ _render_",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/_kit_ (KHTML, like Gecko) Chrome/_chrome_ _render_",
"Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko",
@phuong
phuong / flask-uWSGI-nginx.md
Created July 17, 2018 09:27 — forked from pmav99/flask-uWSGI-nginx.md
How To Serve Flask Applications with uWSGI and Nginx on Ubuntu 14.04+

How To Serve Flask Applications with uWSGI and Nginx on Ubuntu 14.04

@credit Yan Zhu (https://github.com/nina-zhu)

Introduction

Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions, it can help you get your Python application or website off the ground. Flask includes a simplified development server for testing your code locally, but for anything even slightly production related, a more secure and powerful web server is required.

In this guide, we will demonstrate how to install and configure some components on Ubuntu 14.04 to support and serve Flask applications. We will configure the uWSGI application container server to interface with our applications. We will then set up Nginx to reverse proxy to uWSGI, giving us access to its security and performance features to serve our apps.

Prerequisites and Goals

@phuong
phuong / tox.ini
Created May 30, 2017 04:39 — forked from danverbraganza/tox.ini
My standard tox.ini file that allows you to run coverage, lettuce, nosetests and lint, and to pick out a given feature or a module for nosetest (So that you don't have to run the whole suite)
[tox]
envlist=py27,lint
[testenv]
downloadcache={homedir}/.pipcache
distribute=True
sitepackages=False
[testenv:py27]
deps=nose
@phuong
phuong / your.backends.htmlfilebased.py
Created August 26, 2016 04:53
django EmailBackend for developers who want to preview sent emails. This backend will write sent email content to html file instead of send directly to receiver.
import threading
import datetime
from os.path import join, exists
from os import makedirs
from django.core.mail.backends.base import BaseEmailBackend
from django.utils import six
from django.conf import settings
EMAIL_FILE_PATH = join(settings.BASE_DIR, getattr(settings, 'EMAIL_FILE_PATH', 'sent_emails'))
/***
* Simple json Library: https://github.com/ralfstx/minimal-json
* javac -cp ".:lib/json-simple-1.1.1.jar" Json.java
* java -cp ".:lib/json-simple-1.1.1.jar" Json
*/
import org.json.simple.JSONObject;
import org.json.simple.JSONArray;
import org.json.simple.parser.ParseException;
import org.json.simple.parser.JSONParser;