Skip to content

Instantly share code, notes, and snippets.

View moltar's full-sized avatar
📦
Building stuff.

Roman moltar

📦
Building stuff.
View GitHub Profile
#!/bin/bash
#
# chkconfig: - 16 84
# description: Start up transmission-daemon
#
# processname: transmission-daemon
# config: /etc/sysconfig/transmission
# source function library
. /etc/rc.d/init.d/functions
@moltar
moltar / Web.pm
Created February 20, 2013 22:46
routing
my $r = $self->routes;
push @{$r->namespaces}, 'Atlas::Backup::Web::Controller';
my $job = $r->route('/job')->to(controller => 'Backup::Job');
$job->get('')->to(action => 'collection');
for my $method (qw/get post put delete/) {
$job->$method('/:id')->to(action => "single_$method");
}
@moltar
moltar / ResultSet.pm
Last active December 12, 2015 00:28
dbic stash example
package App::Schema::ResultSet;
use strict;
use warnings;
use parent 'DBIx::Class::ResultSet';
__PACKAGE__->mk_group_accessors(inherited => qw/
stash
/);
@moltar
moltar / design.txt
Created January 28, 2013 23:18
help with class organization
App::ControllerBase::REST
App::ControllerBase::REST::API
App::ControllerBase::REST::GUI
App::Controller::API::V1::Manufacturer (currently inherits from App::ControllerBase::REST::API)
App::Controller::GUI::Manufacturer (currently inherits from App::ControllerBase::REST::GUI)
But also needs to inherit from a common ::Manufacturer class that actually implements most of the
shared functionality for fetching records from store. Currently done via Traits, but this is undesirable
due to __PACKGE__->config needing to be shared as well, which cannot be added via Traits.
@moltar
moltar / go.pl
Last active December 11, 2015 17:58
go go go
sub fetch : Chained('base') PathPart('') CaptureArgs(1) {
my ($self, $c, $company_id) = @_;
## $company_id is undef AFTER ->go
}
sub edit : Chained('fetch') PathPart('edit') Args(0) {
my ($self, $c) = @_;
## ...
@moltar
moltar / res.sql
Created January 21, 2013 04:22
Array of subqueries
SELECT `me`.`id`, `me`.`parent_id`, `me`.`created`, `me`.`updated`, `me`.`type`, `me`.`name`, `me`.`contact_id`
FROM (
SELECT `me`.`id`, `me`.`parent_id`, `me`.`created`, `me`.`updated`, `me`.`type`, `me`.`name`, `me`.`contact_id`
FROM `companies` `me`
WHERE `id` IN ( (
SELECT `me`.`company_id`
FROM `user_roles` `me`
WHERE `user_id` = 'ARRAY(0x7fbb6072f818)'
GROUP BY `company_id`
), (
@moltar
moltar / complex_join.sql
Created December 30, 2012 02:21
complex join
select *
from products p
left join product_custom_fields pcf1 on p.id = pcf1.product_id and pcf1.custom_field_id = 1
left join product_custom_fields pcf2 on p.id = pcf2.product_id and pcf2.custom_field_id = 3
@moltar
moltar / InlineHelp.pm
Created December 14, 2012 15:53
Bootstrap inline help
package SW::Web::Form::Component::InlineHelp;
use warnings;
use strict;
use HTML::FormHandler::Moose::Role;
=head2 inline_help
Inline help for a field.
@moltar
moltar / index.html
Created December 11, 2012 15:01
modx homepage output
<html>
<head>
<title>MODX Revolution - Home</title>
<base href="http://www.example.com/roman-modx-003/" />
</head>
<body>
</body>
</html>
@moltar
moltar / screener.js
Created December 6, 2012 18:47
screen 10 times
var url = 'http://www.google.com';
var prefix = 'CA';
var totalScreenshots = 10;
var screenshotDelay = 10; // seconds
var i = 0;
function makeScreenshot(url, filename, callback) {
var page = new WebPage();
page.settings.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0';
page.open(url, function(status) {