Skip to content

Instantly share code, notes, and snippets.

View hinrik's full-sized avatar

Hinrik Örn Sigurðsson hinrik

View GitHub Profile
@hinrik
hinrik / lpeg_utf8_locale.lua
Created June 18, 2012 18:18 — forked from daurnimator/lpeg_unicode.lua
UTF-8 character classes for LPeG, using ICU4Lua
local lpeg = require 'lpeg'
local U = require 'icu.ustring'
local re = require 'icu.regex'
local utf8_codepoint
do
-- decode a two-byte UTF-8 sequence
local function f2 (s)
local c1, c2 = string.byte(s, 1, 2)
return c1 * 64 + c2 - 12416
require 'celluloid'
module CellMixin
include Celluloid # seems to have no effect
def foo
p Celluloid.current_actor # causes Celluloid::NotActorError
end
end
require 'celluloid'
class PluginOne
include Celluloid
def foo(args)
args[:first_added] = true
yield :continue
end
end
/home/hinrik/.rvm/gems/ruby-1.9.3-p0/gems/celluloid-0.9.0/lib/celluloid.rb:88:in `new': undefined local variable or method `allocate' for Connector:Module (NameError)
from lib/connector.rb:11:in `<main>'
##################
require 'celluloid/io'
module Connector
include Celluloid::IO
@hinrik
hinrik / bootstrap-modal-confirmation.js.coffee
Created February 29, 2012 18:10
Bootstrap modal confirmation dialog for Rails
# Replace Rails' confirmation dialog with a translatable Bootstrap modal dialog.
# Requires jQuery 1.7, Bootstrap, and i18n-js (https://github.com/fnando/i18n-js)
# Translation strings used: confirm.title, confirm.ok, confirm.cancel
$ ->
$.rails.confirm = (message) ->
$("#confirm_dialog > .modal-body").html("<p><i class='icon-warning-sign'></i> " + message + '</p>')
false
if $('[data-confirm]')
$('body').append("<div class='modal hide' id='confirm_dialog'><div class='modal-header'><a class='close' data-dismiss='modal'>×</a><h3>" + I18n.t('confirm.title') + "</h3></div><div class='modal-body'></div><div class='modal-footer'><a class='btn btn-primary'></a><a href='#' data-dismiss='modal' class='btn'>" + I18n.t('confirm.cancel') + "</a></div></div>")
$('[data-confirm]').each ->
@hinrik
hinrik / jquery_ui_confirm.js.coffee
Created February 25, 2012 17:08
A better Rails confirmation dialog
# Replace Rails' confirmation dialog with a translatable jQuery UI modal dialog.
# Requires i18n-js (https://github.com/fnando/i18n-js)
# Translation strings used: confirm.title, confirm.ok, confirm.cancel
$ ->
$.rails.confirm = (message) ->
$("#confirm_dialog").html('<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>' + message + '</p>')
false
if $('[data-confirm]')
$('body').append("<div id='confirm_dialog' title='" + I18n.t('confirm.title') + "'></div>")
diag_elem = $('#confirm_dialog')
@hinrik
hinrik / Grok.pm
Created January 5, 2012 18:20
A simple IRC bot plugin which answers grok queries
# You can run this like so (see https://metacpan.org/release/App-Pocoirc):
# $ pocoirc -itv -I /source/dir -n grokbot -s irc.freenode.net -j '#perl6' -a Connector -a 'Grok{"Channels": ["#perl6"]}
package Grok;
use strict;
use warnings FATAL => 'all';
use Carp qw(croak);
use App::Grok;
use App::Grok::Resource::Functions qw<func_fetch>;
12:01:34 <@Hinrik> this bug I'm trying to track down is just insane
12:02:49 <@Hinrik> as I remove more lines of code to make it as simple as possible, it's taking more runs of the program to trigger the bug
12:07:00 <@dngor> BinGOs: There are potential races with SIGCHLD. It can be delivered ahead of the pipe read that registers EOF.
12:07:31 <@Hinrik> sounds like something I'm experiencing
12:07:55 <@BinGOs> it wasn't so much the delivery order, but the fact that a forked process of the PWR process was holding the wheel 'open'
12:08:02 <@dngor> What happens if you add a sleep wherever you've been removing code?
12:09:49 <@BinGOs> was that for me ?
12:10:22 <@dngor> It was for Hinrik. He's seeing a race that goes away as he simplifies the test case.
12:10:33 <@BinGOs> Oh fine >:)
12:11:05 <@BinGOs> I think the forked process is holding the STDOUT/ERR filehandles open, so in my case the wheel doesn't close.
@hinrik
hinrik / devise.is.yml
Created November 6, 2011 01:03 — forked from sozialhelden/devise.is.yml
devise i18n translations for icelandic
---
is:
errors:
messages:
not_found: "Afsakið, síðan fannst ekki."
not_authorized: "Afsakið, auðkenning mistókst."
not_available: "Afsakið, þessa síða er niðri tímabundið."
not_existent: "Afsakið, þessi síða er ekki til."
devise:
confirmations:
from Munin munin@projects.linpro.no
date Thu, Oct 27, 2011 at 10:02 AM
subject Re: [Munin] #819: mailman plugin fails to start for the first time
#819: mailman plugin fails to start for the first time
---------------------+------------------------------------------------------
Reporter: Hinrik | Owner: nobody
Type: defect | Status: closed
Priority: normal | Milestone: Munin 1.4.3
Component: plugins | Version: 1.4.2