Skip to content

Instantly share code, notes, and snippets.

View hnq90's full-sized avatar
🎯
Focusing

Huy Nguyen Quang hnq90

🎯
Focusing
View GitHub Profile
@hnq90
hnq90 / mysql_import.php
Created February 26, 2016 10:10
mysql import
<?php
try {
if (! @include_once( './data/install.php' )) {
throw new Exception ('install.php does not exist');
}
if (!file_exists('./data/install.php' )) {
throw new Exception ('install.php does not exist');
} else {
require_once('./data/install.php' );
}
@hnq90
hnq90 / docker-destroy-all.sh
Created December 10, 2015 08:55 — forked from JeffBelback/docker-destroy-all.sh
Destroy all Docker Containers and Images
#!/bin/bash
# Stop all containers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
def get_permutations(string):
# base case
if len(string) <= 1:
return [string]
all_chars_except_last = string[:-1]
last_char = string[-1]
# recursive call: get all possible permutations for all chars except last
permutations_of_all_chars_except_last = get_permutations(all_chars_except_last)
@hnq90
hnq90 / bobp-python.md
Created November 24, 2015 15:51 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
var animals = [
{ animal: 'Horse', name: 'Henry', age: 43 },
{ animal: 'Dog', name: 'Fred', age: 13 },
{ animal: 'Cat', name: 'Frodo', age: 18 }
];
console.table(animals);
console.trace('trace car');
console.debug
debug(car.funcY);
@hnq90
hnq90 / Linux Static IP
Created September 28, 2015 03:50 — forked from fernandoaleman/Linux Static IP
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@hnq90
hnq90 / Preferences.sublime-settings
Created September 16, 2015 04:54
My SublimeText config
{
"auto_complete": true,
"auto_complete_commit_on_tab": true,
"bold_folder_labels": true,
"caret_extra_width": 1,
"caret_style": "phase",
"close_windows_when_empty": false,
"color_scheme": "Packages/Material Color Scheme/sublime/material-dark.tmTheme",
"copy_with_empty_selection": true,
"detect_indentation": false,
@hnq90
hnq90 / utils.js
Created September 14, 2015 08:17
Redactor Utils
utils: function()
{
return {
isMobile: function()
{
return /(iPhone|iPod|BlackBerry|Android)/.test(navigator.userAgent);
},
isDesktop: function()
{
return !/(iPhone|iPod|iPad|BlackBerry|Android)/.test(navigator.userAgent);
#!/usr/bin/env php
<?php
$dictionaries = include "primary.php";
$apiKey = 'API-KEY';
$total = count($dictionaries);
$i = 0;
$dict = array();
foreach ($dictionaries as $key => $value) {
$i++;
$url = 'https://www.googleapis.com/language/translate/v2?q=' . rawurlencode($key) . '&source=ja&target=en' . '&key=' . $apiKey;