Skip to content

Instantly share code, notes, and snippets.

View ericwwsun's full-sized avatar

Eric Sun ericwwsun

  • IBM iX
  • New York City
View GitHub Profile
@ericwwsun
ericwwsun / gist:ea3e73be4a77b997563f
Created June 16, 2014 16:29
[CSS] keeping ratio box
.square {
//width within the parent
width: 100%;
&:before {
content: "";
float: left;
//essentially the aspect ratio. 100% means the
//div will remain 100% as tall as it is wide, or
//square in other words.
padding-bottom: 100%;
@ericwwsun
ericwwsun / gist:9694363
Created March 21, 2014 19:33
[Javascript] [Angular] Capturing document level keypress events in AngularJS
<html lang="en" ng-controller="AppController" ng-keyup="keyup($event)">
var AppController = function($scope) {
$scope.keyup = function(keyEvent) {
console.log('keyup', keyEvent);
};
};
/*
* Author: http://stuffandnonsense.co.uk/blog/about/hardboiled_css3_media_queries/
*/
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
ERROR 2014-01-13 20:47:23,637 base 5337 140188056676096 Internal Server Error: /account/profileCancelPlanRenew/
Traceback (most recent call last):
File "/persistent/dramafever/.virtualenvs/df/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/persistent/dramafever/.virtualenvs/df/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 20, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/persistent/dramafever/trunk/dramafever/main/views.py", line 1101, in plan_cancel_renew_view
next_billing_period_amount, discount_amount = userSubs.get_deter_cancel_discount_info()
File "/persistent/dramafever/trunk/dramafever/premium/models.py", line 1472, in get_deter_cancel_discount_info
sub = braintree.Subscription.find(self.subscription_id)
@ericwwsun
ericwwsun / gist:6582606
Created September 16, 2013 15:57
[Javascript] Map object for googlemaps
PL.maps = (function(){
var map,
geoData;
var init = function(mapId,options){
var div = document.getElementById(mapId);
map = new google.maps.Map(div, options);
return map;
@ericwwsun
ericwwsun / gist:3124925
Created July 16, 2012 20:44
Javascript: Project Js Pattern
var $j = jQuery.noConflict();
$j(document).ready(function(){
ms.header.init();
ms.home.init();
ms.footer.init();
}); // end of document ready
/* ------------------------------------------
* Project Namespace
@ericwwsun
ericwwsun / index.html
Created July 4, 2012 15:28
Javascript: HTML5 template - yet another
<!doctype html><!-- simplified doctype works for all previous versions of HTML as well -->
<!-- Paul Irish's technique for targeting IE, modified to only target IE6, applied to the html element instead of body -->
<!--[if lt IE 7 ]><html lang="en" class="no-js ie6"><![endif]-->
<!--[if (gt IE 6)|!(IE)]><!--><html lang="en" class="no-js"><!--<![endif]-->
<head>
<!-- simplified character encoding -->
<meta charset="utf-8">
@ericwwsun
ericwwsun / gist:2999231
Created June 26, 2012 21:27
Javascript: jQuery ajax example
var jqxhr = $j.ajax({
type: 'post', //post or get
url: cartUrl,
//dataType: 'json', //if necessy
data: { product : pid, qty: 1, isAjax: 1 } // Important!!
}).done(function(data){
//console.log(data.status);
if ( data.status == "SUCCESS") {
// do something...
}
@ericwwsun
ericwwsun / gist:2999079
Created June 26, 2012 21:12
Javascript: On window scrolling, do something based on % of document height
// On window scrolling
$j(window).scroll(function(){
// update the ruler's color based on scroll position
var docHeight = $j(document).height();
var scrollTop = $j(window).scrollTop();
var currPos = scrollTop/docHeight*100;
//console.log( currPos + "%");
if( (currPos > 13 && currPos < 21) || currPos > 64 ) {
//do something in between 13% and 21% and grater than 64%
} else {
@ericwwsun
ericwwsun / gist:2999009
Created June 26, 2012 21:06
Javascript: Delay Redirection Syntax
setTimeout( "window.location = '../yourpath/yourdestination?" + params +"';" , 3000);