Skip to content

Instantly share code, notes, and snippets.

def create
@admin = Admin.find_by_provider_and_uid(auth["provider"], auth["uid"])
if @admin and @admin.approved
session[:user_id] = @admin.id
flash[:success] = "Hej #{@admin.name} du er nu logget ind"
redirect_to session[:return_to] || manage_golds_path
else
unless @admin.present?
new_admin = Admin.create(:name => auth["info"]["name"], :provider => auth["provider"], :uid => auth["uid"])
BankAccountMailer.admin_created(new_admin).deliver
@mkrogh
mkrogh / fileless_file.rb
Created March 3, 2012 00:51
Carrierwave proccess zipfile contents
#A nice little carrierwave IO faker class
class FilelessFile < StringIO
attr_accessor :original_filename
end
@mkrogh
mkrogh / included.js
Created January 18, 2012 18:20
Titanium ImageView path problem
// located in: /js/include.js
// this works just fine:
// The leftImage is shown
var table = Ti.UI.createTableView({
data: [{leftImage: '/icons/test.png', "title": "test"}]
});
//This does not work:
// neither does image: '../icons/test.png'"
@mkrogh
mkrogh / ruby-1.8.7.rb
Created January 12, 2012 21:32
rubyzip + open-uri (1.8.7 and 1.9.2)
require "open-uri"
require "zip/zip"
img_url = "http://jquery.com/demo/thickbox/images/plant4.jpg"
img_name = "plant4.jpg"
#this works in 1.8.7, but not in 1.9.2:
Zip::ZipFile.open("test.zip", Zip::ZipFile::CREATE) do |zipfile|
img = open(img_url)
zipfile.add(img_name, img.path)
@mkrogh
mkrogh / gist:1220514
Created September 15, 2011 21:22
Markdown syntax oddity

One would suspect that the following markdown code would yield first an un-ordered list followed by an ordered list.

  • An item
  • Another item
  • Just an extra item to make it interesting
  1. First you would expect this ordered list item to be a separate list due to the double linebreak
  2. Secondly you would not expect the above item to be wrapped in a paragraph tag.