Skip to content

Instantly share code, notes, and snippets.

View gr2m's full-sized avatar
🧚
automatin'

Gregor Martynus gr2m

🧚
automatin'
View GitHub Profile

What’s new in Hoodie Code land

Everything is gearing towards our “Tent Release”, not yet meant for production, but Hoodie is using PouchDB for sync and is rewritten from the ground up.

The core modules, Account (server, client) & Store (server, client), are now feature complete. The Hoodie main module (server, client) which pulls everything together, is still a bit rough around the edges, but ready, too.

We also created a new Hoodie default application: Something tracker. It’s a minimalistic app to track numbers and time without telling any meaning, so it’s great as a starting point to explore Hoodie and build an app

var fs = require('fs')
var PDF = require('dream-pdf')
var tableData = require('./table.json')
PDF.plugin(require('dream-pdf-text'))
PDF.plugin(require('dream-pdf-image'))
PDF.plugin(require('dream-pdf-table'))
pdf = new PDF({
size: [210, 297]
function securityWrapper(checkAllowed, original, args) {
var userCtx = args.options.userCtx || {
//Admin party!
name: null,
roles: ["_admin"]
};
if (userCtx.roles.indexOf("_admin") !== -1) {
return original();
}
if (!checkAllowed) {
@gr2m
gr2m / gistbook.json
Created December 10, 2014 18:10
Anonymous Gistbook
{"title":"Anonymous Gistbook","author":"gr2m","pages":[{"pageName":"","sections":[{"type":"text","source":"# Welcome to Gistbook!\n\n$$x = \\int_a^b{x\\mathrm{d}x}$$"},{"type":"html","source":"<div>hello</div>"},{"type":"css","source":"div {\n\n background: #333;\n}"},{"type":"javascript","source":"var _ = require('underscore');\n\n_.each([1,2,3], function(num) {\n console.log('hello');\n})"}]}],"public":true}
promise = new Promise(function (resolve, reject) {
// do stuff here
}
promise.then(null, null, function progressHandler() {
// how to get here?!
});
@gr2m
gr2m / combine_requests.js
Created September 4, 2014 11:51
How to achive the logic below with the native JavaScript Promise implementation?
var requestPromise;
function getCurrentState() {
// prevent sending multiple GET requests to /state.json. If one is pending, return its promise
if (requestPromise.isPending()) return requestPromise;
requestPromise = ajaxRequestReturningPromise('GET', '/state.json');
return requestPromise;
}
promise1 = getCurrentState()
promise2 = getCurrentState()
@gr2m
gr2m / reproduce.md
Last active August 29, 2015 14:05
showcase of problem with PhantomJS

setup

git clone https://github.com/hoodiehq/hoodie-admin-dashboard/
cd hoodie-admin-dashboard
gco admin_dashboard_tests
npm install
bower install
grunt serve
@gr2m
gr2m / .bash_profile
Created July 30, 2014 13:44
serve the assets of current folder with CORS headers
alias corsserver="echo -e \"from SimpleHTTPServer import SimpleHTTPRequestHandler\nimport BaseHTTPServer\nclass CORSRequestHandler (SimpleHTTPRequestHandler):\n def end_headers (self):\n self.send_header('Access-Control-Allow-Origin', '*')\n SimpleHTTPRequestHandler.end_headers(self)\nif __name__ == '__main__':\n BaseHTTPServer.test(CORSRequestHandler, BaseHTTPServer.HTTPServer)\" | python"
@gr2m
gr2m / learnings.md
Last active August 29, 2015 14:04
I've read the whole Bootstrap 3 documentation. I learned a few new things.
@gr2m
gr2m / hoodie.plugins.js
Created May 28, 2014 17:55
Hoodie Plugin that maintains a local list of user accounts that have been used in a browser. See discussion at https://github.com/hoodiehq/discussion/issues/42
'use strict';
var hoodie = require('backbone').hoodie;
hoodie.extend(function(hoodie,lib, utils) {
var PROFILES_STORE_KEY = '_hoodie_profiles';
var store = utils.localStorageWrapper;
var api = getAllProfiles;
var profiles = store.getObject(PROFILES_STORE_KEY) || [];
//