Skip to content

Instantly share code, notes, and snippets.

bounces = 1; //total number of bounces
duration = .5; //duration of each bounce in seconds
amp = 1.5; //multiplier for incoming velocity used in bounce
decay = 2; //exponential decay of bounce height
n=0;
if(numKeys>0){n=nearestKey(time).index;if(key(n).time>time){n--;}}
n==0?t=0:t=time-key(n).time;
freq=1/duration;
mult = (bounces-Math.floor(t*freq))/bounces;
transition = 20;
if (marker.numKeys<2){
tSecs = transition / ( 1 / thisComp.frameDuration);
linear(time, inPoint, inPoint + tSecs, 0, 100)
- linear(time, outPoint - tSecs, outPoint, 0, 100)
}else{
linear(time, inPoint, marker.key(1).time, 0, 100)
- linear(time, marker.key(2).time, outPoint, 0, 100)
}
@spencejs
spencejs / sub_and_super.php
Created November 20, 2013 06:41
Add Subscript and Superscript buttons to TinyMCE
function enable_more_buttons($buttons) {
$buttons[] = 'sub , sup';
return $buttons;
}
add_filter("mce_buttons_2", "enable_more_buttons");
@spencejs
spencejs / remove_comments_url_field.php
Created November 5, 2013 22:49
Remove URL Field from Comment Form
add_filter('comment_form_default_fields', 'url_filtered');
function url_filtered($fields)
{
if(isset($fields['url']))
unset($fields['url']);
return $fields;
}
@spencejs
spencejs / help_tab.php
Created November 5, 2013 19:35
Add Help Info To Help Tab
//hook loading of new page and edit page screens
add_action('load-page-new.php','add_custom_help_page');
add_action('load-page.php','add_custom_help_page');
function add_custom_help_page() {
//the contextual help filter
add_filter('contextual_help','custom_page_help');
}
function custom_page_help($help) {
@spencejs
spencejs / show_form_fields.js
Created November 5, 2013 07:22
Show Form Fields Based On Field Value
function toggleFields() {
$('.additional-field').hide();
var selected = $('#business-type').val();
switch (selected) {
case 1:
$('#soletrader').show();
break;
case 3:
$('#publicsector').show();
//Remove Admin Bar Items
function mytheme_admin_bar_render() {
global $wp_admin_bar;
// we can remove a menu item, like the Comments link, just by knowing the right $id
$wp_admin_bar->remove_menu('comments');
// or we can remove a submenu, like New Link.
$wp_admin_bar->remove_menu('new-link', 'new-content');
// we can add a submenu item too
$wp_admin_bar->add_menu( array(
'parent' => 'new-content',
<?php
$images =& get_children( array (
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image'
));
if ( empty($images) ) {
// no attachments here
} else {
/*
Source Tutorial: http://www.paulund.co.uk/create-wordpress-widget-to-display-twitter-updates
*/
define('MAGPIE_CACHE_ON', 1); //2.7 Cache Bug
define('MAGPIE_CACHE_AGE', 180);
define('MAGPIE_INPUT_ENCODING', 'UTF-8');
define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
@spencejs
spencejs / Add TinyMCE Buttons
Created June 11, 2013 20:30
Add NextPage and Other Buttons to TinyMCE
//Add NextPage and Other Buttons to TinyMCE
add_filter('mce_buttons', function ($mce_buttons) {
$pos = array_search('wp_more', $mce_buttons, true);
if ($pos !== false) {
$buttons = array_slice($mce_buttons, 0, $pos + 1);
$buttons[] = 'wp_page';
$buttons[] = 'hr';
$mce_buttons = array_merge($buttons, array_slice($mce_buttons, $pos + 1));