Skip to content

Instantly share code, notes, and snippets.

View urosgruber's full-sized avatar
🐢

Uros Gruber urosgruber

🐢
  • Squarebox
  • Slovenia
View GitHub Profile
// Released under MIT license: http://www.opensource.org/licenses/mit-license.php
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
// The trick is to use an object that coordinates between all of the views and the layout.
// This is often referred to as a "mediator" - from the mediator pattern. Marionette provides
// a `Controller` type that fits this need perfectly.
// This is basically a "component" - a group of related objects that have been put together
// with a single public interface (defined by the controller instance) to manage it all.
MyController = Marionette.Controller.extend({
initialize: function(options){
@urosgruber
urosgruber / FadeTransitionRegion.js
Created October 24, 2012 21:09 — forked from brian-mann/FadeTransitionRegion.js
Allows jQuery animation transitions between marionette regions
var FadeTransitionRegion = Backbone.Marionette.Region.extend({
show: function(view){
this.ensureEl();
view.render();
this.close(function() {
if (this.currentView && this.currentView !== view) { return; }
this.currentView = view;
@urosgruber
urosgruber / Client.coffee
Created October 19, 2012 14:31 — forked from mikeobrien/Client.coffee
Error handling with backbone.js + fubumvc
# Proxies ajax errors to the event aggregator
define 'ajaxerrorproxy', ['jquery', 'postal'], ($, postal) ->
options = {}
$(document).ajaxError (error, xhr, settings, thrownError) ->
json = !xhr.getResponseHeader('content-type').indexOf('application/json')
status = options[xhr.status] ? {}
channel = postal.channel "error.ajax.#{status.alias ? xhr.status}"
channel.publish
status: status.alias ? xhr.status
message: status.message ? thrownError
#!/usr/bin/env ruby
# Aside from removing Ruby on Rails specific code this is taken verbatim from
# mislav's git-deploy (http://github.com/mislav/git-deploy) and it's awesome
# - Ryan Florence (http://ryanflorence.com)
#
# Install this hook to a remote repository with a working tree, when you push
# to it, this hook will reset the head so the files are updated
if ENV['GIT_DIR'] == '.'
@urosgruber
urosgruber / gist:3802048
Created September 28, 2012 20:57 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@urosgruber
urosgruber / gist_line_numbers.css
Created August 30, 2012 14:12 — forked from potch/gist_line_numbers.css
CSS to add line numbers to embedded gists
.gist-highlight {
border-left: 3ex solid #eee;
position: relative;
}
.gist-highlight pre {
counter-reset: linenumbers;
}
.gist-highlight pre div:before {
/**
* Expected to return \Zend\ServiceManager\Config object or array to
* seed such an object.
*
* @return array|\Zend\ServiceManager\Config
*/
public function getViewHelperConfig()
{
return array(
'initializers' => array(
@urosgruber
urosgruber / gist:3331477
Created August 12, 2012 11:28
Doctrine cli config
<?php
// cli-config.php
use Doctrine\Common\ClassLoader,
Doctrine\ORM\EntityManager,
Doctrine\ORM\Tools\Setup;
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
@urosgruber
urosgruber / ML, Python and virtualenv.md
Created July 27, 2012 07:15 — forked from thesharp/ML, Python and virtualenv.md
Quick virtualenv fix on Mountain Lion

Quick virtualenv fix on Mountain Lion

Overview

It appears that Apple somehow broke Python in Mountain Lion, so even with the latest Command Line Tools and Xcode 4.4 virtualenv won't properly work. During virtual environment creation it will try to install easy_install inside /Library hierarchy. So let's give it a quick workaround. Let's install custom python into your $HOME-directory using pythonbrew!

Installing proper Command Line Tools

Without the Apple Mac Developer account you won't even see the proper download link for the latest CL Tools and the old one won't work on ML. So here's the link: http://goo.gl/iBTXh. It points towards the Apple website so don't worry.