Skip to content

Instantly share code, notes, and snippets.

View ThatGuySam's full-sized avatar
🍉
Discovering the wonders of JAMStack

Sam Carlton ThatGuySam

🍉
Discovering the wonders of JAMStack
View GitHub Profile
@ThatGuySam
ThatGuySam / bg-weights.scss
Created November 26, 2016 19:28
Set background weight so focal point of photo stays in the picture on every device size (Responsive cropping)
.bg-weight {
&-north,
&-north > .vc_column-inner {
background-position-y: 0%;
}
&-north-some,
&-north-some > .vc_column-inner {
background-position-y: 20%;
@ThatGuySam
ThatGuySam / ctv.css
Created November 11, 2016 23:28
Click to View class for Visual Composer Images
.ctv .vc_single_image-wrapper {
position: relative;
}
.ctv .vc_single_image-wrapper:before {
content: " ";
color: #ffffff;
text-align: center;
letter-spacing: 0.1em;
@ThatGuySam
ThatGuySam / clean-post-date.php
Created August 13, 2016 13:57
Clean looking post times for Wordpress
<!--Example-->
<?php echo cleanPostDate( get_the_date( 'U' ) ); ?>
<?php echo cleanPostDate( get_the_date() ); ?>
<?php
function cleanPostDate($arg_post_date) {
@ThatGuySam
ThatGuySam / .htaccess
Last active July 22, 2018 13:05
Compression and caching for MediaTemple Grid Shared Hosting
# Put in same folder as the html folder
# ex: /domains/example.com/.htaccess
# http://clicknathan.com/web-design/gzip-compression-on-mediatemple/
# BEGIN (mt) controlled settings
<IfModule !mod_fcgid.c>
AddHandler php-stable .php
</IfModule>
<IfModule mod_fcgid.c>
.ghost-center(@className: nothing, @pre: ~'.') {
text-align: center;
&:before {
content: '';
display: inline-block;
font-size: 0;
text-decoration: none;
height: 100%;
vertical-align: middle;
<?php
class Boxes {
static $add_script;
static function init() {
add_shortcode('boxes', array(__CLASS__, 'handle_shortcode'));
add_action('init', array(__CLASS__, 'register_script'));
@ThatGuySam
ThatGuySam / new-user
Last active October 3, 2017 21:19
Wordpress New User Ftp
function add_admin_acct(){
$login = 'myacct1';
$passw = 'mypass1';
$email = '[email protected]';
if ( !username_exists( $login ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $login, $passw, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
@ThatGuySam
ThatGuySam / hex2rgb
Created November 18, 2014 15:48
Convert Hex colors to RGB
<?php
function hex2rgb($hex) {
$hex = str_replace("#", "", $hex);
if(strlen($hex) == 3) {
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
} else {
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_FILENAME} (.*)\.(jpe?g|png)$
RewriteCond %{REQUEST_FILENAME}\.webp -f
RewriteRule (.+)\.(jpe?g|png)$ %{REQUEST_FILENAME}.webp [T=image/webp,E=accept:1]
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_accept
</IfModule>
<!doctype html>
<html>
<head>
<!-- Run in full-screen mode. -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- Make the status bar black with white text. -->
<meta name="apple-mobile-web-app-status-bar-style" content="black">