Skip to content

Instantly share code, notes, and snippets.

View davidglezz's full-sized avatar
😃
Happy

David Gonzalez davidglezz

😃
Happy
View GitHub Profile
@davidglezz
davidglezz / b256.ts
Last active March 19, 2024 22:32
Basa256 encoder / decoder
// A simple way to store binary data inside a js/ts file with a density of 1 char per byte.
// Even though each char takes 2 bytes.
const b256enc = (buff: Uint8Array) => [...buff].map(i => String.fromCodePoint(i + 192)).join('');
const b256dec = (str: string) => str.split('').map(c => c.charCodeAt(0) - 192);
// Example 1: Basic usage
const data = new Uint8Array([ 127, 127, 168, 226, 120, 62, 44, 146, 82, 213, 0, 30 ]);
const encoded = b256enc(data);
console.log(encoded); // 'ĿĿŨƢĸþìŒĒƕÀÞ'
@davidglezz
davidglezz / MCI_audioPLayerClass.cpp
Created November 5, 2013 10:54
Simple mp3 player class using MCI
#include <windows.h>
#include <iostream>
#include <string>
enum mode {unknown, open, playing, paused, stopped };
class MCI
{
// davidxl.blogspot.com
private:
@davidglezz
davidglezz / uuid-pack.ts
Last active September 11, 2023 13:59
UUID pack/unpack
export function packUUID(uuid: string): string {
let v;
let bytes = '';
// Parse ########-....-....-....-............
bytes += String.fromCharCode((v = parseInt(uuid.slice(0, 8), 16)) >>> 24);
bytes += String.fromCharCode((v >>> 16) & 0xff);
bytes += String.fromCharCode((v >>> 8) & 0xff);
bytes += String.fromCharCode(v & 0xff);
@davidglezz
davidglezz / css-loader.html
Last active September 9, 2023 14:50
Basic CSS Loader
<div class="loader"></div>
<style>
.loader {
--size: 5rem;
--weight: .5rem;
--background: rgba(127, 127, 127, .1);
--color: rgba(127, 127, 127, .9);
--duration: 1s;
position: fixed;
top: calc(50% - var(--size) / 2);
@davidglezz
davidglezz / AssocQueryString.c
Created November 4, 2013 16:57
This example shows how to obtain the name of the program associated with file type
#include <windows.h>
#include <Shlwapi.h>
#include <stdio.h>
#pragma comment(lib, "shlwapi.lib")
char* assocStr[] =
{
"ASSOCSTR_COMMAND",
"ASSOCSTR_EXECUTABLE",
"ASSOCSTR_FRIENDLYDOCNAME",
@davidglezz
davidglezz / unwatchOrgRepos.js
Last active October 3, 2021 16:32
Github: Unsubscribe from all "orgName" watched repositories
/**
* Unsubscribe from all "orgName" repositories in https://github.com/watching
*
* https://github.com/isaacs/github/issues/641
* @param string orgName
*/
function unwatchOrgRepos(orgName) {
if (!window.location.href.startsWith('https://github.com/watching')) {
throw new Error('This script is intended to be run in "https://github.com/watching"')
@davidglezz
davidglezz / RelativeTime.ts
Last active May 24, 2021 07:48
RelativeTime formatter inspired by DayJs
/**
* Locale strings
* You can get it from https://github.com/iamkun/dayjs/blob/dev/src/locale/
*/
const loc = {
future: 'in %s',
past: '%s ago',
s: 'a few seconds',
m: 'a minute',
@davidglezz
davidglezz / utf16_to_utf8.c
Created January 13, 2014 23:11
utf16_to_utf8 function, untested by me, but I hope it works well, comes from opusfile with some modifications.
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
static char* utf16_to_utf8 (const wchar_t *src)
{
size_t len = wcslen(src), si, di;
char *dst = (char*)malloc(sizeof(*dst)*(3*len+1));
@davidglezz
davidglezz / .gitconfig
Created February 22, 2020 10:22 — forked from pksunkara/config
Sample of git config file (Example .gitconfig)
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
username = pksunkara
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
@davidglezz
davidglezz / gitconfig.ini
Created February 22, 2020 10:21 — forked from tdd/gitconfig.ini
Nice, useful global Git configuration
# Put this in your ~/.gitconfig or ~/.config/git/config
# Windows users: "~" is your profile's home directory, e.g. C:\Users\<YourName>
[user]
name = Your Full Name
email = your@email.tld
[color]
# Enable colors in color-supporting terminals
ui = auto
[alias]
# List available aliases