Skip to content

Instantly share code, notes, and snippets.

addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
/**
* Respond to the request
* @param {Request} request
*/
async function handleRequest(request) {
const originalResponse = await fetch('https://www.waterdatafortexas.org/reservoirs/recent-conditions.json', {
@benwillkommen
benwillkommen / __readme.md
Created April 5, 2020 20:51
Delete Slack Messages

This script (probably) deletes all your Slack messages, for all channels in a given Slack Workspace. It is intended to be run from the Chrome Devtools console.

Usage

  1. Get an API token for a given workspace from: https://api.slack.com/legacy/custom-integrations/legacy-tokens
  2. Replace the API token on line 1 with the one you received from the page in step 1.
  3. Navigate to the web client for your Slack Workspace.
  4. Paste the whole thing into your Chrome Devtools console and execute it.
  5. You'll now have an async function called fuckMeUpFam in the global scope. Invoke it, passing in your Slack display name. E.g. if you get @-replied as "Jeff Gravy", you would invoke await fuckMeUpFam("Jeff Gravy") in the console.
@benwillkommen
benwillkommen / _readme.md
Last active June 27, 2022 21:27
Unsubscribe from all watched repositories in a particular organization

Remove All Subscriptions from a Specific Github Organization

This script will delete all the subscriptions in your account for the Github Organization passed to it.

This script was created when I took a new job, and my notification settings inadvertantly subscribed me to all 600+ of their repos. I wanted a better signal to noise ratio in my notifications, but I didn't want to click the "Unwatch All" button, which would remove my subscriptions to repos outside my new employer's org.

How To

  1. Create a Personal Access Token with the "repo" scope, and expose it as the GITHUB_PERSONAL_ACCESS_TOKEN environment variable:
$ export GITHUB_PERSONAL_ACCESS_TOKEN=
@benwillkommen
benwillkommen / Program.cs
Created June 24, 2016 15:42
non web.config config
using System;
namespace ConsoleApplication1
{
public static class SosConfig
{
public static string CatalogApiUrl
{
get
{
@benwillkommen
benwillkommen / Program.cs
Created May 24, 2016 14:48
Availability Hash Tables
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace AvailabilityMatrix
{
class Program
@benwillkommen
benwillkommen / tests.js
Created May 9, 2016 19:54
mocking w/ sinon example
//weird codewars function
function _if(bool, func1, func2) {
if(bool === true){
return func1();
} else {
return func2();
}
};
//arrange
@benwillkommen
benwillkommen / Class1-disassembled.cs
Last active May 9, 2016 15:15
using statement v.s. try-catch-finally
using System;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
namespace UsingIlTest
{
public class Class1
{
public Class1()
@benwillkommen
benwillkommen / get-pageloadtime.ps1
Created March 17, 2016 18:35
get-pageloadtime.ps1
$ie = new-object -com internetexplorer.application
$ie.visible = $false
$timer = [System.Diagnostics.Stopwatch]::StartNew()
$ie.navigate2("http://example.com")
while($ie.busy){
}
$time = $timer.Elapsed.ToString()
$ie.quit()
[cmdletbinding()]
param (
[parameter(ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[string[]]$ComputerName = $env:computername
)
begin {}
process {
foreach ($Computer in $ComputerName) {
if(Test-Connection -ComputerName $Computer -Count 1 -ea 0) {
public string SessionId()
{
return Session.SessionID;
}