Skip to content

Instantly share code, notes, and snippets.

View mfts's full-sized avatar
🎯
Focusing on open source

Marc Seitz mfts

🎯
Focusing on open source
View GitHub Profile
@mfts
mfts / Bash Prompt
Last active December 12, 2018 10:24
Terminal prompt to show "user@computer:working_directory (git_branch) $ "
# Copy the functions below to your ~/.bash_profile
git-dirty() {
[[ $(git status 2>/dev/null | tail -n1) != "nothing to commit, working tree clean" ]] && echo "*"
}
parse_git_branch() {
git branch 2> /dev/null | sed -e "/^[^*]/d" -e "s/* \(.*\)/ (\1$(git-dirty))/"
}
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[0;34m\$(parse_git_branch)\[\033[00m\] $ "
@mfts
mfts / haiku
Created February 7, 2016 15:50 — forked from friggeri/haiku
random heroku-like name generator
haiku = ->
adjs = [
"autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark",
"summer", "icy", "delicate", "quiet", "white", "cool", "spring", "winter",
"patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue",
"billowing", "broken", "cold", "damp", "falling", "frosty", "green",
"long", "late", "lingering", "bold", "little", "morning", "muddy", "old",
"red", "rough", "still", "small", "sparkling", "throbbing", "shy",
"wandering", "withered", "wild", "black", "young", "holy", "solitary",
"fragrant", "aged", "snowy", "proud", "floral", "restless", "divine",
@mfts
mfts / import_json_appsscript.js
Created February 18, 2016 12:22 — forked from chrislkeller/import_json_appsscript.js
Adds what amounts to an =ImportJSON() function to a Google spreadsheet... To use go to Tools --> Script Editor and add the script and save.
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
// This little script lets you untag photos on Facebook. While only 10 at a time, I'm working on untagging multiple ones at once. Also you kinda have to preload, i.e. scroll down on the page, until as much tagged photos are loaded that you wish to iterate over.
// (1) Go to https://www.facebook.com/{YOURFACEBOOKIDHERE}/allactivity?log_filter=taggedphotos
// (2) Copy all JS from this page http://code.jquery.com/jquery-latest.min.js and
// (3) Paste into console
// (4) JQuery selectors $(..) are now available
// The following are lines to be entered into the console each at a time. (I was lazy)
var nameOfTagger = "Peter Pan";
<?
/////////////////////
// slack2html
// by @levelsio
/////////////////////
//
/////////////////////
// WHAT DOES THIS DO?
/////////////////////
//
module.exports = [
{
"ID": 1,
"Content": "Diagnose Number",
"Prefix": "",
"OPC UA Node ID": "Application.USERVARGLOBAL.enErrorID_gb",
"Data Source": "UserVarGlobal",
"Data Access": "Read",
"Data Format": "INT",
"Data Unit": "16#0=No Error; 16#1=Invalid Input; 16#2= com. Error; 16#3=Resource Error; 16#4=Access Error; 16#5=State Error; 16#6=Out of Range; 16#7=Calc. Error; 16#8=Device Error; 16#7EEE=Undef. Error; 16#7FFF=System Error;",
@mfts
mfts / .zshrc
Last active December 5, 2019 20:35
Zsh Prompt to show dirty and clean status of git branch
autoload -U colors && colors
setopt prompt_subst
# Get branch and open commits in prompt
function git-dirty() {
[[ $(git status 2>/dev/null | tail -n1) != "nothing to commit, working tree clean" ]] && echo "*"
}
function parse_git_branch() {
git branch 2> /dev/null | sed -e "/^[^*]/d" -e "s/* \(.*\)/ (\1$(git-dirty))/"
}
@mfts
mfts / letsencrypt.sh
Created January 29, 2020 18:19
Create Letsencrypt wildcard certificate
brew install certbot
# change <my.domain> to preferred domain
certbot certonly --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory --manual-public-ip-logging-ok -d '*.<my.domain>' -d <my.domain>
# add certificates to heroku
heroku certs:add -a eduqai-prod /etc/letsencrypt/live/<my.domain>/fullchain.pem /etc/letsencrypt/live/<my.domain>/privkey.pem
# may need to run with sudo
@mfts
mfts / sidekiq_monitoring
Created May 24, 2020 22:50 — forked from ngsmrk/sidekiq_monitoring
Sidekiq queue checking via rails console
stats = Sidekiq::Stats.new
stats.queues
stats.enqueued
stats.processed
stats.failed
@mfts
mfts / cert.sh
Created June 3, 2020 08:58
Let's Encrypt for Wildcard Domains with Heroku and Cloudflare
#!/bin/sh
set -e
# NEEDS THE FOLLOWING VARS IN ENV:
# DOMAIN
# CLOUDFLARE_EMAIL
# CLOUDFLARE_API_KEY
# HEROKU_APP
# Download dependencies