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 / disable.sh
Created December 20, 2019 08:10 — forked from junkblocker/disable.sh
Disable bunch of #$!@ in Catalina
#!/bin/bash
if [[ "$(sw_vers -productVersion)" != 10\.15* ]]; then
echo "This is only meant to run on macOS 10.15.* Catalina" >&2
exit 1
fi
reply=
printf "Are you pretty damn sure you want to run this? (Yes/No) "
read -r reply
[[ $reply != Yes ]] && exit 1
@lxneng
lxneng / disable.sh
Created December 20, 2019 08:05
Disable bunch of #$!@ in Catalina
#!/bin/bash
# IMPORTANT: Don't forget to logout from your Apple ID in the settings before running it!
# IMPORTANT: You will need to run this script from Recovery. In fact, macOS Catalina brings read-only filesystem which prevent this script from working from the main OS.
# This script needs to be run from the volume you wish to use.
# E.g. run it like this: cd /Volumes/Macintosh\ HD && sh /Volumes/Macintosh\ HD/Users/sabri/Desktop/disable.sh
# WARNING: It might disable things that you may not like. Please double check the services in the TODISABLE vars.
# Get active services: launchctl list | grep -v "\-\t0"
# Find a service: grep -lR [service] /System/Library/Launch* /Library/Launch* ~/Library/LaunchAgents
@lxneng
lxneng / async-foreach.js
Created August 7, 2019 02:29 — forked from Atinux/async-foreach.js
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
# List all tables:
select db_id, id, name, sum(rows) as mysum
from stv_tbl_perm where db_id = 100546
group by db_id, id, name order by mysum desc;
# list all running processes:
select pid, query from stv_recents where status = 'Running';
# describe table
select * from PG_TABLE_DEF where tablename='audit_trail';
@lxneng
lxneng / _write_dataframe_to_csv_on_s3.py
Created December 27, 2018 06:06 — forked from jitsejan/_write_dataframe_to_csv_on_s3.py
Write a Pandas dataframe to CSV format on AWS S3.
import boto3
from io import StringIO
def _write_dataframe_to_csv_on_s3(dataframe, filename):
""" Write a dataframe to a CSV on S3 """
print("Writing {} records to {}".format(len(dataframe), filename))
# Create buffer
csv_buffer = StringIO()
# Write dataframe to buffer
dataframe.to_csv(csv_buffer, sep="|", index=False)
@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'
@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 分支的操作系统.

参考