Skip to content

Instantly share code, notes, and snippets.

View sabman's full-sized avatar
😀
Building, Shiping, Sharing!

Shoaib Burq sabman

😀
Building, Shiping, Sharing!
View GitHub Profile
#!/bin/sh
# The least terrible way to resolve a symlink to its real path.
function realpath() {
/usr/bin/perl -e "use Cwd;print Cwd::abs_path(@ARGV[0])" "$0";
}
CONTENTS="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"
# BINARY_NAME="$(ls "$CONTENTS/MacOS/")"
BINARY_NAME="$(command ls --color=none "$CONTENTS/MacOS/")"
@bnekolny
bnekolny / migtrate_data.py
Last active December 15, 2021 14:46
MLFlow migration script from filesystem to database tracking data
import os
import yaml
## Execution for me was:
## `python migrate_data.py > ./migration_inserts.sql`
## `sed -i '' 's/None/NULL/' ./migration_inserts.sql`
## `psql -f ./migration_inserts.sql`
## NOTE: A few things to know about the script here:
## - Artifacts were stored remotely, so no artifact migration
@nathanqthai
nathanqthai / pre-commit.sh
Last active April 23, 2023 18:07
a git pre-commit hook to check for API keys
#!/bin/sh
# stash before we mess around
STASH_NAME="pre-commit-$(date +%s)"
git stash save -q --keep-index $STASH_NAME
# regexes to find keys
TWILIO_KEY="\bAC[a-z0-9]{32}\b"
TWILIO_SECRET="\b[a-z0-9]{32}\b"
API_REGEXPS=( $TWILIO_KEY $TWILIO_SECRET )
@npearce
npearce / install-docker.md
Last active May 9, 2024 18:42
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start

Installation

  1. Spin up an AWS/Azure/GCP machine (Ubuntu - 16.04)
    • ensure you know how to use the web-interface of these IaaS to open ports for an instance
    • open ports 80, 443, 8000, 8888
  2. Follow this link
  3. Create a dir (.jupyterhub) which shall contain jupyterhub specific files
    • mkdir .jupyterhub
    • cd .jupyterhub
    • jupyterhub --generate-config
    • openssl rand -hex 8 > jupyterhub_cookie_secret
@daniel-j-h
daniel-j-h / tiler.py
Last active February 3, 2022 07:04
Tiles GeoTIFF for zoom level
#!/usr/bin/env python3
'''
pip install tqdm numpy pillow mercantile 'rasterio==1.0b1' 'rio-tiler==1.0a7'
'''
import os
import argparse
@eddmann
eddmann / start-stop-ec2-instances.js
Created November 3, 2017 14:00
Scheduled Start/Stop of EC2 Instances using Lambda and CloudWatch Events
// Demonstration video can be found at: https://youtu.be/roAerKVfq-Y
// StopEC2Instance
const AWS = require('aws-sdk');
exports.handler = (event, context, callback) => {
const ec2 = new AWS.EC2({ region: event.instanceRegion });
ec2.stopInstances({ InstanceIds: [event.instanceId] }).promise()
@judy2k
judy2k / parse_dotenv.bash
Created March 22, 2017 13:34
Parse a .env (dotenv) file directly using BASH
# Pass the env-vars to MYCOMMAND
eval $(egrep -v '^#' .env | xargs) MYCOMMAND
# … or ...
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)
@C-Rodg
C-Rodg / Mixin.js
Created January 16, 2017 22:58
A mixin for acquiring object properties without modifying the prototype chain.
function mixin(receiver, supplier) {
if(Object.getOwnPropertyDescriptor) {
Object.keys(supplier).forEach(function(prop) {
let descriptor = Object.getOwnPropertyDescriptor(supplier, prop);
Object.defineProperty(receiver, prop, descriptor);
});
} else { // For older browsers, does not support accessor properties
for(let prop in supplier) {
if (supplier.hasOwnProperty(prop) {
receiver[prop] = supplier[prop];
@johannah
johannah / mb-system-install-notes.md
Last active June 10, 2023 12:41
Instructions for Installing MB-System for Sonar processing

This is documentation for installing MB-System-r2279 on Ubuntu 14.04 as of Nov 2016. Although documentation for mb-system has improved dramatically over the past few years, it can still be difficult. In particular, I have not found step 1.4 in the documentation and missing this step will result in being unable to use gmt shared libraries such as "gmt mbcontour" which is necessary for producing contour lines in maps.

##1) Install GMT 5.1.2 I am using directions from Andrew at: http://andrewjmoodie.com/2014/12/installing-the-generic-mapping-tools-5-gmt-5-1-x-on-ubuntu-linux/ I've added step 1.4 to get this to load shared libraries from mb-system.

##1.1) Install relvent dependencies