Skip to content

Instantly share code, notes, and snippets.

@ctorgalson
ctorgalson / na-phone-pattern.js
Last active February 8, 2016 08:24
North American Phone Number Regex
// This pattern matches the phone numbers ONLY (i.e. it does NOT match the
// extension or text) in:
//
// 250-370-8517 or toll free 1-888-370-8517
// 250 370 8517 or toll free 1 888 3708517
// 250 370 8517 or toll free 18883708517
// 604-851-4700 Ext. 646170
// +12503708517
// 1.250.370.8517
// (250) 370-8517
@ctorgalson
ctorgalson / ipv4-private.js
Created October 15, 2012 22:37
Private IPv4 Addresses
// This pattern matches IPv4 private IP ranges, plus loopback address.
//
// Pattern 1 matches the beginning of the IP address only, so it cannot be used
// in situations where the entire matched IP address is required.
//
// Pattern 2 returns the entire matched IP address.
//
// @see https://en.wikipedia.org/wiki/IP_address#IPv4_private_addresses
var pattern1 = /^(127\.0\.0\.1)|(10\.)|(192\.168)|(172\.(1[6-9]|2[0-9]|3[0-1])\.)/g,
pattern2 = /^(127\.0\.0\.1)|(10\.\d+\.\d+\.\d+)|(192\.168\.\d+\.\d+)|(172\.(1[6-9]|2[0-9]|3[0-1])\.\d+\.\d+)/g;
@ctorgalson
ctorgalson / vhost-pagekite
Created September 16, 2013 16:50
Virtual host for use with Pagekite where the Pagekite subdomain 'component-something.pagekite.me' exists in your account. Remember to set up '127.0.0.1 component.local www.component.local' in /etc/hosts.
<VirtualHost *:80>
ServerName component.local
ServerAlias www.component.local
ServerAlias component-something.pagekite.me
DocumentRoot /Users/Pigsy/Sites/component/public_html
<Directory /Users/Pigsy/Sites/component/public_html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
@ctorgalson
ctorgalson / gist:6769905
Created September 30, 2013 20:37
Drupal theme Flickr photoset into Foundation Clearing gallery
<?php
function themename_flickrfield_photoset($variables) {
$img = $variables['0'];
$photo_url = $variables['1'];
$formatter = $variables['2'];
$photo_data = $variables['3'];
$node = $variables['4'];
//
$output = '<ul class="clearing-thumbs flickr-photoset">';
@ctorgalson
ctorgalson / gist:6829101
Created October 4, 2013 16:57
Feedburner 302 redirect
RewriteCond %{HTTP_USER_AGENT} !FeedBurner
RewriteRule ^/feed/path$ http://feeds.feedburner.com/feedname [R=302,L]
@ctorgalson
ctorgalson / gist:a62655267a966a6b0331
Created November 2, 2014 16:52
Generate a passphrase protected 4096 bit rsa keypair with a custom name
Username$ ssh-keygen -b 4096 -t rsa -f ~/.ssh/demo_key
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/Username/.ssh/demo_key.
Your public key has been saved in /Users/Username/.ssh/demo_key.pub.
The key fingerprint is:
dd:6b:c9:de:d0:df:3c:74:92:97:1c:97:7b:7d:9b:fb Username@Username.local
The key's randomart image is:
+--[ RSA 4096]----+
@ctorgalson
ctorgalson / SublimeLinter.sublime-settings.json
Last active November 23, 2015 12:37
Sample Sublime config file for enabling PHP_CodeSniffer
{
"user":{
"debug":true,
"delay":0.5,
"error_color":"D02000",
"gutter_theme":"Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
"gutter_theme_excludes":[
],
"lint_mode":"background",
@ctorgalson
ctorgalson / 384-vagrant-up-fails-at-restart-php-fpm.diff
Created January 21, 2016 21:26
Adds `extra_parameters` to Apache VirtualHosts
diff --git a/example.config.yml b/example.config.yml
index c1ffbb7..1559c62 100644
--- a/example.config.yml
+++ b/example.config.yml
@@ -75,7 +75,9 @@ configure_local_drush_aliases: true
# Apache VirtualHosts. Add one for each site you are running inside the VM. For
# multisite deployments, you can point multiple servernames at one documentroot.
-# View the geerlingguy.apache Ansible Role README for more options.
+# Note that Apache VirtualHosts requiring PHP must include extra_parameters
<p>8HY - 4 Lead Bi-Polar</p>

<table border="1" cellpadding="1" cellspacing="1">
  <thead>
    <tr>
      <th scope="row" style="background-color: rgb(197, 217, 241);">&nbsp;</th>
      <th colspan="2" scope="col" style="background-color: rgb(197, 217, 241);">Model Number</th>
      <th scope="col" style="background-color: rgb(197, 217, 241);">Connect</th>
      <th scope="col" style="background-color: rgb(197, 217, 241);">Rated Current</th>
@ctorgalson
ctorgalson / datesort.php
Last active August 5, 2016 16:30
Simplified date sort query
<?php
/**
* Called to add the sort to a query.
*/
public function query() {
$this->ensureMyTable();
$configuration = [
'table' => 'node__field_event_date',