Skip to content

Instantly share code, notes, and snippets.

@laurynas
laurynas / batch_result.json
Created October 16, 2012 12:23
detectlanguage.com batch request result example
{
"data":{
"detections":[
[
{
"language":"es",
"isReliable":false,
"confidence":0.4517133956386293
},
{
@laurynas
laurynas / extract_ip_from_log.sh
Created March 8, 2012 13:48
Extract IPs while tailing log file
tail -f log/development.log | grep "[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" | awk 'match($0,/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/){ print substr($0, RSTART, RLENGTH) }'
@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 / result.json
Last active April 1, 2017 21:29
Language detector result
{
"data":{
"detections":[
{
"isReliable":true,
"confidence":39.45,
"language":"es"
},
{
"isReliable":false,
#!/bin/sh
#
MONIK_LISTENER=YOURID
MONIK_TOKEN=YOURTOKEN
MESSAGE=$@
/opt/monik/monik -c log -l $MONIK_LISTENER -t $MONIK_TOKEN -m "$MESSAGE"
@laurynas
laurynas / schedule_wakeup_and_halt.sh
Created May 4, 2011 19:38
Execute ACPI wakeup schedule and halt
#!/bin/sh
#
SCHEDULE_CMD="/opt/schedule_acpi_wakeup/schedule_acpi_wakeup.sh"
if [ ! -x $SCHEDULE_CMD ]; then
echo "$SCHEDULE_CMD not found"
exit 1
fi
@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 / vodafone360_to_vcf.rb
Created January 18, 2011 20:18
Convert vodafone360 contacts html to VCF
# Convert vodafone360 contacts html to VCF
require 'rubygems'
gem 'nokogiri'
gem 'vpim'
require 'nokogiri'
require 'vpim/vcard'
Dir.glob("html/*.html").each do |file|
doc = Nokogiri.parse(File.read(file))
module RenderRemoteHelper
# Generate javascript for rendering remote resource
# * +url+ - resource url
# * +view+ - element id to update
def render_remote(url, view = 'remote', options = {})
options[:update] = view
options[:url] = url
options[:method] = :get
render :inline => %{<span id="#{view}"><p>Loading...</p><script
@laurynas
laurynas / form_builder_multi_locale_patch.rb
Created January 14, 2011 13:33
Multi locale field builder
# depends on i18n_multi_locales_form plugin
# rails plugin install https://github.com/ZenCocoon/i18n_multi_locales_form.git
module MultiLocaleFieldBuilder
def multi_locale_field(method, opts = {})
opts = {
:type => :text_field
}.merge(opts)
type = opts.delete(:type)