Skip to content

Instantly share code, notes, and snippets.

@TheEpicFace007
TheEpicFace007 / npm-quality-of-life.js
Last active May 30, 2021 01:44
Add some quality of life improvement feature on npm
// ==UserScript==
// @name NPM Quality of life changes
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Add some quality of life improvenet to npm
// @author You
// @match http**://www.npmjs.com/**
// @grant none
// ==/UserScript==
function showNotif(notifText) {
@vibe
vibe / NodejsLambda.ts
Created April 2, 2021 11:13
Terraform CDK Lambda Typescript/NodeJS
import { Resource } from "cdktf";
import { Construct } from "constructs";
import { IamRole, LambdaFunction, LambdaLayerVersion, S3Bucket, S3BucketObject, SecurityGroup, Subnet, Vpc } from "@cdktf/provider-aws";
import { copySync, ensureDirSync, mkdtempSync, pathExistsSync, readJSONSync, removeSync, } from "fs-extra"
import { dirname, join, resolve } from "path";
import { buildSync } from 'esbuild'
import { spawnSync } from "child_process";
import { tmpdir } from "os";
import AdmZip from "adm-zip";
import { TemplateDirectory } from "@tf-cdk/template-directory";
@lcanady
lcanady / Graph.ts
Created March 29, 2021 22:23
A Simple Graph class, written with Typescript
export class Graph<T> {
private _adjList: Map<T, Set<T>>;
constructor() {
this._adjList = new Map<T, Set<T>>();
}
/**
* Add a Vert to the Graph
* @param v Vert to add
EnumDisplaySettings
ChangeDisplaySettingsExW
@lyallcooper
lyallcooper / toggle-meet-mute.scpt
Last active December 8, 2023 22:14
AppleScript for toggling mute in Google Meet
tell application "Google Chrome"
repeat with w in (windows)
set i to 1 -- tabs are one indexed
repeat with t in (tabs of w)
if URL of t starts with "https://meet.google.com" then
tell tab i of w
-- These selectors may be unstable, but seem to work well now
execute javascript "document.querySelectorAll('[data-is-muted]')[1].click()"
set muted to (execute javascript "document.querySelectorAll('[aria-label=\"Turn on microphone (⌘ + d)\"]').length === 1")
if muted then
@MohammedALREAI
MohammedALREAI / postorderTraversal.ts
Created March 6, 2021 12:10
145. Binary Tree Postorder Traversal leetcode typescript
/**
* Definition for a binary tree node.
* class TreeNode {
* val: number
* left: TreeNode | null
* right: TreeNode | null
* constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) {
* this.val = (val===undefined ? 0 : val)
* this.left = (left===undefined ? null : left)
* this.right = (right===undefined ? null : right)
Function Set-ScreenResolution {
<#
.Synopsis
Sets the Screen Resolution of the primary monitor
.Description
Uses Pinvoke and ChangeDisplaySettings Win32API to make the change
.Example
Set-ScreenResolution -Width 1024 -Height 768
#>
@SiegeSailor
SiegeSailor / BEM.ts
Last active May 27, 2021 11:42
Create and maintain classes with BEM.
/**
* Create and maintain classes with [BEM](http://getbem.com/).
* @since Feature
*/
export default class BEM {
private _block: string;
private elementArray: string[];
private modifierArray: string[];
private _record: { [element: string]: string[] };
@moosetraveller
moosetraveller / convert-image-to-base64-string.md
Last active March 6, 2024 14:27
Download and Convert Image to Base64 String

Download and Convert Image to Base64 String

Following code snippet fetches the image from an URL and converts the blob to a base64 string before saving the file to the file system. (Saving the file to the file system can be considered being additional boilerplate as a conversion from a blob to a base64 string is not needed to save a file to the file system. See second example.)

The code snippets shows how to:

  • download an image from a server
  • convert image to a base64 string
/**
 * Fetches an image from given URL.
Function Set-ScreenResolution {
param (
[Parameter(Mandatory=$true,
Position = 0)]
[int]
$Width,
[Parameter(Mandatory=$true,
Position = 1)]
[int]
$Height