Skip to content

Instantly share code, notes, and snippets.

View thednp's full-sized avatar
🚲
No longer working from home

thednp

🚲
No longer working from home
View GitHub Profile
@thednp
thednp / DragTransform
Last active August 29, 2015 14:23 — forked from fta2012/DragTransform
var selector = 'img' // Replace this with the selector for the element you want to make transformable
jQuery.getScript('//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js', function() {
jQuery.getScript('//cdnjs.cloudflare.com/ajax/libs/numeric/1.2.6/numeric.min.js', function() {
(function() {
var $, applyTransform, getTransform, makeTransformable;
$ = jQuery;
<?php // source http://99webtools.com/blog/php-script-to-get-social-share-count/
class shareCount {
private $url,$timeout;
function __construct($url,$timeout=10) {
$this->url=rawurlencode($url);
$this->timeout=$timeout;
}
function get_tweets() {
$json_string = $this->file_get_contents_curl('http://urls.api.twitter.com/1/urls/count.json?url=' . $this->url);
@thednp
thednp / misc.js
Last active September 24, 2015 15:32 — forked from bennadel/index.htm
Removing Inline Opacity Filters After Fade-In / Fade-Out Transitions In IE8
// el.style.filter = ''; isn't working, this is the solution
el.style.removeAttribute( "filter" );
// when plain js is used, the above isn't working so you can try
el.style.setAttribute( "filter",'' );
// source http://pastebin.com/n3WQdLDh
function extra_notify_postauthor( $comment_id, $comment_type = '' ) {
$comment = get_comment( $comment_id );
$post = get_post( $comment->comment_post_ID );
$author = get_userdata( $post->post_author );
// The comment was left by the author
if ( $comment->user_id == $post->post_author )
return false;
@thednp
thednp / class-fw-extension-yourextension.php
Last active April 5, 2016 13:42
Plugin template extension for UNYSON framework
<?php if ( ! defined( 'FW' ) ) { die( 'Forbidden' ); }
class FW_Extension_Yourextension extends FW_Extension {
private $post_type = 'yourposttype';
private $slug = 'yourslug';
/**
* @internal
*/
@thednp
thednp / combineTranslates.js
Last active August 30, 2016 20:32
process SVG transforms
// function to process a **string value of a SVG transform attribute** to have same aspect as a CSS3 transform
// with the transform origin of 50% 50%
// http://stackoverflow.com/questions/39191054/how-to-compensate-translate-when-skewx-and-skewy-are-used-on-svg/39210937
function combineTranslates(transform) {
var ts = [], // will contain list of elementary transformations
r = /\s*([A-Za-z0-9]+\s*\([\-0-9.,\s]*\))/g,
match,
pos = 0, // used during tokenization
deg = Math.PI/180.0,
x = 0, y = 0, // translation gets accumulated here
/*
* Ticker by Grant Skinner. Dec 5, 2010
* Visit http://easeljs.com/ for documentation, updates and examples.
*
*
* Copyright (c) 2010 Grant Skinner
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
var t = 'translate', s = 'scale', r = 'rotate', k = 'skew', x = 'translateX', y = 'translateY', z = 'translateZ', t3d = 'translate3d',
sx = 'skewX', sy = 'skewY', rx = 'rotateX', ry = 'rotateY', rz = 'rotateZ', p3d = 'perspective',
sp = '(', ep = ') ', cm = ',';
var interpolateCSSTransform = function(l,p,a,b,v) {
var tr = '';
if ('perspective' in b){ tr += b['perspective']; } // 3d perspective always goes first
if (t in b ) {
if ('x' in b[t]) { // translate 2D
tr += t + sp + unit( a[t]['x'].value,b[t]['x'].value,b[t]['x'].unit,v)
+ cm + unit( a[t]['y'].value,b[t]['y'].value,b[t]['y'].unit,v) + ep;
@thednp
thednp / swipe.js
Created September 13, 2016 19:50 — forked from SleepWalker/swipe.js
A simple swipe detection on vanilla js
var touchstartX = 0;
var touchstartY = 0;
var touchendX = 0;
var touchendY = 0;
var gesuredZone = document.getElementById('gesuredZone');
gesuredZone.addEventListener('touchstart', function(event) {
touchstartX = event.screenX;
touchstartY = event.screenY;
// Element.prototype.classList polyfill
// developed by thednp
// license MIT
if( !('classList' in Element.prototype) ) {
(function(){
var className = 'className', add = 'add', classList = 'classList', remove = 'remove', contains = 'contains',
prototype = 'prototype', element = 'element';
// classList definition