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 / Makefile
Created November 6, 2012 01:46 — forked from turicas/Makefile
Create slugs and abbreviate names using Python
test:
clear
nosetests --with-coverage --cover-package name_utils test_name_utils.py
clean:
find -regex '.*\.pyc' -exec rm {} \;
find -regex '.*~' -exec rm {} \;
.PHONY: test clean

Writing better python code


Swapping variables

Bad code

@lxneng
lxneng / 0_reuse_code.js
Created August 8, 2014 03:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
# 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
@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

目标

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

参考

通过本地镜像安装 ambari

###修改 hostname

##修改 master 的 hostname
# vim /etc/hostname
master
@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})
@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 / schema_convert.sh
Created April 3, 2018 02:56 — forked from shantanuo/schema_convert.sh
script to convert mysql schema to be compatible with data warehouse software
#!/bin/sh
# script to convert mysql schema to be compatible with data warehouse software
# make sure that s3cmd and maatkit utility is installed
db_name=${1:-'test'}
> /root/$db_name.txt
temppath='/mnt/data/pdump1'
host='localhost'
user='maatkit'