This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def guess(guessed, correct) | |
guessed_chars = guessed.split(//) | |
correct_chars = correct.split(//) | |
used_chars = correct_chars.dup | |
result = guessed_chars.map.with_index do |c, idx| | |
if correct_chars[idx] == c | |
used_chars.delete(c) | |
:correct | |
elsif used_chars.include?(c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <cctype> | |
#include <fstream> | |
#include <iostream> | |
#include <list> | |
using namespace std; | |
string random_word(string path) { | |
ifstream file(path); | |
ifstream fileForRead(path); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "#{File.dirname(__FILE__)}/../test_helper" | |
class CreateNewStoreTest < ActionController::IntegrationTest | |
def test_fail_to_manage_without_login | |
new_session do | tom | | |
tom.creates_new_store_and_activates_account | |
tom.logs_out | |
tom.attempts_to_manage_store_but_is_redirected_to_login | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
class NorwegianBankAccount | |
# Pass me any kind of string representing an account number | |
def initialize(str) | |
@numbers = str.gsub(/[^\d]/,'') | |
end | |
# Prettified output | |
def to_s | |
begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NorwegianBankAccount | |
# Pass me any kind of string representing an account number | |
def initialize(str) | |
@numbers = str.gsub(/[^\d]/,'') | |
end | |
# Prettified output | |
def to_s | |
begin | |
parts = @numbers.split(//) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def place_text(text) | |
x = 130 | |
y = 70 | |
message = text.tr("abcdefghijklmnopqrstuvwxyz","nopqrstuvwxyzabcdefghijklm") | |
parts = message.scan(/.{16}/) #rot13 | |
text_params = parts.map.with_index { |m, i| | |
y_pos = y + (i*10) | |
[i, x, y_pos] | |
"-fill orange -draw \"text #{x},#{y_pos} '#{m}'\"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
q1 = Question.new("What is the color of my eyes?", "blue") | |
q1.ask do |answer| | |
answer.correct { puts "Nice!" } | |
answer.incorrect { puts "LOL" } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
msg=`date +"Klokka er %H %M %S"` | |
say -v Nora $msg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math, sys | |
def utm_to_lat_lng(easting, northing, zone=32, northernHemisphere=True): | |
"""Converts from utm to lat_lng. Default zone is the one in which | |
Oslo and Akershus falls.""" | |
if not northernHemisphere: | |
northing = 10000000 - northing | |
a = 6378137 | |
e = 0.081819191 | |
e1sq = 0.006739497 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<HTML> | |
<HEAD> | |
</HEAD> | |
<BODY> | |
<TABLE WIDTH="100%" HEIGHT="100%" STYLE="BACKGROUND-COLOR:BLUE"> | |
<TR> | |
<TD VALIGN="MIDDLE" ALIGN="CENTER"> | |
YO | |
</TD> | |
</TR> |
NewerOlder