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
## Solve Every Sudoku Puzzle | |
## See http://norvig.com/sudoku.html | |
## Throughout this program we have: | |
## r is a row, e.g. 'A' | |
## c is a column, e.g. '3' | |
## s is a square, e.g. 'A3' | |
## d is a digit, e.g. '9' | |
## u is a unit, e.g. ['A1','B1','C1','D1','E1','F1','G1','H1','I1'] |
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
;; depends on [org.imgscalr/imgscalr-lib "4.2"] | |
(ns XXX.image | |
(:refer-clojure :exclude [read]) | |
(:require [clojure.java.io :as io]) | |
(:import [org.imgscalr Scalr Scalr$Method Scalr$Mode] | |
[java.awt Image] | |
[java.awt.image RenderedImage BufferedImageOp] | |
[javax.imageio ImageIO ImageWriter ImageWriteParam IIOImage] |
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
;;;; Translation of Peter Norvig's sudoku solver to idiomatic Clojure | |
;;;; See http://norvig.com/sudoku.html | |
;;;; | |
;;;; Throughout this program we have: | |
;;;; r is a row, e.g. :a | |
;;;; c is a column, e.g. 3 | |
;;;; s is a square, e.g. [:a 3] | |
;;;; d is a digit, e.g. 9 | |
;;;; u is a unit, e.g. [[:a 1] [:b 1] [:c 1] ... [:i 1]] | |
;;;; grid is a grid, e.g. 81 non-blank chars, e.g. starting with ".18...7..." |
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
;; | |
;; NS CHEATSHEET | |
;; | |
;; * :require makes functions available with a namespace prefix. | |
;; | |
;; * :use makes functions available without a namespace prefix | |
;; (i.e., refers functions to the current namespace). | |
;; | |
;; * :import refers Java classes to the current namespace. | |
;; |
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
;;; | |
;;; Blog post at http://wp.me/p12FcK-3 | |
;;; | |
;;; Loom: http://github.com/jkk/loom | |
;;; GraphViz: http://graphviz.org | |
;;; Ubigraph: http://ubietylab.net/ubigraph/ | |
;;; | |
(ns user | |
(:use [clojure.string :only [lower-case split-lines join]] |
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
// @flow | |
import {Record} from 'immutable'; | |
const TestRec = Record({a: 0, b: 0}); | |
// Flow gives an error for the `rec` argument's type: | |
// | |
// RecordClass | |
// Ineligible value used in/as type annotation (did you forget 'typeof'?) | |
// TestRec |
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
function postJson(method, url, params) { | |
let xhr = new XMLHttpRequest(); | |
xhr.open(method, url, true); | |
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); | |
xhr.send(JSON.stringify(params)); | |
xhr.onreadystatechange = function() { | |
let status; | |
let data; | |
if (xhr.readyState === 4) { | |
status = xhr.status; |
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
(definterface IPrimitiveTester | |
(getType [^int x]) | |
(getType [^long x]) | |
(getType [^float x]) | |
(getType [^double x]) | |
(getType [^byte x]) | |
(getType [^short x]) | |
(getType [^char x]) | |
(getType [^boolean x]) | |
(getType [^Object x])) |
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
;; re http://groups.google.com/group/clojure/browse_thread/thread/55faa29db75192d0 | |
(ns user | |
(use [clojure.java.io :only [reader]])) | |
(def re-vote #"([A-z]{1,16})(\+\+|\-\-)") | |
(defn extract-votes | |
[line] | |
(map rest (re-seq re-vote line))) |
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
;; in response to https://gist.github.com/733674 | |
(def m | |
{"Lisa Rose" {"Lady in the Water" 2.5 "Snakes on a Plane" 3.5} | |
"Gene Seymour" {"Lady in the Water" 3.0 "Snakes on a Plane" 3.5}}) | |
;; one way | |
(reduce | |
(fn [m [critic movie rating]] | |
(assoc-in m [movie critic] rating)) |
NewerOlder