Skip to content

Instantly share code, notes, and snippets.

Avatar

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 -->
<Response>
<!-- Say and Dial are Verbs -->
<Say>Thank you for calling Telnyx.</Say>
<Dial>
<Sip>sip:gencredhoj84HXAATNAXTfLJBkZBFv0sr@sip.telnyx.com</Sip>
</Dial>
</Response>
View simple-comp.cljs
(defn button [props _]
(om/component
(dom/button nil (:children props))))
(def render-out (om/render-to-object button {:children "text"}))
(is (= "text" (:children render-out))
@hugobdev
hugobdev / connect-cljs.repl.md
Created Oct 8, 2015
Connect to ClojureScript Node nREPL
View connect-cljs.repl.md

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
hugobdev / a.sh
Created Jun 24, 2015
Run Node REPL with require support
View a.sh
node -e "require('repl').start({ignoreUndefined: true})"
@hugobdev
hugobdev / comp.md
Last active Jun 2, 2017
Composing styles
View comp.md

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
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 <!]]
[clojure.data :as data]
[clojure.string :as string]))
(enable-console-print!)
@hugobdev
hugobdev / readme.md
Created May 18, 2015
Diff two command outputs (stdout) without using files
View readme.md
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,
"folder_exclude_patterns":
[
".svn",
".git",
You can’t perform that action at this time.