Skip to content

Instantly share code, notes, and snippets.

module Kernel
# usage:
# require 'irb_drop'
# ...do some stuff...
# irb_drop(binding) # irb will open here with the current local variables
# ...continue doing stuff...
def irb_drop(context=nil, *argv)
require 'irb'
require 'pp'
require 'yaml'
require 'openid'
require 'openid/consumer'
require "openid/store/filesystem"
require 'openid/extensions/sreg'
class LoginController < ApplicationController
def create
response = openid_consumer.begin(params[:openid_url])
sregreq = ::OpenID::SReg::Request.new
sregreq.request_fields(["email"], true)
@rolfb
rolfb / config.ru
Created March 16, 2011 16:45
Cloudapp plugin for inline images with heroku as proxy
require 'open-uri'
run lambda { |env|
request = Rack::Request.new(env)
clly_url = request.query_string.gsub("#.png", "")
clly_content = clly_url + "/content"
begin
clly_image = open(clly_content)
[302, {'Location'=> clly_content, 'Content-Type' => 'text/html'}, []]
@rolfb
rolfb / gist:1869574
Created February 20, 2012 15:00 — forked from TorD/gist:1869279
def get_field_type_for(kind)
types = {
"nr" => "number",
"tlf" => "number",
"telefon" => "number",
"nummer" => "number",
"merknad" => "text",
"notater" => "text",
"anmerkning" => "text"
@rolfb
rolfb / utf8_test.rb
Last active December 10, 2015 18:28
Example WriteExcel script with UTF-8 strings which doesn't work with jruby-1.7.2 Before running do "gem install writeexcel"
# encoding: utf-8
require 'writeexcel'
string_utf8 = "øæaaø"
string_no_utf8 = "abc"
excel = WriteExcel.new("out.xls")
ws = excel.add_worksheet
ws.write("A1", string_utf8)
num #instances #bytes class name
----------------------------------------------
1: 2928092 281096832 org.apache.xmlbeans.impl.store.Xobj$AttrXobj
2: 2626335 252128160 org.apache.xmlbeans.impl.store.Xobj$ElementXobj
3: 1511986 103759936 [C
4: 88030 58879440 [B
5: 1070984 42839360 java.util.TreeMap$Entry
6: 1507961 36191064 java.lang.String
7: 1016018 32512576 org.apache.poi.xssf.usermodel.XSSFCell
@rolfb
rolfb / Android Font Issues - The Fix.xml
Last active October 22, 2020 13:25
Android Font Issues
<TextView
android:layout_width="54dp"
android:layout_height="54dp"
android:fontFamily="@font/gjenbrowntt_regular"
android:text="1"
android:textSize="24sp"
android:includeFontPadding="false"
android:firstBaselineToTopHeight="24sp"
android:textColor="@color/black" android:background="@drawable/background_rounded_corners"
android:textSize="24sp" android:gravity="center"