Skip to content

Instantly share code, notes, and snippets.

@laurynas
laurynas / blur_detector
Created November 19, 2011 07:29 — forked from pceres/blur_detector
blurry photos detection
#! /bin/bash
#
# Author: Pasquale Ceres (pasquale_c@hotmail.com)
# License: GPL ver. 3
#
# Script originally developed for the
# "San Lorenzo Martire Caposele Church Records Digitalization Project"
#
# http://www.facebook.com/group.php?gid=188973755117&v=photos
@laurynas
laurynas / html_entity_decode_utf8.php
Created August 30, 2010 10:10
Convert escaped html to utf8
<?php
// Returns the utf string corresponding to the unicode value (from php.net, courtesy - romans@void.lv)
function code2utf($num)
{
if ($num < 128) return chr($num);
if ($num < 2048) return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
if ($num < 65536) return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
if ($num < 2097152) return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
return '';
@laurynas
laurynas / schedule_acpi_wakeup.sh
Created May 4, 2011 19:11
Schedule ACPI wakeup script
#!/bin/sh
#
# Schedule ACPI wakeup
#
# Author: Laurynas Butkus (laurynas.butkus at gmail.com)
#
# Some info on ACPI wakeup:
# http://smackerelofopinion.blogspot.com/2009/08/acpi-wake-alarm-bugs.html
#
@laurynas
laurynas / exif_sort.rb
Last active March 31, 2018 15:28
Adjust exif times to preserve sorting for Google Photos (if all photos are set to the same time)
gem 'mini_exiftool'
require 'mini_exiftool'
files = Dir["./*.JPG"].sort
t = Time.parse('2003-08-01 12:00:00 +0300')
files.each_with_index do |file, i|
photo = MiniExiftool.new file
photo.date_time_original = t + i
@laurynas
laurynas / float.rb
Created August 11, 2010 20:52
Convert decimal to degrees, minutes, seconds sexagesimal (used for GPS coordinates)
class Float
# Convert decimal to degrees, minutes, seconds sexagesimal
# (used for GPS coordinates)
def to_sexagesimal
degrees = abs.floor
x = (abs - degrees) * 60
minutes = x.floor
seconds = (((x - minutes) * 60) * 100).round.to_f / 100
sign = self < 0 ? '-' : ''
@laurynas
laurynas / result.json
Last active April 1, 2017 21:29
Language detector result
{
"data":{
"detections":[
{
"isReliable":true,
"confidence":39.45,
"language":"es"
},
{
"isReliable":false,
@laurynas
laurynas / audit.rake
Created March 25, 2017 10:07
Bundler security audit rake task
# run with `bundle:audit_and_notify`
require 'bundler/audit/task'
Bundler::Audit::Task.new
task default: 'bundle:audit'
namespace :bundle do
desc 'Audit and notify about gem vulnerabilities'
task audit_and_notify: :environment do
@laurynas
laurynas / gist:658139
Created November 1, 2010 13:12
Berlin (nuo Dončiaus)
Usualy we hang out in Kreuzberg, Friedrichshein and Prenzlauerberg areas as well as Mitte (center).
http://berlin.unlike.net/locations/39-Club-der-Visionaere
Club der Visionaere - an outside bar/club/place to hang out in Kreuzberg. It's IN one of the canals, on some sort of floating rafts.
Schlesische str., leading to the club is also worth noticing with one of the best indian food restaurants and lots of small watering holes. L.U.X .with live bands and Vendel with experimental poetry in german are my favourites:)
Bar 25 - another outside bar on the bank of river. 3 day parties or just to sit back and spend a warm afternoon. Also has circus, motel and restaurant.
http://berlin.unlike.net/locations/272-Bar-25
Hops & Barley brewery pub (Friedrichshain) - locally brewed beer in one of my favourite neighbourhoods. The whole area between Boxhander str and Simon Dach str. is dense with pubs, thai food restaurants and Kieze-kiosks (small shops with astounishing variety of beers).

> crystal test.cr

Undefined symbols for architecture x86_64:
  "std::string::_Rep::_M_destroy(std::allocator<char> const&)", referenced from:
      Hello::hello(char const*) in hello.a(libhello.o)
  "std::string::_Rep::_S_empty_rep_storage", referenced from:
      Hello::hello(char const*) in hello.a(libhello.o)
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)", referenced from:
      Hello::hello(char const*) in hello.a(libhello.o)
@laurynas
laurynas / watermark.rb
Created November 20, 2010 19:27
Paperclip Watermark processor
# Based on
# https://github.com/ng/paperclip-watermarking-app/blob/master/lib/paperclip_processors/watermark.rb
# Modified by Laurynas Butkus
module Paperclip
class Watermark < Processor
# Handles watermarking of images that are uploaded.
attr_accessor :format, :whiny, :watermark_path, :position
def initialize file, options = {}, attachment = nil