Skip to content

Instantly share code, notes, and snippets.

@peterfpeterson
peterfpeterson / homesick_bash_completion
Created March 28, 2014 21:01
homesick bash completion
# bash completion for homesick(1) -*- shell-script -*-
_castlelist()
{
echo $(homesick list | awk '{print $1}')
}
_homesick()
{
local cur prev words cword
@peterfpeterson
peterfpeterson / nanoc_bash_completion
Last active August 29, 2015 13:58
Bash completion for nanoc. This really is just some of the commands that I use.
# bash completion for nanoc -*- shell-script -*-
_nanoc()
{
local cur prev words cword
_gst_init_completion -n = || return
COMPREPLY=( $( compgen -W "compile create view" -- "$cur") )
} &&
complete -F _nanoc nanoc
# Simple calculator - from https://github.com/mathiasbynens/dotfiles/blob/master/.functions
function calc() {
local result=""
result="$(printf "scale=10;$*\n" | bc --mathlib | tr -d '\\\n')"
# └─ default (when `--mathlib` is used) is 20
#
if [[ "$result" == *.* ]]; then
# improve the output for decimal numbers
printf "$result" |
sed -e 's/^\./0./' `# add "0" for cases like ".5"` \
@peterfpeterson
peterfpeterson / gist.md
Last active August 29, 2015 13:58
How to pull in other peoples forks of your gist
  1. git clone <yourgisturl> <usefulname>
  2. cd <usefulname>
  3. edit the .git/config to have the origin remote point at git@gist.github.com:1234.git rather than the https url. I'm sure there is a
  4. git remote add <name> <forkurl>
  5. git fetch <name>
  6. git merge <name>/master --no-ff
  7. git push origin master
# This script is based on one from
# https://forums.dropbox.com/topic.php?id=9644
_dropbox()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="status help puburl stop running start filestatus ls autostart exclude lansync"
@peterfpeterson
peterfpeterson / load-to-blink1.sh
Created August 13, 2014 18:25
Script for updating blink1 based on system load.
#!/bin/bash
# Automatically change a Blink(1)'s color based on system load
# Using which for convenience at the moment
# blink1-tool needs to be in your PATH
BLINK1_TOOL=`which blink1-tool`
# How long to sleep between polling
# If this is too low and the system is borderline it would swap
# back and forth. Also, since we are watching the load, there is
@peterfpeterson
peterfpeterson / fixwhitespace
Last active August 29, 2015 14:05
Two lines of sed in a bash script to fix up whitespace in files
#!/bin/bash
# remove all trailing whitespace
sed -i 's/[ \t]*$//' $1
# replace tabs with 4 places
sed -i 's/[\t]/ /g' $1
@peterfpeterson
peterfpeterson / IDEformatting.md
Last active August 29, 2015 14:08
C++ IDE formatting options

Defaults are in bold. Lots of ones that are missing can be configured to use clang-format.

tool ver built-in options
clang-format 3.4 LLVM, Google, Chromium, Mozilla, WebKit
MS Visual Studio
QT Creator 3.2.1 Qt, GNU
Eclipse CDT K&R, BSD/Allman, GNU, Whitesmiths
XCode
@peterfpeterson
peterfpeterson / README.md
Last active August 29, 2015 14:08
72 in 7
@peterfpeterson
peterfpeterson / merge_conflicting.md
Last active August 29, 2015 14:11
Merging clang-format branch

Ticket #10813 touched most every file in Framework and will almost definitely create merge conflicts with any branch. Here is a recipe for dealing with those conflicts using feature/10698_DGS_normalization as an example.

Note: There is nothing to worry about until you publish/push your changes.

Recipe

  1. Fetch everything and make sure you are up-to-date. In other words, go to your git repository and git fetch -p -t

  2. Checkout your branch