Skip to content

Instantly share code, notes, and snippets.

View bjrmatos's full-sized avatar

BJR Matos bjrmatos

View GitHub Profile

repeat(a) -> [a]

Inspired by Haskell, I wanted to see if I could replicate, using ES6 features, the repeat function:

repeat :: a -> [a]

So as you can see in repeat.js, I have done exactly that. However there are some caveats.

'use strict';
var React = require('react');
function createAsyncHandler(getHandlerAsync, displayName) {
var Handler = null;
return React.createClass({
displayName: displayName,
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@bjrmatos
bjrmatos / app.js
Last active August 29, 2015 14:21
Testing output of xmldom serializer (.toString) with xml namespaces
'use strict';
var dom = require('xmldom').DOMParser,
select = require('xml-crypto').xpath,
c14n = require("xml-c14n")();
var canonicaliser = c14n.createCanonicaliser("http://www.w3.org/2001/10/xml-exc-c14n#");
var doc = new dom().parseFromString(
'<root xmlns:ds="http://www.w3.org/2000/09/xmldsig#">' +
@bjrmatos
bjrmatos / index.html
Created April 8, 2015 05:44
webpack dev server config
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>React Interval</title>
</head>
<body>
<div id="app"></div>
@bjrmatos
bjrmatos / # Sublime Emmet JSX Reactjs.md
Last active August 29, 2015 14:17 — forked from max-mykhailenko/# Sublime Emmet JSX Reactjs.md
Sublime text 3. Enable Emmet in JSX files with Sublime React plugin

Problem

  • Using emmet in jsx files
  • Emmet expands text when js autocomplete needed
  • Using className instead of class

How it works

  • Install plugin RegReplace
  • Install plugin Chain Of Command
@bjrmatos
bjrmatos / higher-order-error-handling.js
Created January 31, 2015 04:57
higher order error handling
/* Turn this */
router.get("/api/products/:id", function(req, res) {
Product.getProduct(req.params.id, function(err, products) {
if (err) {
res.status(404).json({"message": "Not Found"});
}
else {
res.status(200).json(products);
}
});
@bjrmatos
bjrmatos / friday_deploy.txt
Last active March 25, 2023 17:57 — forked from mathroc/friday_deploy.txt
Friday Deploy ascii image
┐┌┐┌┐
┘└┘└┘\ₒ/
┐┌┐┌┐ ∕ Friday
┘└┘└┘ノ)
┐┌┐┌┐ deploy,
┘└┘└┘
┐┌┐┌┐ good
┘└┘└┘
┐┌┐┌┐ luck!
│││││
@bjrmatos
bjrmatos / dotslashtaskdotjs.markdown
Last active May 19, 2016 11:53
task runner - only plain JS

why ./task.js?

One word: task automation. It's basically zero effort and you can use the ./task.js package manager to handle any repetitive tasks. You can use ./task.js to automate everything with minimum effort.

./task.js provides the structure, order, and authority that you as a developer so desperately crave. ./task.js will also take responsibility for your actions if you need it to. It's what everybody is using now. ./task.js is the new hotness. It's all about ./task.js now, just like that.

This is compared to npm run/bash scripts, which are:

@bjrmatos
bjrmatos / AVOID-RELATIVE-PATH-JADE.txt
Last active August 29, 2015 14:12
Avoid relative paths in jade
To avoid ../../../views/layout you can set jade's basedir
config variable: app.locals.basedir = __dirname + '/views';
and after that you should use 'absolute' (absolute from basedir)
paths in your views, eg: extends /layout