Skip to content

Instantly share code, notes, and snippets.

Hugo Bessa hugobessaa

Block or report user

Report or block hugobessaa

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View simple-comp.cljs
(defn button [props _]
(dom/button nil (:children props))))
(def render-out (om/render-to-object button {:children "text"}))
(is (= "text" (:children render-out))
hugobessaa /
Created Oct 8, 2015
Connect to ClojureScript Node nREPL

jack-in into normal Clojure nREPL. Run:

(require '[cljs.repl :as repl] '[cljs.repl.node :as node])

(compile 'cljs.repl.node)

(cemerick.piggieback/cljs-repl (cljs.repl.node/repl-env))
View angles-fun.js
// radians->degrees
function degrees(radians) {
return radians * 180 / Math.PI;
// gets two positions { x: Number, y: Number } and return
// angle between them in radians
function getAngle(pos1, pos2 = {x: 0, y: 0}) {
let [dx, dy] = [pos1.x - pos2.x, (pos1.y - pos2.y) * -1]
return Math.atan2(dy, dx);
View Redux.js
function createReducer(handlers, initialState) {
return function reducer(state = initialState, action) {
return handlers[action.type] ?
handlers[action.type](state, action)
: state
const math = createReducer({
INCREMENT: (state) => state + 1,
hugobessaa /
Created Jun 24, 2015
Run Node REPL with require support
node -e "require('repl').start({ignoreUndefined: true})"
hugobessaa /
Last active Jun 2, 2017
Composing styles

Composing styles

CSS Wizardry recently wrote a great post about styling: Contextual Styling: UI Components, Nesting, and Implementation Detail. He showed three ways to solve the problem of implementation details in a component's styles. I want to propose another way to solve this problem, one that uses composition.

The original styles of a .nav-primary component are:

.nav-primary {
  /* This is how the nav should always look: */
  margin:  0;
hugobessaa / om.cljs
Created May 24, 2015
My first 100 lines of ClojureScript
View om.cljs
(ns ^:figwheel-always om-tut.core
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[cljs.core.async :refer [put! chan <!]]
[ :as data]
[clojure.string :as string]))
hugobessaa /
Created May 18, 2015
Diff two command outputs (stdout) without using files
View prefs.json
"caret_extra_width": 2,
"caret_style": "phase",
"color_scheme": "Packages/User/base16-ocean.dark (SL).tmTheme",
"dictionary": "Packages/Dictionaries/Portuguese (Brazilian).dic",
"ensure_newline_at_eof_on_save": true,
hugobessaa / ideia-serviç
Last active Aug 29, 2015
Ideias para criação de serviços bem simples
View ideia-serviç

Serviços bem simples baseados em API públicas que tenham como objetivo facilitar a vida na cidade.

Algumas ideias do que é possível fazer:

You can’t perform that action at this time.