Skip to content

Instantly share code, notes, and snippets.

View obinsc's full-sized avatar

obins obinsc

  • Banking
  • Johannesburg
View GitHub Profile
@obinsc
obinsc / c_sharp_for_python.md
Created June 7, 2018 08:37 — forked from mrkline/c_sharp_for_python.md
An intro to C# for a Python developer. Made for one of my coworkers.

C# For Python Programmers

Syntax and core concepts

Basic Syntax

  • Single-line comments are started with //. Multi-line comments are started with /* and ended with */.

  • C# uses braces ({ and }) instead of indentation to organize code into blocks. If a block is a single line, the braces can be omitted. For example,

@obinsc
obinsc / install_caffe2_detectron.sh
Created April 24, 2018 21:16 — forked from matsui528/install_caffe2_detectron.sh
Install script of caffe2 and detectron on AWS EC2 instance with Deep Learning Base AMI
# Install script of Caffe2 and Detectron on AWS EC2
#
# Tested environment:
# - AMI: Deep Learning Base AMI (Ubuntu) Version 3.0 - ami-38c87440 (CUDA is already installed)
# - Instance: p3.2xlarge (V100 * 1)
# - Caffe2: https://github.com/caffe2/caffe2/commit/e1f614a5f8ae92f4ecb828e1d5f84d2cd1fe12bd
# - Detectron: https://github.com/facebookresearch/Detectron/commit/a22302de27f9004422a96414ed4088d05c664978
#
# Usage:
# Launch a fresh EC2 instance, put this script on the /home/ubuntu/, and run the following command.
import tensorflow as tf
import numpy as np
corpus_raw = 'He is the king . The king is royal . She is the royal queen '
# convert to lower case
corpus_raw = corpus_raw.lower()
words = []
for word in corpus_raw.split():
@obinsc
obinsc / create_docker_container.sh
Created May 30, 2017 13:56 — forked from waichee/create_docker_container.sh
Steps to create a docker container with dependencies required for compiling Tensorflow Serving
# Clone the Tensorflow Serving source
git clone https://github.com/tensorflow/serving
cd serving && git checkout <commit_hash>
# Build the docker image (time to go get yourself a coffee, maybe a meal as well, this will take a while.)
docker build -t some_user_namespace/tensorflow-serving:latest -f ./serving/tensorflow_serving/tools/docker/Dockerfile.devel .
# Run up the Docker container in terminal
docker run -ti some_user_namespace/tensorflow-serving:latest
@obinsc
obinsc / build_ts_serving_source.sh
Created May 30, 2017 13:54 — forked from waichee/build_ts_serving_source.sh
Code to Build Tensorflow Serving from source within a Docker container
mkdir -p /work/
# Clone the source from Github
cd /work/ && git clone — recurse-submodules https://github.com/tensorflow/serving
# Pin the version of Tensorflow Serving and its submodule
TENSOR_SERVING_COMMIT_HASH=85db9d3
TENSORFLOW_COMMIT_HASH=dbe5e17
cd /work/serving && git checkout $TENSOR_SERVING_COMMIT_HASH
@obinsc
obinsc / wit-telegram-bot.js
Created May 24, 2016 21:47 — forked from dotcypress/wit-telegram-bot.js
How to build Telegram bot with Wit.ai Bot Engine
// npm install telegraf telegraf-wit
var Telegraf = require('telegraf')
var TelegrafWit = require('telegraf-wit')
var app = new Telegraf(process.env.BOT_TOKEN)
var wit = new TelegrafWit(process.env.WIT_TOKEN)
app.use(Telegraf.memorySession())
@obinsc
obinsc / gist:010bdb5cb188f7fd4c35837130268df8
Created April 22, 2016 08:00 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@obinsc
obinsc / LDA_SparkDocs
Created November 17, 2015 07:56 — forked from jkbradley/LDA_SparkDocs
LDA Example: Modeling topics in the Spark documentation
/*
This example uses Scala. Please see the MLlib documentation for a Java example.
Try running this code in the Spark shell. It may produce different topics each time (since LDA includes some randomization), but it should give topics similar to those listed above.
This example is paired with a blog post on LDA in Spark: http://databricks.com/blog
Spark: http://spark.apache.org/
*/
import scala.collection.mutable
from pyspark import SparkContext, SparkConf
from pyspark.sql import HiveContext, SQLContext
import pandas as pd
# sc: Spark context
# file_name: csv file_name
# table_name: output table name
# sep: csv file separator
# infer_limit: pandas type inference nb rows
def read_csv(sc, file_name, table_name, sep=",", infer_limit=10000):
#!/usr/bin/env python
# encoding: utf-8
"""
linkedin-query.py
Created by Thomas Cabrol on 2012-12-03.
Customised by Rik Van Bruggen
Copyright (c) 2012 dataiku. All rights reserved.
Building the LinkedIn Graph