Skip to content

Instantly share code, notes, and snippets.

View srdjan's full-sized avatar

⊣˚∆˚⊢ srdjan

View GitHub Profile
@srdjan
srdjan / gist:1300262
Created October 20, 2011 02:27
angularjs mvctodo app with coffeescript controller
@TodoController = () ->
@todos = []
@newTodo = ""
@addTodo = () ->
if @newTodo.length > 0
@todos.push( { content: @newTodo, done: false, editing: false } )
@newTodo = ""
@editTodo = (todo) ->
@srdjan
srdjan / observer.coffee
Created November 1, 2011 19:49 — forked from sdiehl/observer.coffee
Observer Pattern in Coffeescript
class Observer
bind : (event, fn) ->
this._events ||= {}
this._events[event] ||= []
this._events[event].push(fn)
unbind: (event, fn) ->
@_events ||= {}
@srdjan
srdjan / xhr.js
Created November 3, 2011 00:49 — forked from mythz/xhr.js
Standalone jQuery-like Ajax Client
//Adds $.xhr and jQuery-like $.ajax methods to the prescribed namespace.
//Inspired from David Flanagans excellent cross-platform utils http://www.davidflanagan.com/javascript5/display.php?n=20-1&f=20/01.js
//Includes underscore.js _.each and _.extend methods
//modified to behave like jQuery's $.ajax(), not complete.
(function($) {
var win=window, xhrs = [
function () { return new XMLHttpRequest(); },
function () { return new ActiveXObject("Microsoft.XMLHTTP"); },
function () { return new ActiveXObject("MSXML2.XMLHTTP.3.0"); },
function () { return new ActiveXObject("MSXML2.XMLHTTP"); }
@srdjan
srdjan / i18n.coffee
Created November 14, 2011 20:06 — forked from madrobby/i18n.coffee
Backbone i18n with CoffeeScript
window.t = (id, vars = {}) ->
template = i18n[__locale][id] or i18n['en'][id] or "(?) #{id}"
_.template(template, vars)
# yes, that's it
@srdjan
srdjan / dnsd.rb
Created February 12, 2012 19:41 — forked from peterc/dnsd.rb
Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# By Peter Cooper
#
# MIT license
#
# * Not advised to use in your production environment! ;-)
# * Requires Ruby 1.9
# * Supports A and CNAME records
# * See http://www.ietf.org/rfc/rfc1035.txt for protocol guidance
# * All records get the same TTL
@srdjan
srdjan / can-it-be-any-simpler.coffee
Created February 27, 2012 21:52
batmanjs Todo app
class App extends Batman.App
@global(yes)
@root('todos#index')
class App.Todo extends Batman.Model
@global(yes)
@persist(Batman.LocalStorage)
@encode('body', 'isDone')
body: ''
class Entity extends Batman.Model
@field: (name, options) ->
@fields ?= {}
@fields[name] = options || {}
constructor: (attributes) ->
@attributes = {}
for name, options of @constructor.fields
@attributes['encode'] = true
@srdjan
srdjan / AA.md
Created July 10, 2012 12:12 — forked from sadache/AA.md
Is socket.push(bytes) all what you need to program Realtime Web apps?

Is socket.push(bytes) all what you need to program Realtime Web apps?

One of the goals of Play2 architecture is to provide a programming model for what is called Realtime Web Applications.

Realtime Web Applications

Realtime Web Applications are applications making use of Websockets, Server Sent Events, Comet or other protocols offering/simulating an open socket between the browser and the server for continuous communication. Basically, these applications offer to users delivery of information as it is published without having the user periodically pinging the service.

There are quite a few web frameworks that target the development of this type of applications. Mostly, however, the solution is by providing an API that allows developers to push/receive messages from/to an open channel, something like:

@srdjan
srdjan / build.fsx
Created December 11, 2012 15:29
Simple FAKE CI script
#r @"../_tools/FAKE/FakeLib.dll"
#r @"../_tools/FAKE/MyFakeTasks.dll"
open Fake
open System.IO
open MyFakeTasks
let author = ["Srdjan Strbanovic"]
let release = @".\WinService\bin\release"
let debug = @".\WinService\bin\debug"
@srdjan
srdjan / gist:4260421
Created December 11, 2012 17:20
Custom Git task for FAKE
using System;
using System.Diagnostics;
using System.Linq;
namespace MyFakeTasks
{
public class GitTasks
{
public static int Pull(string workingDirectory)
{