Skip to content

Instantly share code, notes, and snippets.


Hugo Bessa hugobdev

View GitHub Profile
View example-call-control-texml-app.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- TeXML files must contain the Response element -->
<!-- Say and Dial are Verbs -->
<Say>Thank you for calling Telnyx.</Say>
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))
hugobdev /
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,
hugobdev /
Created Jun 24, 2015
Run Node REPL with require support
node -e "require('repl').start({ignoreUndefined: true})"
hugobdev /
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;
hugobdev / 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]))
hugobdev /
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,
You can’t perform that action at this time.