Skip to content

Instantly share code, notes, and snippets.

@simonwhitaker
simonwhitaker / postcode-regex.js
Last active December 15, 2023 11:29
An example of using a simplified UK postcode regex in Javascript
var tweet = "Currently chilling out at W1B 2EL, then on to WC2E 8HA or maybe even L1 8JF! :-)";
// Here's a simple regex that tries to recognise postcode-like strings.
// See http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Validation
// for the rules on how UK postcodes are formatted.
var postcode_regex = /[A-Z]{1,2}[0-9][0-9A-Z]?\s?[0-9][A-Z]{2}/g;
var postcodes = tweet.match(postcode_regex);
console.log(postcodes);
@barneycarroll
barneycarroll / fileInput.css
Last active April 2, 2023 22:21
Total input[type=file] style control with pure CSS. File type inputs are notoriously hard to style, due to different semi-serious style restrictions in the name of security (the argument being that a file input presents access to the user's private file system, and should as such always look unambiguously like what it is — redundant if you ask m…
.fileContainer {
overflow: hidden;
position: relative;
}
.fileContainer [type=file] {
cursor: inherit;
display: block;
font-size: 999px;
filter: alpha(opacity=0);
@bueltge
bueltge / keep_me_logged_in_for_1_year.php
Last active January 4, 2023 10:39
WordPress Plugin, that set the time that the cookie will be kept at 1 year and active the 'Rember Me' Checkbox for default
<?php
/**
* Plugin Name: Keep me Logged In for 1 Year
* Plugin URI: https://bueltge.de/wordpress-login-unterbinden/1220/
* Description: Set the time that the cookie will be kept at 1 year.
* Version: 0.0.3
* Author: Frank Bültge
* Author URI: https://bueltge.de/
*/
function whichTransitionEvent(){
var t;
var el = document.createElement('fakeelement');
var transitions = {
'transition':'transitionend',
'MSTransition':'msTransitionEnd',
'MozTransition':'transitionend',
'WebkitTransition':'webkitTransitionEnd'
}
@bueltge
bueltge / attachment-taxononimies.php
Created December 6, 2012 11:38
WordPress Attachment Taxonomies with WP 3.5*
<?php
/**
* Plugin Name: Attachment Taxonomies
* Plugin URI: attachment_taxonomies
* Text Domain: addquicktag
* Domain Path: /languages
* Description:
* Version: 1.0.0
* Author: Frank Bültge
* Author URI: http://bueltge.de
@Raysharr
Raysharr / better_setInterval.js
Created October 18, 2012 20:50
Paul Irish's better setInterval
/* From Paul Irish */
/* instead of */
setInterval(function(){ doStuff(); },100);
/* use anonymous self-executing function */
(function thisismyfunctionuniquename(){
doStuff();
setTimeout(thisismyfunctionuniquename,100);
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@visiongeist
visiongeist / Function hook
Created August 20, 2012 08:16
This plugin hooks into an existing jQuery function and calls a user defined function after a jQuery function was called.
/*
* Function hook jQuery plugin
* version 1.0
* author: Damien Antipa
* http://github.com/dantipa/
*/
(function(window, $, undefined){
/**
* Hooks into a given method
@scribu
scribu / taxonomy-columns.php
Created July 12, 2012 15:35
'show_admin_column' => true
<?php
add_action( 'registered_taxonomy', array( 'APP_Tax_Admin_Column', 'register_column' ), 10, 3 );
/**
* Generates a column with the associated terms,
* for any taxonomy with 'show_admin_column' => true
*/
class APP_Tax_Admin_Column {
/**
* Helper class for controlling all aspects of a view.
*
* Supported methods (automatically hooked):
* - init() - for registering post types, taxonomies, rewrite rules etc.
* - parse_query() - for correcting query flags
* - pre_get_posts() - for altering the query, without affecting the query flags
* - posts_search(), posts_clauses(), posts_request() - for direct SQL manipulation
* - the_posts() - for various other manipulations
* - template_redirect() - for enqueuing scripts etc.