Skip to content

Instantly share code, notes, and snippets.

View mnpenner's full-sized avatar
:octocat:

Mark Penner mnpenner

:octocat:
View GitHub Profile
@adtac
adtac / Dockerfile
Last active April 13, 2024 22:33
#!/usr/bin/env docker run
#!/usr/bin/env -S bash -c "docker run -p 8080:8080 -it --rm \$(docker build --progress plain -f \$0 . 2>&1 | tee /dev/stderr | grep -oP 'sha256:[0-9a-f]*')"
# syntax = docker/dockerfile:1.4.0
FROM node:20
WORKDIR /root
RUN npm install sqlite3

Moved to repo: /quenhus/uBlock-Origin-dev-filter

In order to keep filters up to date, please use this repo.

@sebmarkbage
sebmarkbage / WhyReact.md
Created September 4, 2019 20:33
Why is React doing this?

I heard some points of criticism to how React deals with reactivity and it's focus on "purity". It's interesting because there are really two approaches evolving. There's a mutable + change tracking approach and there's an immutability + referential equality testing approach. It's difficult to mix and match them when you build new features on top. So that's why React has been pushing a bit harder on immutability lately to be able to build on top of it. Both have various tradeoffs but others are doing good research in other areas, so we've decided to focus on this direction and see where it leads us.

I did want to address a few points that I didn't see get enough consideration around the tradeoffs. So here's a small brain dump.

"Compiled output results in smaller apps" - E.g. Svelte apps start smaller but the compiler output is 3-4x larger per component than the equivalent VDOM approach. This is mostly due to the code that is usually shared in the VDOM "VM" needs to be inlined into each component. The tr

@vlucas
vlucas / encryption.js
Last active April 2, 2024 14:26
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
@AlinaNova21
AlinaNova21 / apitoken.js
Created October 27, 2016 21:14
apitoken mod for screeps server
// Add a new function to player sandbox space
// Some Super Secret Secret (32 character hex string)
const secret = Buffer.from('DEADBEEF000000000000000000000000', 'hex')
const jwt = require('./lib/jwt')
module.exports = function (config) {
if (config.engine) {
config.engine.onPlayerSandbox = function (sandbox) {
sandbox.getAPIToken = function () {
let key = generateToken(sandbox.module.user)
@moodysalem
moodysalem / promise-cancellable.js
Last active April 9, 2024 18:06
ES6 Cancellable Promise Wrapper
/**
* Returns a promise that has a cancelled method that will cause the callbacks not to fire when it resolves or rejects
* @param promise to wrap
* @returns new promise that will only resolve or reject if cancel is not called
*/
export default function cancellable(promise) {
var cancelled = false;
const toReturn = new Promise((resolve, reject) => {
promise.then(() => {
@Nilpo
Nilpo / password_api_test.php
Created January 8, 2016 08:52
A simple PHP script for testing what cost you should use with your server for password_hash() in PHP 5.5.0+
<?php
/**
* This code will benchmark your server to determine how high of a cost you can
* afford. You want to set the highest cost that you can without slowing down
* you server too much. 8-10 is a good baseline, and more is good if your servers
* are fast enough. The code below aims for ≤ 50 milliseconds stretching time,
* which is a good baseline for systems handling interactive logins.
*/
function_exists('password_hash') or die("Please use PHP 5.5.0 or higher.");
@OlegIlyenko
OlegIlyenko / Event-stream based GraphQL subscriptions.md
Last active February 24, 2024 04:41
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

@smarr
smarr / truffle-material.md
Last active March 16, 2023 14:06
Truffle: Languages and Material
@dzhu
dzhu / screeps.py
Last active November 14, 2020 10:18
description of the HTTP endpoints available from Screeps, and a Python wrapper to access them (requires requests library)
import json
from base64 import b64decode
from collections import OrderedDict
from cStringIO import StringIO
from gzip import GzipFile
import requests
## Python before 2.7.10 or so has somewhat broken SSL support that throws a warning; suppress it