Initial commit.

This commit is contained in:
Gabriel Simmer 2020-06-28 12:17:14 +01:00
commit 6d78a8f5c4
No known key found for this signature in database
GPG key ID: 33BA4D83B160A0A9
7 changed files with 124 additions and 0 deletions

12
.gitignore vendored Normal file
View file

@ -0,0 +1,12 @@
/target
/classes
/checkouts
profiles.clj
pom.xml
pom.xml.asc
*.jar
*.class
/.lein-*
/.nrepl-port
.hgignore
.hg/

24
CHANGELOG.md Normal file
View file

@ -0,0 +1,24 @@
# Change Log
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
## [Unreleased]
### Changed
- Add a new arity to `make-widget-async` to provide a different widget shape.
## [0.1.1] - 2020-06-28
### Changed
- Documentation on how to make the widgets.
### Removed
- `make-widget-sync` - we're all async, all the time.
### Fixed
- Fixed widget maker to keep working when daylight savings switches over.
## 0.1.0 - 2020-06-28
### Added
- Files from the new template.
- Widget maker public API - `make-widget-sync`.
[Unreleased]: https://github.com/your-name/banana-clj/compare/0.1.1...HEAD
[0.1.1]: https://github.com/your-name/banana-clj/compare/0.1.0...0.1.1

24
LICENSE Normal file
View file

@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>

17
README.md Normal file
View file

@ -0,0 +1,17 @@
# banana-clj
A Clojure library for encoding data as... banana.
Securely store your data and confuse your enemies in an impenetrable
yellow peel!
(yes, I've lost my mind, why do you ask?)
## Usage
```clojure
banana.core=> (grow-banana "gmem")
"bannaannnannannanannaananannannan"
banana.core=> (peel-banana "bannaannnannannanannaananannannan")
"gmem"
```

7
project.clj Normal file
View file

@ -0,0 +1,7 @@
(defproject banana-clj "1.0.0"
:description "Encode and decode bananas."
:url "https://github.com/gmemstr/banana-clj"
:license {:name "Public Domain"
:url "http://unlicense.org/UNLICENSE"}
:dependencies [[org.clojure/clojure "1.10.1"]]
:repl-options {:init-ns banana-clj.core})

27
src/banana-clj/core.clj Normal file
View file

@ -0,0 +1,27 @@
; I'm not entirely sure what I'm doing with my life at this point in time.
(ns banana-clj.core
(:require [clojure.string :as string]
[clojure.pprint :as pprint]))
; Binary translation stuff from
; https://gist.github.com/emdeesee/3827341
(defn to-binary [string]
(string/replace (string/trim (
pprint/cl-format nil "~{~8,'0b ~}" (map #(int %) string))) " " ""))
(defn from-binary [binary]
(->> (partition 8 binary)
(map #(char (Integer/parseInt (apply str %) 2)))
(apply str)
(string/trim))
)
(defn grow-banana [seed]
"Grow a banana!"
(str "b" (string/replace (string/replace (to-binary seed) "0" "a") "1" "n"))
)
(defn peel-banana [banana]
"Peel a banana!"
(from-binary (string/replace (string/replace (string/replace banana "a" "0") "n" "1") "b" ""))
)

View file

@ -0,0 +1,13 @@
(ns banana-clj.core-test
(:require [clojure.test :refer :all]
[banana-clj.core :refer :all]))
(deftest grow-test
(testing "Growing a banana."
(is (= "bannaannnannannanannaananannannan" (grow-banana "gmem"))))
)
(deftest peel-test
(testing "Peeling a banana."
(is (= "gmem" (peel-banana "bannaannnannannanannaananannannan"))))
)