Skip to content

Instantly share code, notes, and snippets.

View azolotko's full-sized avatar
🛠️

Alex Zolotko azolotko

🛠️
  • Zaandam, The Netherlands
View GitHub Profile
@azolotko
azolotko / bug.rb
Created October 4, 2011 09:20
rb_data_object_alloc throws exception if klass is NULL
# IP2Location you can get from http://www.ip2location.com/ruby.aspx
require 'IP2Location'
locator = IP2Location.new
locator.open("./IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE.BIN")
@azolotko
azolotko / lein_new_project.sh
Last active December 11, 2015 10:08
1. Start a new project using Leiningen:
lein new awesomeness
cd awesomeness
@azolotko
azolotko / webdriver_project.clj
Last active December 11, 2015 10:08
Add clj-webdriver and phantomjsdriver to the project.clj
(defproject awesomeness "0.1.0-SNAPSHOT"
; ...
:jvm-opts ["-Dphantomjs.binary.path=./phantomjs-1.9.1-linux-x86_64/bin/phantomjs"]
:dependencies [[org.clojure/clojure "1.5.1"]
[clj-webdriver/clj-webdriver "0.6.0"]
[com.github.detro.ghostdriver/phantomjsdriver "1.0.3"]])
@azolotko
azolotko / fetch_phantomjs.sh
Last active December 11, 2015 10:08
Download and unpack PhantomJS
curl https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2 | tar xvj
@azolotko
azolotko / lein_deps.sh
Created January 21, 2013 08:14
Tell Leiningen to update dependencies
lein deps
@azolotko
azolotko / start_repl.sh
Last active December 11, 2015 10:08
Start REPL and test WebDriver
lein repl
package jvmjit;
public class JvmJit {
static long startTime = System.nanoTime();
public static void main(String[] args) {
Test0 me = new Test0();
while (true) {
me.runHello();
}
@azolotko
azolotko / lein_new.sh
Created July 3, 2013 09:17
Tell Leiningen to create a new project
lein new rock-paper-scissors
cd rock-paper-scissors/
@azolotko
azolotko / core_logic_project.clj
Last active December 19, 2015 07:09
Add clojure.core.logic to the project.clj
(defproject rock-paper-scissors "0.1.0-SNAPSHOT"
; ...
:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/core.logic "0.8.3"]])
@azolotko
azolotko / rock_paper_scissors.clj
Last active December 19, 2015 07:09
Write the rules of the rock-paper-scissors game
(ns rock-paper-scissors.core
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defrel beats hand1 hand2)
(facts beats [[:rock :scissor] [:paper :rock] [:scissor :paper]])
(defn play [hand1 hand2]
(run* [result]
(conde