Skip to content

Instantly share code, notes, and snippets.

View misterhat's full-sized avatar
💭
🐸 🐸

zorian misterhat

💭
🐸 🐸
  • winnipeg, mb
  • 04:06 (UTC -05:00)
View GitHub Profile
use async_std::{fs, path::Path, prelude::*};
use rand::{prelude::*, thread_rng};
use std::io::{Error, ErrorKind};
use wallpaper;
const WALLPAPER_DIR: &'static str = "/home/zack/Pictures/Wallpapers";
const ACCEPTED_EXTENSIONS: [&str; 3] = ["jpeg", "jpg", "png"];
async fn read_wallpapers() -> Result<Vec<String>, Error> {
let base_path = Path::new(WALLPAPER_DIR);
@m-bartlett
m-bartlett / README.md
Last active November 21, 2021 22:29
Sparsely clone only a specific git repo directory using a GitHub tree URL

Uses git sparse checkout features to git clone only a given directory path within a repo.

Usage

Provide a GitHub tree-URL (a URL to a specific directory on a branch) as the only argument. Currently this only supports sparse checkout from GitHub.

Example: git clonedir https://github.com/GoogleChrome/chrome-extensions-samples/tree/mv3-migration-snippet/mv2-archive/api/messaging/timer

git Subcommand Note

If you have custom executables named as git-* in $PATH, git will automatically detect and offer these commands as subcommands. Therefore if you place git-clonedir in your $PATH (e.g. /usr/local/bin/) then you can also run it as git clonedir.

@joepie91
joepie91 / es-modules-are-terrible-actually.md
Last active May 9, 2025 15:29
ES Modules are terrible, actually

ES Modules are terrible, actually

This post was adapted from an earlier Twitter thread.

It's incredible how many collective developer hours have been wasted on pushing through the turd that is ES Modules (often mistakenly called "ES6 Modules"). Causing a big ecosystem divide and massive tooling support issues, for... well, no reason, really. There are no actual advantages to it. At all.

It looks shiny and new and some libraries use it in their documentation without any explanation, so people assume that it's the new thing that must be used. And then I end up having to explain to them why, unlike CommonJS, it doesn't actually work everywhere yet, and may never do so. For example, you can't import ESM modules from a CommonJS file! (Update: I've released a module that works around this issue.)

And then there's Rollup, which apparently requires ESM to be u

@kirjavascript
kirjavascript / index.html
Last active September 16, 2020 11:39
MutString
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Static Template</title>
</head>
<body>
<script>
@jesobreira
jesobreira / url-encode.c
Created January 22, 2019 21:21 — forked from sudar/url-encode.c
URL Encoding in C (urlencode / encodeURIComponent)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char* urlencode(char* originalText)
{
// allocate memory for the worst possible case (all characters need to be encoded)
char *encodedText = (char *)malloc(sizeof(char)*strlen(originalText)*3+1);
@shole
shole / Conditionals.inc
Created November 9, 2017 21:17
Branchless shader logic
/*
Branchless shader logic made sane with macros;
usage;
if (depth>pointdepth){
col=tex2D(_CameraColorTextureP,o.uv);
}else{
col=tex2D(_MainTex,o.uv);
}
# -*- coding: utf-8 -*-
import weechat
SCRIPT_NAME = 'mockme'
SCRIPT_AUTHOR = 'hikilaka'
SCRIPT_VERSION = '1.0.0'
SCRIPT_LICENSE = 'none'
SCRIPT_DESC = 'Converts your text into a mOcKiNg VeRsIoN'
@Twinklebear
Twinklebear / main.cpp
Last active April 24, 2025 05:25
Example of render to texture with SDL2
#include <iostream>
#ifdef __linux__
#include <SDL2/SDL.h>
#elif defined(_WIN32)
#include <SDL.h>
#endif
const int WIN_WIDTH = 640;
const int WIN_HEIGHT = 480;