Skip to content

Instantly share code, notes, and snippets.

View iamstoick's full-sized avatar

Stoick The Vast iamstoick

View GitHub Profile
@iamstoick
iamstoick / gitlab.md
Created November 27, 2016 01:59
Gitlab CLI commands

Gitlab gitlab-ctl commands.

Example to start Gitlab services: sudo gitlab-ctl start

deploy-page
  Put up the deploy page
remove-accounts
  Delete *all* users and groups used by this package
upgrade
@iamstoick
iamstoick / 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.

@iamstoick
iamstoick / 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") }'
@iamstoick
iamstoick / list-usb-devices.md
Created August 18, 2024 22:04
List the devices name connected to MacOS
$ ioreg -p IOUSB -w0 | sed 's/[^o]*o //; s/@.*$//' | grep -v '^Root.*

Example ouput:

Apple[REDACTED]
USB 2.0 BILLBOARD
Apple[REDACTED]
@iamstoick
iamstoick / fixNTFS.md
Last active June 3, 2024 18:13
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
@iamstoick
iamstoick / 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.
*/
@iamstoick
iamstoick / 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

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:

@iamstoick
iamstoick / 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

@iamstoick
iamstoick / 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