Skip to content

Instantly share code, notes, and snippets.

View hexcowboy's full-sized avatar
🏜️
out for a ride

hexcowboy hexcowboy

🏜️
out for a ride
View GitHub Profile
@hexcowboy
hexcowboy / Instructions.md
Last active March 29, 2023 04:47
Dell XPS 9360 macOS Guide

Dell XPS 9360 macOS Guide

The Dell XPS 9360 macOS Hackintosh Guide is provided as a hardware specific guide. The information is taken from various resources and if you run into problems you may wish to read the entire document where it is linked. Credits go to the authors of these resources and files.

Following the hardware specs provided in the dedicated repository, here's what we will be working with in this guide:

  • Dell XPS 9360
    • Intel i7-8550U
    • 16GB RAM
    • Sharp SHP144 LQ133Z1 QHD+ (3200x1800) Touchscreen display
@hexcowboy
hexcowboy / offset.md
Last active August 21, 2024 10:32
Twitch Helix API - Get Video/VOD Offset and Comments from Clip ID

Since Twitch decomissioned API V5, there's no correct way to get the VOD offset for a clip. So I just inspected what the Twitch web app was doing and came up with a super cool hack.

I know this looks really complicated but really it just does two things. First it gets the clip information from the official API, then it uses Twitch GraphQL API to get the offset.

kimne78kx3ncx6brgo4mv6wki5h1ko is the Client ID that the Twitch web app uses. It can be used to access Twitch's GraphQL API (undocumented & not for public use). The postData variable contains a request and a sha256Hash. The sha256Hash is basically a job ID and may change in the future, but I added the current hash which should work for all clips as of posting this.

const clientId = "" // Put your Twitch Client ID here
const clientSecret = "" // Put your Twitch Client Secret here
@hexcowboy
hexcowboy / README.md
Last active March 6, 2024 00:10
macOS Remap Keys

Finding your keyboard location

You can typically find the location ID of your keyboard with this command

hidutil list | grep -i keyboard | awk '{print $3}' | sort -u | grep -v 0x0

Replace this part of the bash command to your own keyboard location:

Is there a way to share SplitSink between two different threads?

Yes

The best way to do this is to create an mpsc channel that forwards messages to the SplitSink. In the example below you can see that multiple threads can send to the sink using sender.clone(). Both send_task and recv_task are doing this, and in theory you can make as many senders as you like.

use std::net::SocketAddr;
use std::sync::Arc;
@hexcowboy
hexcowboy / solution.md
Last active April 26, 2023 21:29
Next.js 13 App Directory with Wagmi - `Warning: Expected server HTML to contain a matching <div> in <div>.`

Warning: Expected server HTML to contain a matching <div> in <div>.

You will likely see this error if you ever try to use Wagmi in your Dapp. This solution actually works for any reason if you're seeing the error above.

This article explains the issue in a bit more depth. This gist will give you a simple solution.

Using Wagmi values

Using Wagmi hooks like useAccount() or similar will cause your app to render differently on the client than it does on the server. To make them only run on the client, use this utility component.

@hexcowboy
hexcowboy / chatgpt.md
Last active May 13, 2023 00:31
NFT Image Scraper

Started by asking it to write python code with an example from the Resevoir docs

can you turn this into a python3 request

curl --request GET \
     --url 'https://api.reservoir.tools/tokens/v6?collection=0x3Fe1a4c1481c8351E91B64D5c398b159dE07cbc5&sortBy=tokenId&sortDirection=asc&limit=10&includeAttributes=true' \
     --header 'accept: */*' \
     --header 'x-api-key: demo-api-key'
@hexcowboy
hexcowboy / README.md
Last active September 4, 2023 16:03
React Typescript `useBreakpoint` hook

This react typescript hook will work in tandem with your tailwind config. You can also remove the tailwind references to make it work without.

It is recommended to place this in a folder like hooks/use-breakpoint.ts or src/hooks/use-breakpoint, or next to any other hooks you have defined.

@hexcowboy
hexcowboy / Makefile
Created November 8, 2023 20:22
easy postgres docker Makefile
# Load environment variables from .env
ifneq (,$(wildcard ./.env))
include .env
export
endif
# Export default environment variables
## NOTE: you should only change these for you local environment. For other
## environments like beta or prod, set the DATABASE_URL in your .env file.
DB_USER ?= interested
@hexcowboy
hexcowboy / main.ts
Created February 14, 2024 12:51
JS/TS `fetch` simple abstraction
const request = (fetch => {
return (...args) => fetch(...args).then(res => res.json());
})(fetch);
await request(url);
@hexcowboy
hexcowboy / demo.tsx
Last active February 28, 2024 17:22
Polymorphic React Components
import React from "react";
import { Link } from "react-router-dom";
// Use React.ButtonHTMLAttributes for base button props to support all native button attributes
type BaseButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement>;
// Polymorphic 'as' prop type, allowing for component type override
type AsProp<C extends React.ElementType> = {
as?: C;
};