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 db-test.core | |
(:require [clojure.java.jdbc :as j]) | |
(use [korma.db]) | |
(use [korma.core]) | |
(:gen-class)) | |
(defn setup-connection [] | |
(def oracle-db {:classname "oracle.jdbc.odbc.OracleDriver" | |
:subprotocol "oracle" | |
:subname "thin:@//remotehost:1521/derpina1" |
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
(reduce + (flatten (conj (range 0 1000 5) (range 0 1000 3))))) |
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
... | |
//omitted the ceremony code for declaring this a java class with a main method that creates a new object just to call one method | |
public boolean groupSum(int start, int[] nums, int target) { | |
// Base case: if there are no numbers left, then there is a | |
// solution only if target is 0. | |
if (start >= nums.length) return (target == 0); | |
// Key idea: nums[start] is chosen or it is not. |
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 'gist.core | |
(:use [clj-time | |
[core] | |
[local] | |
[predicates]])) | |
;;create date objects for all 365 days of 2013 | |
(def all-days | |
(for [month (range 1 13) | |
day (case month |
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 quilgame | |
(:use quil.core)) | |
(defn setup [] | |
(def ball-x (atom 200)) | |
(def ball-y (atom 100)) | |
(def speed-x (atom 10)) | |
(def speed-y (atom 2)) | |
(def hit (atom 0)) | |
(def miss (atom 0))) |
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 this kata we want to be able to convert a string to its roman numeral value | |
;;Roman numerals are written in descending order so we should be able to parse | |
;;the string and add up the values | |
;;the only issue is the subtraction rule | |
;; iv = 4 | |
;; we'll have to split the string into a vector of characters | |
;; convert each of those characters into a value | |
;; reduce the all those values into one final value |
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
;;given a url of this structure <base>/Publish<type>?id=<id>&update=<1 or 0> | |
(def content-url "http://www.somesite.com/PublishContent?id=42&update=1") | |
(def article-url "http://www.somesite.com/PublishArticle?id=42&update=1") | |
(let [[_ type] (re-find #"Publish([Content Article]*)" content-url) | |
id (last (re-find #"(id=)([a-zA-Z0-9]*)" content-url)) | |
update? (last (re-find #"(update=)(\d)" content-url))] | |
{:type type | |
:id id | |
:update? update?}) |
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
<!-- server passes in a collection of product maps --> | |
<!-- controller now sends a collection of collections of product maps, specifically (partition-all 4 products) --> | |
{% for product-partition in partitioned-products %} | |
{% for product in product-partition %} | |
<div class="col-sm-10 col-sm-offset-2"> | |
<div class="row"> | |
<div class="col-sm-3" style="height:250px;"> | |
<p>{{product.name}}</p> | |
<p>Price ${{product.price}}</p> |
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
;;compare the two approaches to solving the same problem | |
;;A child plays with a ball on the nth floor of a big building the height of which is known | |
;;(float parameter "h" in meters, h > 0) . | |
;;He lets out the ball. The ball rebounds for example to two-thirds | |
;;(float parameter "bounce", 0 < bounce < 1) | |
;;of its height. | |
;;His mother looks out of a window that is 1.5 meters from the ground | |
;;(float parameters window < h). | |
;;How many times will the mother see the ball either falling or bouncing in front of the window |
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* | |
*ns* | |
aget | |
amap | |
as-> | |
aset | |
atom | |
bean | |
byte | |
case |
OlderNewer