Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<!-- This should be the simplest possible jQuery based CouchApp. Install by uploading to a design document in Futon or putting in _attachments/index.html and running `couchapp push` -->
<head><title>Tiny CouchApp</title></head>
<body ng:init="dbs = couch.allDbs()">
<h1>Tiny CouchApp</h1>
<ul id="databases">
<li ng:repeat="db in dbs"><a href="/_utils/database.html?{{db}}">{{db}}</a></li>
</ul>
</body>
<!doctype html>
<html xmlns:ng="http://angularjs.org/">
<head>
<title>angular invoice demo</title>
<script src="http://code.angularjs.org/angular-0.9.10.html" ng:autobind></script>
</head>
<body>
<table ng:init="invoice= {items:[{qty:10, description:'gadget', cost:9.95}]}">
<tr><th>Qty</th><th>Description</th><th>Cost</th><th>Total</th><th></th></tr>
<tr ng:repeat="item in invoice.items">
@IgorMinar
IgorMinar / gist:1028816
Created June 16, 2011 07:09 — forked from pmenglund/gist:1028805
Angular
<html>
<head>
<script src="http://code.angularjs.org/angular-0.9.16.min.js" ng:autobind></script>
<script>
var SERVICE_URL = "http://blockexplorer.com/q/getdifficulty";
function FormController($xhr) {
this.posint = /^\d+/;
this.fetch = function() {
var self = this;
$xhr('', SERVICE_URL, function(code, response) {
@IgorMinar
IgorMinar / gist:1030586
Created June 16, 2011 23:49 — forked from pmenglund/gist:1028805
Angular
<html>
<head>
<script src="http://code.angularjs.org/angular-0.9.16.min.js" ng:autobind></script>
<script>
function CalculatorController() {
this.integer = /^\d+$/;
this.fraction = /^\d+\.*\d*$/;
this.difficulty = 877226;
this.hashtime = function() { return Math.round(this.difficulty * Math.pow(2, 32) / (this.hashrate * 1000))/(3600*24) };
this.opex = function() { return this.time*24 * this.electricity * this.power / 1000 };
<html>
<head>
<script src="http://code.angularjs.org/angular-0.10.3.js" ng:autobind></script>
<script>
function MyCntrl() {
this.list_of_items = ['this', 'that', 'the other'];
this.foo = {choice:'that'};
}
MyCntrl.prototype = {
loadData: function(){
@IgorMinar
IgorMinar / angular-ctrl-export-proposal.js
Created December 13, 2011 05:44 — forked from vojtajina/angular-ctrl-export-proposal.js
Angular: Export Ctrl Methods Proposal
function($ctrlProvider) {
$ctrlProvider.provide('FooCtrl', FooCtrl);
var export = $ctrlProvider.export;
function FooCtrl($http, $scope) {
this.scope_ = $scope;
this.http_ = $http;
}
FooCtrl.prototype.publicMethodA = export(function(){
@IgorMinar
IgorMinar / gist:1474608
Created December 14, 2011 00:22
Misko's antiminification
case 8: /* Comment */
match = COMMENT_DIRECTIVE_REGEXP.exec(node.nodeValue);
- if (match &&
- (directive = getDirective(nName = camelCase(match[1])))) {
- attrs[nName] = trim(match[2]);
- directives.push(directive);
+ if (match) {
+ nName = camelCase(match[1]);
+ directive = getDirective(nName);
+ if (directive) {
describe('html', function() {
- it('should replace element with template', inject(
+ iit('should replace element with template', inject(
function($compileProvider){
$compileProvider.directive('replace', valueFn({
- html: '<div class="myWidget" new="newAttr"><<CONTENT>></div>',
+ html: '<div class="myWidget" new="newAttr">{{foo}} <<CONTENT>></div>',
compile: function(element, attr){
attr.$set('compile', true);
/// bootstrap code
var myApp = angular.module('myApp', []);
//// resource def
var pops;
pops = function($resource) {
return $resource('/pops/:id', {}, {
@IgorMinar
IgorMinar / angular-bc.js
Created April 2, 2012 22:14 — forked from vojtajina/angular-bc.js
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>
*