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
// markRepeated binding works on table cell (TD) elements. | |
// | |
// If binding value is true, it will check if the current table cell | |
// has the same text as the previous one to its left. | |
// If so, the current table cell will be assigned the CSS class "repeated". | |
// | |
// Note: binding should be positioned after any "text" or "css" binding, in | |
// order for text and css to | |
// | |
// Example: |
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
# encoding: utf-8 | |
require 'mechanize' | |
class GuleSider | |
class NotLoggedInError < StandardError; end | |
def self.log_in(username, password) | |
agent = Mechanize.new | |
agent.ca_file = '/usr/lib/ssl/certs/ca-certificates.crt' |
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
# encoding: utf-8 | |
require 'mechanize' | |
class Ruter | |
class NotLoggedInError < StandardError; end | |
def self.log_in(username, password) | |
agent = Mechanize.new | |
agent.ca_file = '/usr/lib/ssl/certs/ca-certificates.crt' |
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
data Cell = X | O | N deriving (Show, Eq) | |
board = [X,X,O, | |
O,X,X, | |
X,O,O] | |
winner [a,b,c, | |
d,e,f, | |
g,h,i] | isWinner X = X | |
| isWinner O = O |
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
// Scenario: Some event handler is blocking events (event.preventDefault()) that shouldn't be blocked, i.e. because it binds to document instead of a more specific element | |
// 1) Place this before all other JavaScript | |
var originalPreventDefault = Event.prototype.preventDefault; | |
Event.prototype.preventDefault = function () { | |
// Lookup specific event you're expecting, i.e. pressing space | |
if (this instanceof KeyboardEvent && this.keyCode === 32) { | |
// This will log an error with full stack trace | |
make_error_to_see_stacktrace |
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
main = interact $ show . length . words |
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 System.Environment | |
import Data.List | |
main = do | |
args <- getArgs | |
case args of | |
[word] -> interact $ unlines . filter (isInfixOf word) . lines | |
_ -> putStrLn "No word to match against specified!" |
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
number = rand(10).to_i | |
puts "Guess the number!" | |
puts "Wrong answer!" until (gets || '').strip.to_i == number | |
puts "Correct, the number was #{number}." |
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
abstract class Object<T> | |
{ | |
private readonly List<T> _properties; | |
protected abstract string FormatString { get; } | |
protected Object(params T[] properties) | |
{ | |
_properties = new List<T>(properties); | |
} |
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
var module = {}; | |
module.namespace = function recurse(path, base) { | |
base = base || this; | |
if (!path) { | |
return base; | |
} | |
var name = path.substring(0, path.indexOf('.')) || path; |