Skip to content

Instantly share code, notes, and snippets.

View tjanczuk's full-sized avatar

Tomasz Janczuk tjanczuk

View GitHub Profile
@tjanczuk
tjanczuk / ai.md
Created November 7, 2024 20:28
65 Simple Steps to AI Mastery
@tjanczuk
tjanczuk / FusebitEditor.js
Created October 18, 2019 16:28
Fusebit Editor React
import React from "react";
export default class FusebitEditor extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div style={{width: '100%', height: '100%'}} ref={el => this.el = el} />
);
@tjanczuk
tjanczuk / migrate.js
Last active April 2, 2018 20:46
Best effort migration of Node 4 webtask to Node 8
'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;
{"keys":[{"alg":"RS256","kty":"RSA","use":"sig","x5c":["MIIEmDCCAoACCQChbjG7ddWnpzANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJVUzAgFw0xODAzMjYyMzE2MzNaGA8yMjkyMDEwODIzMTYzM1owDTELMAkGA1UEBhMCVVMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC7ohIODS84VeiO6kvxitZcUKXp0NllAdboIk0YXpD5wMsK+IjCmU/whhFGTJOy3P4QjQKsKg1xHiKxjUHwitlyaSB0Qvo6S4PZ89BpzW4BXWxAET9y2f4IVRlaN26aR1J8A3H8KrJjihCRkUNy0umgjlhStiT8/69sS4PIakGuLy2hwrL+nbqKhSuQJNtV0T8iKTLCsYuxWF1EcFEeowt3OBmFDIIHcKhbhF4kPZ2vFRcVVcrFhsDDLkeR27tXDepXzq2R54EwWgrquhifQArTCmYyn4l8+rd7fu6qmbCm3U8B3Ej7tkwP9z2RHORo7dAu6nde4Ur5y/iXaG7sH1Yu0SZpQZJaU74rYUlEgwsYj/1/LkWH1fRSvnzbri3dlahikZ3vD+7yMptuvRBvVmJK4blNHJuTO5xneam6DymgP2Tp3Re12QCVJbIsCrNAtiZPMkTN+nbY0uUJolkX6oSfwcGg0PVzLPmSStOKYq3qex72ZfZicvakuc00673fhZKXP45PZvFctJ3iHGGlwikNX7xK2RgdqyTQ1x98iusdWQLArEfs/xnfwhfkSn557J91IuYnKI/hxK3N4C/RvOwz0gqXNZr+rjETsSOXKObflj9PNbKu4eTz38yB5gJeCUpYpQhOiMCaQySffgNYBg7getbkTvDpSRsHwu7R0kbYPwIDAQABMA0GCSqGSIb3DQEBCwUAA4ICAQC0kud3XmRS9ArOOMxSndDhsIl3WJbYQxK3lekj4iyLEK005Z9krAXAd0iGemU8LaEBw2TVY+FVmYtB

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

@tjanczuk
tjanczuk / foo.js
Last active November 11, 2016 16:13
sdfsdfsdfsdff
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];
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) {
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 });
});
});
});
};
module.exports = function (options, cb) {
return cb(null, function (cb) {
cb(null, options.script);
});
};