Skip to content

Instantly share code, notes, and snippets.

View deekayen's full-sized avatar
🏡
Working from home

David Norman deekayen

🏡
Working from home
View GitHub Profile
@deekayen
deekayen / totals.php
Created October 12, 2013 17:47
Scrape user statistics from drupal.org.
<?php
function curl_request($url) {
$curl_version = curl_version();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Linux; en-US) PHP/' . phpversion() . ' cURL/' . $curl_version['version'] . ' deekayen/1.0');
return curl_exec($ch);
}
@deekayen
deekayen / homebrew-php54-phpini
Created March 4, 2014 00:16
A diff between my /etc/php.ini and the default php.ini file installed by Jose's Homebrew formula.
--- /etc/php.ini 2014-02-27 16:15:52.000000000 -0500
+++ /usr/local/etc/php/5.4/php.ini 2014-02-05 03:22:22.000000000 -0500
@@ -1,7 +1,4 @@
[PHP]
-zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so
-xdebug.remote_enable=On
-detect_unicode = off
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
@deekayen
deekayen / tokutest.php
Last active August 29, 2015 14:01
A shell script, written in PHP, to test the difference in time for importing and exporting dumps from MariaDB using either InnoDB or TokuDB engines. Spoiler: Dumps are the same speed, TokuDB imports are 2x slower than InnoDB. Note: this is a destructive script and will delete anything in the database you configure to be used.
#!/usr/bin/php
<?php
$db = array();
$db['host'] = 'localhost';
$db['user'] = 'root';
$db['password'] = '';
$db['database'] = 'toku';
@deekayen
deekayen / barracuda.php
Created May 14, 2014 04:00
A timer script I wrote to find out how long it would take to do a command-line import of a SQL file. Used to test the difference in import times between the Antelope and Barracuda XtraDB storage formats. Barracuda turned out a 3% speed gain.
#!/usr/bin/php
<?php
$db = array();
$db['host'] = 'localhost';
$db['user'] = 'root';
$db['password'] = '';
$db['database'] = 'barracuda';
@deekayen
deekayen / normananalyzer.js
Created June 18, 2014 12:41
Norman keyboard layout analyzer by Nahuel Caponi from http://jsfiddle.net/Deban/qJLLm/
var keyboards = [];
var text = "";
//To create a keyboard:
//call the CreateKeyboard function, then pass the name, add a comma,
//lastly spam your first 10 keys for each row
//don't use the numbers row and don't use more than 10 keys per row
CreateKeyboard("qwerty", "qwertyuiopasdfghjkl;zxcvbnm,./");
CreateKeyboard("colemak", "qwfpgjluy;arstdhneiozxcvbkm,./");
CreateKeyboard("workman", "qdrwbjfup;ashtgyneoizxmcvkl,./");
@deekayen
deekayen / scan_drupal_nodes.php
Last active August 29, 2015 14:02
Node enumeration script finds the availability of content within a Drupal site for audit purposes. May help uncover pages mistakenly available to anonymous users.
<?php
$url_prefix = 'https://deekayen.net/node/';
$low = 1400;
$high = 1450;
$output_file = '/Users/davidnorman/Sites/scan/scan.csv';
/******************************************/
$fp = fopen($output_file, 'w');
@deekayen
deekayen / spelling.php
Created July 3, 2014 17:25
This file used to work with PHP and the Pspell extension but later around PHP 4.3.1 and the release of Aspell 0.50.2, it stopped working, complaining about not finding the right dictionary.
<?php
// unset it just in case someone tried to set it from the URL with register_globals on
unset($suggestion_found);
session_start();
define("NL", "\n");
function check_textarea($message) {
return htmlspecialchars(stripslashes($message));
DELETE FROM node_revisions WHERE vid IN (
SELECT subquery.vid FROM (
SELECT @row_num := IF(@prev_value=nr.nid,@row_num+1,1) AS RowNumber
,nr.nid
,nr.vid
,nr.timestamp
,@prev_value := nr.nid
FROM node_revisions nr,
(SELECT @row_num := 1) x,
(SELECT @prev_value := '') y
@deekayen
deekayen / trim_drupal_node_revisions.sql
Last active August 29, 2015 14:07 — forked from anonymous/trim_drupal_node_revisions.sql
Delete revisions from the Drupal 7 node_revisions table such that only the newest 3 revisions remain for each node. It joins on the node table to make sure that the current, active vid assigned in the node table doesn't get deleted.
DELETE FROM node_revisions WHERE vid IN (
SELECT subquery.vid FROM (
SELECT @row_num := IF(@prev_value=nr.nid,@row_num+1,1) AS RowNumber
,nr.nid
,nr.vid
,nr.timestamp
,@prev_value := nr.nid
FROM node_revisions nr,
(SELECT @row_num := 1) x,
(SELECT @prev_value := '') y
@deekayen
deekayen / brewStack.md
Last active August 9, 2017 15:23 — forked from shrop/brewStack.md
Localhost Drupal environment setup with Homebrew on Mac OS X

brewStack update for fresh install

Install steps:

  • Install Homebrew:

      $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
      $ brew update
      $ brew install git