Skip to content

Instantly share code, notes, and snippets.

@thagler
thagler / get_node_by_path.php
Created Sep 16, 2016
Drupal 8 Get node ID by path alias
View get_node_by_path.php
<?php
$path = \Drupal::service('path.alias_manager')->getPathByAlias('/this-is-the-alias');
if(preg_match('/node\/(\d+)/', $path, $matches)) {
$node = \Drupal\node\Entity\Node::load($matches[1]);
}
@thagler
thagler / revert_commit.git
Created Sep 13, 2016
Remove the latest commit from a branch already pushed to origin
View revert_commit.git
For a list of the most recent commits
`git log --pretty=oneline --abbrev-commit`
Go back 1 commit to remove
`git rebase -i HEAD~1`
replace ‘pick’ with ‘drop’ in that commit line and save (should be in vi)
`git push origin +my/branch-name`
Note: push +branch_name is like --force, but slightly less of a jerk about it
View mysql-full-backup
#!/bin/bash
#
# MySQL Backup Script
# VER. 2.5 - http://sourceforge.net/projects/automysqlbackup/
# Copyright (c) 2002-2003 wipe_out@lycos.co.uk
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.