Skip to content

Instantly share code, notes, and snippets.

View codescribblr's full-sized avatar

Jonathan Wadsworth codescribblr

View GitHub Profile
@codescribblr
codescribblr / Snipplr-73473.txt
Created February 13, 2014 21:41
Full Width Headline with simple bars to fill the white space
// HTML
<p class="introline"><span class="titleline start"></span><span class="headline">Conferences</span><span class="titleline fin"></span></p>
// CSS
.introline {
text-transform:uppercase;
color: #a3a3a3;
letter-spacing: .5px;
font-size: 14px;
@codescribblr
codescribblr / Snipplr-70530.bash
Created February 13, 2014 21:41
Bash: host email off server linux commands
A couple of things need to happen if you are not hosting email on the server.
1. Remove example.com from /etc/mail/local-host-names
To do this SSH into the server.
su - root
cd /etc/mail
vi local-host-names
2. You might also need to delete the coolantexpress related entries in the /etc/mail/virtusertable
and run vnewvirtmaps
To do this SSH into the server.
@codescribblr
codescribblr / Snipplr-71258.js
Created February 13, 2014 21:41
JavaScript: iOS orientation change zoom bug fix
/*! A fix for the iOS orientationchange zoom bug.
Script by @scottjehl, rebound by @wilto.
MIT License.
*/
(function(w){
// This fix addresses an iOS bug, so return early if the UA claims it's something else.
if( !( /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1 ) ){ return; }
var doc = w.document;
if( !doc.querySelector ){ return; }
var meta = doc.querySelector( "meta[name=viewport]" ),
@codescribblr
codescribblr / Snipplr-58662.txt
Created February 13, 2014 21:41
Javascript (jQuery) markup for saef in expression engine
<script type="text/javascript">
// <![CDATA[
$(document).ready( function() {
//URL Title js
$("input#title").keyup( function() {
var titleText = $("input#title").val().replace(/ /g,"_").toLowerCase();
$("input#url_title").val(titleText);
});
@codescribblr
codescribblr / Snipplr-70525.txt
Created February 13, 2014 21:41
Javascript touch events from click
function touchHandler(event)
{
var touches = event.changedTouches,
first = touches[0],
type = "";
switch(event.type)
{
case "touchstart": type = "mousedown"; break;
case "touchmove": type="mousemove"; break;
@codescribblr
codescribblr / Snipplr-63258.txt
Created February 13, 2014 21:41
Pagination using twitter bootstrap styles
<?php
// Set the current page at 1 if it's not already set
if(!isset($_GET['p'])){$_GET['p']=1;}
$per_page = 100;
$count_transactions = count($transactions);
$pages = ceil($count_transactions / $per_page);
$current_page = (isset($_GET['p'])) ? $_GET['p'] : 1;
$clean_query_string = (isset($_GET['user_id'])) ? str_ireplace("p=".@$_GET['p']."&", "", $_SERVER['QUERY_STRING']) : str_ireplace("p=".@$_GET['p'], "", $_SERVER['QUERY_STRING']);
if(substr($clean_query_string,-1)=="&"){$clean_query_string = substr_replace($clean_query_string, "", -1);}
@codescribblr
codescribblr / Snipplr-70522.js
Created February 13, 2014 21:41
JavaScript: placeholder replacement
$(document).ready(function() {
if(!Modernizr.input.placeholder){
$("input").each(function(){
if($(this).val()=="" && $(this).attr("placeholder")!=""){
$(this).val($(this).attr("placeholder"));
$(this).focus(function(){
if($(this).val()==$(this).attr("placeholder")) $(this).val("");
});
$(this).blur(function(){
if($(this).val()=="") $(this).val($(this).attr("placeholder"));
@codescribblr
codescribblr / Snipplr-69773.js
Created February 13, 2014 21:41
JavaScript: Reset tabindex on pageload
$(function(){
var tabindex = 1;
$('input,select').each(function() {
if (this.type != "hidden") {
var $input = $(this);
$input.attr("tabindex", tabindex);
tabindex++;
}
});
});
@codescribblr
codescribblr / Snipplr-71283.js
Created February 13, 2014 21:41
JavaScript: Safe console.log usage in all browsers
// make it safe to use console.log always
(function(a){function b(){}for(var c="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),d;!!(d=c.pop());){a[d]=a[d]||b;}})
(function(){try{console.log();return window.console;}catch(a){return (window.console={});}}());
@codescribblr
codescribblr / Snipplr-70540.txt
Created February 13, 2014 21:41
Simple iframe shortcode for wordpress
add_shortcode('iframe', 'iframe');
function iframe($atts) {
extract(shortcode_atts(array(
'src' => "",
'width' => "800",
'height' => "600"
), $atts));
$iframe = '<iframe src="'.$src.'" width="'.$width.'" height="'.$height.'" scrolling="no" allowtransparency="yes" frameborder="0" ></iframe>';