Skip to content

Instantly share code, notes, and snippets.

View DrBoolean's full-sized avatar

Brian Lonsdorf DrBoolean

View GitHub Profile
@DrBoolean
DrBoolean / notification_3.js
Last active August 26, 2015 21:45
Blog post about salesforce design system + react 5
render: function() {
return (
<div className="slds-notify-container">
<div className="slds-notify slds-notify--alert" role="alert">
<span className="slds-assistive-text">info</span>
<button className="slds-button slds-notify__close slds-icon--small">
<svg aria-hidden="true" className="slds-button__icon slds-button__icon--inverse" dangerouslySetInnerHTML={{__html:'<use xlink:href="/assets/icons/action-sprite/svg/symbols.svg#close"></use>'}}>
</svg>
<span className="slds-assistive-text">Close</span>
</button>
@DrBoolean
DrBoolean / notification_4.js
Last active August 27, 2015 00:19
Blog post about salesforce design system + react 6
var Notification = React.createClass({
render: function() {
var theme = this.props.theme || 'info';
var themeClass = 'slds-theme--' + theme;
var className = "slds-notify slds-notify-alert " + themeClass;
return (
<div className="slds-notify-container">
<div className={className} role="alert">
@DrBoolean
DrBoolean / notification_5.js
Last active August 27, 2015 00:20
Blog post about salesforce design system + react 7
var Notification = function(variant) {
var comp = React.createClass({
render: function() {
var theme = this.props.theme || 'info';
var themeClass = 'slds-theme--' + theme;
var className = "slds-notify slds-notify--" + variant + ' ' + themeClass;
return (
<div className="slds-notify-container">
<div className={className} role="alert">
@DrBoolean
DrBoolean / app_3.js
Created August 26, 2015 17:36
Blog post about salesforce design system + react 8
var App = React.createClass({
render: function() {
return (
<div>
<Notification.Toast theme="error">
<h2 className="slds-text-heading--small">Beware of the Trash Dragons!</h2>
</Notification.Toast>
</div>
);
@DrBoolean
DrBoolean / app_4.js
Created August 26, 2015 23:36
Blog post about salesforce design system + react n
var App = React.createClass({
render: function() {
return (
<div>
<Notification theme="error">
<h2 className="slds-text-heading--small">Beware of the Trash Dragons!</h2>
</Notification>
</div>
);
@DrBoolean
DrBoolean / io-example.js
Created September 15, 2015 19:08
IO reason
// createView = {} -> Html
//+ setHtml :: String -> Html -> IO DOM
var setHtml = curry(function(sel, h){
return new IO(function() {return jQuery(sel).html(h) })
})
var updateDom = compose(setHtml('#tag-cloud'), createView)
// IO(DOM)
@DrBoolean
DrBoolean / debug.md
Last active July 30, 2018 18:15
Debugging Functional post

Debugging Functional

What's the problem

When working with ramda or lodash-fp, one may run into some rather cryptic error messages. When trying to console.log a function we're presented with the guts of some internal curry or compose implementation that tells us nothing. At Loop/Recur we enjoy working with Functional JavaScript so I'd like to see this improve.

This post will demonstrate a simple solution that can go a long way to enhance the debugging experience in functional JavaScript applications.

Test subjects

@DrBoolean
DrBoolean / d1.js
Created October 6, 2015 17:57
debug_1
var add = curry(function add(x, y){ return x + y });
var map = curry(function map(f, xs){ return xs.map(f) });
var head = function(xs){ return xs[0] };
@DrBoolean
DrBoolean / d2.js
Created October 6, 2015 18:02
Debug_2
function curry(fx) {
var arity = fx.length;
function f1() {
var args = Array.prototype.slice.call(arguments, 0);
if (args.length >= arity) return fx.apply(null, args);
function f2() {
return f1.apply(null, args.concat(Array.prototype.slice.call(arguments, 0)));
}
@DrBoolean
DrBoolean / d3.js
Created October 6, 2015 18:03
Debug_3
var inc = add(1);
console.log(inc)
// function f2() {
// return f1.apply(null, args.concat(Array.prototype.slice.call(arguments, 0)));
// }