Skip to content

Instantly share code, notes, and snippets.

@elliotk
elliotk / stream.R
Created February 1, 2016 00:33
Stream data from stdin
#!/usr/bin/env Rscript
# Stream data from stdin
# usage: $ seq 5 | Rscript stream.R
f <- file("stdin")
open(f)
while (length(line <- readLines(f, n = 1)) > 0) {
write(as.integer(line)^2, stdout())
}
@elliotk
elliotk / fizzbuzz.pl
Last active December 24, 2015 11:39
Solution to the Fizz Buzz problem using Perl.
#!/usr/bin/perl
# Author.....: Elliot Kleiman
# Date.......: 2 Oct 2013
# File.......: fizzbuzz.pl
# Description: Write a program that prints the numbers from 1 to 100. But for
# multiples of three print "Fizz" instead of the number and for
# the multiples of five print "Buzz." For numbers which are
# multiples of both three and five print "FizzBuzz."
# Usage......: % perl fizzbuzz.pl
@elliotk
elliotk / multiScatterPlot.R
Created November 17, 2010 22:58
Multi-scatter plot example in R using 'split.screen' function
## Author........: Elliot kleiman
## Date..........: 11/13/2010
## File..........: multiScatterPlot.R
## Description:..: multi-scatter-plot example with rotated axis labels.
## Usage.........: source("multiScatterPlot.R")
## clear all graphics devices
graphics.off()
## save graph to file
@elliotk
elliotk / copyAndChangeFileExtension.pl
Created October 12, 2010 02:28
Copy and change files to a new file extension using Perl
#!/usr/bin/perl
# file: copyAndChangeFileExtension.pl
# description: copy and change files to a new file extension
# usage: % perl copyAndChangeFileExtension.pl FULLPATH_SOURCE file_ext FULLPATH_DEST new_file_ext
#################################################################################################
# enforce pragmas
use strict;
use warnings;
use File::Copy; # using File::Copy module from CPAN