I hereby claim:
- I am savonarola on github.
- I am savonarola (https://keybase.io/savonarola) on keybase.
- I have a public key ASAQ2_Bp3Kt9GRSfwyhYdzjSDXLtugV6f1loBeE1kBbwfQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
defmodule FindIndex do | |
def find_index(list, pred, index \\ 0) | |
def find_index([], _pred, _index), do: :notfound | |
def find_index([el | rest], pred, index) do | |
case pred.(el) do | |
{:ok, value} -> {:ok, value, index} | |
:notfound -> find_index(rest, pred, index + 1) | |
end |
defmodule ParseResult do | |
@type arg_value :: term | |
@type flag_value :: boolean | pos_integer | |
@type option_value :: term | [term] | |
@type t :: %ParseResult{ | |
args: %{atom => arg_value}, | |
flags: %{atom => flag_value}, | |
options: %{atom => option_value}, | |
unknown: [String.t] |
pub struct Batcher<T> { | |
iter: T, | |
batch_size: usize, | |
finished: bool | |
} | |
impl<T> Batcher<T> where T: Iterator { | |
pub fn new(iter: T, batch_size: usize) -> Batcher<T>{ | |
Batcher{ | |
iter: iter, |
use std::{thread, time}; | |
fn watchdog<F, T>(f: F) -> () | |
where | |
F: Send + 'static + Fn() -> T, | |
T: Send + 'static | |
{ | |
thread::spawn(move||{ | |
loop { | |
let handle = thread::spawn(f); |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 51, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ |
import System.Environment | |
import System.IO | |
import System.IO.Error | |
import Control.Exception | |
withFiles :: [FilePath] -> IOMode -> ([Handle] -> IO a) -> IO a | |
withFiles paths mode f = withFiles' paths mode f [] | |
withFiles' [] mode f handles = do | |
result <- f handles |
#!/usr/bin/perl | |
# | |
# Install "Perl" package via DSM Web UI | |
# | |
# Add this script to crontab: | |
# */5 * * * * root /usr/bin/perl /volume1/synology/scripts/reindex.pl /volume1/synology/download >> /root/reindex.log | |
# | |
# Then restart crond (DSM5): | |
# /usr/syno/sbin/synoservicectl --restart crond |
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
my @ps_output = `ps ax -o pid,ppid,rss,command`; | |
shift @ps_output; | |
my %processes = map{ $_->[0], { pid => $_->[0], ppid => $_->[1], rss => $_->[2], command => $_->[3] } } map { [split(/\s+/, $_, 4)] } map { chomp; s/^\s+//; $_ } @ps_output; |
#!/usr/bin/env ruby | |
require 'nokogiri' | |
if ARGV.size < 2 | |
abort "Usage:\n\n #{$0} VK_MUSIC_PAGE.HTML TARGET_PATH" | |
end | |
doc = Nokogiri::HTML::Document.parse(File.read(ARGV[0])) | |
target = ARGV[1] |