Skip to content

Instantly share code, notes, and snippets.

View davesgonechina's full-sized avatar

WW Henderson davesgonechina

View GitHub Profile
@davesgonechina
davesgonechina / list-dbt-tags-in-use.txt
Last active March 28, 2024 13:43
List tags in a dbt project
# Found in https://github.com/dbt-labs/dbt-core/issues/7749
1. Install jq
2. dbt --quiet ls --output json --output-keys tags | jq .tags | jq -s 'add | unique'
@davesgonechina
davesgonechina / gist:3932f9f56287ab340b234afab1ab0c52
Last active October 4, 2017 16:37
bash concat multiple csvs
head -1 file1.csv > final.csv
IFS=$(echo -en "\n\b")
for filename in $(ls file*.csv); do sed 1d $filename >> final.csv; done
@davesgonechina
davesgonechina / Fix sudo gittery permissions
Last active July 12, 2017 14:16
Error while pull from git - insufficient permission for adding an object to repository database .git/objects
### repair working tree after an accidental sudo
sudo chown -R $USER:$USER "$(git rev-parse --show-toplevel)/.git"
@davesgonechina
davesgonechina / PostgreSQL PK value violation testing
Last active March 8, 2017 20:34
PostgreSQL PK value violation testing
select pg_get_serial_sequence(TABLENAME,'id'); //check sequence id
select MAX(id) from TABLENAME; //Check current max for id
select nextval(RESULTOFPG_GET_SERIAL_SEQUENCE); //Increment sequence id
INSERT INTO TABLENAME(NONPKCOLUMN) VALUES(null); //test insert
SELECT setval(RESULTOFPG_GET_SERIAL_SEQUENCE, (SELECT MAX(id) FROM TABLENAME));
@davesgonechina
davesgonechina / MySQL dedup
Last active January 27, 2017 02:16
MySQL dedup
CREATE TABLE new_table as
SELECT * FROM old_table WHERE 1 GROUP BY [column to remove duplicates by];
@davesgonechina
davesgonechina / libjvm.so: cannot open shared object file: No such file or directory
Last active August 29, 2015 14:27
libjvm.so: cannot open shared object file: No such file or directory
sudo ln -s /usr/lib/jvm/jdk1.7.0_51/jre/lib/amd64/server/libjvm.so /usr/lib/
Rubygems: https://ruby.taobao.org/
NPM: http://npm.taobao.org/
Pypi: http://pypi.douban.com/
NodeJS: http://registry.cnpmjs.org/
@davesgonechina
davesgonechina / MySQL Data Too Long Error
Last active August 29, 2015 14:27
MySQL Data Too Long Error
To change the mode
This can be done in two ways:
Open your "my.ini" file within the MySQL installation directory, and look for the text "sql-mode".
Find:
Code:
# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
Replace with:
Code:
# Set the SQL mode to strict
@davesgonechina
davesgonechina / Hash Sum Mismatch
Last active August 29, 2015 14:27
Hash/Sum Mismatch
sudo rm -f /var/cache/apt/partial/*
sudo rm -R /var/lib/apt/lists/partial/*
sudo rm -R /var/lib/apt/lists/*
@davesgonechina
davesgonechina / ASCII Seperated Values (ASVs)
Last active August 29, 2015 14:27
ASCII Seperated Values (ASVs)
https://ronaldduncan.wordpress.com/2009/10/31/text-file-formats-ascii-delimited-text-not-csv-or-tab-delimited-text/
MySQL, IIRC, choked cuz these are 2-character not 1-char separators.
^\ ␜ File Separator
^] ␝Group Separator
^^ ␞Record Separator
^_ ␟Unit Separator