Skip to content

Instantly share code, notes, and snippets.

@paxperscientiam
paxperscientiam / seekincompatonedrive.sh
Created October 9, 2017 01:32
Find files with filenames containing characters incompatible with OneDrive.
#!/bin/sh
/usr/bin/find . \( -iname "*\:*" \
-o -iname "*\?*" \
-o -iname "*\**" \
-o -iname "*\\\*" \
-o -iname "*\<*" \
-o -iname "*\>*" \
-o -iname "*\|*" \
-o -iname "*\"*" \) -print
@paxperscientiam
paxperscientiam / TrueColour.md
Created October 20, 2017 04:28 — forked from XVilka/TrueColour.md
True Colour (16 million colours) support in various terminal applications and terminals

Colours in terminal

It's a common confusion about terminal colours... Actually we have this:

  • plain ascii
  • ansi escape codes (16 colour codes with bold/italic and background)
  • 256 colour palette (216 colours + 16 ansi + 24 gray) (colors are 24bit)
  • 24bit true colour ("888" colours (aka 16 milion))
printf "\x1b[${bg};2;${red};${green};${blue}m\n"
@paxperscientiam
paxperscientiam / globalpips.bash
Last active December 28, 2017 23:23
Custom shell functions for invoking pip3 with python36 and pip with python27 for installation and packages listing
#!/usr/bin/env bash
# Note: only tested on macOS; asssumes appropriate pips installed
# Disclaimer: use at your own peril
# Parting words: have a nice day
shopt -s expand_aliases
# edit this accordingly
pyverz=(

SSH agent forwarding and screen

When connecting to a remote server via SSH it is often convenient to use SSH agent forwarding so that you don't need a separate keypair on that server for connecting to further servers.

This is enabled by adding the

ForwardAgent yes

option to any of your Host entries in ~/.ssh/config (or alternatively with the -A option). Don't set this option in a wildcard Host * section since any user on the remote server that can bypass file permissions can now als use keys loaded in your SSH agent. So only use this with hosts you trust.

@paxperscientiam
paxperscientiam / camelCase.js
Created November 15, 2017 02:09 — forked from johnsmith17th/camelCase.js
To convert string to camel case in javascript.
function toCamelCase(str) {
return str.toLowerCase().replace(/(?:(^.)|(\s+.))/g, function(match) {
return match.charAt(match.length-1).toUpperCase();
});
}
@paxperscientiam
paxperscientiam / -
Last active November 20, 2017 02:46
#!/bin/bash
# notify user when connected to public wifi
shopt -s expand_aliases
alias wifi='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport'
# exit if not connected to wifi
wifi -I | grep running > /dev/null
@paxperscientiam
paxperscientiam / spinner.bash
Last active November 30, 2017 05:46
Simple 'spinner' for your scripts. Disclaimer: use at your own peril!
#!/usr/bin/env bash
:
function spinner () {
trap 'tput cnorm' RETURN SIGINT
:
sprite=('|' '/' '–' '\')
SECONDS=0
TIME_LIMIT=
:
local OPTIND opt d
@paxperscientiam
paxperscientiam / craigslist-sans-bs.txt
Last active January 8, 2018 01:09
Craigslist search filters
Useful for jobs and gigs:
Craigslist gigs in Vermont:
Example for gigs in Vermont sorted by date:
https://vermont.craigslist.org/search/ggg?query=-bondage+-%28exotic+dancer*%29+-stripper*+-nude+-massage+-escort*+-model*+-sexy+-snapchat+-kik+-survey*+-unpaid+-%28photo+shoot%29+-%28CL+POSTER%29+-scene*+-casting+-film+-actor*&sort=date&is_paid=yes
Craigslist jobs in Vermont:
@paxperscientiam
paxperscientiam / ask.sh
Created February 24, 2018 23:00
Bash General-Purpose Yes/No Prompt Function ("ask")
# This is a general-purpose function to ask Yes/No questions in Bash, either
# with or without a default answer. It keeps repeating the question until it
# gets a valid answer.
ask() {
# https://djm.me/ask
local prompt default reply
while true; do
@paxperscientiam
paxperscientiam / .htaccess
Created April 4, 2018 21:05
Using SSL in production only (set conditional)
# This assumes a, say, virtualhost on your dev machine like the following:
# <Virtualhost *:80>
# # ...
# SetEnv APPLICATION_ENV "development"
# # ...
# </Virtualhost>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{ENV:APPLICATION_ENV} !^development$