This file contains hidden or 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 http = require('http'); | |
| var url = require('url'); | |
| var messages = ["welcome to nodeChat"]; | |
| http.createServer(function (req, res) { | |
| res.writeHead(200, {'Content-Type': 'text/plain'}); | |
| var query = url.parse(req.url, true).query; | |
| if ( query.message ){ | |
| messages.push( query.message ); | |
| res.end("thanks"); | |
| } else { |
This file contains hidden or 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 java.util.Arrays; | |
| import java.util.Random; | |
| /** | |
| * Created by Matthew Gilliard | |
| * Date: 10/07/11 | |
| * Time: 18:22 | |
| */ | |
| public class SortedRespectDue { |
This file contains hidden or 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 java.util.Arrays; | |
| import java.util.Random; | |
| /** | |
| * Created by Matthew Gilliard | |
| * Date: 10/07/11 | |
| * Time: 18:22 | |
| */ | |
| public class SortedRespectDue { |
This file contains hidden or 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
| /** | |
| * Src is the source array that starts at index 0 | |
| * Dest is the (possibly larger) array destination with a possible offset | |
| * low is the index in dest to start sorting | |
| * high is the end index in dest to end sorting | |
| * off is the offset to generate corresponding low, high in src | |
| */ | |
| private static void mergeSort(Object[] src, | |
| Object[] dest, |
This file contains hidden or 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 hello) | |
| (defn ^:export greet [n] | |
| (str "Hello " n)) |
This file contains hidden or 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 b(c){throw c;}var f=null;function aa(){return function(c){return c}}function i(c){return function(){return this[c]}}function j(c){return function(){return c}}var k; | |
| function n(c){var a=typeof c;if(a=="object")if(c){if(c instanceof Array)return"array";else if(c instanceof Object)return a;var d=Object.prototype.toString.call(c);if(d=="[object Window]")return"object";if(d=="[object Array]"||typeof c.length=="number"&&typeof c.splice!="undefined"&&typeof c.propertyIsEnumerable!="undefined"&&!c.propertyIsEnumerable("splice"))return"array";if(d=="[object Function]"||typeof c.call!="undefined"&&typeof c.propertyIsEnumerable!="undefined"&&!c.propertyIsEnumerable("call"))return"function"}else return"null"; | |
| else if(a=="function"&&typeof c.call=="undefined")return"object";return a}function ba(c){return typeof c=="string"}Math.floor(Math.random()*2147483648).toString(36);var ca={"\000":"\\0","\u0008":"\\b","\u000c":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\u000b":"\\x0B",'"':'\\"',"\\":"\\\\"},da={"'":"\\'"}; | |
| fun |
This file contains hidden or 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
| (defn make-js-map | |
| "makes a javascript map from a clojure one" | |
| [cljmap] | |
| (reduce #(aset %1 (name (first %2)) (second %2)) (js-obj) cljmap)) | |
| ; (make-js-map {:a "Hello"}) returns "Hello", not the js-map :( |
This file contains hidden or 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
| (def jquery (js* "$")) | |
| (defn show [msg] | |
| (let [data-as-json ((js* "JSON.stringify") msg nil 4)] | |
| ((js* "alert") data-as-json))) | |
| (defn make-js-map | |
| "makes a javascript map from a clojure one" | |
| [cljmap] | |
| (let [out (js-obj)] |
This file contains hidden or 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 helloclosure | |
| (:require [goog.net.Jsonp :as jsonp])) | |
| (defn show [msg] | |
| (let [data-as-json ((js* "JSON.stringify") msg nil 4)] | |
| ((js* "alert") data-as-json))) | |
| (defn doajax [] | |
| (.send (goog.net.Jsonp. (goog.Uri. "http://api.stackoverflow.com/1.1/users/268619") "jsonp") | |
| nil |
This file contains hidden or 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
| (defn calculate | |
| "A list of coin-values from coins, which sum to target" | |
| [coins target] | |
| (let [coin (max-coin coins target)] | |
| (cond | |
| (not coin) (js-alert "No solution") | |
| (= coin target) (list coin) | |
| (< coin target) (cons coin (recur coins (- target coin)))))) |
OlderNewer