Skip to content

Instantly share code, notes, and snippets.

View fcjurado's full-sized avatar

Francisco Calderón Jurado fcjurado

View GitHub Profile
git status | grep 'deleted:' | cut -d':' -f2 | xargs -t -I {} git add -u "{}"
@fcjurado
fcjurado / main.js
Last active January 22, 2020 13:00
Really simple DialogFlow V2 JS connection with jQuery
var projectID = "xxxx-xxxx";
// session-id can apparently be set to an arbitrary value, eg. "abcd1234-abcd-abcd-abcd-abcd12345678".
var sessionID = "xxxx-xxxx";
var serviceAccountEmail = "xxxx-xxxxx@xxxxxxxx.iam.gserviceaccount.com";
var serviceAccountPrivateKey = "-----BEGIN PRIVATE KEY-----\nXXXXXXX==\n-----END PRIVATE KEY-----\n";
var ClaimSet = /** @class */ (function () {
function ClaimSet(scopes, issuerEmail) {
this.scopes = scopes;
this.issuerEmail = issuerEmail;
@fcjurado
fcjurado / gist:61e507ad941cee86a9fbf55e32673079
Created October 9, 2018 11:44
Drupal 8: Preprocess hook to avoid duplicates
/*
* Implements hook_preprocess_HOOK().
*/
function rest_views_views_pre_render(&$view) {
if ($view->storage->id() == 'articles') {
$matchedGroupIds = array();
foreach ($view->result as $row) {
$id = $row->_entity->id();
if(!in_array($id, $matchedGroupIds)){
array_push($matchedGroupIds, $id);
@fcjurado
fcjurado / gist:4be64cd39fc76dac827827c2ce720331
Created April 7, 2018 11:40
WordPress delete all posts & attachments
wp post delete $(wp post list --post_type='post' --format=ids) --force
wp post delete $(wp post list --post_type='attachment' --format=ids) --force;
@fcjurado
fcjurado / wp-permissions-script
Created April 7, 2018 10:59 — forked from macbleser/wp-permissions-script
WordPress Permissions Configuration Script
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro
#
WP_OWNER=changeme # <-- wordpress owner
WP_GROUP=changeme # <-- wordpress group
WP_ROOT=/home/changeme # <-- wordpress root directory
@fcjurado
fcjurado / phpversion.sh
Last active February 24, 2018 10:00 — forked from vjandrea/phpversion.sh
Change php cli version in plesk
#!/bin/sh
printf "Switching php to version 7.1 with symlinks.\n"
printf "Press any key to continue...\n"
read CONTINUE
printf "Creating backups..."
# Backup original binaries
@fcjurado
fcjurado / screenshots.sh
Last active February 6, 2018 14:32
Take screenshots from several resolutions: First of all, download and install Pageres from https://github.com/sindresorhus/pageres-cli
#!/bin/bash
# http://gs.statcounter.com/screen-resolution-stats
# https://medium.com/@uiuxlab/the-most-used-responsive-breakpoints-in-2017-of-mine-9588e9bd3a8a
resolutions=("1920x1080" "1600x900" "1440x900" "1366x768" "1280x1024" "1280x800" "1080x1920" "1024x768" "768x1024" "750x1334" "720x1280" "640x960" "640x1136" "480x800" "360x640" "320x568" "320x534")
urls=("search/mario" "search/luigi" "search/koopa" )
for r in "${resolutions[@]}"
do
for u in "${urls[@]}"
do
@fcjurado
fcjurado / fix-drupal7-permissions.sh
Last active June 21, 2017 12:40 — forked from GreenSkunk/fix-drupal7-permissions.sh
Drupal - Bash shell script to fix Drupal 7 permissions where the PHP Handler is FastCGI. Forked from https://gist.github.com/mejpark/2294266
#!/bin/bash
path=${1%/}
user=${2}
group=${3}
help="\nHelp: This script is used to fix permissions of a Drupal 7 installation\nwhere the PHP Handler is FastCGI\nyou need to provide the following arguments:\n\t 1) Path to your drupal installation\n\t 2) Username of the user that you want to give files/directories ownership\n\nNote: This script assumes that the group is the same as the username if your PHP is compiled to run as FastCGI. If this is different you need to modify it manually by editing this script or checking out forks on GitHub.\nUsage: bash ${0##*/} drupal_path user_name\n"
echo "Refer to https://www.Drupal.org/node/244924"
@fcjurado
fcjurado / batch-mp4gif.sh
Created October 8, 2016 11:16
Converts a mp4 to gif in batch
#!/bin/bash
if [ ! -d "./converted" ]; then mkdir "./converted"; fi
if [ ! -d "./tmp" ]; then mkdir "./tmp"; fi
for i in $(find ./ -name '*.mp4')
do
for word in $i
do
case "$word" in
*converted* )
##########################################
# To run:
# curl -sSL https://gist.githubusercontent.com/fcjurado/ba266337014912bde974bed47219cd28/raw/87bb06a6aa72ff9783725ae8ce14c5f9508eaff5/install-docker-mint.sh | bash -x
##########################################
# Check that HTTPS transport is available to APT
if [ ! -e /usr/lib/apt/methods/https ]; then
sudo apt-get update
sudo apt-get install -y apt-transport-https
fi