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 / jquery.spin.js
Created September 7, 2012 02:13 — forked from innotekservices/jquery.spin.js
jQuery Plugin for Spin.js
/*
You can now create a spinner using any of the variants below:
$("#el").spin(); // Produces default Spinner using the text color of #el.
$("#el").spin("small"); // Produces a 'small' Spinner using the text color of #el.
$("#el").spin("large", "white"); // Produces a 'large' Spinner in white (or any valid CSS color).
$("#el").spin({ ... }); // Produces a Spinner using your custom settings.
$("#el").spin(false); // Kills the spinner.
@jCrip
jCrip / jquery.pubsub.js
Created October 31, 2012 16:45 — forked from cowboy/HEY-YOU.md
jQuery: Tiny Pub/Sub
/* jQuery Tiny Pub/Sub */
(function($) {
var o = $({});
$.subscribe = function() {o.on.apply(o, arguments);};
$.unsubscribe = function() {o.off.apply(o, arguments);};
$.publish = function() {o.trigger.apply(o, arguments);};
}(jQuery));
@jCrip
jCrip / hidpi.txt
Created November 6, 2012 13:19 — forked from simX/hidpi.txt
Enable HiDPI mode in Mountain Lion w/o Quartz Debug
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool YES;
sudo defaults delete /Library/Preferences/com.apple.windowserver DisplayResolutionDisabled;
// by the way, you need to logout and log back in for this to take effect. Or at least that's what
// Quartz Debug says. Who knows, maybe it's lying?
// P.S. Go to [Apple menu --> System Preferences --> Displays --> Display --> Scaled] after logging
// back in, and you'll see a bunch of "HiDPI" resolutions in the list to choose from.
@jCrip
jCrip / high-dpi-media.css
Last active December 11, 2015 21:59 — forked from marcedwards/high-dpi-media.css
high-dpi-media.css
/* ---------------------------------------------------------- */
/* */
/* A media query that captures: */
/* */
/* - Retina iOS devices */
/* - Retina Macs running Safari */
/* - High DPI Windows PCs running IE 8 and above */
/* - Low DPI Windows PCs running IE, zoomed in */
/* - Low DPI Windows PCs and Macs running Firefox, zoomed in */
/* - Android hdpi devices and above */
(function() {
var script,
scripts = document.getElementsByTagName('script')[0];
function load(url) {
script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);
@jCrip
jCrip / notepad.html
Last active December 19, 2015 18:09 — forked from jdkanani/notepad.html
Browser Editor
data:text/html, <style type="text/css">.e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div class="e" id="editor"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("editor");e.setTheme("ace/theme/tomorrow_night_eighties");e.getSession().setMode("ace/mode/html");</script>
<!--
For other language: Instead of `ace/mode/ruby`, Use
Markdown -> `ace/mode/markdown`
Python -> `ace/mode/python`
C/C++ -> `ace/mode/c_cpp`
Javscript -> `ace/mode/javascript`
Java -> `ace/mode/java`
Scala- -> `ace/mode/scala`
$ = jQuery
TIMEOUT = 20000
lastTime = (new Date()).getTime()
setInterval ->
currentTime = (new Date()).getTime()
# If timeout was paused (ignoring small
# variations) then trigger the 'wake' event
if currentTime > (lastTime + TIMEOUT + 2000)
@jCrip
jCrip / array_mode.rb
Last active December 21, 2015 10:09 — forked from parksilk/array_mode.rb
def mode(array)
counter = Hash.new(0)
# this creates a new, empty hash with no keys, but makes all default values zero. it will be used to store
# the information from the array, such that the keys will be each unique number from the array (IOW, if there
# are two or more 4's in the array, there will just be one key that is a 4), and the value for each key will
# be the number of times that integer appears in the array.
array.each do |i|
counter[i] += 1
end
# this interates throught the array, and for each element it creates a key for that integer (if it hasn't been
@jCrip
jCrip / rpn.md
Created August 23, 2013 03:41 — forked from malandrina/gist:3744867
Implementing a Reverse Polish notation calculator in Ruby

Implementing a Reverse Polish notation calculator in Ruby

A couple weeks ago I had a go at implementing an RPN calculator in Ruby. I knew I wanted the calculator to function by popping operands out of an array populated with the values of the input expression, operating upon the operands with the appropriate operator, and pushing the result back into the stack of operands.

I was able to implement this in version 1, but it took forever and the resulting code was not very beautiful. Why?

  • I started coding before I had a thorough understanding of RPN

    Wait, 20 10 5 4 + * - is what now?