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 / gh-org-top-contributors.ts
Last active March 28, 2025 13:30
List the top contributions of an organization
#!/usr/bin/env node
/**
* Create top contributors list for a GitHub organization.
* Usage: ./gh-org-top-contributors.ts <org-name>
*/
const accessToken = process.env.GITHUB_TOKEN || process.env.GH_TOKEN || 'your-token'
const headers = {
Authorization: `token ${accessToken}`,
@davidglezz
davidglezz / jest-to-vitest.sh
Last active March 27, 2025 15:06
Jest to vitest migration script
#!/bin/bash
# This is a copy of:
# https://gist.github.com/wojtekmaj/6defa1f358daae28bd52b7b6dbeb7ab6
# read the comments
# Also: npx codemod jest/vitest
# Ensure we're working on the latest version of the main branch
# git switch develop
# git fetch
@davidglezz
davidglezz / replace-v-t-syntax.js
Last active March 24, 2025 17:09
Replace v-t="x" attribute with $t(x) function in vue files
const fs = require('node:fs')
const path = require('node:path')
const glob = require('glob')
// Find all Vue files
const vueFiles = glob.sync(path.join(__dirname, '../**/*.vue'))
vueFiles.forEach(filePath => {
let content = fs.readFileSync(filePath, 'utf8')
@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 / StrTrimLeft.c
Created November 4, 2013 16:12
This function remove whitespaces from the beginning.
void StrTrimLeft(char *source, char *dest)
{
int nIndex = 0;
while (source[nIndex] == ' ')
nIndex++;
strcpy(dest, &source[nIndex]);
}
@davidglezz
davidglezz / removeQuotes.c
Last active October 12, 2024 23:23
Remove quotes from command line arguments
void removeQuotes(LPSTR szCommand)
{
int nGet = 0, nSet = 0;
while (szCommand[nGet] != '\0')
{
if (szCommand[nGet] == '\"')
nGet++;
else
{
@davidglezz
davidglezz / OpenFileDialog.c
Last active October 12, 2024 23:23
Display 'Open File' dialog-box in Windows
//Display 'Open File' dialog-box
BOOL OpenFileDialog(LPSTR lpFilename)
{
OPENFILENAME of;
char szFilter[] = "Music Files (*.ogg)\0*.ogg\0Image Files (*.png)\0*.png\0All files (*.*)\0*.*\0\0";
char szFile[MAX_PATH] = "\0";
char szTitle[] = "Select a file";
char szExt[] = "ogg";
of.lStructSize = sizeof(of);
@davidglezz
davidglezz / screenshot.c
Created November 4, 2013 16:53
make a screenshot and save it to disk. Windows
#include <windows.h>
int main()
{
int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
int top = GetSystemMetrics(SM_YVIRTUALSCREEN);
int left = GetSystemMetrics(SM_XVIRTUALSCREEN);
int size = width * height * 3;
int headerSize = sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER);
@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 / mouseClick.c
Last active October 12, 2024 23:22
Example of how to simulate a mouse click
#include <windows.h>
int main()
{
//allocate a data
INPUT *data = new INPUT[3];
// Move to position. data
data->type = INPUT_MOUSE;
data->mi.dx = 0; // Position x