Skip to content

Instantly share code, notes, and snippets.

View geraldvillorente's full-sized avatar

Stoick The Vast geraldvillorente

  • Philippines
View GitHub Profile
@geraldvillorente
geraldvillorente / import.md
Created June 14, 2017 05:03
How to import database in MySQL in Docker?

This is a simple way of importing MySQL database in Docker.

  1. In you Dockerfile you must have a shared folder. Shared folder is a directory in your host machine that is mounted to Docker instance.

  2. Put the exported sql file in the shared folder.

  3. Login to your Docker instance via docker exec -it DOCKER_CONTAINER_ID bin/bash.

  4. Login to MySQL via mysql -u USERNAME -p.

@geraldvillorente
geraldvillorente / fixNTFS.md
Last active January 6, 2024 10:01
How to fix Ubuntu unable to mount NTFS partition
Unable to mount [DEVICE_NAME]

Error mounting /dev/sdc1 at /media/gerald/PicsBooks: Command-line 
'mount -t "ntfs" -o "uhelper=udisks2,nodev,nosuid,uid=1000,gid=1000,dmask=0077,fmask=0177" "/dev/sdc1" 
"/media/gerald/PicsBooks"' exited with non-zero exit status 14: The disk contains an unclean file system (0, 0).
Metadata kept in Windows cache, refused to mount.
Failed to mount '/dev/sdc1': Operation not permitted
The NTFS partition is in an unsafe state. Please resume and shutdown
Windows fully (no hibernation or fast restarting), or mount the volume
@geraldvillorente
geraldvillorente / sitemap-crawler.php
Last active September 11, 2023 10:51
Sitemap crawler to test 301 and 404.
/**
* Crawl the sitemap.xml for 301 redirections and 404 errors.
* Source: http://edmondscommerce.github.io/php/crawl-an-xml-sitemap-quality-check-301-and-404.html
*
* To use this script you need to allocate a huge amount of time to maximum_execution_time to
* avoid Fatal error: Maximum execution time...I suggest to run this script on terminal.
* Ex: $ php test-xml.php > ~/Desktop/sitemap-curl-result.txt
*
* For 3000 links the average time the script consumed is around 45 minutes to 1 hour.
*/
@geraldvillorente
geraldvillorente / timezone.md
Last active June 12, 2023 14:55
Setting timezone in Ubuntu via commandline

To list the timezones:

timedatectl list-timezones

To set the timezone:

sudo timedatectl set-timezone Asia/Manila
@geraldvillorente
geraldvillorente / php.md
Created July 26, 2017 07:03
How to check an average memory usage by single PHP-FPM process
ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'
ps --no-headers -o "rss,cmd" -C apache2 | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'

Keybase proof

I hereby claim:

  • I am geraldvillorente on github.
  • I am stoickthevast (https://keybase.io/stoickthevast) on keybase.
  • I have a public key ASD1dECCTmvuLrZot45BcLtf1yD6taZCEVQtA_HUDw7jrAo

To claim this, I am signing this object:

@geraldvillorente
geraldvillorente / resolve.md
Last active October 27, 2022 01:40
curl resolve script

Application

This script is useful if there is a proxy or a CDN between the client and the Pantheon Global CDN. This script will allow you to bypass the external CDN/proxy and resolve the request directly to Pantheon GCDN.

Default request flow:

Client browser -> Cloudflare/ Proxy -> GCDN -> Pantheon Origin

With this script:

Client browser -> GCDN -> Pantheon Origin

@geraldvillorente
geraldvillorente / dig.md
Created October 25, 2022 01:59
Get the TTL from the authoritative server
#!/bin/bash

show_help(){
        echo Usage $0 domain
}

if [ -z "$1" ]; then
        show_help
 exit 1
@geraldvillorente
geraldvillorente / redis.md
Created July 26, 2017 14:55
How to test if Redis is working

In order to check if Redis is really working.

First, flush all keys stored in redis in order to remove old cache entries

$ redis-cli FLUSHALL

Monitor REDIS realtime.

$ redis-cli MONITOR
@geraldvillorente
geraldvillorente / cache-warm.php
Created November 22, 2021 23:23
Cache warmer - Pantheon
<?php
if ($_ENV['PANTHEON_ENVIRONMENT'] != 'live') {
die();
}
$config['email'] = '[EMAIL]';
$config['sitemap'] = 'https://www.mydomain.com/post-sitemap.xml';
check_sitemap_urls($config['sitemap'], $config['email'], 30);