Skip to content

Instantly share code, notes, and snippets.

@mmhan
mmhan / javascript_in_php
Created September 26, 2011 08:37 — forked from Djuki/javascript_in_php
Mix javascript and php
$javascript = <<<JS
function javascriptFunction()
{
/* Some javascript code here */
}
JS;
@mmhan
mmhan / ratio.js
Created September 26, 2011 07:57
will dynamically resize the object to a ratio specified in "#videoratio"
$(function(){
var ratioEl = $("#videoratio");
if(ratioEl){
var ratio = ratioEl.html().split(':');
$("#dnn_dnnARTICLE_aembed object").attr('height', 500 * ratio[1] / ratio[0]);
}
});
@mmhan
mmhan / demo.html
Created September 21, 2011 12:00
Video Player embed tag
<html>
<head>
<title>Video Player</title>
</head>
<body>
<div id="silverlightControlHost">
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="640" height="480">
<param name="source" value="VideoPlayer.xap"/>
<param name="background" value="white" />
<param name="initParams" value="m=http://www.sonypictures.com/movies/21/video/trailer/21_trailer_high.asx" />
@mmhan
mmhan / jquery-1.2.4a.js
Created September 21, 2011 08:54
jquery 1.2.4a and jquery-ui-all-1.5b2 (packed) with detection for better version before loading
(!window.jQuery || window.jQuery().jquery < '1.2.4a') && /** detect if a better jquery is there before loading. If better jquery is there stop loading to avoid conflicts **/
(function(){if(window.jQuery){var _jQuery=window.jQuery;}var jQuery=window.jQuery=function(selector,context){return new jQuery.prototype.init(selector,context);};if(window.$){var _$=window.$;}window.$=jQuery;var quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;var isSimple=/^.[^:#\[\.]*$/;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;return this;}else{if(typeof selector=="string"){var match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1]){selector=jQuery.clean([match[1]],context);}else{var elem=document.getElementById(match[3]);if(elem){if(elem.id!=match[3]){return jQuery().find(selector);}else{this[0]=elem;this.length=1;return this;}}else{selector=[];}}}else{return new jQuery(context).find(selector);}}else{if(jQuery.isFunction(
@mmhan
mmhan / cw_player.js
Created May 18, 2011 03:01
CWPlayer, Comwerks' Silverlight Videoplayer using http://slvideoplayer.codeplex.com/
(function($){
$.fn.CwPlayer = function(options){
var settings = {
'thumbs' : 'cwVidThumb',
'width' : 640,
'height' : 360,
'source' : ''
};
function getVideoTemplate(url, options){
@mmhan
mmhan / fb_decode.php
Created April 25, 2011 02:33
A useful class to retrieve SignedRequest from a Facebook App embedded as tab in a Facebook Page. Particularly useful in finding out visiting user's ID and whether the user like the page or not.
<?php
/*************************************
* Class with methods to decode a signed request easily, for App embedded as Tab on a profile page.
*
* @ModifiedBy Mike - @mmhan - mmhan.net
* @author Nathron
* @url http://nathrondevblog.blogspot.com/2010/09/how-to-get-user-id-in-profile-tab.html
*
* @usage:
* //In facebook tab page.
function FBReady( func ) {
// If facebook is already loaded,
// just call the function
if ( FBReady.done ) return func();
// If the stack already exists,
// push the function onto it,
// otherwise, initialize a stack
// of functions