Skip to content

Instantly share code, notes, and snippets.

@jwebcat
jwebcat / lightbox.css
Created June 10, 2016 07:20 — forked from Shiti/lightbox.css
AngularJS Lightbox directive
.modal {
width: 800px;
left: 40%;
}
.lightbox-content {
width: 100%;
}
.lightbox-image {
@jwebcat
jwebcat / detect-mobile-browser.js
Created June 2, 2016 07:56 — forked from niksmac/detect-mobile-browser.js
Nodejs Express code to redirect mobile user agets
var express = require('express'),
app = express();
app.listen(80);
app.get('/', function(req, res){
var ua = req.header('user-agent');
// Check the user-agent string to identyfy the device.
if(/mobile|iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile|ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(ua)) {
res.sendfile(__dirname + '/mobile.html');
} else {
res.sendfile(__dirname + '/index.html');
if [ ! -d "htdocs" ]; then
echo 'Installing WordPress (release version) in realestate/htdocs...'
mkdir ./htdocs
cd ./htdocs
wp core download --allow-root
wp core config --dbname="realestate" --dbuser=wp --dbpass=wp --dbhost="localhost" --allow-root
wp core install --url=realestate.dev --title="realestate - A WordPress Site" --admin_user=admin --admin_password=password --admin_email=demo@example.com --allow-root
cd -
else
echo 'Updating WordPress in realestate/htdocs...'
@jwebcat
jwebcat / resize-fun.js
Created January 26, 2014 08:17
function to do cool stuff on resize - variable are stored in the body:after attribute
$(function() {
var currentSize = "kitty"; // null var so its never the current size to start
$(window).resize(function() {
var size = window.getComputedStyle(document.body, ':after').getPropertyValue('content');
var $menu = $('.nav-collapse');
/* Ridiculous thing to deal with inconsistent returning of
@jwebcat
jwebcat / cpt-tags-cats-boxes.php
Created January 24, 2014 08:19
Add category and tag boxes to custom post type admin edit screen WP
add_action('init', 'demo_add_default_boxes');
function demo_add_default_boxes() {
register_taxonomy_for_object_type('category', 'fonts');
register_taxonomy_for_object_type('post_tag', 'fonts');
}
@jwebcat
jwebcat / is-blog.php
Created January 24, 2014 08:16
Add is_blog() function to WP
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
@jwebcat
jwebcat / vertical-align.scss
Created January 24, 2014 08:14
vertical align
%vertical-align {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
@jwebcat
jwebcat / override-woocommerce.php
Created September 9, 2013 21:48
Override Woo Commerce Add to cart and go straight to checkout page. Also, override fields comments field Checkout page.
add_filter ('add_to_cart_redirect', 'redirect_to_checkout');
function redirect_to_checkout() {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;
}
add_filter('single_add_to_cart_text', 'woo_custom_cart_button_text');
@jwebcat
jwebcat / on-sent-ok.js
Created September 7, 2013 10:50
for redirect on for submit success for Contact 7
on_sent_ok: "location = 'http://itunes.com/';"
@jwebcat
jwebcat / gist:6338370
Created August 26, 2013 05:39
change css based on url hash
if (window.location.hash.split('-')[0] == '#item') {
$('ul.side').addClass('hashed');
}
// the below is questionable
$(function () {
if (window.location.hash) {
getHash();
}