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 python3 | |
| import argparse | |
| docs = """ | |
| orig_data_size uncompressed size of data stored in this disk. | |
| This excludes same-element-filled pages (same_pages) since | |
| no memory is allocated for them. | |
| Unit: bytes | |
| compr_data_size compressed size of data stored in this disk | |
| mem_used_total the amount of memory allocated for this disk. 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
| #!/usr/bin/env bash | |
| set -e | |
| [ $EUID -ne 0 ] && echo "run as root" >&2 && exit 1 | |
| ########################################################## | |
| # You should not need to update anything below this line # | |
| ########################################################## |
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 clog | |
| (:refer-clojure :exclude [==]) | |
| (:use clojure.core.logic)) | |
| ;; ------------------ | |
| (def db | |
| #{ | |
| [#uuid "9d6280a3-7043-4e7e-9187-ad800743406a" :last-name "Downey"] | |
| [#uuid "9d6280a3-7043-4e7e-9187-ad800743406a" :street "Hanam"] |
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 http-server | |
| (:require [ring.adapter.jetty :as jetty]) | |
| (:import [org.eclipse.jetty.server.handler.gzip GzipHandler])) | |
| (defn- add-gzip-handler [server] | |
| (.setHandler server | |
| (doto (GzipHandler.) | |
| (.setIncludedMimeTypes (into-array ["text/css" | |
| "text/plain" | |
| "text/javascript" |
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 exprPattern extends App { | |
| sealed trait Expr | |
| case class Add(e1: Expr, e2: Expr) extends Expr | |
| case class Sub(e1: Expr, e2: Expr) extends Expr | |
| case class Num(n: Int) extends Expr | |
| def value(e: Expr): Int = e match { | |
| case Add(e1, e2) => value(e1) + value(e2) | |
| case Sub(e1, e2) => value(e1) - value(e2) | |
| case Num(n) => 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
| ;; Clojure | |
| (require 'clojure-mode) | |
| (setq auto-mode-alist (cons '("\\.cljs$" . clojure-mode) auto-mode-alist)) | |
| (setq inferior-lisp-program "lein repl") | |
| ;; clj-refactor | |
| (require 'clj-refactor) | |
| (add-hook 'clojure-mode-hook (lambda () | |
| (clj-refactor-mode 1) | |
| (cljr-add-keybindings-with-prefix "C-c C-o"))) |
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 itertools | |
| print("Klara is the best") | |
| numbers = map(float,range(1,10)) | |
| ops = ['+','-','*','/'] | |
| all_ops = list(itertools.product(ops,repeat=8)) | |
| print('There are {} different ways to order {} between {}' | |
| .format(len(all_ops), ops, numbers)) |
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
| package akka.tutorial.first.java; | |
| import akka.actor.ActorRef; | |
| import akka.actor.UntypedActor; | |
| import akka.actor.UntypedActorFactory; | |
| import akka.actor.ActorSystem; | |
| import akka.actor.Props; | |
| public class Hello { | |
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- log-time [{:keys [ns name line]} f & args] | |
| (let [start (System/nanoTime) | |
| res (apply f args) | |
| elapsed (quot (- (System/nanoTime) start) 1000)] | |
| (log/debug (format "%s/%s:%s %dus" ns name line elapsed)) | |
| res)) | |
| (defn enable-timing [var] |
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
| (time | |
| (def data-thread | |
| (let [c (chan) | |
| res (atom [])] | |
| ;; fetch em all | |
| (doseq [i (range 10 100)] | |
| (thread (>!! c (blocking-get (format "http://fssnip.net/%d" i))))) | |
| ;; gather results | |
| (doseq [_ (range 10 100)] | |
| (swap! res conj (<!! c))) |
NewerOlder