Skip to content

Instantly share code, notes, and snippets.

@dra1n
dra1n / storybook.md
Last active September 3, 2021 08:40

What it gives?

  • Visual documentation

    • Discoverability (Easier to find existing components. Potentially works for designers too. As a result, we are saving time because we are not doing the same thing again and again)
    • Regression (Breaking design or API changes will be reflected)
    • Describes component API (And edge cases)
    • Hints to intended usage
  • Faster design delivery (than having component embedded into the page)

  • Early design feedback
(ns logical-boys-girls.core
(:require [clojure.core.logic :as logic]
[clojure.core.logic.fd :as fd]))
(logic/run*
[q]
(let [students-count (fd/interval 1 100)]
(logic/fresh [boys girls h-girls q-girls h-boys q-boys]
;; boring part
;; every lvar belongs to number from interval
* The Reasoned Schemer
* Seven More Languages in Seven Weeks, Brues Tate, Chapter 6. miniKanren
* Joy Of Cloure, Michael Fogus, Chapter 16. Thinking Programs
* https://www.youtube.com/watch?v=lzCIyvFgUVk
(ns number-puzzles.core
(:refer-clojure :exclude [==]) ;; Prevent ns conflict
(:require [clojure.core.logic :refer :all]))
(run* [q]
(fresh [a b c variants]
(== [0 1 2 3 4 6 7 8] variants)
(membero a variants)
(membero b variants)
(membero c variants)
@dra1n
dra1n / Command line shortcuts
Created December 21, 2020 09:11
Command line shortcuts
Ctrl + a – Go to the start of the command line
Ctrl + e – Go to the end of the command line
Ctrl + k – Delete from cursor to the end of the command line
Ctrl + u – Delete from cursor to the start of the command line
Ctrl + w – Delete from cursor to start of word (i.e. delete backwards one word)
Ctrl + y – Paste word or text that was cut using one of the deletion shortcuts (such as the one above) after the cursor
Ctrl + xx – Move between start of command line and current cursor position (and back again)
Alt + b – Move backward one word (or go to start of word the cursor is currently on)
Alt + f – Move forward one word (or go to end of word the cursor is currently on)
Alt + d – Delete to end of word starting at cursor (whole word if cursor is at the beginning of word)
const events = {
RIDE: "RIDE",
RIDE_TAXI: "RIDE_TAXI",
RIDE_BUS: "RIDE_BUS",
WALK: "WALK"
}
const getHomeMachine = Machine({
type: 'parallel',
states: {
@dra1n
dra1n / machine.js
Last active December 2, 2020 07:55
Generated by XState Viz: https://xstate.js.org/viz
const getHomeMachine = Machine({
initial: 'global',
states: {
global: {
initial: 'walking',
on: {
RIDE_TAXI: 'global.riding.taxi',
RIDE_BUS: 'global.riding.bus'
},
states: {
(defn rle
[s]
(->> s
(partition-by identity)
(map #((juxt first count) %))))
(defn rld
[pairs]
(->> pairs
(map (fn [[k v]] (clojure.string/join (repeat v k))))
// https://jsbin.com/lagobuzoxu/1/edit?html,js,output
let state = []
const handleToggle = value => {
state = state.includes(value)
? R.without([value], state)
: [...state, value]
}
@dra1n
dra1n / spacemacs-keybindings
Created April 2, 2019 07:11 — forked from adham90/spacemacs-keybindings
spacemacs keybindings that i need to learn
SPC s c remove highlight
**** Files manipulations key bindings
Files manipulation commands (start with ~f~):
| Key Binding | Description |
|-------------+----------------------------------------------------------------|
| ~SPC f c~ | copy current file to a different location |
| ~SPC f C d~ | convert file from unix to dos encoding |
| ~SPC f C u~ | convert file from dos to unix encoding |