Skip to content

Instantly share code, notes, and snippets.

Tomasz Janczuk tjanczuk

Block or report user

Report or block tjanczuk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tjanczuk
tjanczuk / migrate.js
Last active Apr 2, 2018
Best effort migration of Node 4 webtask to Node 8
View migrate.js
'use strict';
const Async = require('async');
const Acorn = require('acorn');
const AcornWalk = require('acorn/dist/walk');
const Astring = require('astring');
const Superagent = require('superagent');
module.exports = migrate;
View Foo.json
{"keys":[{"alg":"RS256","kty":"RSA","use":"sig","x5c":["MIIEmDCCAoACCQChbjG7ddWnpzANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJVUzAgFw0xODAzMjYyMzE2MzNaGA8yMjkyMDEwODIzMTYzM1owDTELMAkGA1UEBhMCVVMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC7ohIODS84VeiO6kvxitZcUKXp0NllAdboIk0YXpD5wMsK+IjCmU/whhFGTJOy3P4QjQKsKg1xHiKxjUHwitlyaSB0Qvo6S4PZ89BpzW4BXWxAET9y2f4IVRlaN26aR1J8A3H8KrJjihCRkUNy0umgjlhStiT8/69sS4PIakGuLy2hwrL+nbqKhSuQJNtV0T8iKTLCsYuxWF1EcFEeowt3OBmFDIIHcKhbhF4kPZ2vFRcVVcrFhsDDLkeR27tXDepXzq2R54EwWgrquhifQArTCmYyn4l8+rd7fu6qmbCm3U8B3Ej7tkwP9z2RHORo7dAu6nde4Ur5y/iXaG7sH1Yu0SZpQZJaU74rYUlEgwsYj/1/LkWH1fRSvnzbri3dlahikZ3vD+7yMptuvRBvVmJK4blNHJuTO5xneam6DymgP2Tp3Re12QCVJbIsCrNAtiZPMkTN+nbY0uUJolkX6oSfwcGg0PVzLPmSStOKYq3qex72ZfZicvakuc00673fhZKXP45PZvFctJ3iHGGlwikNX7xK2RgdqyTQ1x98iusdWQLArEfs/xnfwhfkSn557J91IuYnKI/hxK3N4C/RvOwz0gqXNZr+rjETsSOXKObflj9PNbKu4eTz38yB5gJeCUpYpQhOiMCaQySffgNYBg7getbkTvDpSRsHwu7R0kbYPwIDAQABMA0GCSqGSIb3DQEBCwUAA4ICAQC0kud3XmRS9ArOOMxSndDhsIl3WJbYQxK3lekj4iyLEK005Z9krAXAd0iGemU8LaEBw2TVY+FVmYtB
View Howto.md

In order to use this slash webtask, you must configure the following secrets in the webtask editor:

TWILIO_NUMBER - the "from" twilio number
TWILIO_SID, TWILIO_AUTH_TOKEN - your twilio credentials

View bash-compiler.js
var spawn = require('child_process').spawn;
module.exports = function (options, cb) {
return cb (null, function (ctx, req, res) {
res.writeHead(200, 'text/plain');
var env = process.env;
if (Object.keys(ctx.secrets).length > 0) {
env = {};
for (var e in process.env)
env[e] = process.env[e];
View sql_compiler.js
var mysql = require('mysql');
// Webtask compiler entry point. options.script contains parameterized T-SQL script.
module.exports = function (options, cb) {
// Return a JavaScript function in one of the three basic signatures supported by Webtasks
return cb(null, function (ctx, cb) {
// Create MySQL connection on first invocation
if (!global.connection) {
View login-success.js
module.exports = function (options, cb) {
options.nodejsCompiler('return ' + options.script, function (error, func) {
if (error) return cb(error);
return cb(null, function (ctx, cb) {
func(ctx.body.user, ctx.body.context, function (error, user, context) {
cb(error, error ? null : { user: user, context: context });
});
});
});
};
View reflector_compiler.js
module.exports = function (options, cb) {
return cb(null, function (cb) {
cb(null, options.script);
});
};
@tjanczuk
tjanczuk / hello-auth.js
Created May 6, 2016
Authenticated Webtask
View hello-auth.js
var app = new (require('express'))();
var ejs = require('ejs');
var wt = require('webtask-tools');
Function.prototype.stringify = function () {
var match = this.toString().match(/[^]*\/\*([^]*)\*\/\s*\}$/);
return match ? match[1] : '';
};
app.get('/', function (req, res) {
View ldap.js
"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.' });
You can’t perform that action at this time.