Skip to content

Instantly share code, notes, and snippets.

@zhongxiao37
zhongxiao37 / data_flow.py
Last active August 24, 2023 09:30
Parse the SQL files to draw the table flows with DOT
import re
import os
from collections import defaultdict
import json
import pydot
def parse_relationships_from_sql_files(sql_folder_path):
full_relationships = []
for root, _, files in os.walk(sql_folder_path):
@zhongxiao37
zhongxiao37 / update_manager.rb
Created July 19, 2021 08:59
Use Arel::UpdateManager to generate query
table = Dev::Account.arel_table
stmt = Arel::UpdateManager.new
stmt.table table
stmt.where(table[:sfid].eq('0010H00002Ez1waQAB'))
stmt.set("name='Tracy'")
stmt.to_sql
@zhongxiao37
zhongxiao37 / executecommand.gradle
Created March 2, 2021 07:12
Execute commands in Java/Gradle
def executeCommand(String command) {
println('executing commands:')
println(command)
StringBuffer output = new StringBuffer();
Process p;
try {
p = Runtime.getRuntime().exec(command);
p.waitFor();
BufferedReader reader =
new BufferedReader(new InputStreamReader(p.getInputStream()));
@zhongxiao37
zhongxiao37 / ExcelXLSXEncrypt.groovy
Created February 25, 2021 12:27
Encrypt the XLSX file with password by using POI
```groovy
// http://poi.apache.org/encryption.html
import org.apache.poi.poifs.filesystem.POIFSFileSystem
import org.apache.poi.poifs.crypt.EncryptionInfo
import org.apache.poi.poifs.crypt.Encryptor
import org.apache.poi.poifs.crypt.EncryptionMode
import org.apache.poi.openxml4j.opc.OPCPackage
@zhongxiao37
zhongxiao37 / 10M_ints_count.go
Last active December 2, 2020 01:08
Count the frequency of 10M integers
package main
import "fmt"
import "math/rand"
import "time"
func main(){
const n = 10000000
var arr [n]int
var counter [100]int