Skip to content

Instantly share code, notes, and snippets.

@josep11
josep11 / README.md
Last active May 9, 2022 11:01
ths-modal-templates

Ths modal templates

They will be injected by Tampermonkey

Info

index-testing-modal1.html and index-testing-modal2.html are only for testing locally the UI. The ones that will be injected will be modal1-select.html and modal2.html

modal1 is for selecting templates

@josep11
josep11 / pre-commit
Created November 23, 2021 11:04
pre-commit hook to run unit tests
#!/bin/bash
current_branch=`git rev-parse --abbrev-ref HEAD`
if [[ $current_branch =~ master|main ]]; then
message="Please don't push directly to $current_branch."
echo -e "\033[1;31mERROR: $message\033[0m";
exit 1
fi
repo_dir=`git rev-parse --show-toplevel`
@josep11
josep11 / policy-allow-crud-s3-bucket.json
Created August 5, 2021 18:50
AWS Policy CRUD to a specific s3 bucket
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:ListBucket",
@josep11
josep11 / Dynamo.js
Last active August 3, 2021 06:47
Upload json folder Dataset to DynamoDB
// ------------ NodeJS runtime ---------------
// Add aws-sdk in package.json as a dependency
// Example:
// {
// "dependencies": {
// "aws-sdk": "^2.0.9",
// }
// }
// Create your credentials file at ~/.aws/credentials (C:\Users\USER_NAME\.aws\credentials for Windows users)
// Format of the above file should be:
@josep11
josep11 / average.sh
Last active June 25, 2018 15:26
sed example
#!/bin/bash
awk '{s+=$1}END{print "\nAverage:",s/NR,"\n"}' numbers.txt
@josep11
josep11 / gist:8766d64b775c5d35100c9d1902ab6cbc
Last active July 7, 2016 11:04
TamperMonkey - Create Youtube Search for Radionomy tracks
// ==UserScript==
// @name Youtube Link for tracks
// @namespace http://tampermonkey.net/
// @version 0.2
// @updateURL https://gist.github.com/josep11/8766d64b775c5d35100c9d1902ab6cbc/gistfile.user.js
// @downloadURL https://gist.github.com/josep11/8766d64b775c5d35100c9d1902ab6cbc/gistfile.user.js
// @description Creates a link to search in youtube for the selected song
// @author Josep Alsina <josep_a11@hotmail.com>
// @match http://www.radionomy.com/*
// @exclude http://www.radionomy.com/*/ad/*
@josep11
josep11 / sort.php
Created April 14, 2015 10:40
Sort associative array by attribute
/*
sortByAttribute($people, 'age'); //orders $people by age
$people = [
[
'name' => 'Josep',
'age' => '22'
],
[
'name' => 'Laura',
'age' => '54'
@josep11
josep11 / date.vbs
Created November 15, 2014 18:07
Know if a batch has been executed in the last X hours
'################ name it date.vbs #################
Function Write(data, outFile)
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write data & vbCrLf
objFile.Close
End Function
Function ReadDate()
@josep11
josep11 / 0_reuse_code.js
Last active August 29, 2015 14:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console