Skip to content

Instantly share code, notes, and snippets.

View xslogic's full-sized avatar

Arun Suresh xslogic

  • Microsoft
  • Sunnyvale, CA
View GitHub Profile
#!/bin/bash
# Get job properties
JOB=nodemanager
index=<%= index %>
host_suffix=<%= spec.networks.methods(false).grep(/[^=]$/).first.to_s %>.<%= spec.deployment %>.<%= p("global.boshType")%>
server=<%= index %>.<%= spec.job.name %>.${host_suffix}
yum_repo_server=0.<%= p("global.yum-repo_job") %>.${host_suffix}
@xslogic
xslogic / gist:820056
Created February 10, 2011 06:45
Ring
-module(ringu).
-export([start/2]).
start(N, M) ->
Pid_0 = self(),
statistics(runtime),
statistics(wall_clock),
Pid = spawn(fun() -> ringu(N, M, self(), Pid_0) end),
Pid ! x,
receive
@xslogic
xslogic / gist:732986
Created December 8, 2010 07:05
problem2 mod
grid_id(Lat, Long, XMax, YMax) ->
{X, Y} = scale(Long, Lat, XMax, YMax),
grid_id(X, Y, XMax div 2, YMax div 2, []).
grid_id(_, _, X, Y, Val) when (X < 1) andalso (Y < 1)->
list_to_integer(lists:reverse(Val));
grid_id(X, Y, XTh, YTh, Val) when (X > XTh) andalso (Y > YTh) ->
grid_id(X - XTh, Y - YTh, XTh div 2, YTh div 2, [$4|Val]);
grid_id(X, Y, XTh, YTh, Val) when (X > XTh) andalso (Y =< YTh) ->
grid_id(X - XTh, Y, XTh div 2, YTh div 2, [$3|Val]);
@xslogic
xslogic / gist:732947
Created December 8, 2010 05:55
problem 2
-module(grid).
-export([grid_id/4]).
%% Rather than provide 1000 blocks as input,
%% it would be easier to provide a Height and breadth
%% of the bounding box.. making it easier to scale
grid_id(Lat, Long, XMax, YMax) ->
{X, Y} = scale(Lat, Long, XMax, YMax),
grid_id(X, Y, XMax div 2, YMax div 2, []).
@xslogic
xslogic / gist:700908
Created November 15, 2010 20:43
FTP Patch for resuming FTP download..
diff --git a/lib/inets/src/ftp/ftp.erl b/lib/inets/src/ftp/ftp.erl
index 534fcae..1062c08 100644
--- a/lib/inets/src/ftp/ftp.erl
+++ b/lib/inets/src/ftp/ftp.erl
@@ -31,11 +31,11 @@
%% API - Client interface
-export([cd/2, close/1, delete/2, formaterror/1,
lcd/2, lpwd/1, ls/1, ls/2,
- mkdir/2, nlist/1, nlist/2,
+ mkdir/2, nlist/1, nlist/2, sizeof/2,
@xslogic
xslogic / gist:663636
Created November 5, 2010 04:18
Instantiating a thrift client
{ok, TFactory} =
thrift_socket_transport:new_transport_factory(
phoebus_utils:get_env(thriftfs_hostname, "localhost"),
phoebus_utils:get_env(thriftfs_port, 8899), []),
{ok, PFactory} =
thrift_binary_protocol:new_protocol_factory(TFactory, []),
{ok, Protocol} = PFactory(),
{ok, Client} =
thrift_client:new(Protocol, thriftHadoopFileSystem_thrift),