Skip to content

Instantly share code, notes, and snippets.

View doraemoncito's full-sized avatar

José Hernández doraemoncito

View GitHub Profile
@doraemoncito
doraemoncito / gist:b367b05345abf1f0c52b98a699781744
Created June 3, 2025 20:10 — forked from doginthehat/gist:1890659
compare block helper for handlebars
// {{compare unicorns ponies operator="<"}}
// I knew it, unicorns are just low-quality ponies!
// {{/compare}}
//
// (defaults to == if operator omitted)
//
// {{equal unicorns ponies }}
// That's amazing, unicorns are actually undercover ponies
// {{/equal}}
// (from http://doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates/)
@doraemoncito
doraemoncito / LoggingClientHttpRequestInterceptor.java
Created March 25, 2022 08:59 — forked from jkuipers/LoggingClientHttpRequestInterceptor.java
RestTemplate-interceptor that logs outgoing requests and resulting responses
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpRequest;
import org.springframework.http.MediaType;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.util.StreamUtils;
@doraemoncito
doraemoncito / HowToOTGFast.md
Created December 7, 2021 22:08 — forked from gbaman/HowToOTGFast.md
Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way!

Setting up Pi Zero OTG - The quick way (No USB keyboard, mouse, HDMI monitor needed)

More details - http://blog.gbaman.info/?p=791

For this method, alongside your Pi Zero, MicroUSB cable and MicroSD card, only an additional computer is required, which can be running Windows (with Bonjour, iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
1. Flash Raspbian Jessie full or Raspbian Jessie Lite onto the SD card.
2. Once Raspbian is flashed, open up the boot partition (in Windows Explorer, Finder etc) and add to the bottom of the config.txt file dtoverlay=dwc2 on a new line, then save the file.
3. If using a recent release of Jessie (Dec 2016 onwards), then create a new file simply called ssh in the SD card as well. By default SSH i

@doraemoncito
doraemoncito / code.py
Created December 3, 2021 18:03 — forked from idriszmy/code.py
Keyboard Emulator Using Raspberry Pi Pico (Maker Pi Pico) and CircuitPython
#
# Keyboard Emulator Using Maker Pi Pico and CircuitPython
#
# References and credit to
# - https://learn.adafruit.com/circuitpython-essentials/circuitpython-hid-keyboard-and-mouse
#
# Raspberry Pi Pico
# - [Maker Pi Pico] https://my.cytron.io/p-maker-pi-pico?tracking=idris
#
# Additional Libraries
@doraemoncito
doraemoncito / ffmpeg_mkv_mp4_conversion.md
Created October 26, 2021 17:45 — forked from jamesmacwhite/ffmpeg_mkv_mp4_conversion.md
Easy way to convert MKV to MP4 with ffmpeg

Converting mkv to mp4 with ffmpeg

Essentially just copy the existing video and audio stream as is into a new container, no funny business!

The easiest way to "convert" MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost, it is also a fairly quick process and requires very little CPU power. The main factor is disk read/write speed.

With ffmpeg this can be achieved with -c copy. Older examples may use -vcodec copy -acodec copy which does the same thing.

These examples assume ffmpeg is in your PATH. If not just substitute with the full path to your ffmpeg binary.

Single file conversion example

@doraemoncito
doraemoncito / web-servers.md
Created May 20, 2021 12:44 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@doraemoncito
doraemoncito / sample-postgresql-openapi-docker-database.md
Last active May 8, 2021 16:48
Sample PostgreSQL database with OpenAPI support in Docker

Dockerized PostgreSQL database with OpenAPI support

Here's a quick and simple way to get up and running with a local sample PostgreSQL database with content that is also served via a RESTful interface using PostgREST and Swagger UI.

To get started you must have docker installed. Copy the text below into a file called compose.yaml

services:
    postgresql:
        image: aa8y/postgres-dataset:latest
@doraemoncito
doraemoncito / machine_epsilon.md
Last active October 10, 2020 08:48
Java code to compute the machine precision (also known as machine epsilon)
/**
 * Computes the machine precision (also known as machine epsilon) by
 * repeatedly dividing `epsilon' by two until it is too small to add
 * to one without causing roundoff.
 * 
 * @return
 *	Computed machine precision value
 */
static double maxPrecision()

Save all links in the current Safari session to the macOS clipboard

Copy all links from Safari to the clipboard as a list of URLs in JSON format

Open automator and create an application script called safe-safari-session-to-clipboard-json.app.

  1. Add a JavaScript step with the following content

function run(input, parameters) {

@doraemoncito
doraemoncito / schemacrawler-sqlite-macos-howto.md
Created March 29, 2020 22:36 — forked from dannguyen/schemacrawler-sqlite-macos-howto.md
How to use schemacrawler to generate schema diagrams for SQLite from the commandline (Mac OS)