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
#(second (reduce (fn [[t r] x] | |
(if (= (last t) (dec x)) | |
[(conj t x) r] | |
(if (> (count t) (max 1 (count r))) | |
[[x] t] | |
[[x] r]))) | |
[[] []] (conj % -1))) |
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 gapmap | |
"Returns a lazy sequence consisting of the result of applying f to all | |
adjacent values of coll. f should be a function of 2 arguments. If coll | |
contains less than 2 items, it is returned and f is not called." | |
{:added "1.6"} | |
([f coll] | |
(if-let [r (next coll)] ; at least two items? | |
(lazy-seq (gapmap-internal f (first coll) r)) | |
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
module Jekyll | |
class RedcarpetWithoutPygmentsParser < Converter | |
safe true | |
priority :high | |
def initialize(config) | |
require 'redcarpet' | |
@config = config | |
@redcarpet_extensions = {} |
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 io.djui.misc) | |
;; Use case example for tree-seq | |
(defn- map-traverse | |
"Traverse a map with vectors in values as branches and return a list of key | |
x's values. Example: | |
{:a nil :x {:foo 1} :b [{:c nil :x 42} \"test\"]} => [{:foo 1} 42]" | |
[map-tree x] | |
(let [map-vals #(when (map? %) (vals %)) | |
branch? (comp (partial some sequential?) map-vals) |
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 CHEATSHEET | |
;; | |
;; * :require makes functions available with a namespace prefix. | |
;; | |
;; * :use makes functions available without a namespace prefix | |
;; (i.e., refers functions to the current namespace). | |
;; | |
;; * :import refers Java classes to the current namespace. | |
;; |
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
(let [xs (map #(Thread/sleep (* % 1000)) [1 9])] | |
(doseq [x xs] | |
(print x))) |
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 | |
youtube-dl -i -w -q https://www.youtube.com/playlist?list=PLBXmeocYXDfCFnkCoxkSpFChle3gmidEn | |
youtube-dl -i -w -q https://www.youtube.com/playlist?list=PLOcrXzpA0W82rsJJKrmeBlY3_MS0uQv3h |
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
from __future__ import print_function | |
import cookielib | |
import getpass | |
import HTMLParser | |
import re | |
import sys | |
import urllib | |
import urllib2 |
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 '[com.keminglabs.zmq-async.core :refer [register-socket!]] | |
'[clojure.core.async :refer [>! <! <!! >!! go chan sliding-buffer close!]]) | |
(let [addr "tcp://*:9999" | |
[s-in s-out] (repeatedly 2 #(chan (sliding-buffer 64)))] | |
(register-socket! {:in s-in :out s-out :socket-type :rep | |
:configurator (fn [socket] (.bind socket addr))}) | |
(println "waiting messages...") |
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 | |
# -*- coding: utf-8 -*- | |
import argparse | |
import os | |
import sys | |
import traceback | |
__version__ = '1.0' |