PhpStorm now bundles WordPress coding style natively, starting from version 8.
- Go to
Project Settings
>Code Style
>PHP
. - Select
Set From...
(top right of window) >Predefined Style
>WordPress
.
No longer need to muck with this import! :)
<?php | |
// Note: CA state law says no robocalls before 9AM, so wait until 12PM EST. | |
$sid = 'Your SID'; | |
$token = 'Your Token'; | |
$telephoneNumber = 'Your Telephone Number, the one that Twilio gives you.'; | |
$client = new Services_Twilio($sid, $token); |
#simple version (http://mysite.com/+ goes to your Google+ account) | |
Redirect /+ https://plus.google.com/[yourid] | |
Redirect /@ https://twitter.com/[twitterusername] | |
#powerhouse (http://mysite.com/+/about goes to your Google+ about page) | |
RedirectMatch ^/\+(.*)$ http://plus.google.com/[yourid]$1 | |
RedirectMatch ^/@(.*)$ http://twitter.com/[twitterusername]$1 |
/* | |
* Quick and Dirty sprintf | |
* Copyright 2011 Nicholas C. Zakas. All rights reserved. | |
* BSD licensed | |
*/ | |
/* | |
* This function does not attempt to implement all of sprintf, just %s, | |
* which is the only one that I ever use. | |
*/ |
Implementation of the Luhn 10 algorithm to check validity of credit card numbers. See http://en.wikipedia.org/wiki/Luhn_algorithm for details on the algorithm.
var validCreditCard = function(a,b,c,d,e){for(d=+a[b=a.length-1],e=0;b--;)c=+a[b],d+=++e%2?2*c%10+(c>4):c;return!(d%10)};
validCreditCard('378282246310005'); //=> true
validCreditCard('378282246310006'); //=> false
// some numbers to test with
// 378282246310005 371449635398431 378734493671000
<?php | |
// secure hashing of passwords using bcrypt, needs PHP 5.3+ | |
// see http://codahale.com/how-to-safely-store-a-password/ | |
// salt for bcrypt needs to be 22 base64 characters (but just [./0-9A-Za-z]), see http://php.net/crypt | |
$salt = substr(strtr(base64_encode(openssl_random_pseudo_bytes(22)), '+', '.'), 0, 22); | |
// 2y is the bcrypt algorithm selector, see http://php.net/crypt | |
// 12 is the workload factor (around 300ms on my Core i7 machine), see http://php.net/crypt |
// ==UserScript== | |
// @name UTM param stripper | |
// @author Paul Irish | |
// @namespace http://github.com/paulirish | |
// @version 1.2 | |
// @description Drop the UTM params from a URL when the page loads. | |
// @extra Cuz you know they're all ugly n shit. | |
// @include http*://* | |
// ==/UserScript== |
// converts milliseconds to '3:45' or if hours > 0, '2:01:23' | |
var getTimeFromMillis = function( ms ) { | |
var seconds = ~~( ( ms / 1000 ) % 60 ), | |
minutes = ~~( ( ms / ( 1000 * 60 ) ) % 60 ), | |
hours = ~~( ( ms / ( 1000 * 60 * 60 ) ) ), | |
twoDigit = function ( n ) { | |
return n < 10 ? '0' + n : n; | |
}, | |
seconds = ':' + twoDigit( seconds ); |
// ---------------------------------------------------------- | |
// A short snippet for detecting versions of IE in JavaScript | |
// without resorting to user-agent sniffing | |
// ---------------------------------------------------------- | |
// If you're not in IE (or IE version is less than 5) then: | |
// ie === undefined | |
// If you're in IE (>=5) then you can determine which version: | |
// ie === 7; // IE7 | |
// Thus, to detect IE: | |
// if (ie) {} |
<!DOCTYPE html> | |
<!-- Helpful things to keep in your <head/> | |
// Brian Blakely, 360i | |
// http://twitter.com/brianblakely/ | |
--> | |
<head> | |
<!-- According to Heather Champ, former community manager at flickr, | |
you should not allow search engines to index your "Contact Us" |