Skip to content

Instantly share code, notes, and snippets.

@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
@xdhmoore
xdhmoore / changeorientation.ps1
Last active February 26, 2025 17:51
Various POCs for changing windows wallpapers, lockscreen wallpapers, screen orientation, etc. with powershell
# These files are code I wrote years ago to change windows 7 wallpaper, etc. with powershell.
# It's been several years since I've used most of them and they may not have been tested on windows 10 or powershell core.
# In particular the Lockscreen code and PoshWinRT dependency do not work w/o powershell core without modifications.
# They were written only for my use and are thus pretty rough. But...it took me a bit of research to get them working and
# they did work at some point (for varying values of "work"). A lot of the content is copied and adapted from blog posts
# I've found, but which at this point I don't remember the source in order to give any attribution.
# Anyway, maybe someone will find them useful. They are here by request, but without any cleanup or polish.
# A few functions require pre-existing files to exist at particular locations on the file system.
# Use at your own risk!
(fn comprehend [init update ...]
(let [clauses [...] n (length clauses) result (gensym)]
(tset clauses n (update result (. clauses n)))
(for [i (- n 1) 1 -1] (table.insert (. clauses i) (. clauses (+ i 1))))
`(do (var ,result ,init) ,(. clauses 1) ,result)))
(fn tbl [...]
(comprehend {}
(fn [result expr] `(match ,expr (k# v#) (tset ,result k# v#)))
...))
@MikuAuahDark
MikuAuahDark / capture.cpp
Created January 6, 2021 16:34
Simple peak meter with ANSI escape codes written in C++ using WASAPI audio loopback as audio measurement.
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <atomic>
#include <chrono>
#include <thread>
#include <type_traits>
#include <windows.h>
#include <combaseapi.h>
; vim:set ft=lisp:
(fn filterMap [pred iter inv startControl]
(var control startControl)
(fn filterMapIter []
(let [(newControl value) (iter inv control)]
(set control newControl)
(if (= value nil)
nil
(let [mapped (pred value)]