Skip to content

Instantly share code, notes, and snippets.

View SalvadorP's full-sized avatar
🦊

Salvador P. SalvadorP

🦊
View GitHub Profile
@SalvadorP
SalvadorP / copyfile_picker.sh
Created June 21, 2022 06:50
Picks files by filename and then copies them to a destination folder
#!/bin/bash
# Searches for filenames and then copies them to the destination folder.
# Searches for first parameter then copies where the second says.
ls | grep "$1" | while read i; do cp -p "$i" $2 ; done
@SalvadorP
SalvadorP / rename.sh
Created June 21, 2022 06:42
Rename files based on pattern
#!/bin/bash
# Renames all files in the actual directory.
# Searches for first parameter then changes for the second.
for f in *; do mv "$f" "$(echo "$f" | sed s/$1/$2/)"; done
@SalvadorP
SalvadorP / google-app-launcher.markdown
Last active October 20, 2022 20:47
Google App launcher
@SalvadorP
SalvadorP / curl.md
Created October 9, 2018 07:07 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@SalvadorP
SalvadorP / drupal_after_node_save_callback.php
Created September 4, 2017 14:26
Quick snippet which shows how to call a callback function after a node has been updated and persisted to the database.
<?php
// Same for hook_node_save!
function my_module_node_update($node) {
if ($node->type == 'content_type_name') {
// Invoke your callback function AFTER the node is updated.
drupal_register_shutdown_function('_my_module_the_function_to_call', $node);
}
}
@SalvadorP
SalvadorP / jsopenalinks.js
Created September 1, 2017 09:36
Script to open all a links which have target = "_blank"
@SalvadorP
SalvadorP / git_cheatsheet.md
Last active August 7, 2024 11:26
Own cheatsheet of useful git commands, different from commit, fetch, branch, ...

Git create branch

see where are we

git branch

make sure we are up to date

git pull

create the branch and change to it

@SalvadorP
SalvadorP / joinpdf.sh
Created May 3, 2017 10:24
Join PDFs with PDFTK
pdftk *.pdf cat output joined_pdfs.pdf
@SalvadorP
SalvadorP / batchpdfcompress.sh
Last active February 8, 2017 11:03
Compress pdfs in batch, giving 2 types of qualities.
# Less compression nice results, links broken
ls | cat -n | while read n f; do ps2pdf "$f" "$f.comp2.pdf"; done
# A lot of compression jpg quality loss, respects links, changing PDFSettings can alter results more/less compression/quality
ls | cat -n | while read n f; do gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$f.comp.pdf" "$f"; done
@SalvadorP
SalvadorP / batchrename.sh
Created February 8, 2017 10:15
Unix CLI batch rename files
# https://stackoverflow.com/questions/3211595/renaming-files-in-a-folder-to-sequential-numbers/34153342#34153342
ls | cat -n | while read n f; do mv "$f" "$n.extension"; done