Skip to content

Instantly share code, notes, and snippets.

use Mojolicious::Lite;
use Mojo::EventEmitter;
helper events => sub { state $events = Mojo::EventEmitter->new };
get '/' => 'chat';
websocket '/channel' => sub {
my $c = shift;
@potch
potch / style.js
Last active August 29, 2015 14:12
2015 JavaScript Style Guide
// Bad
"Your Framework Sucks."
// Bad
"Browserify? Have you heard about WebPack?"
// Bad
"Ember vs Angular: 10 Things You Should Know"
@mikecharles
mikecharles / activate.csh
Last active October 31, 2021 19:38
Activate and deactivate a conda environment in C Shell
#!/bin/csh
# Get the name of this script
if ( $?_ ) then
# With tcsh the name of the file being sourced is available in
# $_.
set script_name = `basename $_`
else
# Fall back to $0 which, sometimes, will be the name of the
anonymous
anonymous / Storable.pm
Created June 10, 2014 21:24
package Minion::Backend::Storable;
use Mojo::Base 'Minion::Backend';
use Sys::Hostname 'hostname';
use Time::HiRes 'time';
sub new { shift->SUPER::new(file => shift) }
sub register_worker {
my $guard = shift->_guard;
#!/usr/bin/env perl
=pod
Using Mojolicious and L<MCE> for forked independant workers,
communicating via L<MCE::Queue>.
Run this with C<./mce_mojolicious.pl daemon>, then visit C<http://localhost:3000>.
There are 4 queues:
@jberger
jberger / URLQueue.pl
Last active November 10, 2022 20:58
Modularization of my answer from SO on URL queuing for non-blocking ua
#!/usr/bin/env perl
package Mojo::URLQueue;
use Mojo::Base 'Mojo::EventEmitter';
use Mojo::UserAgent;
has queue => sub { [] };
has ua => sub { Mojo::UserAgent->new(max_redirects => 5) };
has concurrency => 4;
@genehack
genehack / applescript
Created November 5, 2012 05:51
Applescript and shell code for Skotch.app
on check_file(filename)
tell application "Finder"
if exists filename then
return "yes"
else
return "no"
end if
end tell
end check_file
AddHandler cgi-script .pl
Options +ExecCGI
IndexIgnore *
DirectoryIndex script.pl
RewriteEngine on