This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on http://blogs.perl.org/users/randy_stauner/2011/06/exploratory-one-liners-with-less-typing.html | |
# and a couple more things which are *really* handy | |
function raptor { | |
case "$1" in | |
-*) break ;; | |
'') | |
echo "Syntax: raptor [-lneEp etc] 'code' | |
The code can make use of: | |
DD() to Data::Dumper::Dumper() a thing, D() to say() it | |
YY() to YAML::Dump() a thing, Y() to say() it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A typical piece of data | |
> mixed_data = {"id"=>18929882, "title"=>"Lorem Ipsum", "author"=>"Sit Dolor"} | |
# JSON stores the data in a reasonable amount of space... | |
> mixed_data.to_json.length | |
=> 58 | |
# But messagepack does much better | |
> MessagePack.pack(mixed_data).length | |
=> 44 | |
# That's a pretty big difference! But its even more efficient with numbers | |
> numerical_array = [1223, 2190, 1980092, 8932191892, 98321982189] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# grep --- all lines including foo | |
ls -al | grep foo | |
ls -al | pru /foo/ | |
ls -al | perl -ne 'print if /foo/' | |
perl -E 'say for <*foo*>' | |
# grep --- all lines including current date | |
ls -al | grep $(date +"%Y-%m-%d") | |
ls -al | pru 'include?(Time.now.strftime("%Y-%m-%d"))' | |
ls -al | perl -MTime::Piece -ne '$d=localtime->strftime("%Y-%m-%d");print if /$d/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use strict; | |
use Acme::CPANAuthors; | |
use File::Find; | |
use Getopt::Long; | |
use LWP::Simple; | |
use File::Temp qw(tempdir); | |
use Acme::CPANAuthors::Japanese; | |
use CPAN::DistnameInfo; | |
use Compress::Zlib; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#these are meant to be run in a REPL, and the java one in beanshell of something of the sort: | |
#ruby | |
[1,2,3,4].select{ |x| x.even? } | |
#python | |
[x for x in [1,2,3,4] if not x%2] | |
#or, more norvingly | |
filter(lambda x: not x%2, [1,2,3,4]) | |
#clojure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use File::Monitor; | |
use File::Path::Expand; | |
use File::Copy; | |
use File::Remove; | |
use App::Rad; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use MooseX::Declare; | |
class WithDeclare { | |
has greetings => | |
is => 'rw', | |
isa => 'Str', | |
default => "Hello" | |
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | |
<script> | |
var socket; | |
$(function() { | |
// ws_path should be of the form ws://host/_hippie/ws | |
var ws_path = "ws:<% request.base.opaque %>_hippie/ws"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# scoping in ruby 1.8.7 | |
x = 0 | |
[1,2,3].each{|x| puts x} | |
puts x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use autodie qw(:all); | |
use Benchmark qw(:all); | |
use File::Temp qw(tempdir); | |
use File::Spec::Functions qw(catfile); | |
my $dir = tempdir(CLEANUP => 0); | |
my $obj_file = emit_c($dir); |