Skip to content

Instantly share code, notes, and snippets.

I may be slow to respond.

Zohaib Rauf zabirauf

I may be slow to respond.
View GitHub Profile
zabirauf / sieve_server.erl
Last active August 29, 2015 14:03
A simple server which load balances a request among different process based on round robin algorithm. Written this to understand how could i do load balancing among different processes in Erlang
View sieve_server.erl
test(Pid,Request) ->
test_internal(Pid, Request) ->
zabirauf / gist:7000a1587ab42dd2b752
Created February 12, 2015 10:45
View gist:7000a1587ab42dd2b752
<?xml version="1.0" encoding="UTF-8"?>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" requireAccess="Script"/>
<httpPlatform stdoutLogEnabled="true" stdoutLogFile="elixir.log" startupTimeLimit="20" processPath="C:\inetpub\wwwroot\azure-elixir\run.bat"
<environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%"/>
View peer_channel.ex
defmodule EphemeralShare.PeerChannel do
use Phoenix.Channel
require Logger
alias EphemeralShare.PeerManager
@doc """
Join the topic `peer:<GUID>` and add the peer in the peer manager
def join("peer:" <> peer_id, _auth_msg, socket) do
View peer_state.ex
defmodule EphemeralShare.PeerState do
require Logger
use GenServer
def start_link(peer_id) do
GenServer.start_link(__MODULE__, [peer_id], [name: {:global, peer_state_proc_id(peer_id)}])
def stop(peer_id) do
zabirauf / Codify Particle.lua
Created November 2, 2011 19:27
Codify Particle script. Use single touch to make particles go away from you. Use double touch to attract particles.
View Codify Particle.lua
-- Use this function to perform your initial setup
function setup()
print("Hello World!")
for i=0,ps do
p[i]= {x=math.random(WIDTH*10)/10,
y=math.random(HEIGHT*10)/10, ox=0.0, oy=0.0, vx=math.random(20)-10,
zabirauf / gulpfile.js
Created October 19, 2015 00:09
Gulpfile for a bower library
View gulpfile.js
var gulp = require('gulp'),
gutil = require('gulp-util'),
eslint = require('eslint'),
babelify = require('babelify'),
source = require('vinyl-source-stream'),
browserify = require('browserify');
var paths = {
ALL: ['index.js', 'lib/*.js'],
JS: ['index.js', 'lib/*.js'],
zabirauf / messages_controller.ex
Last active June 15, 2016 05:06
Messages controller that receives message from user and sends it to Wit. Complete project at
View messages_controller.ex
defmodule EchoBot.MessagesController do
use MicrosoftBot.Phoenix.Controller
alias ExMicrosoftBot.Models.Message
def message_received(conn, %Message{} = message) do
session_id = message.conversationId
spawn fn ->
%{from: from, to: to, id: msgId} = message
context = %{"session" => %{
zabirauf / weather_conversation_action.ex
Created June 15, 2016 05:12
Weather conversation actions for the story created to get weather information. Complete project at
View weather_conversation_action.ex
defmodule EchoBot.WeatherConversationAction do
use Wit.Actions
alias Wit.Models.Response.Converse, as: WitConverse
alias ExMicrosoftBot.Client
def say(_session_id, %{} = context, %WitConverse{msg: msg_to_send} = message) do
%{"session" => %{"from" => to, "to" => from, "msgId" => msgId}} = context
message_to_send = %{from: from, to: to, replyToMessageId: msgId, text: msg_to_send}
Client.send_message(get_bot_auth_data(), message_to_send)
zabirauf / SuaveBootstrapFlynn.fs
Last active October 16, 2016 21:30
A F# Suave web app that outputs HTML
View SuaveBootstrapFlynn.fs
module SuaveBootstrapFlynn
open Suave
open Suave.Successful
open Suave.Web
open Suave.Operators
open Suave.Filters
open System
open System.Net
zabirauf / FunctionBinder.ts
Last active March 8, 2017 07:42
And example for FunctionBinder class
View FunctionBinder.ts
interface CurriedFunction2<T1, T2, R> {
(t1: T1): (t2: T2) => R;
(t1: T1, t2?: T2): R;
interface CurriedFunction3<T1, T2, T3, R> {
(t1: T1): CurriedFunction2<T2, T3, R>;
(t1: T1, t2?: T2): (t3: T3) => R;
(t1: T1, t2?: T2, t3?: T3): R;