Skip to content

Instantly share code, notes, and snippets.

View smokeyfro's full-sized avatar

Chris Rault smokeyfro

View GitHub Profile
@jacks0n
jacks0n / wp-auto-login.php
Last active November 19, 2023 16:35
Automatically login to WordPress, with a given user and optionally whitelist IPs. Add this to the bottom of wp-config.php, or your theme functions.php. To automatically login, visit the admin login page (/wp-login.php or /wp-admin/).
/**
* Automatically logs in a visitor when accessing the admin login area (/wp-login.php)
*
* @copyright Copyright (c) 2014, Jackson Cooper
* @license MIT
*
* Whitelist IPs: add IPs to whitelist in $ip_whitelist. If it is empty, it will allow all IPs.
* Username: Specify the username to login as with the "user" GET parameter (eg. ?user=admin).
* If the "user" get parameter is not set, $default_user_login will be used. If set
* to "*", it will login as the first administrator found. Otherwise it will use the
@Wysie
Wysie / gist:03934b6a79a715772abd
Last active January 7, 2025 21:32
Upload to Amazon S3 Instead of Server for Sendy Email Image Uploads
//Using S3.php from https://github.com/tpyo/amazon-s3-php-class. Place it in includes/helpers
//Replaces Sendy's includes/create/upload.php
<?php
include('../functions.php');
include('../login/auth.php');
require_once('../helpers/S3.php');
//Init
$file = $_FILES['file']['tmp_name'];
@cdils
cdils / string-body-class.php
Last active January 4, 2016 00:09 — forked from norcross/string-body-class.php
Strip "color" id/value from querystring and use as body class. Prepends "theme-prefix-" to the color name. Example: For http://www.example.com/?color=blue the class would be "theme-prefix-blue."
<?php //remove opening tag
add_filter('body_class', 'string_body_class');
function string_body_class( $classes ) {
if ( isset( $_GET['color'] ) ) :
$classes[] = 'theme-prefix-' . sanitize_html_class( $_GET['color'] );
endif;
return $classes;
}
@James1x0
James1x0 / momentjs.humanized.triplesplit.time.js
Created January 15, 2014 19:42
Get a humanized, "Morning", "Afternoon", "Evening" from moment.js **Great for user greetings!**
function getGreetingTime (m) {
var g = null; //return g
if(!m || !m.isValid()) { return; } //if we can't find a valid or filled moment, we return.
var split_afternoon = 12 //24hr time to split the afternoon
var split_evening = 17 //24hr time to split the evening
var currentHour = parseFloat(m.format("HH"));
if(currentHour >= split_afternoon && currentHour <= split_evening) {
@bomberstudios
bomberstudios / sketch-plugins.md
Last active February 26, 2024 07:02
A list of Sketch plugins hosted at GitHub, in no particular order.
@markjaquith
markjaquith / gist:6225805
Last active September 5, 2024 01:41
WordPress multi-tenant directory structure sharing core files for opcode awesomeness, fast deployments, and low disk usage. With inspiration from @weskoop. "=>" indicates a symlink.
sites
|__ ms.dev
| |__ content
| |__ index.php
| |__ wp => ../../wordpress/stable
| |__ wp-config.php
|__ one.dev
| |__ content
| |__ index.php
| |__ wp => ../../wordpress/stable
@Integralist
Integralist / Description.md
Last active April 25, 2020 16:20
This is how BBC News currently implements it's Image Enhancer for responsive images. Note: this is a completely rebuilt version of the code so the BBC's original source code doesn't actually look anything like the below example.

The BBC has a server-side image service which provides developers with multiple sized versions of any image they request. It works in a similar fashion to http://placehold.it/ but it also handles the image ratios returned (where as placehold.it doesn't).

The original BBC News process (and my re-working of the script) follows roughly these steps...

  • Create new instance of ImageEnhancer
  • Change any divs within the page (which have a class of delayed-image-load) into a transparent GIF using a Base64 encoded string.
    • We set the width & height HTML attributes of the image to the required size
    • We know what size the image needs to be because each div has custom data-attr set server-side to the size of the image
    • We then set a class of image-replace onto each newly created transparent image
  • We use a 250ms setTimeout to unblock the UI thread and which calls a function resizeImages which enhances the image-replace images so their source is now set to a URL whe
@Munter
Munter / falconeers.less
Created July 19, 2013 08:45
This gist shows the development less file of Falcon Social. Profile images are individual images, which are anotated to be sprited in the production build post process. [See the resulting image here](http://global.falconsocial.com/static/69ab1fb324.png). This gives you the power to use images in different modules across the application without h…
.falconeer-profile {
.profile {
margin-top: 8px;
width: 92px;
height: 92px;
background-repeat: none;
}
&#ulrik {
.profile { background-image: url(/images/falconeers/Ulrik-side.png?sprite=falconeers); }
@dylanhthomas
dylanhthomas / delete-dstore.sh
Created June 18, 2013 16:42
Shell - Recursively Delete All .DS_Store Files
find . -name *.DS_Store -type f -exec rm {} \;
@zachleat
zachleat / gist:5407068
Last active December 16, 2015 08:39
Differences between Pure Internet Explorers and IE Compatibility Modes

Or, yet more evidence that you should use feature detection instead of browser/user agent sniffing.

IE9

Not supported in IE9 but works in IE10-as-IE9

  • Unprefixed CSS transform. Should require -ms-transform but doesn’t require it.

IE8