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 os | |
import pickle | |
import hashlib | |
from functools import wraps, reduce | |
def default_filename_fn(args, kwargs): | |
base = reduce(lambda acc,x: acc + str(x), args, "") | |
return hashlib.sha1(base.encode()).hexdigest() |
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 [meander.epsilon :as m]) | |
(def test-data | |
{:root | |
{:first-child | |
[{:inner-child | |
[{:element "1"} | |
{:element "2"}]} | |
{:elements [{:element "3"} | |
{:element "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
(defn xml->map | |
"Konwertuje sparsowanego xml'a na mapę. | |
Uwaga, uwzględnia tylko tagi i zawartość. Ignoruje atrybuty" | |
[xml] | |
(walk/postwalk | |
(fn [e] | |
(let [content (:content e)] | |
(cond | |
(map? e) {(:tag e) | |
(if (<= (count content) 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
(require '[clojure.java.io :as io]) | |
(defn filter-files [path mask] | |
(let [matcher (.getPathMatcher | |
(java.nio.file.FileSystems/getDefault) | |
(str "glob:" mask))] | |
(->> path | |
io/file | |
file-seq | |
(filter #(.isFile %)) |
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 soap-service.core | |
(:import (javax.jws WebMethod WebService WebParam) | |
(javax.xml.ws Endpoint))) | |
(definterface ITestService | |
(^int add [^int a ^int b])) | |
(deftype ^{WebService {:targetNamespace "http://service.test.com"}} TestService [] | |
ITestService | |
(^int ^{WebMethod []} add [_ |
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 crc32 | |
"Calculates CRC32 checksum of string s" | |
[^String s] | |
(let [bytes (.getBytes s)] | |
(. (doto (new java.util.zip.CRC32) | |
(.update bytes 0 (alength bytes))) | |
getValue))) |
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 '(java.time LocalTime) | |
'(java.time.format DateTimeFormatter)) | |
(defn humanize-working-time [time-in-sec] | |
(-> (LocalTime/parse "00:00:00") | |
(.plusSeconds time-in-sec) | |
(.format (DateTimeFormatter/ofPattern "HH:mm:ss")))) |
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 random import randrange | |
import sys | |
import time | |
def beep(): | |
sys.stdout.write('\r\a') | |
def guess(min, max): |
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
[Unit] | |
Description=The Server | |
After=network.target | |
StartLimitIntervalSec=0 | |
[Service] | |
User=the-server | |
Group=the-server | |
ExecStart=/usr/bin/java -Xms512m -Xmx512m -server -cp /path/to/the-server.jar clojure.main -m the-server.server 8090 | |
Restart=always |
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.java.io :as io]) | |
(import '(java.nio.file FileSystems)) | |
(defn glob [path match] | |
(let [file-system (FileSystems/getDefault) | |
path-matcher (-> file-system (.getPathMatcher match))] | |
(->> path io/file .listFiles | |
(map (fn [f] (.getPath file-system path (into-array String [(.getName f)])))) | |
(filter (fn [f] (.matches path-matcher f))) | |
(map (fn [f] (.toFile f)))))) |