Skip to content

Instantly share code, notes, and snippets.

[
{
"name": "Sofle Choc",
"author": "Brian Low"
},
[
{
"y": 0.2,
"x": 3,
"c": "#e8e7e3",
@duese
duese / Tailrec.scala
Created August 13, 2016 23:13
Tree parsing with tailrec recursive method
import scala.annotation.tailrec
class Item(name: String) {
override def toString: String = name
}
class Group(name: String, items: List[Item]) extends Item(name) {
def size: Int = items.size
def get(i: Int): Item = items(i)
}
trait Util {
trait AttributeResolver[T] {
def get(): T
}
implicit object StringResolver extends AttributeResolver[String] {
def get(): String = "Alpha"
}
implicit object IntResolver extends AttributeResolver[Int] {
def get(): Int = 47
@duese
duese / .bashrc
Created March 27, 2016 16:16
Colored prompt with git-prompt enabled
# to get a git prompt:
source /usr/share/git/completion/git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=true
#GIT_PS1_SHOWSTASHSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWCOLORHINTS=true
# colorize bash prompt
# see also http://misc.flogisoft.com/bash/tip_colors_and_formatting
#PS1='[\u@\h \W]\$ ' # To leave the default one
// http://stackoverflow.com/questions/510462/is-system-nanotime-completely-useless
import scala.collection.mutable
val numThreads = 10
val numValuesPerThread = 10
var threadResult = mutable.Map[Int, Seq[Long]]()
@duese
duese / copy-date-to-clipboard.sh
Created December 30, 2015 09:04
Copies the current date to clipboard. Assign a shortcut to this script so you can insert the current date whenever you need it. Ideal for filenames.
#/bin/bash
echo -n $(date +"%Y-%m-%d-") | xsel -b
@duese
duese / watch-for-files.sh
Created December 30, 2015 09:01
Looks for file changes in the current directory
#!/bin/bash
inotifywait -m $PWD -r -e create -e moved_to -e delete |
while read path action file; do
TITLE="Filesystem changed"
MESSAGE="The file '$file' appeared in directory '$path' via '$action'"
echo ${MESSAGE}
notify-send "${TITLE}" "${MESSAGE}"
done
@duese
duese / switch-mouse-buttons
Created November 5, 2015 10:55
Simple script to switch mouse buttons on Openbox. Source: http://crunchbang.org/forums/viewtopic.php?id=1760
#!/bin/bash
# Source: http://crunchbang.org/forums/viewtopic.php?id=1760
current=$(xmodmap -pp | head -5 | tail -1 | awk '{print $2}');
if [ "$current" -eq "1" ]
then
xmodmap -e "pointer = 3 2 1";
else
xmodmap -e "pointer = 1 2 3";
@duese
duese / after.sh
Created June 29, 2015 11:58
Homestead extended bootstrap file ~/.homestead/after.sh
#!/bin/bash
# If you would like to do some extra provisioning you may
# add any commands you wish to this file and they will
# be run after the Homestead machine is provisioned.
# Be sure to keep up to date with the files and default Settings
# if there is an update in the image the paths may change
# based upon laravel/homestead image for virtualbox version 0.2.7