- Source http://tinyurl.com/alice-clj
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 nightcoders.removeme | |
(:require [reagent.core :as r] | |
[quil.core :as q])) | |
(enable-console-print!) | |
(def image-url | |
"https://i.pinimg.com/originals/96/cc/3a/96cc3aafba195cecfc2662acc405c699.gif") | |
(def clojurebridge-url |
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
class Book: | |
def __init__(self, title, author): | |
self.title = title | |
self.author = author | |
def getShortDescription(self): | |
"""The getter for the shortDescription property""" | |
return self.title + ' was written by ' + self.author |
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 trapped-water [towers] | |
(let [maxes #(reductions max %) ; the seq of increasing max values found in the input seq | |
maxl (maxes towers) ; the seq of max heights to the left of each tower | |
maxr (reverse (maxes (reverse towers))) ; the seq of max heights to the right of each tower | |
mins (map min maxl maxr)] ; minimum highest surrounding tower per position | |
(reduce + (map - mins towers)))) ; sum up the trapped water per position | |
;; in the following, # is a tower block and ~ is trapped water: | |
;; | |
;; 10| |
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
class TreeNode: | |
def __init__(self, key, val, left=None, right=None, parent=None): | |
# key e' inutile | |
self.key = key | |
self.payload = val | |
self.leftChild = left | |
self.rightChild = right | |
self.parent = parent | |
def hasLeftChild(self): |
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
class Node: | |
def __init__(self, cargo, next=None): | |
self.cargo = cargo | |
self.next = next | |
def __str__(self): | |
return str(self.cargo) | |
def search(self, needle): |
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 datetime | |
>>> "oggi e' %s" % datetime.date.today() | |
"oggi e' 2017-05-04" | |
>>> "oggi e' %r" % datetime.date.today() | |
"oggi e' datetime.date(2017, 5, 4)" |
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
gifcast () { | |
mkdir /tmp/gifcast | |
ffmpeg -i "$@" -r 10 /tmp/gifcast/gifcast%05d.png | |
convert -layers Optimize /tmp/gifcast/gifcast*.png gifcast.gif | |
rm /tmp/gifcast/gifcast*.png | |
rmdir /tmp/gifcast | |
} |
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 nono.core | |
(:import [javax.imageio ImageIO] | |
[java.io File])) | |
(def test-path "/Users/not-going-to-show-my-user/Downloads/sample.bmp") | |
(defn extract-rgb [pixel] | |
(let [r (bit-and 0x000000FF (bit-shift-right pixel 16)) | |
g (bit-and 0x000000FF (bit-shift-right pixel 8)) | |
b (bit-and 0x000000FF pixel)] |
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 proc | |
(:import [java.lang ProcessBuilder]) | |
(:use [clojure.java.io :only [reader writer]])) | |
(defn spawn [& args] | |
(let [process (-> (ProcessBuilder. args) | |
(.start))] | |
{:out (-> process | |
(.getInputStream) | |
(reader)) |