Skip to content

Instantly share code, notes, and snippets.

@NobbZ
NobbZ / steps.rb
Created November 12, 2011 11:45
These is the cucumber scenario and the corresponding steps that I have the problem with
# Scenario: Creating a product
# Given I am logged in with role "admin"
# When I follow "Admin-Panel"
# And I follow "new product"
# Then I should see "Please enter the new product data"
Given /^I am logged in with role "([^"]*)"$/ do |role|
Factory.create(:user, name: "root")
log_in "root"
end
@NobbZ
NobbZ / httpd.conf
Created July 24, 2012 19:14
Passenger problem
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.14/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.14
PassengerRuby /usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby
PassengerDefaultUser nobbz_de
RailsEnv production
@NobbZ
NobbZ / app.rb
Created November 7, 2012 21:26
Umlauts in Padrino
get :index do
@a = "ä"
render "index"
end
@NobbZ
NobbZ / app.rb
Created November 7, 2012 21:31
Configuring with Padrino
require "yaml"
class DvFa < Padrino::Application
register ScssInitializer
use ActiveRecord::ConnectionAdapters::ConnectionManagement
register Padrino::Rendering
register Padrino::Mailer
register Padrino::Helpers
enable :sessions
@NobbZ
NobbZ / application.html.haml
Created November 20, 2012 21:50
Padrino fragment caching in haml view
-cache "userbox_for_#{current_user.name}", :expires_in => 300
%img{:src => current_user.avatar, :class => "avatar"}
=self.current_user.name
@NobbZ
NobbZ / user.rb
Created December 3, 2012 19:07
Redirecting open-method for rspec test that I dont have to rely on availability of an API-Server
require 'nokogiri'
require 'open-uri'
def User < ActiveRecord::Base
def update_user
xml = Nokogiri::XML(open("http://example.com/api/#{pkey}/#{ukey}"))
self.name = xml.xpath('hordes/headers/owner/citizen').first['name']
self.avatar = xml.xpath('hordes/headers/owner/citizen').first['avatar']
self.last_update = Time.now
@NobbZ
NobbZ / SpriteFontProblem.cs
Created January 13, 2013 18:27
Can't load the spritefont, get exception: Could not load SpriteFont1 asset!
protected override void LoadContent ()
{
spriteBatch = new SpriteBatch (GraphicsDevice);
_spr_font = Content.Load<SpriteFont>("SpriteFont1");
}
$.ajax({
type: "GET",
url: $(this).attr('href') + "." + $(this).data("format"),
dataType: "html",
beforeSend: function() {
$("#dialog").dialog("open");
$("#dialog").dialog("option", "title", "Loading…");
$("#dialog").html("<div id=\"loadingbar\"></div>");
$("#dialog").dialog("option", "width", "200px");
return $("#loadingbar").progressbar({
@NobbZ
NobbZ / prime.lhs
Last active February 1, 2021 00:37
Primzahlen in Haskell
> module Main
> where
> import Data.List
Entnimmt einer Liste solange ein Element, bis das Quadrat des Elementes über-
geben an die Funktion f False ergibt.
> takeWhileSquare :: Num a => (a -> Bool) -> [a] -> [a]
> takeWhileSquare f (x:xs) | f (x^2) = x:takeWhileSquare f xs
> | otherwise = []
import java.io.FileReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.concurrent.Callable;
/**
* Solves Problem 8
*
* Find the greatest product of five consecutive digits in the 1000-digit number.
*