Skip to content

Instantly share code, notes, and snippets.

(defn throttle [c ms]
(let [c' (chan)]
(go
(while true
(>! c' (<! c))
(<! (timeout ms))))
c'))
(import '[java.util.concurrent RejectedExecutionHandler]))
(def block-policy
"When the threadpool is maxed out, submit the runnable to the pool blockingly."
(reify RejectedExecutionHandler
(rejectedExecution [this runnable thread-pool]
(try
(.put (.getQueue thread-pool) runnable)
(catch InterruptedException e
(.interrupt (.currentThread Thread)))))))
@brunoV
brunoV / Array.pm
Created January 17, 2009 19:28
Patches that implement sort and sort_in_place for MX::AttributeHelpers::MethodProviders::(List,Array)
--- ./Array.pm 2009/01/17 16:37:01 1.1
+++ ./Array.pm 2009/01/17 20:16:42
@@ -136,6 +136,18 @@
}
}
+sub sort_in_place : method {
+ my ($attr, $reader, $writer) = @_;
+ return sub {
+ my ($instance, $predicate) = @_;
my $protease = Bio::Protease->new(specificity => 'trypsin');
my $nobel_prize_winning_specificity_model = sub {
my $peptide = shift;
# decide whether to cut $peptide or not
}
my $protease = Bio::Protease->new(
specificity => $nobel_prize_winning_specificity_model;
);
my $cutting_pattern = Bio::Tools::SeqPattern->new(
-SEQ => 'XXXW[^P]RSX', -TYPE => 'Amino'
);
my $protease = Bio::Protease->new(specificity => $cutting_pattern);
my @products = $protease->digest('MAAEEELLKKVVIKP');
my @cut_sites = $protease->cleavage_sites($seq);
my @products = $protease->cut($seq, $cut_sites[rand @cut_sites]);
my $watcher = POE::Component::DirWatch::Object::NewFile->new(
directory => '/home/brunov/translate',
callback => \&translate,
);
sub translate { ... }
$poe_kernel->run();