Skip to content

Instantly share code, notes, and snippets.

View vojtajina's full-sized avatar

Vojta Jina vojtajina

View GitHub Profile
@vojtajina
vojtajina / angular-eventBus.js
Created July 30, 2011 13:41
Angular $eventBus
// pseudocode
angular.service('$eventBus', function() {
var listeners = {};
var mainBus = function(scope) {
return new ChildBus(mainBus, scope);
};
mainBus.emit = function(type) {
var args = Array.prototype.slice.call(arguments, 1);
@vojtajina
vojtajina / git-edit.sh
Created November 5, 2011 08:21
Simple git script for rewriting history
#!/bin/sh
#
# Simple script for rewriting history :-D
# Might be helpful when using "rebasing" strategy to keep your history nice and flat...
#
# Instalation
# >> sudo bash -c "curl https://raw.github.com/gist/1341268/git-edit.sh > /usr/local/bin/git-edit"
# >> sudo chmod a+x /usr/local/bin/git-edit
#
# Usage
@vojtajina
vojtajina / angular-ctrl-export-proposal.js
Created December 13, 2011 04:50
Angular: Export Ctrl Methods Proposal
// GOOGLE3 usage - bigger projects
var MyController = function($scope, $location) {
// controller's private state
this.$location = $location;
this.some = 12;
this.$scope = $scope;
// methods accessible from template
// these methods (defined in constructor) should contain only few logic,
@vojtajina
vojtajina / dynamic-prg.java
Created December 15, 2011 07:24
Dandův houmwork
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
class Pair<First,Second> {
First first;
Second second;
@vojtajina
vojtajina / angular-bc.js
Created January 20, 2012 21:51
Angular: BC module for scope/controller separation
/**
* @license AngularJS
* (c) 2010-2012 AngularJS http://angularjs.org
* License: MIT
*/
/**
* Backward compatibility module for AngularJS
* @author Vojta Jina <vojta.jina@gmail.com>
*
@vojtajina
vojtajina / runner.html
Created January 29, 2012 20:27
Angular: Access to iframe's jQuery
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://code.angularjs.org/0.10.6/angular-scenario-0.10.6.js" ng:autotest></script>
<script type="text/javascript">
angular.scenario.dsl('appElement', function() {
return function(selector, fn) {
return this.addFutureAction('element ' + selector, function($window, $document, done) {
fn.call(this, $window.angular.element(selector));
done();
@vojtajina
vojtajina / angular-scenario-goto-future-url.html
Created February 1, 2012 19:46
Angular: Scenario navigate to future url
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="/build/angular-scenario.js" ng:autotest></script>
<script type="text/javascript">
// this is just copy of browser().navigateTo()
// the only difference is this implementation accepts future value
angular.scenario.dsl('goToFutureUrl', function() {
return function(futureUrl) {
var application = this.application;
@vojtajina
vojtajina / angular-ie8-leak.html
Created February 2, 2012 01:30
Angular: ng:repeat IE8 memory leak
<!DOCTYPE html>
<html id="ng-app" ng-app>
<head>
<title></title>
<script type="text/javascript" src="http://code.angularjs.org/0.10.6/angular-0.10.6.min.js"></script>
<script type="text/javascript">
function Main() {
var $scope = this;
$scope.persons = [];
for(var i = 0; i < 5000; i++) {
@vojtajina
vojtajina / angular-ie8-leak.html
Created February 5, 2012 09:36
Angular: IE8 memory leak test case
<!doctype html>
<html>
<head>
<title>angular-zrm</title>
<script src="http://ci.angularjs.org/job/angular.js-vojta/167/artifact/build/pkg/0.10.7-3173d860/angular-0.10.7-3173d860.min.js"></script>
<script src="foo-controller.js"></script>
</head>
<body ng:app>
<div ng:controller="FooController">
<button ng:click="clear()">Clear</button>
@vojtajina
vojtajina / 12.json
Created February 11, 2012 01:57
Angular: 0.9.19 resource example
)]}',
[{
"name": "one"
}, {
"name": "two"
}]