Skip to content

Instantly share code, notes, and snippets.

@Oshuma
Oshuma / plex.sh
Last active Feb 27, 2020
Spin up a Plex docker container
View plex.sh
#!/usr/bin/env bash
if [ $# -ne 1 ]; then
echo "$(basename $0) <claim-token>"
echo -e "\nGet claim token here: https://www.plex.tv/claim/"
exit 1
fi
claim_token=$1
@Oshuma
Oshuma / restore
Created Oct 27, 2017 — forked from jgillman/restore.sh
pg_restore a local db dump into Docker
View restore
# Assumes the database container is named 'db'
DOCKER_DB_NAME="$(docker-compose ps -q db)"
DB_HOSTNAME=db
DB_USER=postgres
LOCAL_DUMP_PATH="path/to/local.dump"
docker-compose up -d db
docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_HOSTNAME}" < "${LOCAL_DUMP_PATH}"
docker-compose stop db
View git_daily.fish
function git_daily --description 'Daily stats for given git branch'
# git log --since=1.day --author='<YOUR_EMAIL>' --shortstat $argv | awk '/^ [0-9]/ { f += $1; i += $4; d += $6 } END { printf("%d files changed, %d insertions(+), %d deletions(-)", f, i, d) }'
git log --since=12.hours --author='<YOUR_EMAIL>' --shortstat $argv | awk '/^ [0-9]/ { f += $1; i += $4; d += $6 } END { printf("%d files changed, %d insertions(+), %d deletions(-)", f, i, d) }'
end
View .tmux.conf
bind r source-file ~/.tmux.conf
# remap prefix to Control-a
set -g prefix C-a
# bind 'C-a C-a' to type 'C-a'
bind C-a send-prefix
unbind C-b
set -g default-terminal "screen-256color"
View GetHeader.xml
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://webservices.theshootingwarehouse.com/smart/Orders.asmx">&lt;NewDataSet&gt;
&lt;Table&gt;
&lt;ORDNO&gt;2378426&lt;/ORDNO&gt;
&lt;ORCUST&gt;99994&lt;/ORCUST&gt;
&lt;ORPO&gt;123&lt;/ORPO&gt;
&lt;ORCONO&gt;123&lt;/ORCONO&gt;
&lt;ORDATE&gt;151027&lt;/ORDATE&gt;
&lt;MSG&gt;This is a test order.&lt;/MSG&gt;
&lt;ORAIR /&gt;
@Oshuma
Oshuma / sweetAlert-rails.js
Created Oct 21, 2014
Use sweetAlert with Rails UJS.
View sweetAlert-rails.js
$.rails.allowAction = function(link) {
if ( ! link.attr('data-confirm') ) return true;
$.rails.showConfirmDialog(link);
return false;
};
$.rails.confirmed = function(link) {
link.removeAttr('data-confirm');
link.trigger('click.rails');
};
@Oshuma
Oshuma / wma_to_mp3.rb
Created Aug 17, 2014
Convert .wma to .mp3
View wma_to_mp3.rb
#!/usr/bin/env ruby
class WmaToMp3
TEMP_WAV = 'audiodump.wav'
def self.convert!(path)
wma_files = Dir.glob(File.join(path, "**/*.wma"), File::FNM_CASEFOLD)
if wma_files.empty?
STDOUT.puts "No .wma files found at: #{path}"
View flac_to_mp3.fish
for f in (ls *.flac); ffmpeg -i "$f" -acodec libmp3lame -ab 320k (echo mp3/(basename $f .flac).mp3); end
View .gitconfig
[user]
name = YOUR NAME
email = YOUR EMAIL
[github]
user = GITHUB USERNAME
token = GITHUB TOKEN
[core]
pager = less -FMRX
@Oshuma
Oshuma / fetch_and_build.sh
Created Feb 8, 2014
Shell script to pull and compile latest OpenXcom code.
View fetch_and_build.sh
#!/bin/sh
echo "\n== Stashing changes..."
git stash &&
echo "\n== Pulling latest code..."
git pull &&
echo "\n== Removing old build/ dir..."
rm -rf ./build/ &&