Skip to content

Instantly share code, notes, and snippets.

Avatar

srdjan srdjan

View GitHub Profile
@srdjan
srdjan / gist:1300262
Created Oct 20, 2011
angularjs mvctodo app with coffeescript controller
View gist:1300262
@TodoController = () ->
@todos = []
@newTodo = ""
@addTodo = () ->
if @newTodo.length > 0
@todos.push( { content: @newTodo, done: false, editing: false } )
@newTodo = ""
@editTodo = (todo) ->
@srdjan
srdjan / observer.coffee
Created Nov 1, 2011 — forked from sdiehl/observer.coffee
Observer Pattern in Coffeescript
View observer.coffee
class Observer
bind : (event, fn) ->
this._events ||= {}
this._events[event] ||= []
this._events[event].push(fn)
unbind: (event, fn) ->
@_events ||= {}
@srdjan
srdjan / xhr.js
Created Nov 3, 2011 — forked from mythz/xhr.js
Standalone jQuery-like Ajax Client
View xhr.js
//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 Nov 14, 2011 — forked from madrobby/i18n.coffee
Backbone i18n with CoffeeScript
View i18n.coffee
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 Feb 12, 2012 — forked from peterc/dnsd.rb
Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
View dnsd.rb
# 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
View can-it-be-any-simpler.coffee
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: ''
View gist:2039228
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 Jul 10, 2012 — forked from sadache/AA.md
Is socket.push(bytes) all what you need to program Realtime Web apps?
View AA.md

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 Dec 11, 2012
Simple FAKE CI script
View build.fsx
#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 Dec 11, 2012
Custom Git task for FAKE
View gist:4260421
using System;
using System.Diagnostics;
using System.Linq;
namespace MyFakeTasks
{
public class GitTasks
{
public static int Pull(string workingDirectory)
{
You can’t perform that action at this time.