Skip to content

Instantly share code, notes, and snippets.

View masaeedu's full-sized avatar

Asad Saeeduddin masaeedu

  • Montreal, QC, Canada
View GitHub Profile
@masaeedu
masaeedu / averages.linq
Created July 21, 2016 23:03
Interview question
<Query Kind="Program" />
void Main()
{
const string fileName = @"C:\Users\asaeeduddin\Downloads\Interview\scores.csv";
String[] lines = File.ReadAllLines(fileName);
//todo calculate the average for each student and display the student’s name with the highest average.
var averages = lines
// Parse rows (probably could have si
@masaeedu
masaeedu / flattening.ts
Last active August 25, 2016 15:28
Flattening function for arbitrarily nested arrays in TypeScript 2.1
// Note: Prefer static typing over defensive programming, lots of tests
// Note: The simple recursive impl. here is sufficient when dealing with small input (e.g unwrapping JSON), for potentially large input the recursion should be unrolled
interface Nested<T> extends Array<T | Nested<T>> { }
function* flatten<T>(items: Nested<T>): Iterable<T> {
for (var i of items)
if (Array.isArray(i)) yield* flatten(i);
else yield i;
}
@masaeedu
masaeedu / callbackhell.js
Created September 30, 2016 21:59
Wherefore monads?
fs.readdir(source, function (err, files) {
if (err) {
console.log('Error finding files: ' + err)
} else {
files.forEach(function (filename, fileIndex) {
console.log(filename)
gm(source + filename).size(function (err, values) {
if (err) {
console.log('Error identifying file size: ' + err)
} else {
@masaeedu
masaeedu / Program.cs
Created October 7, 2016 21:50
.NET Core starter with NancyFX
using System.IO;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Nancy;
using Nancy.Conventions;
using Nancy.Owin;
namespace ConsoleApplication
{
public class Program
@masaeedu
masaeedu / shittycsvparser.ts
Created December 23, 2016 01:26
Parse csv
function readCSV(path: string) {
const lines = fs.readFileSync(path)
.toString()
.split(/\r?\n/)
.map(line => line.split(/\s*,\s*/));
const header = lines[0];
const data = lines.slice(1);
return data
@masaeedu
masaeedu / profile.ps1
Created January 22, 2017 12:37
Starting GUI apps in with docker-machine or Docker for Windows
# Start X server. Requires xming or cygwin with the xorg packages installed
Function bootx {
XWin :0 -multiwindow -clipboard -wgl -ac -listen tcp
}
# Find local machine's IP on network interface connected to docker server
Function Get-DockerRoutableIP {
if (Get-Command docker-machine -errorAction SilentlyContinue) {
return (Find-NetRoute -RemoteIPAddress $(docker-machine ip default)).IPAddress
}
@masaeedu
masaeedu / Header
Last active January 24, 2017 02:33 — forked from anonymous/Header
#pragma once
#include "SFML\Graphics.hpp"
#include "SFML\Window.hpp"
#include "SFML\System.hpp"
using namespace sf;
class Game
{
private:
@masaeedu
masaeedu / installansible.sh
Last active January 24, 2017 22:47
Install ansible with babun
# Watch out for babun installation asspains. Immediately after babun install, cd to .babun folder and run ./update.bat
# See babun/babun#702
pact install curl python python-devel python-setuptools python-crypto openssl openssl-devel libffi-devel gcc-g++ vim git wget;
# If you've somehow ended up with python < 2.7.9 just give up and shoot yourself in the head now
# Try this first though
pact update python
# If you still don't have the right python, try using easy_install or get_pip.py to install from source or some curl'd down wheel
@masaeedu
masaeedu / linx.md
Created February 3, 2017 21:13
Useful links for no-config P2P actor framework
  • MBrace: Existing, opinionated library for distributed computing
    • Vagabond: F# project for moving compiled thunks around using reflection and ref-emit magic
    • FsPickler: Serialization library
@masaeedu
masaeedu / gist:4b00f9df48ef62813b853b90e299eb97
Created February 3, 2017 21:38
Figure out what serializer surrogates are
https://github.com/dotnet/coreclr/issues/2715#issuecomment-174761980
https://github.com/dotnet/corefx/blob/master/src/System.Runtime.Serialization.Primitives/src/System/Runtime/Serialization/ISerializationSurrogateProvider.cs