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
| - (id)initWithImage:(UIImage *)image | |
| { | |
| self = [super init]; | |
| if (self) { | |
| [self setClipsToBounds:YES]; | |
| [self setAutoresizesSubviews:YES]; | |
| [self setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; | |
| CGImageRef originalImage = [image CGImage]; | |
| _image = image; |
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
| ////////////////////////////////////////// | |
| // Why it's painful to write Objective-C: | |
| ////////////////////////////////////////// | |
| NSString *tagString = [[storyThreadInfo valueForKeyPath:@"interests.name"] componentsJoinedByString:@" "]; | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ;; After writing Clojure: | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;; |
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 arc.core | |
| (:use compojure.core) | |
| (:require [compojure.route :as route] | |
| [compojure.handler :as handler] | |
| [ring.util.response :as response] | |
| [ring.adapter.jetty :as jetty])) | |
| (def route-map (ref {})) | |
| (def ^:dynamic *params* 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
| RGView.prototype.zoom = function(percent) { | |
| var doSuccess = function(rgView) { | |
| return function(data) { | |
| rgView.refreshImage(); | |
| $('#display' + rgView.index).css('zoom', "100%"); | |
| }; | |
| }; | |
| csi.relgraph.zoomPercent(this.vizuuid, percent, { | |
| onsuccess : doSuccess(this) |
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
| (defmacro g-do | |
| "Execute forms on the AWT event thread" | |
| [& forms] | |
| `(SwingUtilities/invokeLater #(do ~@forms))) |
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 fizzbuzz | |
| [n] | |
| (condp #(= 0 (mod %2 %1)) n | |
| 15 "FizzBuzz" | |
| 3 "Fizz" | |
| 5 "Buzz" | |
| n)) | |
| (deftest test-fizzbuzz | |
| (is (= [1 2 "Fizz" 4 "Buzz" "Fizz" 7 8 "Fizz" "Buzz" 11 "Fizz" 13 14 "FizzBuzz"] |
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 pfilter | |
| [f coll] | |
| (filter identity (map #(when %1 %2) | |
| (pmap f coll) | |
| coll))) |
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 | |
| ^{:author "John Cromartie" | |
| :doc "A library for reading and writing gzip-compressed data"} | |
| cljz.core | |
| (:refer-clojure :exclue [spit slurp]) | |
| (require [clojure.java.io :as io]) | |
| (import [java.util.zip GZIPInputStream GZIPOutputStream])) | |
| (defn input-stream | |
| [x & opts] |
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
| # code: | |
| # set up the webhook and wait for a connection | |
| s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | |
| print "binding on host", webhook_host, "port", webhook_port | |
| s.bind((webhook_host, webhook_port)) | |
| print "listening" | |
| s.listen(1) | |
| print "accepting connections" | |
| conn, (addr, port) = s.accept() |
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
| #!/bin/sh | |
| # | |
| # A hook to prevent usage of the bad habit: commit -a | |
| # | |
| if ( ps -o pid,command | grep -q "${PPID} git commit -\w*a\w*" ) | |
| then | |
| echo "please do not use \"commit -a\"" | |
| exit 1 | |
| fi |