Skip to content

Instantly share code, notes, and snippets.

View rarous's full-sized avatar
💭
I may be slow to respond.

Aleš Roubíček rarous

💭
I may be slow to respond.
View GitHub Profile
var Game = function(score) {
this.score = score || [0,0];
};
Game.prototype.isDeuce = function() {
return this.score[0] == 40
&& this.score[1] == 40;
};
Game.prototype.lost = function () {
@rarous
rarous / gist:da7282c8a3305490983e
Last active August 29, 2015 14:06
String Calculator (Clojure)
(use 'speclj.core)
(require '[clojure.string :as str])
(defn- assert-positives [s]
(if-let [neg (re-seq #"-\d+" s)]
(throw (Exception. (str "Unexpected negative numbers: " (str/join ", " neg))))))
(defn- parse-input [s]
(if-let [[[_ sep text]] (re-seq #"//(.+)\n(.+)" s)]
[text sep]
:dependencies [[org.clojure/clojure "1.7.0-alpha2"]
[http-kit "2.1.18"]
[enlive "1.1.5"]
[environ "0.5.0"]
[com.domkm/silk "0.0.1-SNAPSHOT" :exclusions [org.clojure/clojure]]
[prone "0.6.0"]
[ring "1.3.0"]
[ring/ring-defaults "0.1.0"]
[ring-basic-authentication "1.0.5"]
SelectableItem matchingItem = getItems().stream().
filter(x -> x.getTitle().equals(title)).
findFirst().
orElseGet(() -> SelectableItem.EMPTY);
@rarous
rarous / bmi.clj
Last active August 29, 2015 14:05
(ns body-mass-index.core)
(defn calc [mass height]
(/ mass (* height height)))
(defn category [bmi]
(cond
(> bmi 30) ::obese
(> bmi 25) ::overweight
(< bmi 18.5) ::underweight
@rarous
rarous / bmi.php
Last active August 29, 2015 14:05
<?php namespace BodyMassIndex;
abstract class Thresholds {
const UNDERWEIGHT = 18.5;
const OVERWEIGHT = 25;
const OBESE = 30;
}
/**
* Calculates Body Mass Index.
#define LOG
using System;
using System.IO;
using System.Net;
using System.Xml;
using System.Text;
using System.Threading;
using System.Net.Sockets;
using System.Collections;
modifier = <'.'> (title|classes|styles|align)*
title = <'('> #"[^\)]*" <')'>
classes = <'['> ident? (<ws> ident)* <']'>
styles = <'{'> declaration* <'}'>
align = halign|valign|halign valign|valign halign|ε
declaration = property <":" ows> value <";"?>
ws = #"\s+"
ows = #"\s*"
ident = #"#?-?[_a-zA-Z][_a-zA-Z0-9-]*"
property = #"-?[a-zA-Z][_a-zA-Z0-9-]*"
@rarous
rarous / plugin.edn
Last active August 29, 2015 14:00
My user.keymap
{:desc "TODO",
:version "0.0.1",
:source "TODO",
:behaviors "user.behaviors",
;; Do not edit - :dependencies are auto-generated
:dependencies {
"Bracket glow" "0.0.2",
"CSS" "0.0.6",
"Clojure" "0.1.1",
"Emmet" "0.0.2",
@rarous
rarous / ant.js
Created April 11, 2014 08:26
#6 coding dojo
var white = 'x';
var black = 'y';
var north = {o:"N"};
var east = {o:"E"};
var south = {o:"S"};
var west = {o:"W"};
north.right = function() { return east; }
north.left = function() { return west; }
east.right = function() { return south;}