Skip to content

Instantly share code, notes, and snippets.

@visar
visar / 01-vagrant.sh
Created August 9, 2012 12:00 — forked from dalibor/01-vagrant.sh
Set up an Ubuntu 12.04 Precise box with Vagrant for Ruby and NodeJS development
gem install vagrant
vagrant box add precise64 http://files.vagrantup.com/precise64.box
vagrant init
vagrant up
@visar
visar / download_pdf.pl
Created January 5, 2014 14:33
Perl script for downloading multiple pdfs from a web-page
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
use File::Basename;
use LWP::Simple;
use PDF::API2;
my $page = WWW::Mechanize->new();
$page->get("http://www.cs.cmu.edu/~guna/15-123S11/Lectures");
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
use HTTP::Cookies;
use File::Temp;
$| = 1;
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
use HTTP::Cookies;
use MIME::Base64;
$| = 1;
@visar
visar / 0_reuse_code.js
Created June 4, 2014 09:51
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
library(twitteR)
library(ggplot2)
tweets <- list()
dates <- paste("2012-07-",11:18,sep="") # need to go to 18th to catch tweets from 17th
for (i in 2:length(dates)) {
print(paste(dates[i-1], dates[i]))
tweets <- c(tweets, searchTwitter("#ISMB", since=dates[i-1], until=dates[i], n=1500))
}

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@visar
visar / pxe-vm.sh
Created June 24, 2014 06:00 — forked from gdamjan/pxe-vm.sh
#!/bin/bash
MEM=512
LAN=eth0
BRIDGE=virtbr
# runs under the user that started it. make sure it has access to /dev/kvm
function start_vm {
TAPIF=$1
@visar
visar / gentoo
Created September 8, 2014 18:44
Gentoo-20121221 ~ # cryptsetup luksOpen /dev/sdb3 lvm-root
Enter passphrase for /dev/sdb3:
Gentoo-20121221 ~ # cryptsetup luksOpen /dev/sda1 lvm-home
Enter passphrase for /dev/sda1:
Gentoo-20121221 ~ # vgchange -ay
1 logical volume(s) in volume group "gvgh" now active
1 logical volume(s) in volume group "gvgr" now active
Gentoo-20121221 ~ # mount /dev/gvgr/glvr /mnt/gentoo/
Gentoo-20121221 ~ # mount /dev/gvgh/glvh /mnt/gentoo/home/
Gentoo-20121221 ~ # mount /dev/sdb2 /mnt/gentoo/boot/