Skip to content

Instantly share code, notes, and snippets.

View ashic's full-sized avatar

Ashic Mahtab ashic

View GitHub Profile
using System;
using System.Threading.Tasks;
namespace NDSandbox
{
class Program
{
static void Main(string[] args)
{
}
var person = function(opt) {
var obj = {}
obj.name = opt.name || "NA";
obj.age = opt.age || "NA";
obj.getDescription = function(){
return this.name + " " + this.age;
}
```
get_some_data(paramThingy) =
SomeActor ! {self(), {get_stuff, paramThingy},
receive
{From, Res} -> Res
end.
```
%% client code deals with interface paramThingy -> resultType. Simple / complicated / hierarchical / fault tolerant processing via messages is done underneath. But client code can deal with the api without knowing all messaging nitty - gritty. Since it's all async, and Erlang does selective receive, this "blocking" (it's really non-blocking async) code isn't problematic.
using System;
using Contra;
namespace ConsoleApplication8
{
public interface Envelope<out T> {T Message { get; } }
public class MessageEnvelope<T> : Envelope<T>
{
class RabbitMQEventNotifier(host:String, exchange:String, routingKey:String, username:String, password:String, virtualHost:String)
extends EventNotifier with Serializable {
private def createChannel () = {
val factory = new ConnectionFactory()
factory.setUsername(username)
factory.setPassword(password)
factory.setVirtualHost(virtualHost)
factory.setHost(host)
val connection = factory.newConnection()
connection.createChannel()
@ashic
ashic / gist:b5edc7cfdc85aa60b066
Created January 22, 2015 11:26
Rabbitmq receiver
class RmqReceiver(uname:String,
passwd: String,
vHost:String,
host:String,
qName:String,
topic:Option[String])
extends Receiver[Array[Byte]](StorageLevel.MEMORY_AND_DISK_2) with Logging {
{
"TotalResults": 14,
"TotalPages": 3,
"Page": 1,
"_links": {
"self": {
"href": "/beers?page=1"
},
"next": {
"href": "/beers?page=2"
namespace Syndication.Client.Http
{
public class CachingAdapter : HttpClientAdapter
{
readonly HttpClient client;
public CachingAdapter(ICacheStore cacheStore, string[] defaultVaryHeaders)
{
//http://msdn.microsoft.com/en-us/library/system.net.cache.requestcachelevel(v=vs.110).aspx
//http://blog.technovert.com/2013/01/httpclient-caching/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using dokimi.core;
using dokimi.core.dokimi.core.Specs.MessageBased;
using dokimi.core.Specs.MessageBased;
using dokimi.nunit;
using Infura;
@ashic
ashic / gist:5d831738732cf50d3b77
Created June 10, 2014 12:02
From framework to library...
public class VigilEngine
{
private readonly Beam _beam;
public VigilEngine(Beam beam)
{
_beam = beam;
Console.WriteLine("Creating engine. {0}", Thread.CurrentThread.ManagedThreadId);
while (true)