Skip to content

Instantly share code, notes, and snippets.

View mieky's full-sized avatar
🦀

Mike Arvela mieky

🦀
View GitHub Profile
@miohtama
miohtama / gist:4159969
Created November 28, 2012 08:50
Client-size JPEG reader, image upload downscaler and JPEG metadata rotation handler
/**
* Client-side image resizer module.
*
* Copyright 2012 Mikko Ohtamaa
*
* Licensed under MIT license http://opensource.org/licenses/MIT
*/
/*global require, define, window, console, atob, unescape, ArrayBuffer, Uint8Array, jQuery, document, setTimeout */
@pyrtsa
pyrtsa / gist:3499353
Created August 28, 2012 15:51
Too many parentheses, you say?

Too many parentheses, you say?

FWIW, here are a few common answers to clear your worries about parentheses in Clojure in particular:

  1. It's idiomatic to use indentation to display what's nested within a given set of parentheses. The preferred way to indent code is documented fairly well. [Edit: A few examples are found e.g. here: http://clojure-euler.wikispaces.com/Problem+001]

  2. If you're concerned about matching parens somewhere (i.e. you suspect things aren't correctly indented), use your text editor to blink the matching bracket and fix the indents if needed.

  3. Typical function definitions in Clojure are somewhere between 1 and 20 lines — there's isn't much to match. In case you have more, break things to new functions (or more likely, use the core library functions better to your advantage).

@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

requirejs.config({
shim: {
backbone: {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
underscore: {
exports: '_'
},
"Handlebars": {
innerWidth / innerHeight tests @ http://sandbox.thewikies.com/orientation/
--------------------------------------------------------------------------------
Tested (14 devices, 28 browsers):
Droid 2 Global Android 2.2
iPhone 4 iOS5 (Safari, Opera Mini)
Motorola Atrix Android 2.3.4 (Stock browser, Dolphin, Skyfire, Opera Mini, Firefox)
Samsung Galaxy S9000 Android 2.3 (Webkit, Opera Mobile)
Samsung Galaxy Y Android 2.3.5
@kpuputti
kpuputti / gist:1339460
Created November 4, 2011 14:34
touchstart handlers for backbone clicks
// In the events object of the view:
// 'touchstart nav a': 'onNavTouchStart',
// 'touchmove nav a': 'onNavTouchMove',
// 'touchend nav a': 'onNavTouchEnd',
onNavTouchStart: function (event) {
var href = $(event.target).attr('href');
this.navTouchHref = (href && href !== '#') ? href : null;
},
@dmitry
dmitry / backbone-mixin.js
Created October 1, 2011 21:49 — forked from wesen/backbone-mixin.js
Merge backbone views (mixin pattern)
/**
* ## Merging mixin views in backbone.js ##
*
* really just more a test for tumblr gistr
*/
/**
* Merge the mixin (a Backbone.View) into another Backbone.View. Automatically merge events, defaults, and call the parent initializer.
**/
function mergeMixin(view, mixin) {