Skip to content

Instantly share code, notes, and snippets.

View piotr-yuxuan's full-sized avatar
💣
Breaking things, carefully

胡雨軒 Петр piotr-yuxuan

💣
Breaking things, carefully
View GitHub Profile
@piotr-yuxuan
piotr-yuxuan / fizzbuzz.md
Last active May 5, 2020 13:56
FizzBuzz test

Assignment:

Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".

First, explicit solution. The one wich I immediately conceive when hearing at the problem.

(for [x (range 1 (inc 100))]
  (cond
    (and (zero? (mod x 3)) (zero? (mod x 5))) "FizzBuzz"
(require '[graph-fnk-viz :as viz] ;; git clone https://github.com/RedBrainLabs/graph-fnk-viz then lein install
'plumbing.graph
;; Namespaces of graphs
'…)
(def graphs
"Would be wonderful if these graphs would be programmatically found with static code analysis.
So we could run this snippet once in a while and store files in a doc/."
['…])
File /var/folders/0w/wdz5xrr9505_qs_0c49npdcc0000gn/T/com.apple.dt.XCTest/IDETestRunSession-5FA9BD83-ED86-4301-A220-AA3BBF0B277E/FutureAppTests-BC28F6DF-4026-4464-B9D8-2F7B10C9617D/Session-FutureAppTests-2018-02-09_191615-Eme9Bz.log
19:16:15.698 xcodebuild[50950:1216444] Beginning test session FutureAppTests-4AFD66E0-4F23-4D5A-9EEF-D41D0018197B at 2018-02-09 19:16:15.698 with Xcode 9C40b on target <DVTiPhoneSimulator: 0x7fc423412c40> {
SimDevice: iPhone 6 (C32AE35F-AC5D-486C-B37A-2F27D98B70A3, iOS 11.2, Booted)
} (11.2 (15C107))
19:16:15.699 xcodebuild[50950:1216444] /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
-workspace
native/ios/FutureApp.xcworkspace
-scheme
FutureApp
@piotr-yuxuan
piotr-yuxuan / gitflow-breakdown.md
Created March 23, 2018 16:31 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@piotr-yuxuan
piotr-yuxuan / gist.md
Created March 23, 2018 19:55
Non-standard PostgreSQL clause RETURNING

I stumbled upon a rather uncommon feature of PostgreSQL recently, namely, clause RETURNING. Let's say I have a database which contains a table products. I needed to copy some products directly in SQL, and then to invoke a function with the ids of both the old and the new products (for some side-effects irrelevant here).

At first I felt quite confident that a simple INSERT would do the job, but how to get the new ids in the most elegant way? As the doc states:

INSERT conforms to the SQL standard, except that the RETURNING clause is a PostgreSQL extension

So here it is:

INSERT INTO products (name,
$ lein repl
Exception in thread "main" java.lang.ExceptionInInitializerError
at clojure.main.<clinit>(main.java:20)
Caused by: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V, compiling:(closure.clj:100:1)
at clojure.lang.Compiler$DefExpr.eval(Compiler.java:470)
at clojure.lang.Compiler.eval(Compiler.java:7067)
at clojure.lang.Compiler.load(Compiler.java:7514)
at clojure.lang.RT.loadResourceScript(RT.java:379)
at clojure.lang.RT.loadResourceScript(RT.java:370)
at clojure.lang.RT.load(RT.java:460)
@piotr-yuxuan
piotr-yuxuan / encode-url-preserve-macro.clj
Created April 16, 2018 11:52
Encode url and preserve macro
(defn- encoded-macros-map
[macros]
(->> macros
(map (fn [macro]
[(codec/url-encode macro) macro]))
(into {})))
(defn- macro-decoder
[macros-map s]
(reduce (fn [acc [escaped-macro macro]]
@piotr-yuxuan
piotr-yuxuan / minimal-code.md
Last active May 16, 2018 22:05
I can't display a list of headlines which match some tag in org-mode 😕
#+TAGS: SOME(s) ONE(o) TWO(t)
#+STARTUP: hidestars

- 'M-x org-agenda'
- I type 'm' Match a TASKS/PROPS/TODO query
- I type 'SOME' and press enter
- No headings get displayed in the result buffer.

The result buffer contains:
@piotr-yuxuan
piotr-yuxuan / .md
Last active November 27, 2018 11:41
Resource Name Optimized Total % JS Source
npm @material-ui/icons 5.2 MB 86.51 % 5.2 MB 6.7 MB
npm @material-ui/core 438.5 KB 7.32 % 439.3 KB 1.0 MB
jar cljs/core.cljs 113.4 KB 1.89 % 1.3 MB 331.7 KB
npm react-dom 100.0 KB 1.67 % 100.1 KB 101.6 KB
npm jss 35.8 KB 0.60 % 35.9 KB 81.3 KB
npm popper.js 20.0 KB 0.33 % 20.0 KB 85.6 KB
npm react-transition-group 9.4 KB 0.16 % 9.4 KB 32.7 KB
jar reagent/ratom.cljs 6.4 KB 0.11 % 57.6 KB 15.7 KB