This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $ = function(selector) { | |
var matches = { | |
'#': 'getElementById', // $('#myId') | |
'.': 'getElementsByClassName', // $('.myClass') | |
'@': 'getElementsByName', // $('@myName') | |
'=': 'getElementsByTagName', // $('=body') | |
'?': 'querySelectorAll' // $('?anything') | |
}, rex = /[=#@.*]/.exec(selector)[0]; | |
var nodes = document[matches[rex]](selector.split(rex)[1]); | |
return nodes.length > 1 ? nodes : nodes[0]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isElement(obj) { | |
try { | |
// For Firefox, Opera and Chrome | |
return obj instanceof HTMLElement; | |
} | |
catch(e){ | |
// IE Bugfix | |
return (typeof obj==="object") && | |
(obj.nodeType===1) && (typeof obj.style === "object") && | |
(typeof obj.ownerDocument ==="object"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generate a datestamp in your format | |
* @return {string} datestamp | |
*/ | |
function datestamp(seperator) { | |
var today = new Date(), dd = today.getDate(), mm = today.getMonth() + 1, yyyy = today.getFullYear(); | |
seperator = seperator != null && seperator.length > 0 ? seperator : "/"; | |
dd = dd < 10 ? '0' + dd : dd; | |
mm = mm < 10 ? '0' + mm : mm; | |
return dd + seperator + mm + seperator + yyyy; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// All links pure JS solution | |
var anchors = document.getElementsByTagName('a'); | |
for (var i=0; i < anchors.length; i++) { | |
anchors[i].setAttribute('target', '_blank'); | |
} | |
// All links w. jQuery | |
$('a').attr('target', '_blank'); | |
// All outgoing links w. jQuery |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Create excerpt string with n characters | |
/// </summary> | |
/// <param name="longString">The long string</param> | |
/// <param name="delimiter">How many chars there should be</param> | |
/// <returns>Shortened string</returns> | |
public static string Excerpt(string longString, int delimiter = 30) { | |
string shortened = ""; int i = 0; | |
if (String.IsNullOrEmpty(longString) == false) { | |
if (longString.Length > delimiter) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Security checking | |
define('ABSPATH') or die ("Script kiddies!"); | |
// Defining path and filename | |
$outPath = 'postbackup/'; | |
$fileName = 'wp_posts_' . date('m-d-Y-His A e') . '.xml'; | |
// Indlude the wordpress stuff | |
require(dirname(dirname(__FILE__)) . '/wp-load.php'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# for each md file in the directory | |
for file in *.md | |
do | |
# convert each file to html and place it in the html directory | |
# --gfm == use github flavoured markdown | |
marked -o pages/$file.html $file --gfm | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(window, undefined) { | |
var strEq = function(str1, str2) { | |
return str1.toLowerCase() === str2.toLowerCase(); | |
}; | |
var ajaxRequest = function(method, opts) { | |
opts = opts ? opts : {}; | |
opts.data = opts.data || null; | |
opts.success = opts.success || function() { }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(window, undefined) { | |
var defineSingleEventListener = function(element, event, callback) { | |
try { | |
if(element.attachEvent) { | |
return element.attachEvent('on' + event, callback); | |
} else { | |
return element.addEventListener(event, callback, false); | |
} | |
} catch(e) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,300,700,600); | |
* { | |
box-sizing: border-box; | |
-moz-box-sizing: border-box; | |
-webkit-box-sizing: border-box; | |
} | |
html, | |
body, |
OlderNewer