Skip to content

Instantly share code, notes, and snippets.

View diogo-almeida's full-sized avatar

Diogo Almeida diogo-almeida

View GitHub Profile
@fletch
fletch / 2num.pl
Created September 10, 2009 19:42
#!/opt/local/bin/perl
##
## Slightly more idiomatic and optimized Perl of 2num.pl from
## http://github.com/brendano/awkspeed/tree/master
##
use strict;
use warnings;
open( my $vocab_fh, '>', "vocab" ) or die "vocab: $!\n";
@tmtk75
tmtk75 / markdown-tag.rb
Created November 30, 2011 08:10
Jekyll Markdown Tag
=begin
Jekyll tag to include Markdown text from _includes directory preprocessing with Liquid.
Usage:
{% markdown <filename> %}
Dependency:
- kramdown
=end
module Jekyll
class MarkdownTag < Liquid::Tag
def initialize(tag_name, text, tokens)
@ravasthi
ravasthi / _config.yml
Created February 15, 2012 08:59
Multiple authors on Jekyll
authors:
hanzou:
name: Hanzou Hattori
display_name: Hanzou
gravatar: c66919cb194f96c696c1da0c47354a6a
email: hanzou@company.com
web: http://company.com
twitter: company
github: hhattori
jorgen:
@statisfactions
statisfactions / midifunctions.R
Created February 26, 2012 04:19
hack functions to generate MIDI output from R using midicv and play using timidity, with usage example at end
midi <- function(title="R-created Midi", bpm=120){
## Creates empty "midi" object that tracks can be inserted into
options(scipen=7) ## avoids writing anything here in scientific notation
## Create new data.frame and add headers
newdf <- data.frame(matrix(nrow=7,ncol=7))
names(newdf) <- c("tracknum", "time", "type","channel", "note", "velocity", "tempoonly")
newdf[1,] <- c(0,0, "Header", 1, 1, 480, NA)
newdf[2,] <- c(1,0, "Start_track", NA, NA, NA, NA)
@JoFrhwld
JoFrhwld / ling-plot.Rnw
Created April 14, 2012 20:49
A knitr source file for including linguistic notation as graphical elements in ggplot2
\documentclass{beamer}
\usetheme{Singapore}
\usepackage{tipa}
%% Make the r-code small
\ifdefined\knitrout
\renewenvironment{knitrout}{\begin{footnotesize}}{\end{footnotesize}}
\else
\fi
@xandkar
xandkar / awk-one-liners.awk
Created June 1, 2012 15:13
HANDY ONE-LINE SCRIPTS FOR AWK
HANDY ONE-LINE SCRIPTS FOR AWK 30 April 2008
Compiled by Eric Pement - eric [at] pement.org version 0.27
Latest version of this file (in English) is usually at:
http://www.pement.org/awk/awk1line.txt
This file will also be available in other languages:
Chinese - http://ximix.org/translation/awk1line_zh-CN.txt
USAGE:
@zenkay
zenkay / gist:3237860
Created August 2, 2012 15:19
Installation tips for RVM/Ruby on OSX 10.8 Mountain Lion

Ruby, RVM and Mountain Lion

Key problems

Mountain Lion (10.8) has three main difference compared to Lion (10.7):

  • XCode 4.4 does not install Command Line Tools by default
  • X11 isn't available anymore
  • The installed version of OpenSSL has some bugs

How to work around

@dsparks
dsparks / raster_scatter.R
Created October 14, 2012 00:29
Drawing a scatter plot of raster images
# Drawing a scatter plot of raster images
doInstall <- TRUE # Change to FALSE if you don't want packages installed.
toInstall <- c("png", "devtools", "MASS", "RCurl")
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
# Some helper functions, lineFinder and makeTable
source_gist("818983")
source_gist("818986")
@dsparks
dsparks / flag_plot.R
Created October 21, 2012 15:30
Replicating / improving http://shaheeilyas.com/flags/
# Replicating / improving http://shaheeilyas.com/flags/
# Drawing a scatter plot of raster images
doInstall <- TRUE # Change to FALSE if you don't want packages installed.
toInstall <- c("png", "reshape", "ggplot2", "MASS")
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
# Go to https://www.gosquared.com/resources/2400-flags, download the ZIP,
# and put the 64 x 64 files into a directory of your choosing.
@alexbbrown
alexbbrown / d3widget.js
Last active October 18, 2016 20:58 — forked from anonymous/d3widget.js
Simple Shiny Example of Javascript Input and Output
<script src="http://d3js.org/d3.v3.js"></script>
<script type="text/javascript">
(function(){
// Probably not idiomatic javascript.
this.countValue=0;
updateView = function(message) {
var svg = d3.select(".d3io").select("svg")