Skip to content

Instantly share code, notes, and snippets.

View mieky's full-sized avatar
🦀

Mike Arvela mieky

🦀
View GitHub Profile
@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) {
@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;
},
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
requirejs.config({
shim: {
backbone: {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
underscore: {
exports: '_'
},
"Handlebars": {
@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:

@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).

@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 / year_workdays.py
Last active October 13, 2015 09:28
Workdays in 2013
# Install dateutil with "pip dateutil install"
from datetime import date, timedelta as td
from itertools import count, takewhile
def holiday(d): # See https://gist.github.com/pyrtsa/3525697
"""Check whether the given dateutil.date is a Finnish national holiday"""
import dateutil.easter
from datetime import date, timedelta as td
assert isinstance(d, date)
@cobyism
cobyism / gh-pages-deploy.md
Last active April 12, 2025 09:10
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@jareware
jareware / gist.md
Last active June 7, 2018 04:16
Backporting Compass flexbox mixins from bleeding-edge (0.13.alpha.4) to current stable (0.12.2)

⇐ back to the gist-blog at jrw.fi

New Compass flexbox mixins

The current Compass bleeding-edge (0.13.alpha.4) contains awesome new flexbox mixins that allow you to generate styling for all three (!) past and current specifications. See http://css-tricks.com/using-flexbox/ for the details behind the careful interweaving of different properties and prefixes, but the beef is support for:

  • Chrome any
  • Firefox any
  • Safari any
  • Opera 12.1+