Skip to content

Instantly share code, notes, and snippets.

View vsnguyen's full-sized avatar

Vietson Nguyen vsnguyen

View GitHub Profile
@vsnguyen
vsnguyen / gist:05b214998ce41103ac0e
Last active August 29, 2015 14:21
Clojure: Destructuring
;; Vector
(def my-vector [1 2 3])
(let [[x y z] my-vector]
(+ x y z))
;; 6
;; String
(def my-string "hola")
@vsnguyen
vsnguyen / gist:3c61368e636f039c595d
Last active August 29, 2015 14:21
Clojure: Macro
;; defmacro
;; only run at compile time
;; Simple
(defmacro unless [condition expression]
(list 'if condition nil expression))
(unless (> 2 3) true)
;; (if (> 2 3) true nil)
@vsnguyen
vsnguyen / gist:a1a266d9f31a9e678133
Last active August 29, 2015 14:21
Clojure: Atom
(def my-atom (atom nil))
;; @my-atom
;; nil
(defn update-my-atom [value] (reset! my-atom value))
@my-atom
;; nil
(update-my-atom 10)
;; 10
@my-atom
;; 10
;; (replace value regex replacement)
@vsnguyen
vsnguyen / tmux-bash-functions
Last active August 29, 2015 14:22
Quickly create and attach to a tmux session
#!/bin/bash
function tmux-attach(){
SESSION_NAME=$1
tmux attach -t $SESSION_NAME
}
function tmux-new(){
SESSION_NAME=$1
tmux new -s $SESSION_NAME
@vsnguyen
vsnguyen / write-to-bytearrayinputstream.clj
Last active October 10, 2015 17:08
clojure: write to bytearrayinputstream
;; write
(def write-bs
(let [baos (java.io.ByteArrayOutputStream.)]
(with-open [oos (java.io.ObjectOutputStream. baos)]
(.writeObject oos "hello"))
(.toByteArray baos)))
;; read bs
(defn read-bs
[bs]
@vsnguyen
vsnguyen / delete-git-tag-local-and-remote.sh
Created October 20, 2017 13:44
delete-git-tag-local-and-remote
# Local
git tag -d tag-name
# Remote
git push --delete origin tag-name
@vsnguyen
vsnguyen / create-git-tag.sh
Created October 20, 2017 13:45
create-git-tag
# Create
git tag -a tag-name -m "tag message"
# Push
git push --tags
@vsnguyen
vsnguyen / gist:67ad5182aab14cfaa9f60c8c7aace5f7
Created August 24, 2020 19:49
WordPress Docker-Compose
version: '3.1'
services:
app:
depends_on:
- db
image: wordpress:latest
ports:
- 8000:80
environment:
const Comp3 = ({item}) => {
return(
<div>simple return</div>
)
}
const Comp2 = ({data}) => {
return(
<React.Fragment>