Skip to content

Instantly share code, notes, and snippets.

@anantn
anantn / todomvc_angularFire.diff
Created March 22, 2013 22:46
Changes required to make AngularJS/TodoMVC real-time with angularFire.
diff -ur ../todomvc/architecture-examples/angularjs/index.html examples/todomvc/index.html
--- ../todomvc/architecture-examples/angularjs/index.html 2013-03-15 15:31:06.000000000 -0700
+++ examples/todomvc/index.html 2013-03-22 15:21:00.000000000 -0700
@@ -61,9 +61,10 @@
</footer>
<script src="components/todomvc-common/base.js"></script>
<script src="components/angular/angular.js"></script>
+ <script src="https://cdn.firebase.com/v0/firebase.js"></script>
+ <script src="../../angularFire.js"></script>
<script src="js/app.js"></script>
@anantn
anantn / angular_promise.html
Created April 3, 2013 19:21
An example showing the use of angular $q promises to authenticate a Firebase session and then writing data.
<html ng-app="test">
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.1/angular.min.js"></script>
<script type="text/javascript" src="https://cdn.firebase.com/v0/firebase.js"></script>
</head>
<body ng-controller="Test">
<script typ="text/javascript">
function TestController($scope, $q) {
this._q = $q;
this._scope = $scope;
@anantn
anantn / gist:8405484
Last active January 3, 2016 03:59
AngularFire Starter
<!doctype html>
<html lang="en" ng-app="chat">
<head>
<meta charset="UTF-8">
<title>AngularFire Chat Demo</title>
<link rel="stylesheet" type="text/css" href="https://www.firebase.com/css/example.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.min.js"></script>
</head>
<body ng-controller="Chat">
<div>
@anantn
anantn / simple_angular.html
Created January 13, 2014 19:38
Simple 2-way binding with AngularJS
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.5/angular.min.js"></script>
</head>
<body ng-app>
<div ng-controller="MyApp">
<input type="text" ng-model="name"/><br/>
<h1 ng-cloak>Hi {{name}}!</h1>
</div>
</body>
@anantn
anantn / firebase_first_item.js
Last active March 4, 2016 00:04
Firebase: Get the first item in a list. This snippet retrieves only the first item in a list.
function makeList(ref) {
var fruits = ["banana", "apple", "grape", "orange"];
for (var i = 0; i < fruits.length; i++) {
ref.push(fruits[i]);
}
}
function getFirstFromList(ref, cb) {
ref.startAt().limit(1).once("child_added", function(snapshot) {
cb(snapshot.val());
@anantn
anantn / Auctionator.lua
Created January 4, 2015 07:10
Auctionator Plugin for Skillet
--[[
Skillet: A tradeskill window replacement.
Copyright (c) 2007 Robert Clark <nogudnik@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Keybase proof

I hereby claim:

  • I am anantn on github.
  • I am anant (https://keybase.io/anant) on keybase.
  • I have the public key with fingerprint 42DD 4F90 7C5F 4576 D6F4  2202 C31C 2D8C 7B4B 6B02

To claim this, I am signing this object:

@anantn
anantn / firebase_workers.js
Created December 27, 2012 22:11
Firebase: Implementing a worker queue pattern using firebase_queue_pop.js
var Firebase = require("./firebase-node.js");
function Queue(ref) {
this._ref = ref;
}
Queue.prototype.pop = function(cb) {
this._ref.startAt().limit(1).once("child_added", this._pop.bind(this, cb));
}
@anantn
anantn / datachannels.js
Created October 31, 2012 22:48
Data Channel Example
/**
* Assume we've connected a PeerConnection with a friend - usually with audio
* and/or video. For the time being, always at least include a 'fake' audio
* stream - this will be fixed soon.
*
* connectDataConnection is a temporary function that will soon disappear.
* The two sides need to use inverted copies of the two numbers (eg. 5000, 5001
* on one side, 5001, 5000 on the other)
*/
pc.connectDataConnection(5001, 5000);
@anantn
anantn / firebase_chat.html
Created May 6, 2013 18:13
A simple, plugin-free chat room - build with Firebase
<html>
<head>
<script src="https://cdn.firebase.com/v0/firebase.js"></script>
</head>
<body>
<ul id="chat-list">
</ul>
<input type="text" id="msg"/>
<input type="button" id="send" value="Send"/>
<script>