Skip to content

Instantly share code, notes, and snippets.

var http = require('http');
var handler = function(req, res) {
res.write('Hello Node');
res.end();
};
var server = http.createServer( handler );
server.listen(8080 );
@ynonp
ynonp / re.pl
Created May 9, 2013 11:30
perl intel 8/5
use strict;
use warnings;
use v5.14;
my $RE_PATTERN = qr {
#
# This is a cool regular pattern
#
# DIGIT DIIGT DIGIT Ends with an x
[0-9] [0-9] [0-9] x$
@ynonp
ynonp / oneliners
Last active December 16, 2015 21:09
# Program 1 -- print the third column of each line
perl -pe '$_ =perl -ane 'print $F[2], "\n"'
# Program 2 -- treat each line as a number and sum all lines
perl -pe '$\+=$_}{'
# Program 3 -- print an empty line after each line
perl -pe '$\="\n"'
# Program 4 -- number the lines
use strict;
use warnings;
use v5.14;
package Promise::Common;
use Moose::Role;
has 'ctx', is => 'ro', required => 1;
requires 'state';
package bp.logic;
class BPResult {
int bulls;
int cows;
bool is_winner() { ... }
BPResult( int bulls, int cows) {}
}
@ynonp
ynonp / catalyst_db_deploy.pl
Last active December 15, 2015 18:38
install catalyst DB using config file
use strict;
use warnings;
use v5.14;
package My::Script::Params;
use Moose;
with 'MooseX::Getopt';
has 'app_pkg', is => 'rw', required => 1, isa => 'Str';
has 'model', is => 'rw', isa => 'Str';
use strict;
use warnings;
use v5.14;
use List::Util qw/sum/;
use Data::Dumper;
sub diff_sum {
my ( $l_ref, $g_ref ) = @_;
return sum(@$l_ref) - sum(@$g_ref);
}
@ynonp
ynonp / dabblet.css
Created February 27, 2013 09:10
Untitled
#nav {
list-style: none;
padding: 0; margin: 0;
display: none;
}
li {
display: inline-block;
padding: 10px;
background: #777;
.autocomplete {
list-style: none;
position: absolute;
top: 0;
left: 0;
padding: 0;
margin: 0;
outline: 1px solid gray;
display: none;
}
<!DOCTYPE html>
<html>
<head>
<title>Image Gallery</title>
<style>
#gallery {
list-style: none;
}
#gallery img {
width: 200px;