Skip to content

Instantly share code, notes, and snippets.

View chrisdkemper's full-sized avatar

Chris Kemper chrisdkemper

View GitHub Profile
@chrisdkemper
chrisdkemper / DB backup script
Created November 12, 2020 17:31
Backup a DB on a server
#!/usr/bin/env bash
function log {
echo "[`date +'%Y-%m-%d %H:%M:%S.%N'`] $1"
}
MYSQL_BACKUP_USER=$(grep DB_USERNAME ./../.env | awk -F= '{ print $2 }')
MYSQL_BACKUP_PASS=$(grep DB_PASSWORD ./../.env | awk -F= '{ print $2 }')
BACKUP_DIR=/var/mysql-backup/storage
EXCLUDED_DATABASES=(Database information_schema mysql performance_schema sys)
#Installing Neo4j on Ubuntu
#Add the Neo4j key to apt
wget -O - http://debian.neo4j.org/neotechnology.gpg.key | apt-key add -
#Add the Neo4j repositories to apt
echo 'deb http://debian.neo4j.org/repo stable/' > /etc/apt/sources.list.d/neo4j.list
apt-get update -y
@chrisdkemper
chrisdkemper / ocelot-playbook-beginning-neo4j.yml
Created November 4, 2015 20:59
A gist to represent a code sample
##vars.yml
#DigitalOcean stuff
digital_ocean_token: DIGITAL_OCEAN_TOKEN_HERE
digital_ocean_ssh_name: ocelot.pub
digital_ocean_ssh_pub: "{{ lookup('file', '/vagrant/ansible/ssh/ocelot.pub') }}"
digital_ocean_ssh_key: /vagrant/ansible/ssh/ocelot
digital_ocean_droplet_name: ocelotdroplet
digital_ocean_droplet_size_id: 512mb
digital_ocean_droplet_region_id: lon1
//Add some contstraints for good measture, constraints must be ran individually
CREATE CONSTRAINT ON (p:Person) ASSERT p.name IS UNIQUE;
CREATE CONSTRAINT ON (c:Company) ASSERT c.name IS UNIQUE;
//:Start query:
//People
CREATE (person1:Person {name: "Chris"})
CREATE (person2:Person {name: "Kane"})
CREATE (person3:Person {name: "Dave"})
@chrisdkemper
chrisdkemper / ecommerce-example-beginnning-neo4j.cql
Last active October 18, 2020 22:11
This is an example Ecommerce data structure from the book Beginning Neo4j
//Add some contstraints for good measture, constraints must be ran individually
CREATE CONSTRAINT ON (c:Customer) ASSERT c.email IS UNIQUE;
CREATE CONSTRAINT ON (p:Product) ASSERT p.uuid IS UNIQUE;
//:Start Product and customer query:
//Products, bundles and categories
CREATE (product1:Product {name: "Product 1", uuid: "d8d177cc-1542-11e5-b60b-1697f925ec7b", price: 10})
CREATE (product2:Product {name: "Product 2", uuid: "d8d17b28-1542-11e5-b60b-1697f925ec7b", price: 20})
CREATE (product3:Product {name: "Product 3", uuid: "d8d17c72-1542-11e5-b60b-1697f925ec7b", price: 30})
@chrisdkemper
chrisdkemper / main-main.php
Last active August 29, 2015 14:14
Load the 'Main menu' created by Drupal 7 in the code
<?php
/*
* Load the the Main menu
*/
$main_menu = module_invoke('system', 'block_view', 'main-menu');
echo render($main_menu['content']);
?>
@chrisdkemper
chrisdkemper / .bash_profile
Last active August 29, 2015 14:09
Make your git branches a bit more exciting
PATH=$PATH:/usr/local/bin
export PATH
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/'
}