Skip to content

Instantly share code, notes, and snippets.

View jCrip's full-sized avatar
🏠
Working from home

Juan Cristobal Pazos jCrip

🏠
Working from home
  • Modyo
  • Santiago, Chile
View GitHub Profile
@jCrip
jCrip / snippet.js
Created March 8, 2012 14:32 — forked from necolas/snippet.js
Optimised async loading of cross-domain scripts
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
@jCrip
jCrip / pubsub.js
Created March 12, 2012 16:02
jQuery: pub/sub
// PubSub
(function( $ ) {
var o = $( {} );
$.each({
trigger: 'publish',
on: 'subscribe',
off: 'unsubscribe'
}, function( key, val ) {
jQuery[val] = function() {
@jCrip
jCrip / ir.css
Created March 12, 2012 21:11
CSS: Image replacement
.ir {
border: 0;
font: 0/0 a;
text-shadow: none;
color: transparent;
background-color: transparent;
}
@jCrip
jCrip / Asset.html
Created March 15, 2012 14:20
Viewport Scaling Bug
<script>
(function(doc) {
var addEvent = 'addEventListener',
type = 'gesturestart',
qsa = 'querySelectorAll',
scales = [1, 1],
meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];
function fix() {
@jCrip
jCrip / Asset.html
Created March 15, 2012 14:21
Redirect Mobile Devices
<script>
<!--
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
location.replace("http://xxx");
}
-->
</script>
@jCrip
jCrip / Asset.js
Created March 15, 2012 14:22
Modern Event Handling
<script type="text/javascript">
/**
* Attach an event handler on a given Node taking care of Browsers Differences
* @param {Object} node
* @param {String} type
* @param {Function} fn
* @param {Boolean} capture
*/
function addEventHandler(node,type,fn , capture){
if(typeof window.event !== "undefined"){
@jCrip
jCrip / Asset.css
Created March 15, 2012 14:23
Media Queries Bootstrap
// Landscape phones and down
@media (max-width: 480px) { ... }
// Landscape phone to portrait tablet
@media (max-width: 767px) { ... }
// Portrait tablet to landscape and desktop
@media (min-width: 768px) and (max-width: 979px) { ... }
// Large desktop
@jCrip
jCrip / Asset.html
Created March 15, 2012 14:25
Web App Meta Tags
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-startup-image" href="img/splash-screen.png" />
//iPad Landscape
<link rel="apple-touch-startup-image" sizes="1024x748" href="img/splash-screen-1024x748.png" />
//iPad Portrait
<link rel="apple-touch-startup-image" sizes="768x1004" href="img/splash-screen-768x1004.png" />
//iPhone Portrait
<link rel="apple-touch-startup-image" href="img/splash-screen-320x460.png" />
@jCrip
jCrip / canvas-noise.js
Created March 19, 2012 18:47
Create noise with canvas
function generateNoise(opacity) {
if ( !!!document.createElement('canvas').getContext ) {
return false;
}
var canvas = document.createElement("canvas"),
ctx = canvas.getContext('2d'),
x, y,
number,
opacity = opacity || .2;
@jCrip
jCrip / Prefixr+LiveReload.sh
Created March 20, 2012 15:55
Use Nettuts+ Prefixr with LiveReload
css="`cat assets/css/main.css`" && curl -sSd css="$css" http://prefixr.com/api/index.php > assets/css/main.css