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
brew install sqlite pcre | |
git clone https://github.com/ralight/sqlite3-pcre.git | |
cd sqlite3-pcre | |
cc -shared -o pcre.so -I/usr/local/opt/pcre/include -fPIC -W -Werror pcre.c -L/usr/local/opt/pcre/lib -lpcre | |
echo ".load '`pwd`/pcre.so'" >> ~/.sqliterc |
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 | |
# frozen_string_literal: true | |
# Copyright (c) 2019 by Jan Friedrich <janfri26@gmail.com> | |
# License: Public Domain | |
module Ansicolor | |
@codes = {} |
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/python | |
from gimpfu import * | |
import os | |
def plugin_main(timg, tdrawable): | |
non_empty, x1, y1, x2, y2 = pdb.gimp_selection_bounds(timg) | |
if (non_empty): | |
os.system('echo {}, {}, {}, {} | xsel --clipboard'.format(x1, y1, x2 - x1, y2 - y1)) | |
else: | |
os.system('echo "no selection" | xsel --clipboard') |
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 | |
# encoding: utf-8 | |
require 'nokogiri' | |
query = ARGV.shift | |
ARGV.each do |fn| | |
doc = Nokogiri::XML(File.read(fn)) | |
puts doc.search(query) | |
end |
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
require 'fileutils' | |
require 'tempfile' | |
def File.changelines filename, &blk | |
temp = Tempfile.new('changelines') | |
File.foreach(filename) do |line| | |
line = blk.call(line) | |
temp.write(line) | |
end | |
temp.close |
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 | |
# -- encoding: utf-8 -- | |
module Astronomy | |
# Floor as function | |
def floor x | |
x.floor | |
end |
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
require 'csv' | |
require 'multi_exiftool' | |
tags = ["filename", "filesize", "make", "model", "orientation", "modifydate", "exposuretime", "fnumber", "exposureprogram", "iso", "createdate", "flash", "focallength", "quality", "canonflashmode", "continuousdrive", "focusmode", "lenstype", "cameratemperature", "cameratype", "canonimagetype", "canonfirmwareversion", "ownername", "cameraorientation", "focusdistanceupper", "focusdistancelower"] | |
# reading the data | |
reader = MultiExiftool::Reader.new | |
reader.tags = tags | |
reader.filenames = Dir['*.jpg'] | |
results = reader.read |
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 | |
if [ -d $1 ]; then | |
ls -l $1 | |
elif [ -f $1 ]; then | |
less -S $1 | |
fi |
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
Dir['**/*.html'].each do |filename| | |
puts filename | |
data = File.read(filename).encode('UTF-8') | |
File.open(filename, 'w') do |handle| | |
handle.write(data) | |
end | |
end; nil |
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 safe_assert_equal expected, actual | |
assert_equal expected, actual | |
rescue Exception=>e | |
puts e | |
end | |
class Testable < Test::Unit::TestCase | |
def test_something | |
safe_assert_equal 1, 2 | |
end |