Skip to content

Instantly share code, notes, and snippets.

View mauleyzaola's full-sized avatar

Mauricio Leyzaola mauleyzaola

View GitHub Profile
@mauleyzaola
mauleyzaola / GitRecovery
Created January 14, 2024 20:49 — forked from pce1991/GitRecovery
Repair git says object files are empty/corrupted
find .git/objects/ -type f -empty | xargs rm
git fetch -p
git fsck --full
http://stackoverflow.com/questions/11706215/how-to-fix-git-error-object-file-is-empty
@mauleyzaola
mauleyzaola / youtube.txt
Created December 14, 2023 13:50 — forked from iredun/youtube.txt
Youtube API get thumbnail image
Each YouTube video has 4 generated images. They are predictably formatted as follows:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
For the high quality version of the thumbnail use a url similar to this:
@mauleyzaola
mauleyzaola / uuid_bytea_casts.sql
Created June 29, 2023 14:55 — forked from Pigeo/uuid_bytea_casts.sql
Cast UUID into BYTEA (and vice versa) in PostgreSQL
-- UUID to BYTEA:
SELECT DECODE(REPLACE(CAST(uuid_field AS TEXT),'-',''), 'hex') FROM table;
-- BYTEA to UUID:
SELECT CAST(ENCODE(bytea_field, 'hex') AS UUID) FROM table;
-- BONUS --
@mauleyzaola
mauleyzaola / auth-hook.js
Created April 30, 2023 22:34 — forked from ulises-jeremias/auth-hook.js
Examples of hooks utils using axios, recoil.js, keycloak-js, @react-keycloak/web and more.
import { useCallback, useEffect, useState } from 'react';
import { useSetRecoilState } from 'recoil';
import { useKeycloak } from '@react-keycloak/web';
import { commonNotification } from './common';
/**
* Returns the auth info and some auth strategies.
*
*/
@mauleyzaola
mauleyzaola / 2019-https-localhost.md
Created March 12, 2023 18:35 — forked from cecilemuller/2019-https-localhost.md
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@mauleyzaola
mauleyzaola / nginx-stat-failed-13-permission-denied.md
Created February 16, 2023 00:01 — forked from windsting/nginx-stat-failed-13-permission-denied.md
fix: Nginx: stat() failed (13: permission denied)

Nginx: stat() failed (13: permission denied)

from https://stackoverflow.com/questions/25774999/nginx-stat-failed-13-permission-denied

Nginx operates within the directory, so if you can't cd to that directory from the nginx user then it will fail (as does the stat command in your log). Make sure the www-user can cd all the way to the /username/test/static. You can confirm that the stat will fail or succeed by running

sudo -u www-data stat /username/test/static
@mauleyzaola
mauleyzaola / getfriends_select.go
Created October 28, 2022 03:07 — forked from dragonsinth/getfriends_select.go
GetFriends using select
func GetFriends(ctx context.Context, user int64) (map[string]*User, error) {
g, ctx := errgroup.WithContext(ctx)
friendIds := make(chan int64)
// Produce
g.Go(func() error {
defer close(friendIds)
for it := GetFriendIds(user); ; {
if id, err := it.Next(ctx); err != nil {
if err == io.EOF {
@mauleyzaola
mauleyzaola / index.html
Last active September 9, 2022 04:22 — forked from iamsaso/index.html
GraphiQL with JWT
<!DOCTYPE html>
<html>
<head>
<style>
body {
height: 100%;
margin: 0;
width: 100%;
overflow: hidden;
}
@mauleyzaola
mauleyzaola / iterate_pdf_content_python.md
Created June 9, 2022 06:37 — forked from somada141/iterate_pdf_content_python.md
Iterate over decoded PDF page content with Python

Introduction

This note shows how to iteratively retrieve the decoded content of the pages in a PDF file using Python and the pdfminer Python package.

At the time of writing, the latest version of pdfminer was used, i.e., 20140328. Thus, as the package seems poorly maintained and prone to API-breaking changes one may have to explicitly install this version for the following code to work.

Code

The following generator will iterate over a PDF file under a given filename and iteratively yield the text content of each PDF page: