Skip to content

Instantly share code, notes, and snippets.

@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';
package bp.logic;
class BPResult {
int bulls;
int cows;
bool is_winner() { ... }
BPResult( int bulls, int cows) {}
}
use strict;
use warnings;
use v5.14;
package Promise::Common;
use Moose::Role;
has 'ctx', is => 'ro', required => 1;
requires 'state';
@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
@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$
var http = require('http');
var handler = function(req, res) {
res.write('Hello Node');
res.end();
};
var server = http.createServer( handler );
server.listen(8080 );
{
"name": "day12",
"version": "0.0.1",
"private": true,
"dependencies": {
"express" : "*"
}
}
@ynonp
ynonp / Contacts.pm
Last active December 18, 2015 15:19
use strict;
use warnings;
use v5.14;
package Contacts;
sub init {
my %data;
return \%data;
}
/**
* Namespaces in JavaScript are defined using objects
* We'll start from the global object and define nested
* namespaces within.
*
* All namespaces are accessible from every other JS file using
* their fully qualified name starting from global.
* i.e. global.myapp.data.number = 5;
*/
@ynonp
ynonp / mainwindow.cpp
Created July 13, 2013 18:07
QListWidget itemActivated signal example
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QObject::connect(ui->listWidget, SIGNAL(itemActivated(QListWidgetItem*)),