Skip to content

Instantly share code, notes, and snippets.

View geerlingguy's full-sized avatar
:shipit:
Tea, Earl Grey, hot.

Jeff Geerling geerlingguy

:shipit:
Tea, Earl Grey, hot.
View GitHub Profile
@geerlingguy
geerlingguy / crawler_detect.php
Created May 7, 2014 18:48
Detect crawlers/bots/spiders in PHP (simple and fast)
<?php
/**
* Check if the given user agent string is one of a crawler, spider, or bot.
*
* @param string $user_agent
* A user agent string (e.g. Googlebot/2.1 (+http://www.google.com/bot.html))
*
* @return bool
* TRUE if the user agent is a bot, FALSE if not.
@geerlingguy
geerlingguy / windows-environment.md
Created May 28, 2014 16:04
Windows 7 Environment Setup

Windows 7 Environment Setup

I've had the misfortune of having to work on a Windows-based PC from time to time, and it takes a bit of time to figure out the right software required to configure a Windows workstation for proper web development. Additionally, since Windows is harder (if not impossible) to script via simple CM tools like Puppet or Ansible (and I have no desire to learn the vagaries of PowerShell, though some Windows-loving friends seem to think highly of it), I hate having to sit around googling links to get downloads of all the required apps.

Here's a simple list of all the software packages I install on Windows workstations to do development via Linux VMs (configured via Vagrant + VirtualBox):

@geerlingguy
geerlingguy / blinky.ino
Created February 4, 2015 20:11
Blinky
/*
Blinky
Make it look like my Arduino is doing something nefarious.
*/
int led = 13;
void setup() {
pinMode(led, OUTPUT);
}
@webstandardcss
webstandardcss / pedantically_commented_playbook.yml
Last active April 23, 2019 06:03 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options.
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@geerlingguy
geerlingguy / keybase.md
Created February 10, 2015 22:06
Keybase proof

Keybase proof

I hereby claim:

  • I am geerlingguy on github.
  • I am geerlingguy (https://keybase.io/geerlingguy) on keybase.
  • I have a public key whose fingerprint is 31B7 F9E1 C457 BDF5 C57B 59B3 FF8E 69CB D559 848E

To claim this, I am signing this object:

@rgoodie
rgoodie / new-drupal-dev-vm.sh
Last active March 22, 2018 23:47
A function, when added to bash profile, clones the Vagrant Drupal-Dev-VM (https://github.com/geerlingguy/drupal-dev-vm), augments configuration (based on d7 or d8), renames the VM to something other than drupaltest.dev and starts vagrant up. Uses include <newd 7 my-drupal-site> and <newd 8 my-other-drupal-site>.
# new drupal vagrant install
# A function, when added to bash profile, clones the Vagrant Drupal-Dev-VM (https://github.com/geerlingguy/drupal-dev-vm),
# augments config (based on d7 or d8), renames the VM to something other than drupaltest.dev and starts vagrant up. Uses
# include <newd 7 my-drupal-site> and <newd 8 my-other-drupal-site>.
function newd {
if [ $2 == ]; then
echo 'USAGE: newd8 <version> <sitename>'
@geerlingguy
geerlingguy / php7.conf
Created May 31, 2015 20:50
Apache PHP mods-available Config File
<FilesMatch ".+\.ph(p[3457]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".+\.phps$">
SetHandler application/x-httpd-php-source
# Deny access to raw php sources by default
# To re-enable it's recommended to enable access to the files
# only in specific virtual host or directory
Require all denied
</FilesMatch>
#!/usr/bin/env ruby
# Get passed in arguments
projectName = ARGV[0]
drupalVersion = ARGV[1]
vmRepo = 'https://github.com/geerlingguy/drupal-vm.git'
baseDirectory = '/#{Dir.home}/Sites/'
vmDirectory = baseDirectory + projectName + '_vm/'
@geerlingguy
geerlingguy / post-slack-messages-on-interval.js
Created November 13, 2015 19:42
Post Slack messages on an interval - paste this into console on a Slack chat page
setInterval(function() {
jQuery('#message-input').val('ruby--');
jQuery('#message-form').submit();
jQuery('#message-input').val('game of shadows++');
jQuery('#message-form').submit();
}, 30 * 1000);
@geerlingguy
geerlingguy / extension-bookmarklet.js
Created January 10, 2016 03:08
JS bookmarklet - add an extra extension to the end of a domain
function locationreplace(a, b) {
currentLocation = window.location.href;
newLocation = currentLocation.toString().replace(a, b);
document.location.href = newLocation;
}
locationreplace('.org', '.org.etc.etc');