Skip to content

Instantly share code, notes, and snippets.

View charliecm's full-sized avatar

Charlie Chao charliecm

View GitHub Profile
@charliecm
charliecm / twitter-feed.js
Last active February 16, 2017 10:20
Gets user timeline feed from Twitter using API 1.1 and OAuth. Based on codes from http://www.webdevdoor.com/javascript-ajax/custom-twitter-feed-integration-jquery/
/**
* Get Twitter Feed
* Based on codes from http://www.webdevdoor.com/javascript-ajax/custom-twitter-feed-integration-jquery/
* Author: Charlie Chao
*/
$(function() {
var twitterFeed = (function() {
var options = {
user: 'twitter', // Twitter screen name
@charliecm
charliecm / fb-og.html
Created June 16, 2013 06:22
Facebook Open Graph meta tags.
<!-- general Open Graph metas -->
<meta property="og:image" content="/img/.."/>
<meta property="og:title" content="Title"/>
<meta property="og:site_name" content="Title"/>
<meta property="og:url" content="http://website.com/"/>
<meta property="og:type" content="blog"/>
@charliecm
charliecm / anti-spam.html
Created June 16, 2013 18:38
Anti-spam for Anchor CMS.
<!-- from http://forums.anchorcms.com/discussion/spam-prevention-for-comments#post-1882 -->
<script type="text/javascript">/* <![CDATA[ */ document.write('<input type="hidden" name="captcha" id="captcha" value="P' + 'R' + 'O' + 'T' + 'E' + 'C' + 'T" />'); /* ]]> */ </script> <noscript> <label for="captcha">Antispam: "<em>PROTECTED</em>"</label> <input id="captcha" name="captcha" value="" class="input"/> </noscript>
@charliecm
charliecm / .htaccess
Created June 16, 2013 18:40
Various .htaccess security tweaks.
# Block access to .ht* files
<Files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</Files>
@charliecm
charliecm / style.less
Created June 24, 2013 20:49
IE8 hacks and fixes.
/* Transparent PNG image black border removal */
img {
background: transparent;
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF)"; // IE8
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF); // IE6 + 7
zoom: 1;
}
@charliecm
charliecm / shortcode-enclosed.php
Created July 11, 2013 21:49
Minimal shortcode sample.
<?php
// [caption]content[/caption]
function caption_shortcode( $atts, $content = null ) {
extract( shortcode_atts( array(
'class' => 'caption',
), $atts ) );
return '<span class="' . esc_attr($class) . '">' . $content . '</span>';
}
@charliecm
charliecm / Custom.css
Created September 8, 2013 01:10
Custom Chrome dev tool style. Makes element inspector view more readable.
/*#-webkit-web-inspector .script-view,
#-webkit-web-inspector .text-editor-contents,*/
#-webkit-web-inspector #elements-content {
/*#-webkit-web-inspector .sidebar,
#-webkit-web-inspector .sidebar-overlay {*/
font-size: 14px !important;
}
#-webkit-web-inspector li.hovered:not(.selected) .selection {
border-radius: 0 !important;
// Animation
$('selector').on('animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd', function() {
});
// Transition
$('selector').on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() {
});
@charliecm
charliecm / social-share-links.html
Created October 3, 2013 17:50
Share link snippets for major social networks.
@charliecm
charliecm / ie10.js
Created October 7, 2013 16:54
Detection code for IE10+.
// Apply IE10+ detection
if ((/*@cc_on!@*/false && document.documentMode === 10) || navigator.userAgent.match(/Trident\/7.0/)) {
document.documentElement.className += ' ie10';
}