Skip to content

Instantly share code, notes, and snippets.

View jorgeacortes's full-sized avatar

Jorge jorgeacortes

View GitHub Profile
@jorgeacortes
jorgeacortes / spinner.html
Created May 27, 2023 08:59
Tailwind circular spinner
<div class="h-6 w-6 animate-spin rounded-full border-[5px] border-gray-300 border-t-blue-600"></div>
@jorgeacortes
jorgeacortes / deploy.yml
Last active March 18, 2021 18:47
Github actions autodeploy to a server via ssh when pushing to master
name: CI
on: [push]
jobs:
deploy:
if: github.ref == 'refs/heads/master'
runs-on: [ubuntu-latest]
steps:
- name: Push to server
@jorgeacortes
jorgeacortes / commit-template.txt
Created November 4, 2020 17:37
git commit template using conventional commits
#<type>[optional scope]: <description> + 1 Empty line
#[optional body]
#[optional BREAKING CHANGE]: <description>
#[optional footer] [Ticket IDs]
# Type:
@jorgeacortes
jorgeacortes / linux_shell_useful_usecases.md
Created October 25, 2020 11:39
Linux shell useful use cases

Linux shell useful use cases

Useful examples

Convert an absolute path into a relative one (example)

$ echo "/home/stm32/ws/Core/main.c" | sed -e 's/^\/home\/stm32\/ws\///'
Core/main.c
@jorgeacortes
jorgeacortes / git_tips_and_tricks.md
Last active January 14, 2021 15:37
Git tips, tricks and use cases

Git tips, tricks and use cases

Recover a file deleted in a old commit

Use the hash of the last commit where the file was present.

git checkout a22db0d1ddb7bc8777f43c0fda21a1c22dc75daa my_lost_file.c

Add a submodule where a folder was present before

@jorgeacortes
jorgeacortes / nodejs_run_docker.sh
Created October 20, 2020 06:06
Docker run example doing a bind mount excluding node_modules folder that is inside the shared folder.
docker run --rm -v $(pwd):/home/node/app -v /home/node/app/node_modules node:latest bash -c "npm start"
@jorgeacortes
jorgeacortes / swap32.js
Created October 19, 2020 06:14
Function for swapping endianess of 32 bits unsigned value (unsigned)
/**
* @brief swaps a 32 bits value unsigned
* @param val value to swap
* @return Unsigned swapped value
*/
function swap32(val) {
let swapped =
((val & 0xff) << 24)
| ((val & 0xff00) << 8)
| ((val >> 8) & 0xff00)
@jorgeacortes
jorgeacortes / settings.json
Last active September 28, 2020 13:42
Windows terminal custom settings
// Properly delimiter words similar to bash (https://github.com/microsoft/terminal/issues/3196)
"wordDelimiters" : " ()\"':,;<>~!@#$%^&*|+=[]{}~?│",
"profiles":
{
"defaults":
{
"fontFace": "MesloLGLDZ Nerd Font Mono",
"fontSize": 9,
"fontWeight": "medium"
@jorgeacortes
jorgeacortes / stampGitHash.cmake
Created August 16, 2020 14:47
Stamp the Git Hash into a project define
# Use GIT_HASH define to get the git hash in your code like this:
# const int8_t kGitHash[] = GIT_HASH;
macro(stampGitHash)
set (git_cmd "git")
set (git_arg "rev-parse")
set (git_arg2 "HEAD")
execute_process(COMMAND ${git_cmd} ${git_arg} ${git_arg2}
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_hash)
SET(git_hash "\"${git_hash}\"")
@jorgeacortes
jorgeacortes / fetchWpPost.js
Last active August 15, 2020 15:20
Functions to retrieve a Wordpress post data.
/* Retrieves Wordpress post data of the post number idx from a domain.
* Note: idx is the index of the response array of posts.
*/
async function fetchWpPost(domain, idx) {
try {
var ret = {};
const response = await fetch('https://'+domain+'/wp-json/wp/v2/posts')
.then(response => response.json())
.then(data => {
ret.title = data[idx].title.rendered;