Skip to content

Instantly share code, notes, and snippets.

@hanbzu
hanbzu / _.md
Created January 30, 2014 10:05
bub
@hanbzu
hanbzu / _.md
Created January 27, 2014 15:53
reftrips
@hanbzu
hanbzu / usbstartup.sh
Created December 26, 2013 17:19
Linux/Ubuntu: USB startup disk through the command line
# The Ubuntu USB startup creator often crashes.
# This is an alternate way of doing the same process through the command line
# First plug in the USB pendrive. It will mount automatically
# Then check where it is (which device)
df
# Let's say we see it's in /dev/sdb1
# Then we have to use /dev/sdb and NOT /dev/sdb1
@hanbzu
hanbzu / 0_reuse_code.js
Created December 3, 2013 11:01
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
# R Function to Draw Edward Tufte-style Slopeplots
slopegraph <-
function(
df,
xlim = c(.5,ncol(df)+.5),
ylim = c(min(df)-diff(range(df))/100,max(df)+diff(range(df))/100),
main = NULL,
bty = 'n',
yaxt = 'n',
@hanbzu
hanbzu / add_methods_to_exising_classes.scala
Created November 25, 2013 11:52
Scala: Pattern to add missing methods to already existing classes.
// Here we add the 'userInput' method to the Future class
implicit class FutureCompanionOps(f: Future.type) extends AnyVal {
def userInput(message: String): Future[String] = Future {
readLine(message)
}
}
// Without the sintactic sugar:
class FutureCompanionOps(f: Future.type) extends AnyVal {
def userInput(message: String): Future[String] = Future {
@hanbzu
hanbzu / screencast_window.sh
Created November 21, 2013 08:13
Screencast of a single window (Ubuntu)
# Find out the window ID of the window I want to record
xwininfo -display :0
# Copy the window ID (something similar to 0x4600007)
recordmydesktop --windowid 0x4600007
# Now the inside of the window (AND the mouse pointer if it goes inside) will be recorded
# CTRL + C will stop the recording
@hanbzu
hanbzu / virtualbox_adding_space.sh
Created November 8, 2013 09:54
VirtualBox: Adding more disk space to a VM
# This is a short walk through adding more disk space
# in a VirtualBox machine. There's good detailed information here:
# http://trivialproof.blogspot.com.es/2011/01/resizing-virtualbox-virtual-hard-disk.html
# Change to where your VirtualBox VMs are. For a Linux distribution it could be:
cd ~/VirtualBox\ VMs/
# Find the name of the virtual machine you want to resize
cd YOUR_VIRTUAL_MACHINE
@hanbzu
hanbzu / stream_concat.scala
Created November 6, 2013 14:18
Scala: Stream concatenation. Thanks to Pavel Lepin.
val a = Stream(1)
//a: scala.collection.immutable.Stream[Int] = Stream(1, ?)
def b: Stream[Int] = Stream(b.head)
//b: Stream[Int]
a #::: b
//res0: scala.collection.immutable.Stream[Int] = Stream(1, ?)
a append b