Skip to content

Instantly share code, notes, and snippets.

View Atlas7's full-sized avatar

Johnny Chan Atlas7

View GitHub Profile
Atlas7 /
Created February 5, 2018 14:03
Pandas Multi Index Examples

Say I have a multi-index DataFrame that looks like this:

In [5]: sales
             eggs  salt  spam
state month                  
CA    1        47  12.0    17
      2       110  50.0    31
NY 1 221 89.0 72
Atlas7 / theme-son-of-obsidian.css
Created November 22, 2017 18:35 — forked from vgaidarji/theme-son-of-obsidian.css
Son of Obsidian rouge theme
View theme-son-of-obsidian.css
.highlight pre { background-color: #272822; }
.highlight .hll { background-color: #22282A }
.highlight .c { color: #99AA8A } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #93C763 } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #F1F2F3 } /* Name */
.highlight .o { color: #E8E2B7 } /* Operator */
.highlight .p { color: #F1F2F3 } /* Punctuation */
View monokai.css
/* Based on Sublime Text's Monokai theme */
.cm-s-monokai.CodeMirror {background: #272822; color: #f8f8f2;}
.cm-s-monokai div.CodeMirror-selected {background: #49483E !important;}
.cm-s-monokai .CodeMirror-gutters {background: #272822; border-right: 0px;}
.cm-s-monokai .CodeMirror-linenumber {color: #d0d0d0;}
.cm-s-monokai .CodeMirror-cursor {border-left: 1px solid #f8f8f0 !important;}
.cm-s-monokai {color: #75715e;}
.cm-s-monokai {color: #ae81ff;}
Atlas7 /
Created November 19, 2017 00:42 — forked from gunjanpatel/
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}'

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

Atlas7 / shuffle.js
Created November 13, 2017 07:17 — forked from guilhermepontes/shuffle.js
Shuffle array element ES2015, ES6
View shuffle.js
const shuffleArray = arr => arr.sort(() => Math.random() - 0.5)
shuffleArray([1, 2, 3]) //[3, 1, 2]
Atlas7 / nativeJavaScript.js
Created November 2, 2017 09:56 — forked from alexhawkins/nativeJavaScript.js
Implementation of Native JavaScript Methods (forEach, Map, Filter, Reduce, Every, Some)
View nativeJavaScript.js
'use strict';
/*****************NATIVE forEACH*********************/
Array.prototype.myEach = function(callback) {
for (var i = 0; i < this.length; i++)
callback(this[i], i, this);

TensorFlow Serving in 10 minutes!

TensorFlow SERVING is Googles' recommended way to deploy TensorFlow models. Without proper computer engineering background, it can be quite intimidating, even for people who feel comfortable with TensorFlow itself. Few things that I've found particularly hard were:

  • Tutorial examples have C++ code (which I don't know)
  • Tutorials have Kubernetes, gRPG, Bezel (some of which I saw for the first time)
  • It needs to be compiled. That process takes forever!

After all, it worked just fine. Here I present an easiest possible way to deploy your models with TensorFlow Serving. You will have your self-built model running inside TF-Serving by the end of this tutorial. It will be scalable, and you will be able to query it via REST.

Atlas7 / README.rst
Created October 1, 2017 20:50 — forked from dupuy/README.rst
Common markup for Markdown and reStructuredText
View README.rst

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.

Atlas7 /
Last active September 28, 2017 22:24
Open source a Python Module - on PyPi - Guide
Atlas7 /
Last active September 13, 2017 13:12
Initialize Numpy Arrays with Tuple Unpacking Technique, via np.random.rand and np.zeros examples


Consider this numpy array A1, that has a shape 3 by 4 (axis 0 dimensions by axis 1 dimensions):

import numpy as np
A1 = np.arange(12).reshape(3,4)

#array([[ 0,  1,  2,  3],
#       [ 4,  5,  6,  7],