Skip to content

Instantly share code, notes, and snippets.

Avatar

Connor Clark connorjclark

View GitHub Profile
@reillyeon
reillyeon / async_function_return.md
Last active February 22, 2022 16:05
When does an async function return?
View async_function_return.md

When does an async function return?

Someone recently asked me when an async function in JavaScript "returns". This is an interesting question because while a function like f() below has a return statement in it, f() actually returns much earlier than that. To understand how this works, let's take a look at an example function. Here, a() and c() are normal synchronous functions and b() is another asynchronous function.

async function f() {
  a();
  await b();
  return c();
}
@jimmywarting
jimmywarting / custom json replacer reviver.md
Last active August 15, 2022 10:25
Custom json replacer/reviver with extended support
View custom json replacer reviver.md

This custom json replacer/reviver allow you to store more types as json and still keep it as valid json.

features

  • Allow you to stringify/parse
    • BigInt
    • Infinity
    • NaN
    • Date
    • typed arrays & ArrayBuffers as web-safe base64
View csp-bypass.js
const linkEl = document.createElement('link');
linkEl.rel = 'prefetch';
linkEl.href = urlWithYourPreciousData;
document.head.appendChild(linkEl);
@ageis
ageis / systemd_service_hardening.md
Last active March 28, 2023 20:50
Options for hardening systemd service units
View systemd_service_hardening.md

security and hardening options for systemd service units

A common and reliable pattern in service unit files is thus:

NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
DevicePolicy=closed
ProtectSystem=strict
@wu-sheng
wu-sheng / opentracing-zipkin.md
Created December 21, 2016 06:30 — forked from codefromthecrypt/opentracing-zipkin.md
My ramble on OpenTracing (with a side of Zipkin)
View opentracing-zipkin.md

I've had many people ask me questions about OpenTracing, often in relation to OpenZipkin. I've seen assertions about how it is vendor neutral and is the lock-in cure. This post is not a sanctioned, polished or otherwise muted view, rather what I personally think about what it is and is not, and what it helps and does not help with. Scroll to the very end if this is too long. Feel free to add a comment if I made any factual mistakes or you just want to add a comment.

So, what is OpenTracing?

OpenTracing is documentation and library interfaces for distributed tracing instrumentation. To be "OpenTracing" requires bundling its interfaces in your work, so that others can use it to time distributed operations with the same library.

So, who is it for?

OpenTracing interfaces are targeted to authors of instrumentation libraries, and those who want to collaborate with traces created by them. Ex something started a trace somewhere and I add a notable event to that trace. Structure logging was recently added to O

@carlos-jenkins
carlos-jenkins / multihooks.py
Last active March 1, 2023 23:03
Delegating script for multiple git hooks
View multihooks.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2015-2017 Carlos Jenkins <carlos@jenkins.co.cr>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@paulirish
paulirish / bling.js
Last active March 18, 2023 15:36
bling dot js
View bling.js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@dtao
dtao / increment_decrement.py
Created May 25, 2012 16:10
Sublime Text plugin to increment/decrement all selected numbers
View increment_decrement.py
import sublime
import sublime_plugin
class NumberCommand(sublime_plugin.TextCommand):
def run(self, edit):
selection = self.view.sel()
for region in selection:
try:
value = int(self.view.substr(region))
self.view.replace(edit, region, str(self.op(value)))
@rndmcnlly
rndmcnlly / chromatic-maze-generator.lp
Created August 31, 2010 05:06
chromatic maze generator in ASP
View chromatic-maze-generator.lp
%%%%
%%%% A chromatic maze generator
%%%%
% By Adam M. Smith (amsmith@soe.ucsc.edu)
% This answer set program was designed to work with the Potassco (the Potsdam
% Answer Set Solving Collection) tools, namely "clingo".
%% Chromatic Mazes