1. %title: Miscelaneous Debris %author: fREW Schmidt %date: 2015-03-19
-> Outline <-
Docker
Tools
zsh, vi, awesome, smaller stuff
DBIx::Class
DBIx::Class::Helpers
drinkup
Dogma
Simplicity, Async %title: µDocker %author: fREW Schmidt %date: 2015-03-19
-> Docker: Agenda <-
What even is this thing
Brief History
In the small
In the large
Misc
Example / Demo
-> What even is this <-
Process grouping
Process isolation
sorta like crappy virtualization
docker makes this accessible and even fun
-> History <-
chroot
jails See history here
cgroups
LXC
Docker / LMCTFY wow lots of containers
-> In the small <-
Dockerfiles
images
layered
a surprising amount of options (AUFS, OverlayFS, lvm, BTRFS, interesting info)
docker {build,run,stop,rm,rmi,images,ps}
awesome for out-of-the-box dev
(like databases or other deps like that)
haven't had much luck with own code in dev
-f probably helps
no silver bullet for repeatability
esp when initially containerizing
carton
-> In the "large" <-
You'll really want a registry
docker push mapapp.registry.my.domain.com:5000
docker pull mapapp.registry.my.domain.com:5000
run.sh (sortav a bummer)
(this is where the moving parts are)
2. -> Misc <-
pause / unpause - I use this to save battery
sysdig - great observability tool w/ container support
linking containers
complicated but powerful, "safe", and composible
I've only used it for network access
testing
ironically, this can be frustratingly hard
unless you already have CI
mock linking helps
each needed port and volume is a moving part
basically means that image is "incomplete"
-> DEMOS <-
Dockerfile
build it!
run it!
sysdig it!
tail logs! %title: µTools %author: fREW Schmidt %date: 2015-03-19
-> Tools <-
vim
zsh
awesome
wrappers
remote stuff
-> vim Core <-
know your text objects (w, iw, aw, ip, i()
these are actually pluggable (ie, i_, ife)
quickfix
(see unimpaired for fast usage)
I use it daily with Fugitive
gv
-> vim plugins <-
repeat
surround
fugitive
commentary
ultisnips (needs python)
neocomplete (needs lua)
ctrlp
dispatch/projectionist(/haystack)
synastic
matchmaker
unimpaired
Custom textobjs: textobj-between, textobj-underscore, textobj-lastpat, textobj-entire
visual-star-search
-> zsh <-
Cool prompt
Selected options
AUTO_CD
AUTO_PUSHD
3. NO_CASE_GLOB
{PUSHD,HIST}_IGNORE{_ALL,}_DUPS
APPEND_HISTORY
EXTENDED_HISTORY
HIST_FIND_NO_DUPS
HIST_IGNORE_SPACE
SHARE_HISTORY
-> zsh <-
Global aliases
alias -g G="| grep"
alias -g L="| less -F"
alias -g UP="@{upstream}"
alias -g PT="2>&1"
alias -g PTV="2>&1 | vim -"
-> awesome <-
xmonad - haskell
weather
win+u
-> wrappers <-
(git)[https://github.com/frioux/dotfiles/blob/6cee48b27216945d79fc288d1fb2b8f8b0eaafa4/bin/wrap-git]
(tar)[https://github.com/frioux/dotfiles/blob/6cee48b27216945d79fc288d1fb2b8f8b0eaafa4/bin/wrap-tar]
(unzip)[https://github.com/frioux/dotfiles/blob/6cee48b27216945d79fc288d1fb2b8f8b0eaafa4/bin/replace-unzip]
-> remote stuff <-
(corn)[https://github.com/frioux/corn/blob/master/app.psgi]
Docker (Linode vs OVH)
gitolite %title: µDBIC %author: fREW Schmidt %date: 2015-03-19
-> DBIC <-
This is the smallest of overviews
I'm sorta bored of doing DBIC talks
... but feel free to ask questions afterwards!
-> DBIC parts <-
Schema
set of tables
ResultSource
table (go away "actually" guy)
ResultSet
query
Result
Row
-> Relationship Types <-
has_many
other rows have references to my PK
belongs_to
I have a references to some other PK
has_one
4. single special case of has_many
might_have
zero/one special case of has_many
many_to_many
for join tables (not a real rel)
-> THAT'S ENOUGH <-
-> QUESTIONS <-
%title: µDBIx::Class::Helpers %author: fREW Schmidt %date: 2015-03-19
-> DBIx::Class::Helpers <-
A bunch of handy little components I made for DBIC
This talk will go over some of my favorites
There may be more useful ones you should look at, so take a peek
-> ::ResultSet::CorrelateRelationship <-
$cd_rs
->correlate('tracks')
->related_resultset('plays')
->count_rs
Can be used in lots of places like order_by or columns
See especially later slide, ::Row::ProxyResultSetMethod
-> ::ResultSet::DateMethods1 <-
$rs->search(undef, {
columns => {
count => '*',
year => $rs->dt_SQL_pluck({ -ident => '.start' }, 'year'),
month => $rs->dt_SQL_pluck({ -ident => '.start' }, 'month'),
},
group_by => [
$rs->dt_SQL_pluck({ -ident => '.start' }, 'year'),
$rs->dt_SQL_pluck({ -ident => '.start' }, 'month'),
],
});
Simplifies date math for your brain (before/after vs </>)
Converts DT objects for your DB
Extracts Date Parts
Adds dates together
No subtraction yet (super varied, dubious usefulness)
-> ::ResultSet::IgnoreWantarray <-
my @values = paginate($rs->search(...))
Fixes that bug
-> ::ResultSet::SearchOr <-
sub not_passed ($self) {
$self->search_or([$self->failed, $self->untested])
}
Sortav a ghetto union
5. -> ::ResultSet::SetOperations <-
$rs->union($rs2)
->intersect($rs3)
->except($rs4)
Not a ghetto union
The weirdest feature not to be in core
-> DBIx::Class::Candy <-
package MyApp::Schema::Result::Artist;
use DBIx::Class::Candy -autotable => v1;
primary_column id => {
data_type => 'int',
is_auto_increment => 1,
};
column name => {
data_type => 'varchar',
size => 25,
is_nullable => 1,
};
has_many albums => 'A::Schema::Result::Album', 'artist_id';
1;
Great for slides!
(All the following slides assume it)
-> ::Row::OnColumnChange <-
before_column_change amount => {
method => 'bank_transfer',
txn_wrap => 1,
};
sub bank_transfer ($self, $old, $new) {
my $delta = abs($old - $new);
if ($old < $new) {
Bank->subtract($delta)
} else {
Bank->add($delta)
}
}
Just a really useful generic helper ~~ a trigger
-> ::Row::ProxyResultSet{Method,Update} <-
RS Method
sub with_friend_count {
shift->search(undef, {
'+columns' => {
friend_count =>
$self->correlate('friends')
->count_rs
->as_query
},
})
}
In Row
proxy_resultset_method 'friend_count';
6. Access already selected data
Or fetch if it wasn't, and cache it!
(Considering making this warn)
-> QUESTIONS? <-
(you can ask about DBIx::Class::DeploymentHandler if you want) %title: µdrinkup %author: fREW Schmidt %date: 2015-03-
19
-> drinkup <-
Just a thing I made a while ago that's fun to talk about
Was recently asked about cool stuff I'd made
Thankful that one of those things is OSS
List of cool things in no particular order
-> Cool Thing É‘ <-
Cute URLs:
/drinks/ /drinks/data/1 /drinks/find_by_name?name=Mojito /drinks/search_by_name?name=*tini
/drinks/with_some_ingredients?ingredient_id=1&ingredient_id=2 /drinks/with_only_ingredients?ingredient_id=1
/drinks/without_ingredients?ingredient_id=1
Pretty old hat these days I guess...
-> Cool Thing β <-
Nice web backend
Skeleton: https://github.com/frioux/drinkup/blob/master/lib/DU/WebApp.pm
Guts: https://github.com/frioux/drinkup/tree/master/lib/DU/WebApp/Resource
Vaguely the inspiration for Tim's WebAPI::DBIC, (which does much more I promise)
-> Cool Thing ɣ <-
Ingredients are all automatically interchangeable
Matpath!
Too bad taxonomies are the worst
-> Cool Thing δ <-
Efficient set based searching https://github.com/frioux/drinkup/blob/master/lib/DU/Schema/ResultSet/Drink.pm#L164
Fundamentally based on:
What drinks can be made from the ingredients in a given RS
Plus a range of other ingredients
eg if I want to go to the store but only buy a few things:
what drinks can I make if I am ok with buying 1 to 3 ingredients
$drinks->ineq($inventory_rs, 1, 3) %title: µDogma %author: fREW Schmidt %date: 2015-03-19
-> µDogma: Agenda <-
Simplicity
Async linked, not sure why
-> Simplicity <-
DBIx::Class is great
7. Catalyst is great
ExtJS is great
But sometimes, they are all overkill
-> Simplicity <-
project runs only one DB query → DBIx::Class is overkill
project with only 5 endpoints → Catalyst is overkill
etc
-> Simplicity <-
Big frameworks can make you feel more productive
... while making you less productive
... don't use them for everything!
-> Simplicity <-
Hard to define
Examples: Proof, LNM
µServices can help here
(forking (probably) helps RAM usage)
-> Right tool for the job <-
Vanilla DBI (or maybe at least DBIx::Connector) is fine!
Small web frameworks are fine!
Again, µServices can be of benefit here
... use what works in each context
-> Async <-
async is simpler than polling
(I think?)
async can definitely add complexity
Hide it with OO!
Async requires a lot of mental reconfiguration
... but that reconfiguration more accurately matches the real world
-> Async vs Sync <-
Sync
writer → DB → while(1)
Problems:
sleep 1
Write contention
Async
writer → MQ → reader
SOLUTIONS!
Look ma, no sleep!
MQ's tend to be able to handle heavy writes better
8. -> Futures <-
Callbacks sub { ... sub { ... sub { ... } } }
Futures my $f = $http->do_request(...) ->then(sub { ... }) ->then(sub { ... }) ->then(sub { ... })
-> Futures 2 <-
Callbacks are the MOST BASIC and will likely need to be around forever
everything else is an abstraction of these
Futures
represent a single outstanding action from a single direction
you have to store them
There are other abstractions that barely exist in perl
Check this out for a really great overview
-> The End <-