This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This application converts a text message to uppercase by spawning a child process as another user and saves it to a file. | |
* | |
* Usage: app.exe MESSAGE FILE_PATH | |
* or | |
* Usage: app.exe DOMAIN USERNAME PASSWORD MESSAGE FILE_PATH | |
* | |
* | |
* Setup instructions: | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from boto3.session import Session | |
from botocore.auth import SigV4Auth | |
from botocore.awsrequest import AWSRequest | |
from botocore.credentials import Credentials | |
from http.client import HTTPConnection, HTTPSConnection | |
import json | |
import os | |
from urllib.parse import urlparse | |
def sigv4_request( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Represents a node from a binary heap. */ | |
class BinaryHeapNode { | |
/** | |
* Initializes a new instace of the `BinaryHeapNode` class. | |
* @param {number} value | |
* @param {*} ref | |
*/ | |
constructor(value, ref) { | |
this.value = value; | |
this.ref = ref; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { createHash } = require("node:crypto"); | |
/** | |
* Returns a random value betwen 0 and 99 associated with an input value that's | |
* quasi-evenly distributed. | |
* | |
* This function is useful for incrementally rolling out a feature to customers | |
* based on a percentage. | |
* | |
* @param value {string} The input value to derive the output from. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simplified `EventTarget` polyfill. | |
* @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget | |
*/ | |
class EventTarget { | |
/** @type {Map<string, { capture: boolean, listener: Function, once: boolean }[]>} */ | |
_listenersMap = new Map(); | |
/** | |
* @param {string} type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://www.alitajran.com/get-allocation-unit-size-powershell/ | |
Get-CimInstance -ClassName Win32_Volume | Select-Object Name, FileSystem, Label, BlockSize | Sort-Object Name | Format-Table -AutoSize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Even with the strictest settings, the TypeScript compiler may have looser type checking than what you would expect. | |
interface Data { | |
req1: number; | |
req2: number; | |
opt1?: number; | |
opt2?: number; | |
} | |
function logData(data: Data): void { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.function.Consumer | |
import java.util.function.Function | |
import java.util.function.Supplier | |
// Take these ambiguous overloads: | |
fun fn(consumerLike: (String) -> Unit) = consumerLike("").also { println("consumer-like") } | |
fun fn(consumer: Consumer<String>) = consumer.accept("").also { println("consumer") } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json, os, subprocess | |
from argparse import ArgumentParser | |
from configparser import ConfigParser | |
from pathlib import Path | |
# 1. parse args | |
parser = ArgumentParser( | |
prog='mfa-aws-credentials', | |
description='Invokes AWS STS GetSessionToken using the AWS CLI and stores the temporary credentials in ~/.aws/credentials' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createServer } from "node:http"; | |
const CSP = | |
"default-src 'none'; child-src data:; frame-src https://www.example.com; script-src 'nonce-abc'; worker-src data:"; | |
const INDEX_PAGE = ` | |
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> |
OlderNewer