Skip to content

Instantly share code, notes, and snippets.

View saswata-dutta's full-sized avatar
💭
I may be slow to respond.

Saswata Dutta saswata-dutta

💭
I may be slow to respond.
View GitHub Profile
@saswata-dutta
saswata-dutta / python_environment_setup.md
Created October 9, 2018 04:17 — forked from Geoyi/python_environment_setup.md
Setting up your python development environment (with pyenv, virtualenv, and virtualenvwrapper)

Overview

When you're working on multiple coding projects, you might want a couple different version of Python and/or modules installed. That way you can keep each project in its own sandbox instead of trying to juggle multiple projects (each with different dependencies) on your system's version of Python. This intermediate guide covers one way to handle multiple Python versions and Python environments on your own (i.e., without a package manager like conda). See the Using the workflow section to view the end result.

Use cases

  1. Working on 2+ projects that each have their own dependencies; e.g., a Python 2.7 project and a Python 3.6 project, or developing a module that needs to work across multiple versions of Python. It's not reasonable to uninstall/reinstall modules every time you want to switch environments.
  2. If you want to execute code on the cloud, you can set up a Python environment that mirrors the relevant
function unary(type, rhs) {
return {
type : type,
rhs: rhs
};
}
function binary(type, lhs, rhs) {
return {
type : type,

Vim

Finding Your Way Around

Download MacVim (optional)

MacVim

Set up Oh-my-zsh (optional)

@saswata-dutta
saswata-dutta / README.md
Created March 18, 2019 14:45 — forked from magnetikonline/README.md
Python - comparing JSON data structures.

Python - comparing JSON data structures

A function compare_json_data(source_data_a,source_data_b), accepting structures populated with data loaded from json.load() and comparing for equality.

Example

$ python compare.py 
Compare JSON result is: True

JSON files a.json and b.json are loaded via load_json() function and structures passed into compare_json_data() for comparison.

@saswata-dutta
saswata-dutta / curl.md
Created March 18, 2019 15:09 — forked from btoone/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@saswata-dutta
saswata-dutta / curl.md
Created March 18, 2019 15:10 — forked from anzeljg/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@saswata-dutta
saswata-dutta / expr.scala
Created March 19, 2019 14:22 — forked from calincru/expr.scala
Expression problem in Scala
// The expression problem is a new name for an old problem. The goal is to
// define a datatype by cases, where one can add new cases to the datatype and
// new functions over the datatype, without recompiling existing code, and while
// retaining static type safety (e.g., no casts).
// (Philip Wadler)
import scala.language.implicitConversions
object ExpressionProblem extends App {
@saswata-dutta
saswata-dutta / GADTs.scala
Created March 20, 2019 19:03 — forked from pchiusano/GADTs.scala
GADT support in Scala
/** GADTs in Scala and their limitations */
/** Background: what is an algebraic data type (ADT) ?
* ADT: (possibly) recursive datatype with sums and products
* In scala - a trait with case classes (case class is product, subtyping is sum)
*/
/** Motivation: untyped embedded DSL doesn't prevent nonsensical expressions */
sealed trait Expr {
def apply(other: Expr) = Ap(this, other)
@saswata-dutta
saswata-dutta / avro_describe_feilds.py
Last active March 27, 2019 16:52
get all Field's names from an Avro schema json.
# -*- coding: utf-8 -*-
import avro.schema
def get_schema_children(avro_schema):
children = []
if isinstance(avro_schema, avro.schema.UnionSchema):
children = avro_schema.schemas
if isinstance(avro_schema, avro.schema.RecordSchema):
@saswata-dutta
saswata-dutta / Example.java
Created March 29, 2019 16:07 — forked from RyanRamchandar/Example.java
Cancel a running or queued Call with OkHttp3
// ...
Request request = new Request.Builder()
.url(url)
.tag(TAG)
.build();
// Cancel previous call(s) if they are running or queued
OkHttpUtils.cancelCallWithTag(client, TAG);
// New call