Skip to content

Instantly share code, notes, and snippets.

@pjullah
pjullah / vagrant_disk_sizing.sh
Last active April 24, 2017 15:33
Vagrant Disk Sizing
# On host
$ cd ~/VirtualBox\ VMs/<vm>
$ VBoxManage clonehd "box-disk1.vmdk" "clone-disk1.vdi" --format vdi
$ VBoxManage modifyhd "clone-disk1.vdi" --resize 50000
$ VBoxManage storageattach $(pwd | cut -d "/" -f5-) --storagectl "SATA" --port 0 --device 0 --type hdd --medium clone-disk1.vdi
# On VM
$ vagrant up
$ vagrant ssh
$ sudo su -
@pjullah
pjullah / env.clj
Last active May 3, 2017 11:48
Notes on Clojure development environment configuration
;; https://stuartsierra.com/2016/clojure-how-to-ns.html
;; ns cheatsheet https://gist.github.com/ghoseb/287710/
;; Work with library in REPL - example Cheshire
(boot.core/set-env! :dependencies #(conj % '[cheshire "5.5.0"]))
(require '[cheshire.core])
;; add dependency
(set-env! :dependencies #(conj % '[foo/bar "1.2.3"]))
@pjullah
pjullah / clojure_notes.clj
Last active July 4, 2017 12:00
Notes about Clojure
;; Lots of Clojure - http://matthiasnehlsen.com/
; best explanation of apply vs map - http://stackoverflow.com/questions/2311528/clojure-apply-vs-map
(apply F [1 2 3 4 5])
;translates to
(F 1 2 3 4 5)
(map F [1 2 3 4 5])
;translates to
[(F 1) (F 2) (F 3) (F 4) (F 5)]
@pjullah
pjullah / core.async.clj
Last active May 4, 2017 08:51
Notes on using core.async
; Blocking
>!! ; put
<!! ; take
; determine Clojure version
> *clojure-version*
; Look in ~/.m2 to see which Clojure versions are installed.
@pjullah
pjullah / mysql.clj
Last active September 6, 2017 14:50
Working with MySQL in boot
(boot.core/merge-env! :dependencies '[[org.clojure/java.jdbc "x.y.z"][mysql/mysql-connector-java "x.y.z"]])
(require '[clojure.java.jdbc :as sql])
(def db-host "127.0.0.1")
(def db-port 3306)
(def db-name "cmdb")
(def db-user "root")
(def db-password "my-secret-pw")
@pjullah
pjullah / gist:eecd46772959db1691088ac17b8c4c82
Last active May 12, 2017 10:39
Package a Clojure application as a Docker image
#https://juxt.pro/blog/posts/beanstalk.html
FROM java:8

ADD target/myproj.0.1.0-SNAPSHOT-standalone.jar /srv/myproj-app.jar

EXPOSE 8080

CMD ["java", "-jar", "/srv/myproj-app.jar"]
@pjullah
pjullah / readme.md
Last active May 16, 2017 11:39
Example of working with Docker, Boot, and Compojure

Background

https://www.reddit.com/r/Clojure/comments/4j7lyx/docker/

http://www.compoundtheory.com/ - article on Dockerising Clojure

I've been setting up an environment to test out an alternative to CORS for an application I'm developing using Nginx as a reverse proxy in front of three Clojure services. In doing so I needed to setup the backend servers to serve requests. But there was hitch. I was using a Dockerised Nginx which was linking to web service containers. Again, that is working fine.

@pjullah
pjullah / n.clj
Last active June 20, 2017 10:08
Notes of Clojure function usage
; construct a map, using the keys from one vector, and the values from another
(zipmap keys vals)
@pjullah
pjullah / react_notes.md
Last active May 19, 2017 13:18
Some notes about React, Router, Redux, Thunk etc

ReactRouter.withRouter injects route information into wrapped component props.

render() { const { match, location, history } = this.props
const Component = withRouter(Component)

Redux-thunk

@pjullah
pjullah / chapter_1.clj
Created May 23, 2017 13:53
Clojure Applied
(ns clojure-applied.core)
; define a map - values can be looked up in near constant time.
(def earth {
:name "Earth"
:moons 4
:volume 1.083
:mass 5.972
:type :Planet
})