Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am the-paulus on github.
  • I am the_paulus (https://keybase.io/the_paulus) on keybase.
  • I have a public key whose fingerprint is 66E9 292D C084 9FD9 9F36 05E2 69C5 84CB E5CE EAC4

To claim this, I am signing this object:

@the-paulus
the-paulus / products.js
Created April 15, 2017 21:05
Google Sheet script that will convert cells A2:N1000 into a downloadable XML file.
/* Main function for generating XML from spreadsheet. */
function doGet() {
// The sheet that contains the product information.
var productDataSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Products");
// The first row of the sheet that contains all the product attributes (e.g., Color, Weight, Collection, Name, etc.)
var productAttributes = productDataSheet.getRange("A1:N1").getValues();
// Range of rows and columns that contain the product information.
var productData = productDataSheet.getRange("A2:N1000").getValues();
// XML document object.
var document = XmlService.createDocument();
@the-paulus
the-paulus / manufacturers.js
Created April 15, 2017 21:07
Google Sheet script that will convert cells A2:B1000 into a downloadable XML file.
function doGet() {
// The sheet that contains the manufacturer information.
var manufacturerDataSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Manufacturers");
// The first row of the sheet that contains the manufacturer's name and description.
var manufacturerAttributes = manufacturerDataSheet.getRange("A1:B1").getValues();
// Range of rows and columns that contain the manufacturer information.
var manufacturerData = manufacturerDataSheet.getRange("A2:B1000").getValues();
// XML document object.
var document = XmlService.createDocument();
// Root element of the XML output.
@the-paulus
the-paulus / categories.js
Created April 15, 2017 21:08
Google Sheet script that will convert cells A2:D1000 into a downloadable XML file.
function doGet() {
// The sheet that contains the category information.
var categoryDataSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Categories");
// The first row of the sheet that contains the categories' name, description, parent, banner image, and list image.
var categoryAttributes = categoryDataSheet.getRange("A1:D1").getValues();
// Range of rows and columns that contain the category information.
var categoryData = categoryDataSheet.getRange("A2:D1000").getValues();
// XML document object.
var document = XmlService.createDocument();
// Root element of the XML output.
@the-paulus
the-paulus / MacOSTweaks.md
Created April 23, 2017 00:41
Some commands to tweak MacOS

Set The Screen Saver As The Wallpaper:

/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background

Show Hidden Files In Finder

defaults write com.apple.finder AppleShowAllFiles TRUE
@the-paulus
the-paulus / cpanel_cp_akeys.sh
Created May 25, 2017 18:24
Copies ssh authorized keys to each cPanel user account.
for user in $(cat /etc/domainusers | cut -d: -f 1)
do
if [ ! -d /home/$user/.ssh ]
then
mkdir /home/$user/.ssh
chown "$user":"$user" /home/$user/.ssh
fi
cp /root/.ssh/authorized_keys /home/$user/.ssh
chown "$user":"$user" /home/$user/.ssh/authorized_keys
@the-paulus
the-paulus / create_ssh_config.sh
Created May 25, 2017 18:26
Creates a listing of entries for ssh's config file used for public/private key authentication.
while IFS='' read -r line || [[ -n "$line" ]]
do
user=$(echo $line | cut -d: -f 1)
domain=$(echo $line | cut -d' ' -f 2)
printf "\n\nHost $domain\n\tHostName $domain\n\tPort 22222\n\tUser $user\n\tIdentityFile ~/.ssh/id_rsa"
done < /etc/domainusers
@the-paulus
the-paulus / NewFormDrupal.php
Last active October 12, 2017 01:00
Old code snippet for creating forms manually using the form API in Drupal.
<?php
/**
* Implementation of hook_elements().
*/
function referralsources_elements() {
return array('referralsources_select' => array(
'#input' => TRUE,
'#process' => array('referralsources_select_process'),
'#element_validate' => array('referralsources_select_validate'),
@the-paulus
the-paulus / git-author-rewrite.sh
Created March 2, 2018 18:20
Interactive script that rewrites the Author's and Committer's name and email.
#!/bin/sh
read -e -p "Email address of author to update: " OLD_EMAIL
read -e -p "New name of author: " CORRECT_NAME
read -e -p "New email address of author: " CORRECT_EMAIL
git filter-branch --env-filter '
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
@the-paulus
the-paulus / erase_history.sh
Created April 8, 2018 03:06
Commands to erase bash history
# Clears bash history
cat /dev/null > ~/.bash_history
# Prevent history from being recorded
ln -s ~/.bash_history /dev/null
# A copy of the history is stored in memory and written to the file uppon logout.
# To get around this:
cat /dev/null > ~/.bash_history && history -c && exit