Skip to content

Instantly share code, notes, and snippets.

View nacnudus's full-sized avatar

Duncan Garmonsway nacnudus

View GitHub Profile
@RolandColored
RolandColored / transform_pg_dump.sh
Last active March 13, 2024 13:18
Transforms a dump created by `pg_restore --data-only -t table db.pg_dump -f table.tsv` into a regular TSV file to be read by Spark
#!/bin/bash
for filename in *.tsv; do
echo $filename
tail -n +23 $filename | head -n 1 | sed -e 's/.*(\(.*\)).*/\1/' | sed -e 's/, /\t/g' > fixed/$filename
tail -n +24 $filename | head -n -7 >> fixed/$filename
done
@edonosotti
edonosotti / main.tf
Last active July 7, 2022 08:16
Create a Google Cloud Project from scratch with Terraform (contains a workaround for a Google Cloud Platform API issue)
# ========================================================
# Create Google Cloud Projects from scratch with Terraform
# ========================================================
#
# This script is a workaround to fix an issue with the
# Google Cloud Platform API that prevents to fully
# automate the deployment of a project _from scratch_
# with Terraform, as described here:
# https://stackoverflow.com/questions/68308103/gcp-project-creation-via-api-doesnt-enable-service-usage-api
# It uses the `gcloud` CLI:
@whi-tw
whi-tw / rpm
Created June 18, 2020 11:15
Cisco Anyconnect cscan compatibility for Arch Linux
#!/usr/bin/env bash
if [ "${1}" == "-q" ] && [[ ${2} == --qf* ]]; then
arch="$(uname -m)"
ver="$(pacman -Q ${@: -1} | awk '{print $2}')"
if [ ! -z "${ver}" ]; then
echo "{\"name\":\"${@: -1}\",\"version\":\"${ver}\",\"arch\":\"${arch}\"}"
else
echo "package ${@: -1} is not installed"
fi
elif [ "${1}" == "-ql" ]; then
@jobdiogenes
jobdiogenes / demo-of-use-google-drive-sheets-in-r-with-google-colaboratory.ipynb
Last active November 29, 2022 02:54
Demo of use Google Drive/Sheets in R with Google Colaboratory.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@edavidaja
edavidaja / convert_to_xlsx.R
Created May 28, 2019 22:08
convert legacy xls files to xlsx files
library(purrr)
xls_to_xlsx <- function(file) {
if (fs::path_ext(file) != "xls") {
stop("file must have extension xls")
}
sheets <- readxl::excel_sheets(file)
insheets <- map(sheets, ~readxl::read_excel(file, .x, col_names = FALSE))
@dbtek
dbtek / venv_wrapper
Last active March 17, 2024 05:21
Python 3 venv wrapper. Manages all virtual environments under ~/.venv/ .
# venv_wrapper, manage all virtual environments under ~/.venv/
# Include following in .bashrc / .bash_profile / .zshrc
# See https://gist.github.com/dbtek/fb2ddccb18f0cf63a654ea2cc94c8f19
# Usage
# $ mkvenv myvirtualenv # creates venv under ~/.venv/
# $ venv myvirtualenv # activates venv
# $ deactivate # deactivates venv
# $ rmvenv myvirtualenv # removes venv
export VENV_HOME="$HOME/.venv"
@bpmore
bpmore / sort-tabs.txt
Created June 9, 2016 17:41
Sort Tabs in Google Spreadsheets
1. Copy/Paste the information below to the clipboard
2. Open the spreadsheet whose sheets need to be alphabetised
3. Choose Tools > Script editor > Blank (this opens a new tab in the browser)
4. Press Control+A followed by Control+V copy and paste the script in
5. Press Control+S to save the script
6. Choose Run > sortSheets
7. Go back to the spreadsheet tab to view the new sorted tab order
--Copy everything below this line--
function sortSheets () {
local char_to_hex = function(c)
return string.format("%%%02X", string.byte(c))
end
local function urlencode(url)
if url == nil then
return
end
url = url:gsub("\n", "\r\n")
url = url:gsub("([^%w ])", char_to_hex)
@andrewxhill
andrewxhill / minimum_spanning_tree.sql
Created March 13, 2016 14:07
Minimum spanning tree in SQL... just because
CREATE TYPE minimum_spanning_tree_internal AS (
d NUMERIC[],
a INT[],
b INT[],
geoms GEOMETRY[],
ids TEXT[]
);
CREATE TYPE minimum_spanning_tree_unit AS (
d NUMERIC,
@Bill
Bill / docker-compose.yml
Last active July 8, 2022 07:10
Run a local Hypothes.is annotation server (and the services it needs) via docker-compose
# This docker-compose.yml will run the Hypothes.is annotation server.
# (adapted from instructions here https://h.readthedocs.org/en/latest/INSTALL.html)
#
# Place this file in the working directory (clone of https://github.com/hypothesis/h)
# run with docker-compose up -d
#
# Now browse to Hypothes.is at http://192.168.59.103:8000/ and create an account
# You'll see the invitation email in Mailcatcher at http://192.168.59.103:1080/
# Click that invitation link and log in on your local Hypothes.is
# And you are ready to annotate!