Skip to content

Instantly share code, notes, and snippets.

@AVGP
AVGP / test.rb
Created April 10, 2011 00:27
Just a small OOP-Hello-World-alike in Ruby
#!/usr/bin/ruby
class GrussAugust
attr_accessor :name
def initialize(name = "World")
@name = name
end
def greet
describe "IntelligentForwardings" do
describe " on unauthorized access" do
it "should redirect back to original page" do
user = Factory(:user)
visit edit_user_path(user)
#Redirect 1: To the login path
fill_in :email, :with => user.email
fill_in :password, :with => user.raw_password
click_button
#Redirect 2: Back to edit path
@AVGP
AVGP / matrix.css
Created January 30, 2012 00:25
matrix.js allows easy creation of an animated matrix-style background with JavaScript and CSS.
div.matrix {
color: #060;
position: absolute;
font-family: mono-space, sans-serif;
font-size: 10px;
top: 5px;
left: 10px;
z-index: 2;
width: 99%;
overflow: hidden;
@AVGP
AVGP / langdetect.class.php
Created February 7, 2012 19:09
A class to detect the language of a text (supports German/English but can be extended)
class LangDetect {
protected $dict = array(
'German' => array('ich','du','er','sie','es','wir','ihr','sie','der','die','das'),
'English' => array('i','you','he','she','it','we','us','they','this', 'the', 'a')
);
protected $sourceText;
public function __construct($text) {
$this->sourceText = $text;
}
describe "Users" do
describe "Sign up" do
describe "with invalid data" do
it "should not create user" do
lambda do
visit signup_path
fill_in "Name", :with => ""
fill_in "Email", :with => ""
fill_in "Password", :with => ""
fill_in "Confirm password", :with => ""
@AVGP
AVGP / rspec_user.rb
Created April 18, 2012 19:12
RSpec example
describe "Users" do
describe "Sign up" do
describe "with invalid data" do
it "should not create user" do
lambda do
visit signup_path
fill_in "Name", :with => ""
fill_in "Email", :with => ""
fill_in "Password", :with => ""
fill_in "Confirm password", :with => ""
@AVGP
AVGP / sane-pixma log
Created July 9, 2012 21:19
sane-pixma problem
[pixma] Discover response:
[pixma] 00000000:42 4a 4e 50 82 01 00 00 00 00 00 00 00 00 00 10
[pixma] 00000010:00 01 08 00 06 04 2c 9e fc 34 95 9d c0 a8 01 27
[pixma] Found scanner at ip address: 192.168.1.39
[pixma] bjnp_allocate_device(bjnp://192.168.1.39:8612)[pixma] Get scanner identity
[pixma] 00000000:42 4a 4e 50 02 30 00 00 00 00 00 00 00 00 00 00
[pixma] udp_command: Sending UDP command to 192.168.1.39:8612
[pixma] scanner identity:
[pixma] 00000000:42 4a 4e 50 82 30 00 00 00 00 00 00 00 00 00 67
[pixma] 00000010:00 67 4d 46 47 3a 43 61 6e 6f 6e 3b 43 4d 44 3a
@AVGP
AVGP / Message.java
Created September 21, 2012 15:13
Sample Java Library
package org.avgp.sample;
import org.avgp.sample.User;
import org.json.JSONString;
public class Message implements JSONString {
protected User sender;
protected User receipient;
protected String content;
@AVGP
AVGP / demo.rb
Created September 21, 2012 15:37
Ruby sample code to access the sample library
require "java"
require "json.jar"
require "Sample.jar"
alice = Java::OrgAvgpSample::User.new("Alice")
bob = Java::OrgAvgpSample::User.new("Bob")
puts alice.getId()
puts bob.getId()
message = Java::OrgAvgpSample::Message.new(alice, bob, "Hello Bob!")
@AVGP
AVGP / haml.template
Created December 10, 2012 21:41
Template comparison
%html
%body
%h1
Hello,
%= name