Skip to content

Instantly share code, notes, and snippets.

const apiCall = async () => {
let response = await fetch("https://jsonplaceholder.typicode.com/todos/1");
let json = await response.json();
console.log(json)
}
@herecydev
herecydev / timehandler.js
Last active December 27, 2018 12:13
timehandler.js
const taskHandler = async (task) => {
try {
const start = Date.now();
log.info("Executing {taskId}", { taskId: task.taskId });
const handler = await import(`handlers/${task.taskId}`);
const result = await handler.execute(task);
const end = Date.now();
log.info("Task Handler {taskId} succeeded in {time}ms", { taskId: task.taskId, time: end - start });
return result;
}
@herecydev
herecydev / errorhandler.js
Created December 27, 2018 11:35
errorhandler.js
const taskHandler = async (task) => {
try {
log.info("Executing {taskId}", { taskId: task.taskId });
const handler = await import(`handlers/${task.taskId}`);
return await handler.execute(task);
}
catch (error) {
log.error(error, "Task Handler {taskId} failed", { taskId: task.taskId });
return -1;
}
@herecydev
herecydev / basehandler.js
Created December 27, 2018 11:30
basehandler.js
const taskHandler = async (task) => {
try {
const handler = await import(`handlers/${task.taskId}`);
return await handler.execute(task);
}
catch {
return -1;
}
}
public class Startup
{
public IConfiguration Configuration { get; }
public Startup()
{
var builder = new ConfigurationBuilder()
.AddEnvironmentVariables();
Configuration = builder.Build();
}
@herecydev
herecydev / gist:d804be07f0a2909bbe88827fc7395500
Created April 20, 2017 10:10
Dynamic resolver and proxy pass for nginx
http {
resolver 127.0.0.11 valid=1s;
server {
listen 80;
set $foo "http://foo:80";
set $bar "http://bar:80";
location /foo/ {
rewrite ^/foo/(.*) /$1 break;
@herecydev
herecydev / base.js
Last active March 15, 2017 12:04
WebpackMerge array
let clientConfig = {
entry: "./src/website/js/App.tsx"
}
let serverConfig = {
entry: "./src/server/server.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "server.js",
},
declare type DataReceived = (data: any) => void;
class Connection {
constructor() {
let thisHubConnection = this;
this.dataReceived = data => {
this.log(data);
thisHubConnection.log(data);
};
@herecydev
herecydev / Helloworld.cs
Last active October 10, 2016 19:43
Merge problem
//Instatiate A and call start
public class A
{
private readonly C _c;
public A()
{
_c = new C();
var b = new B(new[] { _c });