Skip to content

Instantly share code, notes, and snippets.

View aaronott's full-sized avatar

Aaron Ott aaronott

  • Rule4
  • Thornton, CO
View GitHub Profile
@aaronott
aaronott / install_drush_globally
Last active August 29, 2015 14:07
Quickly install latest drush globally with composer
#!/bin/bash
set -x
# This assumes that composer is already installed
sudo mkdir -p /usr/share/composer \
&& sudo composer -vvv global require drush/drush:dev-master --working-dir=/usr/share/composer \
&& sudo ln -s /usr/share/composer/vendor/drush/drush/drush /usr/local/bin/drush
diff --git a/src/libwaitress/waitress.c b/src/libwaitress/waitress.c
index f6d4d03..19e0f01 100644
--- a/src/libwaitress/waitress.c
+++ b/src/libwaitress/waitress.c
@@ -1058,8 +1058,8 @@ WaitressReturn_t WaitressFetchCall (WaitressHandle_t *waith) {
/* certificate verification function */
gnutls_session_set_ptr (waith->request.tlsSession,
(gnutls_transport_ptr_t) waith);
- gnutls_certificate_set_verify_function (waith->tlsCred,
- WaitressTlsVerify);
@aaronott
aaronott / gist:3278232
Created August 6, 2012 20:40
Make a user login prior to accessing anything on the site.
global $user;
/*
* If the user is not logged in, require them to login prior to being
* redirected to the form
*/
if ($user->uid === 0 && arg(0) != 'user') {
$dest = drupal_get_path_alias($_GET['q']);
drupal_goto('user', array('query' => array('destination' => $dest)));
}
@aaronott
aaronott / d7_fixperms.sh
Created October 17, 2012 20:37
Fix D7 file permissions
#!/bin/sh
PERM_USER=nobody
PERM_GROUP=dev
APACHE_USER=apache
if [ $# -ne 1 ] ; then
echo "USAGE $0 <d7 root dir>"
exit;
fi
#!/bin/bash
# Usage:
# ./download.sh allmodules.txt
#
# Assumes allmodules.txt is a newline-separated list of projects you want to
# download.
# @todo Error handling of any kind. :P I'm so optimistic. :P
# Versions to attempt to download, in order of preference.
@aaronott
aaronott / gist:4551942
Last active December 11, 2015 05:28
Find any url in a string and replace it with a clickable lin
#!/usr/bin/env php
<?php
function create_link($msg) {
$pattern = array(
'/(((http|https|ftp|ftps)\:\/\/)(?:[\w\-\d]+\.)+[\w\-\d]+(?:\/[\w\-\d]+)*(?:\/|\.[\w\-\d]+)?(?:\?[\w\-\d]+\=[\w\-\d\+]+)?(?:\&[\w\-\d]+\=[\w\-\d\+\.\%]+)*(?:\#[\w\-\d]*)?)/',
);
$replace = array(
'<a href="$1">$1</a> [<a href="$1" target="_blank">^</a>]' ,
@aaronott
aaronott / regexp switch
Last active December 11, 2015 05:28
regexp to switch firstname.lastname@email.com to lastname.firstname@email.com
%s/\(\w\+\).\(\w\+\)@/\2.\1@/
In vim, this will take a pattern such as firstname.lastname@email.com
and replace it with lastname.firstname@email.com
@aaronott
aaronott / user_cleanup.php
Last active December 12, 2015 10:38
Disable all Drupal users except Admin via Drush
#!/usr/bin/env drush
<?php
#
# This script removes all drupal users with uid > 1 (e.g., skips
# admin user) and reassigns their content to anonymous.
#
// check if we can bootstrap
$self = drush_sitealias_get_record('@self');
if (empty($self)) {
@aaronott
aaronott / rs.repl_lag.js
Last active December 14, 2015 06:48
Testing for repl_lag This script will display the difference between the optime of current node and the primary node in a replSet. login to your server `mongo` and run `rs.repl_lag()`
rs.repl_lag = function () {
var s = db._adminCommand("replSetGetStatus");
// if this is primary, go no further.
if (s.myState == 1) {
return 0;
}
var mytime = 0;
var primarytime = 0;
@aaronott
aaronott / lifeblocks.html
Created March 17, 2016 03:17
lifeblocks
<html>
<head>
<title>life in blocks</title>
<style>
span {
width:5px;
height:8px;
border:1px solid black;
display:block;