Skip to content

Instantly share code, notes, and snippets.

@zfz
zfz / diff_json.md
Last active January 12, 2021 21:49 — forked from ipan/diff-jq.md
compare two JSONs with jq #json #jq
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@zfz
zfz / jump.py
Last active February 18, 2019 21:16
class Solution(object):
def solution(self, A):
n = len(A)
res = [n-1] # last element is counted
even = {n-1: True, None: False}
odd = {n-1: True, None: False}
def check_pos(i, flag):
if flag % 2:
if i in odd:
> const _ = require('lodash');
> obj = {'a': {'b': [1,2,3]}}
{ a: { b: [ 1, 2, 3 ] } }
> obj1 = _.cloneDeep(obj);
{ a: { b: [ 1, 2, 3 ] } }
> obj1.a.b.push(4)
@zfz
zfz / mongo-service
Created September 25, 2018 16:02
MongoDB service scripts and configurations
#!/bin/bash
MONGO_CONFIG=/vagrant/Applications/mongodb-linux/scripts/mongod.conf.yaml
MONGO_DB_PATH=/home/vagrant/Data/mongo
# Mongo start and stop
function start_mongo() {
mongod --config ${MONGO_CONFIG}
}
@zfz
zfz / curl_info.sh
Last active November 2, 2017 06:19
curl wttr.in/beijing
curl ipinfo.io/8.8.8.8
curl ipinfo.io/ip
curl ipinfo.io
# Insert your preferred key mappings here.
map <c-h> goBack
map <c-l> goForward
map <c-j> previousTab
map <c-k> nextTab
map <c-d> removeTab
# Proxy switch to ShadowSocksX-NG
function set_proxy() {
export {http,https,ftp}_proxy='127.0.0.1:1087'
}
function unset_proxy() {
unset {http,https,ftp}_proxy
}
import os
import sys
import time
def detached(f):
"""Generator for creating a forked process
from a function"""
def wrapper(*args, **kwargs):
"""Wrapper function to be returned from generator.
@zfz
zfz / phoenix
Last active June 11, 2018 07:12
# Load csv data by mapreduce
HADOOP_CLASSPATH=/opt/hbase-0.98.19-hadoop2/lib/hbase-protocol-0.98.19-hadoop2.jar:/opt/hbase-0.98.19-hadoop2/conf hadoop jar /opt/phoenix-4.7.0-HBase-0.98-bin/phoenix-4.7.0-HBase-0.98-client.jar org.apache.phoenix.mapreduce.CsvBulkLoadTool --table WEB_STAT --input /tmp/WEB_STAT.csv
# Create table in Phoenix
/opt/phoenix-4.7.0-HBase-0.98-bin/bin/psql.py hadoop-offline012.dx.momo.com,hadoop-offline013.dx.momo.com,hadoop-offline014.dx.momo.com,hadoop-offline015.dx.momo.com,hadoop-offline016.dx.momo.com,hadoop-offline017.dx.momo.com,hadoop-offline018.dx.momo.com:2181 /opt/phoenix-4.7.0-HBase-0.98-bin/examples/WEB_STAT.sql
# Display complete columns
!outputformat vertical