Skip to content

Instantly share code, notes, and snippets.

View lxneng's full-sized avatar
🎯
Focusing

Eric Luo lxneng

🎯
Focusing
View GitHub Profile
@lxneng
lxneng / renderers.py
Created August 4, 2016 06:46 — forked from jvanasco/renderers.py
pyramid renderer
from pyramid.config import Configurator
from zope.interface.registry import Components
import simplejson as json
import datetime
import decimal
from .. import lib
@lxneng
lxneng / ecommerce-example-beginnning-neo4j.cql
Created July 6, 2016 08:54 — forked from chrisdkemper/ecommerce-example-beginnning-neo4j.cql
This is an example Ecommerce data structure from the book Beginning Neo4j
//Add some contstraints for good measture, constraints must be ran individually
CREATE CONSTRAINT ON (c:Customer) ASSERT c.email IS UNIQUE;
CREATE CONSTRAINT ON (p:Product) ASSERT p.uuid IS UNIQUE;
//:Start Product and customer query:
//Products, bundles and categories
CREATE (product1:Product {name: "Product 1", uuid: "d8d177cc-1542-11e5-b60b-1697f925ec7b", price: 10})
CREATE (product2:Product {name: "Product 2", uuid: "d8d17b28-1542-11e5-b60b-1697f925ec7b", price: 20})
CREATE (product3:Product {name: "Product 3", uuid: "d8d17c72-1542-11e5-b60b-1697f925ec7b", price: 30})

通过本地镜像安装 ambari

###修改 hostname

##修改 master 的 hostname
# vim /etc/hostname
master

目标

使用 apt-mirror 来同步 hortonworks 镜像服务器上的 Ambari, HDP, HDP-UTILS 仓库, 方便本地搭建 Hadoop 集群. 适合于 Ubuntu/Debian 分支的操作系统.

参考

@lxneng
lxneng / folding-python-code-in-python.md
Created May 9, 2016 02:38
How can you fold and unfold Python code in Vim?

set foldmethod=indent

use zo and zc to fold and unfold in normal mode

use zR and zM to fold and unfold all folds

@lxneng
lxneng / folding-python-code-in-python.md
Created May 9, 2016 02:38
How can you fold and unfold Python code in Vim?

set foldmethod=indent

use zo and zc to fold and unfold in normal mode

use zR and zM to fold and unfold all folds

@lxneng
lxneng / xxx.rb
Created September 18, 2015 14:18
url validates in rails model
validates :url, uniqueness: true, format: { with: URI::regexp(%w(http https))}
@lxneng
lxneng / cache.py
Last active May 27, 2016 03:24 — forked from cloverstd/cache.py
# coding: utf-8
try:
import cPickle as pickle
except ImportError:
import pickle
try:
import hashlib
sha1 = hashlib.sha1
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
sudo apt-get install mongodb-org
# http://zh.wikipedia.org/wiki/中文数字
# http://china.younosuke.com/03_013.html
module ChineseNum
extend self
UPPER_ZERO = '零'
LOWER_ZERO = '〇'
UPPER_DIGITS = %w[壹 贰 叁 肆 伍 陆 柒 捌 玖].unshift nil
LOWER_DIGITS = %w[一 二 三 四 五 六 七 八 九].unshift nil