Skip to content

Instantly share code, notes, and snippets.

@gary-liguoliang
gary-liguoliang / setup-local-Jekyll-environment-in-10-minutes-using-Vagrant-VirtualBox.md
Last active March 26, 2017 09:36
Setup local Jekyll environment in 10 minutes using Vagrant + VirtualBox
  1. install VirtualBox v5.1.0
  2. install Vagrant v1.9.2
  3. open command line: cd c:/tmp
  4. git clone [email protected]:guoliang-dev/jekyll-vagrant.git
  5. cd jekyll-vagrant
  6. vagrant up, it may take few minutes to start the VM. it'll download a Ubuntu 14 to your PC during first time run.
  7. ssh vagrant@localhost -p 2222 with vagrant/vagrant and execute:
  cd /vagrant  # /vagrant is the share folder pointing to folder jekyll-vagrant in the host. 
jekyll new my-awesome-site
@gary-liguoliang
gary-liguoliang / auto_publish_to_news_dbanotes_net.py
Last active April 2, 2017 14:03
news.dbanotes.net自动发布脚本
# -*- coding: utf-8 -*-
import requests
from BeautifulSoup import BeautifulSoup
def get_fnid_from_html(html):
soup = BeautifulSoup(html)
return soup.find("form").find("input").get('value')
@gary-liguoliang
gary-liguoliang / select.jsx
Created April 4, 2017 15:13 — forked from jbottigliero/select.jsx
React <select> Component (JSX)
/** @jsx React.DOM */
define(['reactjs'], function(React){
return React.createClass({
getDefaultProps: function(){
return {
multiple: false
/*
name: 'mySelect'
@gary-liguoliang
gary-liguoliang / spark-load-and-join-csv-files.java
Created January 24, 2018 11:56
Spark load and join CSV files
package com.test;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;
import java.util.List;
import java.util.regex.Pattern;
@gary-liguoliang
gary-liguoliang / oracle-select-from-EAV-entity–attribute–value.md
Last active February 10, 2018 07:41
oracle-select-from-EAV-entity–attribute–value

test data:

CREATE TABLE ORDERS (
  order_id         NUMBER,
  attribute_name   VARCHAR2(32),
  text_value       VARCHAR2(32),
  number_value     NUMBER
);

INSERT INTO ORDERS VALUES (1, 'Currency', 'USD', NULL);
@gary-liguoliang
gary-liguoliang / gist:1c12645fe8150a49950224d780dc4acf
Created October 23, 2018 14:03
How to automate setting Chrome as default browser in Windows 10
https://superuser.com/questions/1069346/how-to-automate-setting-chrome-as-default-browser-in-windows-10
import org.apache.poi.ss.usermodel.*;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class ReadExcel {
public static void main(String[] args) throws IOException {
  • install homebrew

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    

    source: https://brew.sh/

  • install iterm2

    brew cask install iterm2
    
with open('pretty.json', "w+") as a:
a.write(json.dumps(data, indent=4, sort_keys=True))
if expected != actual:
import json
with open("expected.json", "w+") as e:
e.write(json.dumps(expected, indent=4, sort_keys=True))
with open("actual.json", "w+") as a:
a.write(json.dumps(actual, indent=4, sort_keys=True))