Skip to content

Instantly share code, notes, and snippets.

View iamstoick's full-sized avatar

Stoick The Vast iamstoick

View GitHub Profile
@iamstoick
iamstoick / drush.md
Created June 2, 2017 07:17
A handy Drush command to get page generation time
time drush php-eval '
$path="node/NODEID";
menu_set_active_item($path);
menu_execute_active_handler($path,
TRUE);' > /dev/null

Sample output.

@iamstoick
iamstoick / certbot.md
Created May 22, 2017 12:52
How to install Cerbot in Ubuntu

This is how to manage Letsencrypt in Ubuntu.

sudo add-apt-repository ppa:certbot/certbot
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-apache

# Create ssl certificate
sudo certbot --apache
@iamstoick
iamstoick / parse_csv.md
Last active May 10, 2017 04:01
Parse CSV via FAPI
ini_set('auto_detect_line_endings', true);

$rows = array();

// Load the csv file.
if ($csv_file = file_load($form_state['values']['csv_file'])) {
    if (($handle = fopen($csv_file->uri, "r")) !== FALSE) {
        while (($data = fgetcsv($handle, NULL, ",")) !== FALSE) {
 array_push($rows, $data);
@iamstoick
iamstoick / google-drive.md
Created February 26, 2017 22:30
How to Access Google Drive on Ubuntu 16.04

Install required packages

sudo apt install gnome-control-center gnome-online-accounts

Go to Settings > Online Account and add your Google account. Also make sure that the Files toggle button is on.

On Nautilus, you will find your gmail account being added on the left panel (navigation).

@iamstoick
iamstoick / drush-drupal.md
Last active February 26, 2017 22:12
A bash snippet to manage Drupal database backup

Create a file called drupal-db-backup.sh and put the script below.

#!/usr/bin/env bash

# @param $1
#   The directory where the dump sql file will ba saved. 
#
# @param $2
#   The database name that is going to backup. Note that Drupal and Drush don't really need
# this param but only for attachment on the filename.
@iamstoick
iamstoick / drush.md
Created January 26, 2017 07:53
List overridden features in Drupal

drush fl --status=enabled | grep -o "\S\+\s\+Enabled.\+" | grep "Overridden"

@iamstoick
iamstoick / checksum.md
Created January 18, 2017 00:48
Checksum comparison from mobile to API endpoint
function _x($data) {
  // Store the hash data from mobile.
  $hash_from_mobile = end($data);

  // Remove the hash data as it is not needed anymore.
  array_pop($data);
  // Serialize the data before in order to calculate the checksum value.
  $query_string = serialize($data);
 $hash = md5($query_string);
@iamstoick
iamstoick / ssh.md
Created January 5, 2017 03:53
How to add SSH key to remote server

cat ~/.ssh/id_rsa.pub | ssh user@hostname 'cat >> .ssh/authorized_keys'

@iamstoick
iamstoick / tools.md
Last active February 28, 2020 14:30
My Tools

For full list of tools please see this repo: Development Note

  1. git
  2. geany
  3. letsencrypt
  4. docker
  5. vagrant
  6. meld
  7. git-sweep
  8. htop
@iamstoick
iamstoick / drush.md
Last active February 26, 2017 21:58
A Drush snippet on how to backup Drupal database and compress it after.

drush sql-dump --gzip --result-file=/path/to/target/[DATABASE_NAME]-$(date +%Y-%m-%d-%H.%M).sql

Remove all caches

drush sql-dump --gzip --skip-tables-list=cache,cache_* --result-file=/path/to/target/[DATABASE_NAME]-$(date +%Y-%m-%d-%H.%M).sql

Just changed the [DATABASE_NAME] with your database.