Skip to content

Instantly share code, notes, and snippets.

View Jaesin's full-sized avatar

Jaesin Mulenex Jaesin

View GitHub Profile
@Jaesin
Jaesin / empty-db.sh
Created April 30, 2015 02:25
Drop all tables.
# Drop all tables in a db.
function mysql-drop-tables {
if [[ $1 != "" ]]; then
if [[ $(get_yes "$@") != "1" ]]; then
echo "You are about to drop all files in the $1 database. Are you sure? (Y or N):"
read RESPONSE
fi
if [[ $(get_yes "$@") == "1" || $RESPONSE == "y" || $RESPONSE == "Y" ]]; then
mysqldump -uroot --add-drop-table --no-data $1 | grep ^DROP | mysql -uroot $1
echo "$1 has been emptied!"
@Jaesin
Jaesin / php7_install.sh
Last active August 29, 2015 14:20
Install php 7 in /usr/local/builds/php/7.x in OSX 10.10.3
#!/bin/bash
# The easy version is `curl -s http://php-osx.liip.ch/install.sh | bash -s 7.0`
# It might be better to use (build-entropy-php)[https://github.com/liip/build-entropy-php] for building.
# Create the destinaiton folder.
mkdir -p /usr/local/builds/php
# Clone the php source (Just using the master branch).
git clone https://git.php.net/repository/php-src.git /usr/local/builds/php/7.x
@Jaesin
Jaesin / rest-request.php
Last active February 23, 2023 10:39
Guzzle 4 in Drupal 8. Get a JSON version of a node.
<?php
// Example using cookie auth.
print (string) \Drupal::httpClient()
->get('http://example.com/node/1', [
'headers' => ['Accept' => 'application/json'],
'cookies' => ['SESS07e0668737e9f97189850d2cf0c79892' => 'dasGegKQ6ZzEF0xvRZWWzwrl9tt7UT8fGuXrAeLC9P1'],
])
->getBody(TRUE);
@Jaesin
Jaesin / user_shell.sh
Created June 12, 2015 02:44
Get the user shell for user in OS X
#!/bin/bash
dscl . -read /Users/$user UserShell | sed s/^UserShell:\ //
@Jaesin
Jaesin / delete_content_entities.d8.php
Created June 22, 2015 07:14
Delete all content entities in Drupal 8.
<?php
// Delete all nodes.
entity_delete_multiple('node', \Drupal::entityQuery('node')->execute());
// Delete all files.
entity_delete_multiple('file', \Drupal::entityQuery('file')->execute());
// Delete all taxonomy terms.
entity_delete_multiple('taxonomy_term', \Drupal::entityQuery('taxonomy_term')->execute());
@Jaesin
Jaesin / drupal-8.conf
Last active April 20, 2021 16:13
Drupal 8 Nginx configuration
# @file
# NGINX Configuration file for Drupal 8
# Redirect index to php.
location / {
try_files $uri @rewrite;
}
# Allow but don't log access to /favicon.ico and /robots.txt
location ~ (^/favicon\.ico$|^/robots\.txt$) {
@Jaesin
Jaesin / .travis.yml
Last active January 12, 2017 21:27
Working Travis CI file for D8 with specific simpletest suport.
# @file
# .travis.yml - Drupal 8 Travis CI Integration
language: php
sudo: false
env:
global:
# The name of the moduel to run tests on (this module).
- DRUPAL_MODULE=example
@Jaesin
Jaesin / config-snaphot.php
Last active October 13, 2015 21:27
Rebuild Config Snapshot.
<?php
/**
* Creates a new snapshot of the current state of configuration.
*/
\Drupal::service('config.manager')->createSnapshot(\Drupal::service('config.storage'), \Drupal::service('config.storage.snapshot'));
@Jaesin
Jaesin / zeepro-bootstrap.sh
Last active March 3, 2016 23:11
Zeepro Zim provisioning bash script.
#!/bin/bash
# This script is for initializing a zim and installing a pre-compiled version of octoprint.
# Run as root. If using sudo, use "sudo -i -u root"
echo "Making root writable"
mount -o remount,rw /
echo "Add some aliases for root."
@Jaesin
Jaesin / zim-oprint.sh
Last active March 19, 2016 06:22
Zeepro zim Install OctoPrint
#!/bin/bash
# Run as root. If using sudo, use "sudo -i -u root"
# This script is for building octoprint on a zim cubieboard.
# I have since moved to building a binary version of octoprint in an armhf qemu vm.
# I am using a build virtual machine to build octoprint. Qemu immulates armhf and
# is used to hostthe build machine.
#
# Debian Wheezy armhf images were obtained from: https://people.debian.org/~aurel32/qemu/armhf/