Skip to content

Instantly share code, notes, and snippets.

@seathief
seathief / Git_mergetool_commands
Last active December 9, 2021 08:51 — forked from RohanBhanderi/Git_mergetool_commands
Git Mergetool and difftool with Beyond Compare 4
//Git Mergetool and difftool with Beyond Compare 4
//Install command line tools
//For osx
//IF running this command in git bash then escape $ with \
git config --global diff.tool bcomp
git config --global difftool.bcomp.cmd "\"bcomp\" \"\$LOCAL\" \"\$REMOTE\""
git config --global difftool.prompt false
git config --global merge.tool bcomp
git config --global mergetool.bcomp.cmd "\"bcomp\" \"\$LOCAL\" \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""
@seathief
seathief / gist:c2a1a7fc708c1286a1b51330036a6b37
Created November 22, 2021 06:56
sort json array by key in jq
# ref: https://stackoverflow.com/questions/30331504/how-to-sort-a-json-file-by-keys-and-values-of-those-keys-in-jq
[
{
"Date": "2011-04-01",
"AnswerCount": "3913"
},
{
"Date": "2010-04-02",
"AnswerCount": "2995"
@seathief
seathief / merge_bom.sh
Created August 26, 2020 04:43
merge utf-8 BOM csv files into single file and keep header from first file.
#!/bin/bash
# ref:https://zzz.buzz/2016/07/30/bom-in-iconv/
# ref:https://stackoverflow.com/questions/16890582/unixmerge-multiple-csv-files-with-same-header-by-keeping-the-header-of-the-firs
for filename in *.csv; do
sed -i 's/\xef\xbb\xbf//' $filename
done
awk 'FNR==1 && NR!=1{next;}{print}' *.csv > merge-bom.csv
@seathief
seathief / ExportTo-ExcelPDF.ps1
Created August 20, 2020 01:22
Save a Microsoft Excel Workbook as a PDF File by Using PowerShell
# ref: https://devblogs.microsoft.com/scripting/save-a-microsoft-excel-workbook-as-a-pdf-file-by-using-powershell/
# run as administrator priviledge
$path = Get-Location
$xlFixedFormat = "Microsoft.Office.Interop.Excel.xlFixedFormatType" -as [type]
$excelFiles = Get-ChildItem -Path $path -include *.xls, *.xlsx -recurse
$objExcel = New-Object -ComObject excel.application
$objExcel.visible = $false
foreach($wb in $excelFiles)
{
@seathief
seathief / pd_read_html.py
Created June 29, 2020 14:32
[pandas read_html] pandas syntax for parsing html #pandas
from io import StringIO
with open('MA.html', 'r') as f:
sio = StringIO(f.read())
dfs = pd.read_html(sio)
@seathief
seathief / protocol-fix.txt
Created May 19, 2020 02:38 — forked from eculver/protocol-fix.txt
How to deal with tmux "protocol version mismatch"
$ tmux attach
protocol version mismatch (client 7, server 6)
$ pgrep tmux
3429
$ /proc/3429/exe attach
@seathief
seathief / History|-110803c1|entries.json
Last active October 18, 2022 08:27
vscode extension list
{"version":1,"resource":"file:///Users/seathief/PycharmProjects/BLI_chat/.gitignore","entries":[{"id":"7fAf","source":"textFileCreate.source","timestamp":1663048101895},{"id":"R18z","source":"Workspace Edit","timestamp":1663048120735},{"id":"vnpN","source":"Workspace Edit","timestamp":1663048163028},{"id":"ATfx","source":"Workspace Edit","timestamp":1663048173732},{"id":"Wuy5","timestamp":1663048178393},{"id":"YsQ2","source":"Workspace Edit","timestamp":1663048198006},{"id":"pzt9","source":"Workspace Edit","timestamp":1663048214825},{"id":"jAyu","source":"Workspace Edit","timestamp":1663048229396},{"id":"6byA","timestamp":1663048237174},{"id":"9ZLb","source":"Workspace Edit","timestamp":1663048253163},{"id":"CSUd","timestamp":1663048262734},{"id":"V20c","source":"Workspace Edit","timestamp":1663048269486},{"id":"Qin7","source":"Workspace Edit","timestamp":1663048298047}]}
# html
<input type="text" class="form-control" id="appName1"
data-sync="input" data-target="#appName2">
# javascript
$("[data-sync='input']").blur(function(){
$($(this).data('target')).val($(this).val());
});
@seathief
seathief / remount.sh
Created February 2, 2018 03:00 — forked from ertseyhan/remount.sh
Temporarily increase size of tmp folder on Arch linux
#!/bin/bash
sudo mount -o remount,size=10G,noatime /tmp
echo "Done. Please use 'df -h' to make sure folder size is increased."
@seathief
seathief / idno_generator.py
Created May 23, 2017 06:15
簡易身份證產生器
import string
import random
def idno_generator():
'''
credit goes to
https://stackoverflow.com/questions/2257441/random-string-generation-with-upper-case-letters-and-digits-in-python
'''
return random.choice(string.ascii_uppercase) + ''.join(random.choice(string.digits) for _ in range(10))