Skip to content

Instantly share code, notes, and snippets.

View Overbryd's full-sized avatar

Lukas Rieder Overbryd

View GitHub Profile
@Overbryd
Overbryd / rails_admin_without_devise.md
Created July 6, 2011 19:17 — forked from phoet/rails_admin_without_devise.rb
Using RailsAdmin without devise

Using rails_admin without devise

Having a buckload of code to authorize users on your application is something you may like or not. Speaking for myself I hate it. But I still love rails_admin, here's how you install it without devise. Thanks to phoet for providing the hints in the gist I have forked from.

Add RailsAdmin to your Gemfile

do NOT add devise

gem "rails_admin", :git => "git://github.com/sferik/rails_admin.git"

@Overbryd
Overbryd / js_steps.rb
Created July 7, 2011 22:19 — forked from kilaulena/js_steps.rb
Test capybara visibility
Then /^"([^"]+)" should not be visible(?: within "([^\"]*)")?$/ do |text, selector|
wait_until do
its_hidden = page.evaluate_script("$('#{selector}:contains(#{text})').is(':hidden');")
its_not_in_dom = page.evaluate_script("$('#{selector}:contains(#{text})').length == 0;")
(its_hidden || its_not_in_dom).should be_true
end
end
Then /^"([^"]+)" should be visible(?: within "([^\"]*)")?$/ do |text, selector|
wait_until do
@Overbryd
Overbryd / browser_time_step.md
Created July 7, 2011 22:25
Modify browser time using capybara

A step definition to modify the browser time when testing with cucumber/capybara

Works for all javascript function that use Date.getTime()

When /^the browser time passes for (\d+) minutes$/ do |minutes|
  # The browser needs to catch up a little bit
  sleep(0.5)
  page.execute_script(<<-JAVASCRIPT
    if (Date.prototype._getTime == undefined){

var _getTimeMinutesOffset = 0;

@Overbryd
Overbryd / mbp-on-a-express-card-ssd.md
Created July 8, 2011 19:57
MacBook Pro Core 2 Duo Late 2009 running on a ExpressCard/34 SSD

MacBook Pro Core 2 Duo Late 2009 running on a ExpressCard/34 SSD

My idea is to use my ExpressCard/34 slot with a SSD. Installing the system and applications on the SSD, leaving a large HDD for storage. So I bought a Wintec Filemate ExpressCard 96GB SSD. I've installed it in my ExpressCard slot and it works just fine. MacOSX recognizes it with it's SATA controller. The actual usable disk space shows up as 92.4 GB. Using the Disk Utility I have split the SSD into one 90 GB HFS+ partition and another 2.4 GB. I'll use the latter for swap.

Migrate the existing system

I didn't want to do a reinstall, as my system is just fine and I have no problems with it.

@Overbryd
Overbryd / rails_admin_and_globalize3.md
Created July 14, 2011 20:31
RailsAdmin and Globalize3

RailsAdmin and Globalize3

I have a project where I need translated content. Therefore I use globalize3, wich stores its translated attributes in a seperate table that belongs to the original model. And I use RailsAdmin for painless record management.

It took me some time to figure out how to get those working together, but eventually I found a solution that is non invasive and still ok to work with.

The translated model

In my case there is a Snippet class. It holds content for static pages or text passages on the website. There is a good README for globalize3 for installation instructions and documentation.

@Overbryd
Overbryd / anchors_on_the_fly.diff
Created July 20, 2011 07:52
InfoBubble set anchors / position on the fly
@@ -347,6 +347,20 @@ InfoBubble.prototype.setArrowStyle = function(style) {
InfoBubble.prototype['setArrowStyle'] =
InfoBubble.prototype.setArrowStyle;
+InfoBubble.prototype.setAnchor = function(anchor) {
+ if (anchor) {
+ this.set('anchor', anchor);
+ this.bindTo('anchorPoint', anchor);
+ this.bindTo('position', anchor);
+ } else if (this.get('anchor')) {

Ramendan

Ponyo Ramen

Find out more about the @ramendan event on their website http://ramendan.com.

Preparation

There is only a few days left, and here is how I prepare myself for Ramendan. First of all, I did some research to find restaurants in Berlin that serve Ramen.

@Overbryd
Overbryd / 0-testing-contact-forms-in-production.md
Created July 29, 2011 12:25
Testing contact forms in production

Testing contact forms in production

Not long time ago a client of mine had huge problems with his blog network. After a server move all the contact forms stopped working. His company was basically "out of business" for more than a week when one of his employees eventually found the error.

I have to state here, that I have an agreement that resolves responsiblity in this case. And I'm just lucky that my responsiblity ends right when I finished moving the servers. I had no clue about the existance of those contact forms, and I just tested the moved data, wordpress functionality, backups and directory permissions.

But I really feel bad that something like this happens on my servers. So I started to think about continous production testing.

@Overbryd
Overbryd / sqlite2sql.sh
Created October 25, 2011 11:20
Quickly create a sql dump from a sqlite3 file
#!/bin/bash
sqlite3 $1 .dump | sed -e '/sqlite_sequence/d' \
-e '/PRAGMA/d' \
-e '/BEGIN TRANSACTION/d' \
-e '/COMMIT/d' \
-e 's/"/`/g'
@Overbryd
Overbryd / tmproj-check.rb
Created November 21, 2011 10:24
Textmate Project check
#!/usr/bin/env ruby
require 'rubygems'
require 'plist'
require 'fileutils'
tmproj = ARGV[0] || "#{Dir.pwd}/#{Dir.pwd.split('/').last}.tmproj"
dir = ARGV.length >= 2 && ARGV[1] || File.dirname(tmproj)
properties = Plist::parse_xml(tmproj)
document = properties['documents'].shift