Skip to content

Instantly share code, notes, and snippets.

@oconn
oconn / re-frame-routing.cljs
Last active July 26, 2019 18:03
re-frame-routing example
;; Container views (usally in seperate views
(defn home
[{:keys [route-key path-parms query-params]}]
[:div "Home"])
(defn sign-in
[{:keys [route-key path-parms query-params]}]
[:div "Sign In"])
{:deps {org.clojure/clojurescript {:mvn/version "1.10.520"}
lilactown/hx {:local/root "../../opensource/hx"}
com.bhauman/figwheel-main {:mvn/version "0.2.0"}
com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}}
:paths ["src" "resources" "target"]
:aliases {:build {:main-opts ["--main" "cljs.main"
"--compile-opts" "prod.cljs.edn"
"--compile"]}
:dev {:main-opts ["--main" "figwheel.main"
@oconn
oconn / sample_state.json
Last active March 15, 2017 13:31
Sample Bot State
{
"global-coords": [
6,
6
],
"arena": [
[
{
"contents": {
"type": "open",
;; Goal
;; In this example, I want to be able to say that parent route "/users" requires the admin role. I then specify
;; on a case by case basis that a specific child route also allows additional permissions. ex: "users/:user-id" also
;; allows the user role.
;;
;; Problem
;; A user that only contains the "user" role will not be allowed to access the "user/get-user-by-id" handler because
;; the authorize interceptor at "/users" will run first.
;;
;; Proposed Solution
@oconn
oconn / action.js
Created November 18, 2016 16:31
Request Middleware
export const REQUEST_DELETE_USER = 'REQUEST_DELETE_USER';
export const USER_REMOVE_USER = 'USER_REMOVE_USER';
export const removeUser = (userId) => {
return (dispatch, getState) => {
// The middleware picks up on the following signature
//
// 1. request prop
// 2. request prop is thenable
//
import { append, equals, map, merge, omit, pluck, prepend, reject, zipObj } from 'ramda';
/**
* @method itemByKey
*
* pulls an items key and asigns itself to its key
*/
export const itemByKey = (item, key = '_id') => {
return { [item[key]]: item };
};
(ns battlebots.constants.arena)
(def arena-key {:open {:type "open"
:display " "
:transparent true}
:ai {:type "ai"
:display "@"
:transparent true
:energy 20}
:block {:type "block"
@oconn
oconn / 0_reuse_code.js
Created February 10, 2016 15:48
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@oconn
oconn / javascript_arguments.md
Created April 29, 2014 12:25
Javascript Arguments

Javascript Arguments

Javascript arguments are stored in an array like structure where indicies can be accesses using bracket notation, however none of the objects properties are available except length.

function args(){
  return arguments;
}
@oconn
oconn / javascript_functions.md
Last active August 29, 2015 14:00
Javascript Functions

Functions

Defining functions

var functionOne = function(){};

vs