This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'fileutils' | |
def base_dir | |
File.dirname(File.expand_path(__FILE__)) | |
end | |
def read_matrix path, file | |
IO.readlines(File.join(path, file))\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def chunks a, size | |
chunk_count = a.size/size | |
chunk_count -= 1 if (a.size % size) == 0 | |
(0..chunk_count).map do |k| | |
a.slice(k*size, size) | |
end | |
end | |
chunks((1...100).to_a, 20).each { |x| puts x.inspect } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
require 'nokogiri' | |
doc = Nokogiri::HTML($stdin.read) | |
doc.search('//a[contains(@href, \'wiki\') or contains(@href, \'omsk\')]'). | |
each { |a| a.replace(doc.create_text_node(a.text)) } | |
doc.search('//sup').remove | |
puts doc.to_html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'fileutils' | |
raise 'This is ruby 1.9 script' if RUBY_VERSION =~ /^1\.8/ | |
def process file, simulate | |
raise 'Please point at movie file' if (File.extname(file) == '.srt' || !File.file?(file)) | |
name = File.basename(file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'uri' | |
magnet = URI.unescape ARGV.first | |
benc = "d10:magnet-uri#{magnet.size}:#{magnet}e" | |
exit(1) unless magnet =~ /xt=urn:btih:([a-zA-Z0-9]+)/ | |
File.open("meta-#{$1}.torrent", 'w') { |f| f.write benc } | |
#[[ "$1" =~ xt=urn:btih:([^&/]+) ]] || exit; | |
#echo "d10:magnet-uri${#1}:${1}e" > "meta-${BASH_REMATCH[1]}.torrent" | |
# vim: ft=ruby |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
VOL=$1 | |
if [ -z "$VOL" ] ; then | |
echo Usage: $0 vol | |
exit 1 | |
fi | |
LABEL="" | |
command -v e2label > /dev/null && [ -z "$LABEL" ] && LABEL=`e2label $VOL 2>/dev/null` | |
command -v dosfslabel > /dev/null && [ -z "$LABEL" ] && LABEL=`dosfslabel $VOL 2>/dev/null` | |
command -v ntfslabel > /dev/null && [ -z "$LABEL" ] && LABEL=`ntfslabel -f $VOL 2>/dev/null` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# automounting usb flash drives | |
ACTION=="add", SUBSYSTEM=="block", KERNEL=="[sh]d[b-z][0-9]*",RUN+="/usr/bin/pmount --sync --umask 000 %k %c" | |
ACTION=="remove", SUBSYSTEM=="block", KERNEL=="[sh]d[b-z][0-9]*",RUN+="/usr/bin/pumount /dev/%k" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
DJVUPATH=/usr/local/djvulibre/bin/ | |
djvuname=$1 | |
shift | |
for file in $* ; do | |
base=`echo $file | sed 's/\.[^\.]*$//'` | |
djvus="$djvus $base.djvu" | |
ppms="$ppms $base.ppm" | |
echo $base ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NAME=report | |
BIBROOT=$(PWD)/../.. | |
.PHONY: FORCE_MAKE | |
all: $(NAME).pdf | |
%.pdf: %.tex FORCE_MAKE | |
BIBINPUTS=$(BIBROOT) latexmk -pdf -dvi- -ps- $< |