Skip to content

Instantly share code, notes, and snippets.

@teknikqa
teknikqa / 50_purge_varnish.sh
Created July 21, 2016 13:09 — forked from heathdutton/50_purge_varnish.sh
Acquia Cloud hook for flushing Varnish .com domains securely.
#!/bin/bash
#
# Cloud Hooks: code-deploy, code-update, db-copy, web-activate
# Essentially any time code or db changes are made.
#
# Purges Varnish cache for all .com domains assigned to the environment in Acquia Cloud.
site="$1"
target_env="$2"
drush_alias=$site'.'$target_env
@teknikqa
teknikqa / gist:5c9b5367d32fb6ad66cc20303c46f384
Created July 21, 2016 13:24 — forked from heathdutton/gist:cc29284de3934706acd1
Start an Acquia drush command, and wait for it to complete before continuing.
#!/bin/bash
# Runs an acquia task, and waits for the task to complete before continuing.
# This is a helper script, to be used in others as needed.
if [[ $1 = "" ]] || [[ $2 = "" ]]
then
echo "Runs an acquia drush command, waiting for the results before continuing."
echo "Can be used as a replacement for drush."
echo
echo " Usage: $0 <site-alias> <ac-drush-command>"
@teknikqa
teknikqa / full_width.html
Created July 25, 2016 13:13
CSS to create a full width container inside a fixed width container. Works on IE9 and above.
<div class="container" style="width: 750px; margin: 0 auto;">
<div class="row-full">
--- Full width container ---
</div>
</div>
@teknikqa
teknikqa / sort_files.sh
Created December 4, 2016 13:13
Categorize files into sub-directories based on their file type.
#!/bin/bash
die () {
echo -e "\033[0;31m$*\033[m" >&2
exit 1
}
DIR=${1:-.}
if [ ! -d "$DIR" ]; then
@teknikqa
teknikqa / gitLatexDiff.sh
Created December 4, 2016 13:14
Creates a diffed latex document comparing your recent uncommitted changes to your git last commit.
#!/bin/bash
#This script creates a diffed latex document comparing your recent uncommitted changes to your git last commit.
#
# ./gitLatexDiff.sh "folder path containing the git repository"
#
#You need to make sure that the current version at least compiles.
#
#The file and folder structure:
#
@teknikqa
teknikqa / prevent_logout.py
Created December 4, 2016 13:21
Script that randomly presses 'w', 'a', 's' or 'd' every once in a while and kills itself when another key is pressed.
#!/usr/bin/env python3
import datetime
import random
import subprocess
import sys
import time
import threading
import keylogger
WASD = ['w', 'a', 's', 'd']
def random_time(minimum=30, maximum=60):
@teknikqa
teknikqa / Rename_files.sh
Last active December 6, 2016 12:41
Rename files and all instances of old name within the files
brew install rename
# Rename all filenames from old_name to new_name
rename 's/old_name/new_name/g;' *
# Rename all instances of old_name with new_name inside the files in current directory
perl -pi -w -e 's/old_name/new_name/g;' *
# Just to be safe search for the old_name
ag old_name
@teknikqa
teknikqa / autokey-acquia.sh
Created January 22, 2017 13:26 — forked from nhoag/autokey-acquia.sh
Auto-handling of ssh keys for Acquia Hosting
#!/bin/bash
# Acquia
CLOUDAPI_ID='id'
CLOUDAPI_KEY='key'
DOCROOT="docroot"
CREDS="${CLOUDAPI_ID}:${CLOUDAPI_KEY}"
ssh-keygen -q -b 4096 -t rsa -N "" -f ./script.key
Source: https://www.bluespark.com/blog/uninstalling-and-purging-field-modules-all-once
The job is divided in three parts: The data definition, field data purge and module list clean.
In the data definition task we provide all the required data we need to perform the task, the name of the field to delete, and given that
information, we get the field_info array and the name of the module to be uninstalled. Finally, field_delete_field() is executed.
After that the field data is purged in the batch body, and since we don't know how much data we will have to purge, we remove just 100
database rows per batch execution. After each purge we check if all the data has been removed to decide if we have to remove more data
from the database or continue to the final part.
@teknikqa
teknikqa / html.tpl.php
Created October 18, 2017 11:46 — forked from pascalduez/html.tpl.php
Drupal 7 — Move $scripts at page bottom
<!DOCTYPE html>
<html<?php print $html_attributes; ?>>
<head>
<?php print $head; ?>
<title><?php print $head_title; ?></title>
<?php print $styles; ?>
<?php print $head_scripts; ?>
</head>
<body<?php print $body_attributes;?>>