This file contains 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
build () { | |
SliverPersistentHeader( | |
delegate: SliverAppBarDelegate((context, _, __) { | |
return Container( | |
color: CupertinoColors.white, | |
child: Padding( | |
padding: EdgeInsets.symmetric( | |
vertical: 8.0, horizontal: 16.0), | |
child: SearchView( | |
autofocus: true, |
This file contains 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
; When a candle finishes burning it leaves a leftover. makeNew leftovers can be combined to make a new candle, which, when burning down, will in turn leave another leftover. | |
; You have candlesNumber candles in your possession. What's the total number of candles you can burn, assuming that you create new candles as soon as you have enough leftovers? | |
; Example | |
; For candlesNumber = 5 and makeNew = 2, the output should be | |
; candles(candlesNumber, makeNew) = 9. | |
; Here is what you can do to burn 9 candles: |
This file contains 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 expand-home [s] | |
(if (.startsWith s "~") | |
(clojure.string/replace-first s "~" (System/getProperty "user.home")) | |
s)) |
This file contains 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 file-exists? [_] | |
(.exists (clojure.java.io/as-file _))) |
This file contains 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
;; password input is visible when use run | |
;; but it's invincible if it's executed using java -jar target/your-uberjar-standalone.jar | |
(defn read-password [prompt] | |
;; Based on https://groups.google.com/forum/#!topic/clojure/ymDZj7T35x4 | |
(if (= "user" (str (.getName *ns*))) | |
(do | |
(print (format "%s [will be echoed to the screen]" prompt)) | |
(flush) | |
(read-line)) |
This file contains 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 write-file [filename spitted-string] | |
(clojure.java.io/make-parents filename) | |
(spit filename spitted-string)) |
This file contains 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 candles[c n]{:pre[(not(nil? c))(>= c 1)(<= c 15)(not (nil? n))(>= n 2)(<= n 5)]}(if(> n c)c(loop [r c b [c]](let[m (mod r n)f(int(double(/ r n)))](if(<= r n)(reduce + (flatten[b f]))(recur(+ m f)(conj b f))))))) |
This file contains 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
(def decipher | |
(fn [e] | |
(loop [s e | |
r []] | |
(if (= (count s) 0) | |
(apply str (map #(char (read-string (apply str %)))r)) | |
(let [l (if (= \1 (first s)) 3 2) | |
v (vec s)] | |
(recur (subvec v l) | |
(conj r (take l v)))))))) |
This file contains 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
// declare variable at the top inside class | |
Timer _debounce; | |
Duration _debounceDuration = Duration(seconds: 1); | |
// initState | |
@override | |
void initState() { | |
super.initState(); | |
// add listener to textfield controller |
This file contains 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
// https://twitter.com/samccone/status/1200967148580921344?s=20 | |
this.obs = new IntersectionObserver(onHit, { | |
rootMargin: '0px', | |
threshold: 0.2 | |
}); | |
this.obs.observe(elms); | |
onHit(entries) { |