Skip to content

Instantly share code, notes, and snippets.

View tjanczuk's full-sized avatar

Tomasz Janczuk tjanczuk

View GitHub Profile
@tjanczuk
tjanczuk / ldap.js
Last active February 3, 2016 19:51
"use latest";
module.exports = (ctx, req, res) => {
const end = (statusCode, data) => {
res.writeHead(statusCode, { 'Content-Type': 'application/json' });
res.end(JSON.stringify(data, null, 2));
};
if (!ctx.data.connection) {
return end(500, { message: 'The Auth0 AD/LDAP Connection is missing.' });
@tjanczuk
tjanczuk / assembly.js
Created November 4, 2015 03:25
Get file name of Edge.js generated assembly
console.log(require('edge').func(function () {/*
async (input) =>
{
return System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
}
*/})(null, true));
@tjanczuk
tjanczuk / modules
Created October 26, 2015 23:55
webtask.io modules
{
"ramda": [
"0.18.0"
],
"plaid": [
"1.0.7"
],
"s3-blob-store": [
"0.1.0"
@tjanczuk
tjanczuk / capture_logs.md
Last active September 14, 2015 18:01
Per-request webtask logs

How to capture per-request webtask logs

Suppose the user has authored the following Node.js function. You want to execute it in webtasks while capturing the output generated by console.log calls within that function:

function (param, callback) {
  console.log('In my custom function. Parameter is:', param);
  callback(null, { hello: 'world' });
}
@tjanczuk
tjanczuk / getcode.md
Created September 8, 2015 23:28
Get code of named webtask

Getting the source code of the named webtask

Given webtask code in getcode.js:

module.exports = function (ctx, req, res) {
    if (ctx.query.code && req.method === 'GET') {
        var token = require('jsonwebtoken').decode(ctx.token);
        return require('request').get(token.url).pipe(res);
    }
@tjanczuk
tjanczuk / express_test.js
Created September 4, 2015 23:59
Express test
var Boom = require('boom');
var Bluebird = require('bluebird');
var Express = require('express');
var Webtask = require('webtask-tools');
var app = Express();
var router = Express.Router();
// do some async stuff
app.use(function (req, res, next) {
@tjanczuk
tjanczuk / xpub-xsub.js
Created August 24, 2015 23:59
How to connect 5 publishers with 5 subscribers over TCP using ZeroMQ's XPUB/XSUB proxy
// How to connect 5 publishers with 5 subscribers
// over TCP using ZeroMQ's XPUB/XSUB proxy.
// sub (connect)
// <-8701->
// (bind) xpub <---> xsub (bind)
// <-8700->
// (connect) pub
var zmq = require('zmq');
Lukasz Madon
lukasz.madon at google's mail
Experience:
September 2014 - Current, Green Man Gaming Ltd, London, United Kindom, Full Stack Developer
Extending bespoke e-commerce solution (Python, Django).
Integrating third-party API (Python, Cellery).
Scraping infrastructure for Xbox API (Go, CouchDB).
Building a new e-commerce platform in EPiServer (C#, ASP.Net) - Developing e-commerce frontend (AngularJS, Grunt, Node).
====================
December 2013 - September 2014, Firstartr.co, London, United Kindom, Full Stack Developer
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.4/raphael-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-sequence-diagrams/1.0.6/sequence-diagram-min.js"></script>
</head>
<body>
<h2>Create named webtask</h2>
<p>(revocation checking and authorization omitted for brevity)</p>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.4/raphael-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-sequence-diagrams/1.0.6/sequence-diagram-min.js"></script>
</head>
<body>
<h2>From zero to webtask</h2>
<div class="diagram">