Skip to content

Instantly share code, notes, and snippets.

View joneff's full-sized avatar

Иван Жеков joneff

View GitHub Profile
@mislav
mislav / easy_way.rb
Last active May 20, 2020 13:48
RESOLVE SHORT URLS before storing. Short URLs are for microblogging; you should never actually keep them around.
require 'net/http'
# WARNING do not use this; it works but is very limited
def resolve url
res = Net::HTTP.get_response URI(url)
if res.code == '301' then res['location']
else url.to_s
end
end
@jgable
jgable / ModuleExport.js
Created October 18, 2011 05:33
Modern Web Development Blog Post code - Module Export Pattern
// Initialize our apps namespace; add a pages holder for later.
var MYAPP = {
pages: {}
};
// A closure to encapsulate our HomePage class.
(function($, app) {
// This little guy is private to this closure.
function bindButtons($page) {
@jgable
jgable / ready.core.js
Created September 27, 2011 22:07
document.ready alternatives for jQuery Mobile - core.js
// Create our namespace object, use one that already exists if it's available, fall back to new object "{}".
var MYAPP = MYAPP || {};
(function($, ns) {
// .. This is a closure, so we don't muddy up our global namespace.
// .. $ = jQuery, ns = MYAPP (For those playing along at home)
// Extend our namespace with some stuff we're going to add later.
ns = $.extend(ns, {
@chriseppstein
chriseppstein / 0_selector_hacks.scss
Created September 14, 2011 04:27
This gist demonstrates some uses of the new sass feature: Passing content blocks to mixins.
@mixin ie6 { * html & { @content } }
#logo {
background-image: url("/images/logo.png");
@include ie6 { background-image: url("/images/logo.gif"); }
}
@jgable
jgable / TransitionPageClickHandler.js
Created June 21, 2011 22:24
Page Transition Click Handler Example
// Get our transition links in the nav
opts.$navLinks = $('nav a[transition-link]');
// Attach click handlers for all links with our special transition attribute.
opts.$navLinks.click(function(e) {
// Prevent navigation...
e.preventDefault();
opts.toggleLoading(true);
@jgable
jgable / jQuery-linqHelpers.js
Created April 20, 2011 14:06
jQuery-linqHelpers - Helper functions from linq.
/* Author:
Jacob Gable, http://jacob4u2.posterous.com
License:
MS-PL
*/
jQuery.any = function (collection, compareFunc) {
if (!$.isArray(collection) || !$.isFunction(compareFunc)) {
return false;
}