Skip to content

Instantly share code, notes, and snippets.

View vehas's full-sized avatar
🎯
Focusing

Veha Suwatphisankij vehas

🎯
Focusing
  • Thailand
View GitHub Profile
@vehas
vehas / clj.sh
Created February 9, 2021 00:34
ray cast script command to run clojure (babashka)
#!/bin/bash
# work with ray cast script command https://github.com/raycast/script-commands
# Dependency: requires babashka (https://github.com/babashka/babashka)
# Install via bash: `bash < <(curl -s https://raw.githubusercontent.com/babashka/babashka/master/install)`
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title clj
# @raycast.mode compact
@vehas
vehas / SketchSystems.spec
Last active November 23, 2020 04:58
local
local
local enter*
add new block -> local text
local text
edit -> local CRDT
finish edit -> remote text
local CRDT
edit -> local CRDT
no attention -> local text
update to remote -> remote CRDT
@vehas
vehas / tennis.cljc
Created April 11, 2019 15:11
kata from http://codingdojo.org/kata/Tennis/ take winner and game state, return updated game state
(ns tennis.tennis)
(def next-score
{0 15
15 30
30 40})
(defn tennis [winner {:keys [score advantage] :as game-state}]
"kata from http://codingdojo.org/kata/Tennis/
take winner and game state, return updated game state"
@vehas
vehas / group-location.clj
Created May 7, 2018 09:37
group-location solution for the problem in clojure in thai FB group
(def local
[{:province :a, :district :b, :amphoe :c}
{:province :a, :district :k, :amphoe :g} ])
(defn group-by-fn
([func groupping]
(fn [hmap]
(group-by-fn func groupping hmap)))
([func groupping hmap]
(->> hmap
@vehas
vehas / swap-sub.clj
Last active May 2, 2018 09:07
swap-sub.clj
(def qs {1 [:a :b] 2 [:a] 3 [:b] 4 [:b :c] 5 [:a] 6 [:a :c]})
(defn swap-sub [m]
(->> m
(mapcat (fn [[k v]] (zipmap v (repeat k))))
(group-by first)
(map (fn [[k v]] [k (mapv second v)]))
(into {})))
(swap-sub qs) ;=> {:a [1 2 5 6], :b [1 3 4], :c [4 6]}
@vehas
vehas / queryDB.js
Last active October 26, 2015 02:30
/**
* query movie main character form movie name
* @constructor
* @param {string} name
* @param {function} success(characterArray) - success callback funtion return all record character
* @param {function} err(string) - error callback funtion return error string
*/
function queryDB(name,success,err){
var intern= {