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 android.os.Environment; | |
| import android.support.annotation.NonNull; | |
| import java.io.File; | |
| import java.io.FileOutputStream; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.util.concurrent.TimeUnit; |
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
| defmodule Pipe do | |
| defmacro a|>b do | |
| pos = tuple_size(b) -1 | |
| Macro.pipe(a, b, pos) | |
| end | |
| defmacro __using__(_extras) do | |
| quote do | |
| import Kernel, except: [|>: 2] | |
| import Pipe |
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
| defmodule MySigils do | |
| def sigil_i(string, []), do: String.to_integer(string) | |
| def sigil_i(string, [?n]), do: -String.to_integer(string) | |
| end |
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
| defprotocol Blank do | |
| @doc "Returns true if data is considered blank/empty" | |
| @fallback_to_any true | |
| def blank?(data) | |
| end | |
| defimpl Blank, for: Any do | |
| def blank?(_), do: false | |
| end |
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
| defmodule MyUnless do | |
| defmacro unless(clause, then_clause, else_clause \\ nil) do | |
| quote do | |
| if !unquote(clause) do | |
| unquote(then_clause) | |
| else | |
| unquote(else_clause) | |
| end | |
| end | |
| end |
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
| ;;Code for https://www.jinshuju.net/f/EGQL3D | |
| (defn- read-n-numbers [n] | |
| (repeatedly n #(let [x (read-line)] | |
| (Integer/valueOf x)))) | |
| (defn- say-what [inputs words n] | |
| (let [[x y z] inputs | |
| rs (filter #(zero? (rem n %)) inputs)] | |
| (cond | |
| ;;rule 5 |
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.io.File; | |
| import java.io.FileInputStream; | |
| import java.util.List; | |
| import org.apache.poi.hwpf.HWPFDocument; | |
| import org.apache.poi.hwpf.extractor.WordExtractor; | |
| import org.apache.poi.xwpf.usermodel.XWPFDocument; | |
| import org.apache.poi.xwpf.usermodel.XWPFParagraph; | |
| public class DocReader { |
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
| (fn best-hand [card-strings] | |
| (let [card-parser (fn [[s r]] | |
| (let [suit ({\S :spade, \H :heart, | |
| \D :diamond, \C :club} s) | |
| rank (if (> (Character/digit r 10) -1) | |
| (- (Character/digit r 10) 2) | |
| ({\T 8, \J 9, | |
| \Q 10, \K 11, \A 12} r))] | |
| {:suit suit, :rank rank})) | |
| cards (map card-parser card-strings) |
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 [exp10 #(reduce * 1 (repeat % 10)) | |
| combine (fn [n1 ev] | |
| (loop [r n1 n2 (if ev n1 (quot n1 10))] | |
| (if (zero? n2) r | |
| (recur (+ (* 10 r) (rem n2 10)) (quot n2 10))))) | |
| gen (fn gen [start end ev] | |
| (lazy-cat | |
| (if ev nil (map #(combine % ev) (range start end))) | |
| (map #(combine % true) (range (if ev start (quot end 10)) end)) | |
| (gen end (* end 10) false))) |
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
| on run {targetBuddyPhone, targetMessage, repeatCount} | |
| tell application "Messages" | |
| set targetService to 1st service whose service type = iMessage | |
| set targetBuddy to buddy targetBuddyPhone of targetService | |
| set myCount to repeatCount as integer | |
| repeat myCount times | |
| send targetMessage to targetBuddy | |
| end repeat | |
| end tell | |
| end run |
NewerOlder