Skip to content

Instantly share code, notes, and snippets.

View dariocravero's full-sized avatar

Darío Javier Cravero dariocravero

View GitHub Profile
@dariocravero
dariocravero / README.md
Created May 22, 2016 10:31 — forked from marten-de-vries/README.md
Running CouchApps on PouchDB in the browser using service workers - without any modifications!

Running CouchApps on PouchDB in the browser using service workers

What is this?

A description of how to run an existing CouchApp on PouchDB in the browser using service workers - without any modifications to existing code being necessary! The best thing is that if service workers aren't available, the CouchApp will still run as normal: that is, online.

Demo

@dariocravero
dariocravero / app.js
Last active March 10, 2016 20:57
overly simplistic and dumb cold reload poc
import coldReload from './cold-reload';
// ...
const cold = coldReload();
const store = configureStore(cold.state);
cold.run(store);
// ...
@dariocravero
dariocravero / withsection.erl
Last active February 22, 2016 20:19
jwt-blacklist
jwt_authentication_handler(Req) ->
case header_value(Req, "Authorization") of
"Bearer " ++ Token ->
try
ensure_safe_token(Token, couch_config:get("jwt_auth_blacklist")),
token_auth_user(Req, decode(Token))
catch
% return generic error message (https://www.owasp.org/index.php/Authentication_Cheat_Sheet#Authentication_Responses)
throw:_ -> throw({unauthorized, <<"Token rejected">>});
error:_ -> throw({unauthorized, <<"Token rejected">>})
couch_jwt_auth [master*] $ ./build.sh
==> erlsha2 (get-deps)
==> jsx (get-deps)
==> ejwt (get-deps)
==> couch_jwt_auth (get-deps)
==> erlsha2 (compile)
Compiling c_src/erlsha2_nif.c
Compiling c_src/hmac_nif.c
==> jsx (compile)
==> ejwt (compile)
import { Howl } from 'howler/src/howler.core';
export default function createHowl(src, onEnd) {
return new Promise(function(resolve, reject) {
const howl = new Howl({
autoplay: false,
onend: onEnd,
src: [src],
onload() { resolve(howl) },
onloadeerror: reject
export async function load({id, src, onEnd}) {
const node = await createNode(src, onEnd);
nodes[id] = node;
return {
duration: node.duration()
};
}
iframe.contentWindow.addEventListener('beforeunload',() => this.middlewareCleanupWrapper() );
if (this.observer) {
this.observer.disconnect();
}
this.observer = new MutationObserver(mutations => {
iframe.parentElement.style.height = iframe.contentDocument.documentElement.offsetHeight + 'px';
});
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"app.com":[function(require,module,exports){
// app.js
var PanelsUi = require('panels-ui');
var React = require('react');
var lookup = [
'/hi-:name'
];
var panels = {
server {
listen 80 default_server;
server_name _;
keepalive_timeout 5;
root /var/www/panels-pages;
access_log /var/log/panels-pages-nginx.access.log;
error_log /var/log/panels-pages-nginx.error.log;
@dariocravero
dariocravero / colour-signal.html
Created December 28, 2015 23:35
colour signal in a very old angular implementation by uxtemple, we'll hopefully release a new one soon http://s15.postimg.org/hczxtghzv/Screen_Shot_2015_12_28_at_22_37_45.png
<div class="colour-signal">
<div class="colour-signal-basics colour-signal-choices clearfix">
<div class="colour-signal-basics-transparent colour-signal-choice colour-signal-basics-choice" ng-class="{ &#39;colour-signal-choice-active&#39;: colour === &#39;transparent&#39; }" ng-click="colour=&quot;transparent&quot;"></div>
<div class="colour-signal-basics-white colour-signal-choice colour-signal-basics-choice" ng-class="{ &#39;colour-signal-choice-active&#39;: hue === 0 &amp;&amp; saturation === 0 &amp;&amp; lightness &gt;= 50}" ng-click="hue=0;saturation=0;lightness=100;"></div>
<div class="colour-signal-basics-black colour-signal-choice colour-signal-basics-choice" ng-class="{ &#39;colour-signal-choice-active&#39;: hue === 0 &amp;&amp; saturation === 0 &amp;&amp; lightness &lt; 50 }" ng-click="hue=0;saturation=0;lightness=0;"></div>
<input class="colour-signal-custom" ng-model="colour" style="border-color: {{ colour }}" />
</div>
<div class="colour-signal-hue colour-signal-choices clea