Skip to content

Instantly share code, notes, and snippets.

@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;
@ynonp
ynonp / dabblet.css
Created February 4, 2013 08:01
Untitled
body {
font-size: 16px;
}
div {
font-size: 1.5em;
}
h1 {
font-size: 2em;
/**
* Created with JetBrains WebStorm.
* User: ynonperek
* Date: 1/28/13
* Time: 9:14 PM
*
* Mongoose plugin that adds a hashed password field
*/
var bcrypt = require('bcrypt');