Skip to content

Instantly share code, notes, and snippets.

View gcpantazis's full-sized avatar

George Pantazis gcpantazis

View GitHub Profile
@gcpantazis
gcpantazis / gist:3940373
Created October 23, 2012 18:01
Example of In-App Init Prevention.
// In your actual app's JS, do not initialize if site is iframed.
require(['app-global'], function(AppGlobal) {
if ( top !== self ) {
return;
}
// Otherwise
@gcpantazis
gcpantazis / gist:3940361
Created October 23, 2012 17:57
QUnit Module, Showing Iframe Loading / Destruction Calls.
// Tests : Example
var i, // testing iframe.
w; // testing iframe's window object.
module("Backbone Routers", {
setup: function() {
// Async, hold tests until iframe loads.
@gcpantazis
gcpantazis / gist:3940352
Created October 23, 2012 17:56
Creating and Destroying Iframes, Qunit Tests.
// Create an <iframe>, return the DOM object
// back to the caller once loaded.
var iframeLoad = function(pageURL, cb){
var iframe = document.createElement('iframe');
iframe.onload = function(event) {
// Return iframe to callback.
@gcpantazis
gcpantazis / gist:3907345
Created October 17, 2012 18:49
Bash Profile
# Colors
BLACK="\[\e[0;30m\]"
BLUE="\[\e[1;34m\]"
GREEN="\[\e[0;32m\]"
LIME="\[\e[1;32m\]"
CYAN="\[\e[0;36m\]"
ORANGE="\[\e[1;31m\]"
RED="\[\e[0;31m\]"
PURPLE="\[\e[0;35m\]"
BROWN="\[\e[0;33m\]"
@gcpantazis
gcpantazis / gist:3867218
Created October 10, 2012 18:02
Reduced loader example.
<script type="text/template" id="template_loader">
<div class="loader <%= className %>">
<% for ( var i = 0; i <= 11; i++ ) { %>
<div class="bar<%= i %>"></div>
<% } %>
</div>
</script>
@gcpantazis
gcpantazis / gist:3254584
Created August 4, 2012 04:42
Making 3D shapes using CSS Transforms
var CupView = Backbone.View.extend({
'events': {},
'settings': {
'shardCount': 10,
'columnWidth': 300,
'columnHeight': 500
},
@gcpantazis
gcpantazis / gist:3077894
Created July 9, 2012 17:55
Compass - Subjectively Better Sprite Mixin
$icons: sprite-map("icons/*.png");
$icons-background: sprite-url($icons) no-repeat transparent;
@mixin icons-image-replacement($sprite) {
background: $icons-background;
background-position: sprite-position($icons, $sprite);
border: 0;
color: transparent;
display: block;
@gcpantazis
gcpantazis / gist:2961257
Created June 20, 2012 18:02
Opacity CSS
#foo { display: block; float: left;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=40)";
filter:alpha(opacity=40);
opacity: 0.4;
}
@gcpantazis
gcpantazis / gist:2871256
Created June 4, 2012 22:37
Add jQuery support for outerHTML, with feature detection
// Add support for outerHTML, which in FF was only added at version 11.
// Only use elem.outerHTML once support for FF<11 is no longer needed.
(function($){
$.fn.outerHTML = function() {
var a = this.get(0).outerHTML;
return a ? a : $('<p/>').append(this.clone()).html();
}
})(jQuery);
@gcpantazis
gcpantazis / gist:2866174
Created June 4, 2012 03:35
Sort strings and numbers.
var x = [1,3,'b',5,2,4,'a'];
x.sort(function(a,b){
if ( typeof a === typeof b ) {
return (a > b);
} else {
return typeof a > typeof b;
}
});