Skip to content

Instantly share code, notes, and snippets.

View pestilence669's full-sized avatar

Paul Chandler pestilence669

View GitHub Profile
@pestilence669
pestilence669 / CMakeLists.txt
Last active December 23, 2016 01:22
Run CPU utilization very high
# vim: set ts=4 sw=4 noet fileencoding=utf-8:
#
# cmake -DCMAKE_BUILD_TYPE=Debug ..
# cmake -DCMAKE_BUILD_TYPE=Release ..
cmake_minimum_required(VERSION 2.8)
set(PACKAGE_NAME "evil")
set(PACKAGE_VERSION "0.0.1-dev")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
@pestilence669
pestilence669 / obliterateFileFromGit.sh
Created September 16, 2016 22:37
p4 obliterate (for Git)
#!/bin/bash
#
# run from the project's root with the full relative path to the file
# to destroy from history.
#
git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch $1" \
--prune-empty --tag-name-filter cat -- --all
@pestilence669
pestilence669 / factorial.scala
Last active July 12, 2016 06:57
Various ways to implement factorial in Scala
#!/bin/sh
exec scala "$0" "$@"
!#
// vim: set ts=2 sw=2 et fileencoding=utf-8:
import java.lang.reflect.Method
import scala.annotation.tailrec
import scala.language.postfixOps
/**
@pestilence669
pestilence669 / shell.scala
Created July 9, 2016 23:09
Scala shell script template
#!/bin/sh
exec scala "$0" "$@"
!#
// vim: set ts=2 sw=2 noet:
// http://alvinalexander.com/scala/how-to-handle-stdout-stderr-external-system-commands-scala
import sys.process._
val stdout = new StringBuilder
val stderr = new StringBuilder
@pestilence669
pestilence669 / CMakeLists.txt
Last active June 18, 2016 00:36
Basic CMake C++11 w/ Boost configuration
# vim: set ts=4 sw=4 noet fileencoding=utf-8:
#
# cmake -DCMAKE_BUILD_TYPE=Debug ..
# cmake -DCMAKE_BUILD_TYPE=Release ..
#
cmake_minimum_required(VERSION 3.5)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -Wall")
@pestilence669
pestilence669 / CMake.sublime-build
Last active May 5, 2017 11:04
Basic build system (and run) for CMake for C & C++ within Sublime Text 3
{
"cmd": [
"mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. && make && ./main"
],
"shell": true,
"selector": ["source.cpp", "source.c", "source.c++"],
"working_dir": "${project_path}",
}
@pestilence669
pestilence669 / saver
Created February 2, 2016 06:57
Launch Mac OS X screensaver
#!/bin/bash
sudo open -a /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app
@pestilence669
pestilence669 / gist:f135d6d0bf6ff08d93f8
Last active January 11, 2016 23:07 — forked from jessitron/gist:8376139
scala: print all URLs on classpath
def urlses(cl: ClassLoader): Array[java.net.URL] = cl match {
case null => Array()
case u: java.net.URLClassLoader => u.getURLs() ++ urlses(cl.getParent)
case _ => urlses(cl.getParent)
}
val urls = urlses(getClass.getClassLoader)
println(urls.filterNot(_.toString.contains("ivy")).mkString("\n")
@pestilence669
pestilence669 / figlet_demo.sh
Created October 8, 2015 07:44
Show a message using all available fonts for figlet
#!/bin/bash
# vim: set ts=4 sw=4 noet fileencoding=utf-8:
fontDir=`figlet -I2`
if [[ $# -eq 0 ]]; then
echo "usage: $(basename $0) [message] -- print given message for every available font in figlet"
exit 0
fi
@pestilence669
pestilence669 / fetch_upstream_master_and_rebase.sh
Last active April 10, 2017 23:50
Fetch upstrem master and rebase
#!/bin/bash
# vim: set ts=4 sw=4 noet:
# get current checked out branch
B=`git rev-parse --abbrev-ref HEAD`
if [ $? -ne 0 ]; then # problem, likely not a git repo
exit -1 # leave whatever error occurred alone
fi
# sync from the upstream origin