Skip to content

Instantly share code, notes, and snippets.

View nicolechung's full-sized avatar

nicole chung nicolechung

View GitHub Profile
@nicolechung
nicolechung / gist:2001463
Created March 8, 2012 15:16
JQuery, HTML: Youtube player with preview image
$(".videobox").click(function() {
/* html
* <div class="videobox" id="youtube-id">
* <img src="previewimage.jpg" />
* </div>
*/
console.log('clicked' + $(this).attr('id'));
@nicolechung
nicolechung / gist:2007781
Created March 9, 2012 18:01
Fancybox: youtube (regular link)
$("#fancybox-youtube-link").click(function(e) {
e.preventDefault();
var url = $(this).attr('href');
$.fancybox({
'width': 660,
'height': 380,
'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
'type': 'iframe' // see this?
});
});
@nicolechung
nicolechung / gist:2011347
Created March 10, 2012 12:55
Fancybox: Vimeo
$(".vimeobox").click(function(e) {
e.preventDefault();
var id = $(this).attr('id');
var title = 0; // hide vimeo title
var byline = 0; // hide byline
var portrait = 0; // hide thumbnail portrait
var autoplay = 1;
var url = "http://player.vimeo.com/video/" + id +
"?title=" + title +
"&byline="+ byline +
@nicolechung
nicolechung / gist:2029519
Created March 13, 2012 15:48
jQuery: Limit a textarea
jQuery(document).ready(function($) {
/*
* <textarea id="custom_excerpt">Text</textarea>
* <p id="error"></p>
*/
$('#custom_excerpt').keyup(function() {
// get the limit from the maxlength attribute
var limit = 100;
// get the current text inside the textarea
@nicolechung
nicolechung / gist:2032931
Created March 14, 2012 00:23
Wordpress: sort admin columns for a custom post
add_action('restrict_manage_posts','restrict_menu_post');
function restrict_menu_post() {
global $typenow;
global $wp_query;
if ($typenow=='menu') {
$taxonomy = 'menutype';
$menu_taxonomy = get_taxonomy($taxonomy);
wp_dropdown_categories(array(
'show_option_all' => __("Show All {$menu_taxonomy->label}"),
'taxonomy' => $taxonomy,
@nicolechung
nicolechung / example.htaccess
Created March 14, 2012 13:25
HTACCESS: Wordpress, Gzip, Expires, Cache
# BEGIN WordPress
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /your-site/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /your-site/index.php [L]
</IfModule>
@nicolechung
nicolechung / edit_admin.php
Created March 15, 2012 09:54
Wordpress: Edit Admin Menu
function remove_menus () {
global $menu;
if( (current_user_can('install_themes')) ) {
$restricted = array(); } // check if admin and hide nothing
else { // for all other users
if ($current_user->user_level < 10)
$restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins')); // this removes a lot! Just delete the ones you want to keep showing
end ($menu);
@nicolechung
nicolechung / less.css
Created March 19, 2012 20:17
LESS vs CSS
/* less file */
.my_mixin {
display: block;
text-indent: -9999em;
background-color: transparent;
background-position: 0 0;
background-repeat: no-repeat;
overflow: hidden;
}
h1 a, .pagination em, .cog a {
@nicolechung
nicolechung / gist:2141037
Created March 20, 2012 20:37
Apache .htaccess: mod_rewrite (local, snow leopard)
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
@nicolechung
nicolechung / gist:2141039
Created March 20, 2012 20:38
Apache: Local username.conf (enable mod_rewrite)
<Directory "/Users/your-username/Sites/">
Options Indexes MultiViews FollowSymlinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>