Skip to content

Instantly share code, notes, and snippets.

View toklok's full-sized avatar
💭
Permanent 418 status

Joseph Curtis toklok

💭
Permanent 418 status
View GitHub Profile
@gd3kr
gd3kr / script.js
Created February 15, 2024 06:30
Download a JSON List of twitter bookmarks
/*
the twitter api is stupid. it is stupid and bad and expensive. hence, this.
Literally just paste this in the JS console on the bookmarks tab and the script will automatically scroll to the bottom of your bookmarks and keep a track of them as it goes.
When finished, it downloads a JSON file containing the raw text content of every bookmark.
for now it stores just the text inside the tweet itself, but if you're reading this why don't you go ahead and try to also store other information (author, tweetLink, pictures, everything). come on. do it. please?
*/
@hayden-donnelly
hayden-donnelly / make_crop_labels.py
Last active January 27, 2024 04:29
Script to make square crop labels for images.
# Example usage:
# python make_crop_labels.py --input_path data/images --output_path --data/cropped_images --csv_path data/crops.csv
# Controls:
# scroll to change crop size, mouse to aim the crop, left click to crop image and move to next, x to skip to the next image.
# The script is pretty messy since I quickly hacked it together with little regard for quality, but it works.
import pygame
import argparse
@johnwahba
johnwahba / leetcode_etl.rb
Last active October 6, 2023 01:22
Create an sqlite db of your leetcode visits and submissions to track progress
# Script runs on mac. Would need to be adapted to run on windows.
require 'sqlite3'
require 'json'
require 'zip'
require 'tmpdir'
require 'find'
# Function to unzip the file
def unzip_file(file, destination)
@Hebilicious
Hebilicious / cloudflare-pages-bun.env
Last active June 2, 2024 20:48
Cloudflare Pages and Bun
# Bun is now officially supported and these environments variables are no longer needed. Keeping this gist for legacy purposes.
# SKIP_DEPENDENCY_INSTALL=true
# UNSTABLE_PRE_BUILD=asdf install bun latest && asdf global bun latest && bun i
@ChrisHayduk
ChrisHayduk / merge_qlora_with_quantized_model.py
Last active July 13, 2024 19:27
Merging QLoRA weights with quantized model
"""
The code below combines approaches published by both @eugene-yh and @jinyongyoo on Github.
Thanks for the contributions guys!
"""
import torch
import peft
type Primitive = | null | undefined | string | number | boolean | symbol | bigint;
type LiteralUnion<LiteralType, BaseType extends Primitive,> = LiteralType | (BaseType & Record<never, never>);
export interface Shopify {
PaymentButton: {
init(): any
}
autoloadFeatures(param: any): any
/**
* Only show in Theme previews, it's a class instance, yuck.
@rememberlenny
rememberlenny / instructions.md
Last active April 6, 2023 01:32
GPT powered Poetic Git Commit Messages (Written by GPT-4)

In this guide, I'll show you how to create a Bash script that generates a short poem based on the changes made in your Git repository and uses it as a commit message. We'll integrate the OpenAI API to generate the poems and override the git commit -m command to use our custom script.

Step 1: Create the Poetic Commit Script

Create a file called poetic_commit.sh and paste the following code:

#!/bin/bash

# Save your OpenAI API Key in the OPENAI_API_KEY variable
@samleong123
samleong123 / readme.md
Last active July 5, 2024 17:06
Install Apple Music Preview on Windows 10 21H2 with Lossless Audio Support

Install Apple Music Preview on Windows 10 with Lossless Audio Support

Disclaimer

I will not be responsible on any inconvenience / damage / loss on behalf this tutorial nor the modified Apple Music Preview bundle.

Only for research purposes.

Minimum Tested System Requirement

System / Package Name Version
@Vogtinator
Vogtinator / README.md
Last active July 23, 2024 07:21
Run Win11 on ARM in QEMU

When following this guide on a host not capable of native arm64 KVM, replace -M virt -cpu host -accel kvm with -M virt,virtualization=on -cpu max.

The reason for virtualization=on is that the Windows bootloader does an smc #0 PSCI call, but without EL2, QEMU's TCG does not handle those because PSCI is in HVC mode and such that instruction is treated as undefined. With KVM enabled, smc #0 is handled properly.

Workaround in QEMU for using TCG without virtualization=on:

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index b871350856..de11ff51d1 100644
--- a/hw/arm/virt.c

Inject addEventListener hook

With (Tamper|Violent|Grease)monkey, you can run any JavaScript code on any web pages. This allows you to rewrite the content and style of web pages and override their behaviors. However, manipulating the event listeners is a bit more difficult. In particular, to disable or delete a registered event listener, you must have a reference to the event listener function object, which is usually not available. Chrome DevTools (or similar browser developer functionalities) can do this, but in any case it is not available from Tampermonkey.

This code snippet will help you to remove event listeners by inserting a hook into EventTarget.proptotype.addEventListener, the standard method for registering event listeners, and logging all calls to it. For example, to remove all click events, you can use the following code:

//...
(function() {
    'use strict';
    window.addEventListene