Skip to content

Instantly share code, notes, and snippets.

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

Nam D. Nguyen namndev

🏠
Working from home
View GitHub Profile
@namndev
namndev / memcached_value_mapping.py
Last active July 5, 2016 08:43
Example Python scrip working with memcached + InnoDB
import memcache
import sys
from datetime import datetime, timedelta
import pymysql
def banner(message):
print("=" * len(message))
print(message)
print ("=" * len(message))
@namndev
namndev / new_table_memcached.sql
Last active July 5, 2016 08:47
Script SQL for test memcached_value_mapping
CREATE TABLE IF NOT EXISTS user (usr_id VARCHAR(20) NOT NULL COMMENT 'User ID',
usr_surveyoff CHAR(1) NOT NULL DEFAULT '0' COMMENT 'If True, this user should not see any survey',
usr_createdon VARCHAR(19) NOT NULL COMMENT 'When the user was created',
usr_gatheringoff CHAR(1) DEFAULT '0',
flags INT, cas BIGINT UNSIGNED, expiry INT, primary key(usr_id))
ENGINE = INNODB;
INSERT INTO `innodb_memcache`.`containers` ( `name`, `db_schema`, `db_table`, `key_columns`, `value_columns`,
`flags`, `cas_column`, `expire_time_column`, `unique_idx_name_on_key`)
VALUES ('mobience', 'test', 'user', 'usr_id', 'usr_surveyoff|usr_createdon|usr_gatheringoff', 'flags','cas','expiry','PRIMARY');
@namndev
namndev / Dracula.terminal
Created July 13, 2016 19:37
Dracula Theme for Terminal OSX
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NGMCAw
IDAAEAKAAtIQERITWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xvcqISFFhOU09iamVj
dF8QD05TS2V5ZWRBcmNoaXZlctEXGFRyb290gAEIERojLTI3O0FITltiaWttcn2GjpGa
@namndev
namndev / Vagrantfile
Last active March 2, 2017 04:36
Xenial vagrant (ubuntu 16.04)
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.hostname = "ubuntu-xenial"
config.vm.network "public_network", ip: "192.168.0.131"
config.vm.synced_folder "/Volumes/Data/Shares", "/home/ubuntu/Shares", create: true
config.vm.provider "virtualbox" do |vb|
vb.name = "ubuntu-xenial64"
@namndev
namndev / upgrade-postgres-9.3-to-9.5.md
Created July 20, 2016 03:53
Upgrading PostgreSQL from 9.3 to 9.5 on Ubuntu

Install Postgres 9.5, and then:

sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main

@namndev
namndev / javascript_resources.md
Created July 20, 2016 04:23
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@namndev
namndev / css_resources.md
Created July 20, 2016 04:27
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@namndev
namndev / python_resources.md
Created July 20, 2016 04:28
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides

@namndev
namndev / ovpn-writer.sh
Created September 1, 2016 15:23
Script to generate an OpenVPN client configuration file in the unified format
#!/bin/sh
##
## Usage: ./ovpn-writer.sh SERVER CA_CERT CLIENT_CERT CLIENT_KEY SHARED_SECRET > client.ovpn
##
server=${1?"The server address is required"}
cacert=${2?"The path to the ca certificate file is required"}
client_cert=${3?"The path to the client certificate file is required"}
client_key=${4?"The path to the client private key file is required"}
@namndev
namndev / Vagrantfile
Created September 16, 2016 03:35
Vagrant file deploying a redis serve
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
$INSTALL_REDIS = <<SCRIPT
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y redis-server