Skip to content

Instantly share code, notes, and snippets.

View lupomontero's full-sized avatar

Lupo Montero lupomontero

View GitHub Profile
////////////////////////////////////////////////////////////////////////////////
// /Users/lupo/Documents/workspace/wrangr/hoodie-server/node_modules/hoodie/dist/hoodie.js
////////////////////////////////////////////////////////////////////////////////
// Hoodie.js - 0.6.3
// https://github.com/hoodiehq/hoodie.js
// Copyright 2012 - 2014 https://github.com/hoodiehq/
// Licensed Apache License 2.0
!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.Hoodie=e():"undefined"!=typeof global?global.Hoodie=e():"undefined"!=typeof self&&(self.Hoodie=e())}(function(){var define,module,exports;return (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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof requi
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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.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})({1:[function(require,module,exports){
Hoodie.extend(function(hoodie) {
hoodie.email = {
send: hoodie.task('email').start
}
});
},{}],2:[function(require,module,exports){
// TODO: This is not being included at all at moment as we are not loading
// hoodie.js using `/_api/_files/hoodie.js` because that seems to throw an error
<html>
<head>
<title>Test</title>
<script type="text/javascript">
'use strict';
(function () {
console.log('Got here.');
}());
</script>
var psl = require('psl');
var parsed = psl.parse('a.b.c.d.foo.uk.com');
console.log(parsed.tld); // 'uk.com'
console.log(parsed.sld); // 'foo'
console.log(parsed.domain); // 'foo.uk.com'
console.log(parsed.subdomain); // 'a.b.c.d'
var psl = require('psl');
var parsed = psl.parse('a.b.ide.kyoto.jp');
console.log(parsed.tld); // 'ide.kyoto.jp'
console.log(parsed.sld); // 'b'
console.log(parsed.domain); // 'b.ide.kyoto.jp'
console.log(parsed.subdomain); // 'a'
var parsed2 = psl.parse('www.sony.jp');
var psl = require('psl');
var parsed = psl.parse('www.食狮.中国');
console.log(parsed.tld); // '中国'
console.log(parsed.sld); // '食狮'
console.log(parsed.domain); // '食狮.中国'
console.log(parsed.subdomain); // 'www'
var parsed2 = psl.parse('shishi.中国');
@lupomontero
lupomontero / gist:a2e3f023c3eee09e6873
Last active August 29, 2015 14:11
Getting instance of hoodie plugins API in static hook
var path = require('path');
// `npm install --save hoodie-plugins-api` in your plugin dir
var PluginAPI = require('hoodie-plugins-api').PluginAPI;
//
// Poor man's hoodie API.
//
function getHoodie(settings) {
var hoodieAdmin = {
user: process.env.HOODIE_ADMIN_USER,
@lupomontero
lupomontero / gist:9df6f28dd6eb4b31d1eb
Last active August 29, 2015 14:22
Install pre-compiled PhantomJS 1.9.8 on SmartOS
PREFIX=/opt/local
SRC=$PREFIX/src/phantomjs
DOWNLOAD_FILE=phantomjs-1.9.8-smartos-i386.tgz
DOWNLOAD_URL=https://us-east.manta.joyent.com/pkgsrc/public/packages/SmartOS/phantomjs/$DOWNLOAD_FILE
# Create directory where we are going to put phantomjs' source files
mkdir -p $SRC
# Go into dir, download and extract archive
cd $SRC
wget $DOWNLOAD_URL
# Enable GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
# END GZIP
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE "application/atom+xml" \
"application/javascript" \
"application/json" \
@lupomontero
lupomontero / intersection-functional-es6.js
Last active February 15, 2017 20:41
Declarativo vs Imperativo
function intersection(a, b) {
return a.filter(value => b.indexOf(value) > -1).sort();
}