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
    
  
  
    
  | ;; Generating static HTML using Clojure macros | |
| ;; It is possible to write a DSL in Clojure that generates HTML markup without the need to write a separate parser and compiler (e.g. HAML). | |
| ;; Our aim here would be to write code that converts the following Clojure code into the HTML below it | |
| ;; (html | |
| ;; (head) | |
| ;; (body | |
| ;; (h1 "An example") | 
  
    
      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 busy-cursor.core | |
| (:use seesaw.core)) | |
| (defn long-running-task | |
| [] | |
| (Thread/sleep 5000) | |
| "The result") | |
| (defn run-task-with-busy-cursor | |
| [c] | 
  
    
      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
    
  
  
    
  | ; nREPL 0.1.7-preview | |
| user> (use 'seesaw.core) | |
| nil | |
| user> (def myframe (frame :title "Hello" :on-close :exit)) | |
| #'user/myframe | |
| user> (import com.mxgraph.view.mxGraph) | |
| com.mxgraph.view.mxGraph | |
| user> (def mygraph (mxGraph.)) | |
| #'user/mygraph | |
| user> (defn display [content] | 
  
    
      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
    
  
  
    
  | (comment | |
| This is the easiest and most concise way of calling an external process in Java. The inheritIO methods causes the command to output stdout and errout to the same place as your current process (which most of the times is the console), no need to create mechanisms for reading asynchronously from input streams to get at the information. | |
| http://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html | |
| ) | |
| (def ret (.waitFor (-> (ProcessBuilder. ["gzip" "-t" "g.txt.gz"]) .inheritIO .start))) | |
  
    
      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
    
  
  
    
  | (require '[clojure.core.async :as async :refer :all]) | |
| (defn fake-search [kind] | |
| (fn [query] | |
| (Thread/sleep (int (* (java.lang.Math/random) 1000))) | |
| (str kind " result for " query))) | |
| (def web (fake-search "Web")) | |
| (def image (fake-search "Image")) | |
| (def video (fake-search "Video")) | 
  
    
      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
    
  
  
    
  | object x { | |
| // stream a sql query | |
| def sql( str:String ):Stream[ResultSet] = withStatement { s => | |
| val rs = s executeQuery str | |
| new Iterator[ResultSet] { def hasNext = rs.next ; def next = rs }.toStream | |
| } | |
| // loan a sql statement | 
  
    
      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 pdf2svg | |
| (:require [clojure.java.io :as io]) | |
| (:import [org.apache.pdfbox.pdmodel PDDocument PDPageable] | |
| [org.apache.batik.dom GenericDOMImplementation] | |
| [org.apache.batik.svggen SVGGeneratorContext SVGGraphics2D])) | |
| (let [document (PDDocument/load "hoge.pdf") | |
| pageable (PDPageable. document) | |
| dom-impl (GenericDOMImplementation/getDOMImplementation) | |
| svg-document (.createDocument dom-impl "http://www.w3.org/2000/svg" "svg" 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
    
  
  
    
  | user> (use 'criterium.core) | |
| nil | |
| user> (def sites (vec (for [i (range 1000)] {:stations (vec (for [j (range 10)] [{:id (str i "-" j)}]))}))) | |
| #'user/sites | |
| user> (bench (doall (mapcat (fn [site] (map :id (:stations site))) sites))) | |
| Evaluation count : 74280 in 60 samples of 1238 calls. | |
| Execution time mean : 802.413222 µs | |
| Execution time std-deviation : 10.087328 µs | |
| Execution time lower quantile : 786.940250 µs ( 2.5%) | |
| Execution time upper quantile : 823.245990 µs (97.5%) | 
  
    
      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
    
  
  
    
  | # NOTE: the most updated version of PowerView (http://www.harmj0y.net/blog/powershell/make-powerview-great-again/) | |
| # has an updated tricks Gist at https://gist.github.com/HarmJ0y/184f9822b195c52dd50c379ed3117993 | |
| # get all the groups a user is effectively a member of, 'recursing up' | |
| Get-NetGroup -UserName <USER> | |
| # get all the effective members of a group, 'recursing down' | |
| Get-NetGroupMember -GoupName <GROUP> -Recurse | |
| # get the effective set of users who can administer a server | 
  
    
      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
    
  
  
    
  | #!/usr/bin/env boot | |
| ;; -*- mode: Clojure;-*- | |
| (set-env! :dependencies '[[seesaw "1.4.5"]]) | |
| (use 'seesaw.core) | |
| (import '(javafx.scene.web WebView) | |
| '(javafx.scene SceneBuilder) | |
| '(javafx.scene.layout VBoxBuilder)) |