Skip to content

Instantly share code, notes, and snippets.

View TastyToast's full-sized avatar

Donnie Conner TastyToast

View GitHub Profile
@TastyToast
TastyToast / handlebars-debug-helper.js
Created March 7, 2013 01:34
Handlebars Debug helper
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
console.log("====================");
console.log(this);
if (optionalValue) {
console.log("Value");
console.log("====================");
console.log(optionalValue);
}
{% plugin rawtext desktop_url %}
<script type="text/javascript">
top.location.href="{{ desktop_url }}";
</script>
@TastyToast
TastyToast / reverseArrSwap.js
Created March 15, 2013 03:50
Return Reversed Array (Swap method)
function temporarySwap(array)
{
var left = null;
var right = null;
var length = array.length;
for (left = 0, right = length - 1; left < right; left += 1, right -= 1)
{
var temporary = array[left];
array[left] = array[right];
array[right] = temporary;
@TastyToast
TastyToast / fblogin-onebutton.js
Last active December 15, 2015 03:19
Login and Get Perms with a click of a button
// LOGIN AND GET PERMS WHEN THE USER CLICKS <div id="yes"><a></a></div>
(function($){
var app = app || {
init: function(){
console.log("INIT");
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
var uid = response.authResponse.userID;
@TastyToast
TastyToast / handebars.html
Last active December 15, 2015 05:09
Handlebars Example
{% raw %}
<script type="text/x-handlebars-template" id="gallery-template">
{{#each cards}}
<div class="entry" data-index="{{itemIndex}}">
{{{image}}}
<div class="share-btns">
<div class="fbshare"><a href="#">Share</a></div>
<div class="tweet-btn"><a href="#">Tweet</a></div>
{{{shareActions}}}
</div>
@TastyToast
TastyToast / comparehandlebars.js
Created March 21, 2013 00:11
Comparison Helper for handlebars.js
// Comparison Helper for handlebars.js
// Pass in two values that you want and specify what the operator should be
// e.g. {{#compare val1 val2 operator="=="}}{{/compare}}
Handlebars.registerHelper('compare', function(lvalue, rvalue, options) {
if (arguments.length < 3)
throw new Error("Handlerbars Helper 'compare' needs 2 parameters");
operator = options.hash.operator || "==";
@TastyToast
TastyToast / siaf.js
Created May 23, 2013 23:57
self invoking anonymous function
(function($){
})(jQuery);
@TastyToast
TastyToast / preloader.js
Created July 3, 2013 21:51
Tiny Preloader
$.preloadImages = function(){
for(var i = 0; i < arguments.length; i++){
$("<img />").attr("src", arguments[i]);
}
};
@TastyToast
TastyToast / liveupdate.js
Created August 2, 2013 20:24
Live update
// FROM http://orderedlist.com/blog/articles/live-search-with-quicksilver-style-for-jquery
(function($) {
var self = null;
$.fn.liveUpdate = function(list) {
return this.each(function() {
new $.liveUpdate(this, list);
});
};
@TastyToast
TastyToast / youtube_parser.js
Created August 14, 2013 16:09
Youtube Video Id Parser
<script type="text/javascript">
function youtube_parser(url){
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
var match = url.match(regExp);
if (match&&match[7].length==11){
return match[7];
}else{
alert("Url incorrecta");
}
}