This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.models import Model | |
from keras.layers import Input, Dense | |
input_1 = Input(..., name='input_1') | |
x = Dense(...)(input_1) | |
x = Dense(...)(x) | |
... | |
output_1 = Dense(dim_output_1, ..., name='output_1') | |
input_2 = Input(..., name='input_2') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
===== BLOG HEADER ===== | |
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/agate.min.css"> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/highlight.min.js"></script> | |
<style> | |
.inner { max-width:50em; } | |
pre .lines { margin-top:-12px; } | |
</style> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input()) | |
L = list(map(int, input().strip().split())) | |
X = [0] * n | |
count = 0 | |
for i, x in enumerate(L): | |
start = (i+1)%n # OK to START collection at the pos after the "i" | |
end = (start - x + n)%n # WORST place to start the collection | |
X[start] += 1 | |
X[end] -= 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use TQDM if installed | |
tqdm_installed = False | |
try: | |
from tqdm import tqdm | |
tqdm_installed = True | |
except: | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################## | |
# Tell ``ls`` to be colorful # | |
############################## | |
export CLICOLOR=1 | |
COLOR_BOLD="\[\e[1m\]" | |
COLOR_DEFAULT="\[\e[0m\]" | |
#PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$\[\033[00m\]' | |
#PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$\[\033[00m\]' | |
PS1="\[\033[32m\]\u\[\033[31m\]:\[\033[34m\]\w⚡ \[\033[00m\] " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################### | |
# ~/.tmux.conf for iTerm2 # | |
# # | |
# by Jovian Lin # | |
########################### | |
########## | |
# Basics # | |
########## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import sys | |
if sys.version_info[0] >= 3: | |
from urllib.request import urlretrieve | |
else: | |
from urllib import urlretrieve | |
local_filename, headers = urlretrieve('http://jovianlin.com') | |
html = open(local_filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random, sys, time | |
from termcolor import colored | |
colors = ['grey', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', None] | |
generated = '' | |
sys.stdout.write(generated) | |
for i in range(100): | |
sys.stdout.write(colored('%02d ' % i, random.choice(colors))) | |
sys.stdout.flush() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def is_kernel(): | |
""" | |
Determine if we're in an IPython notebook session | |
Source: Source: http://stackoverflow.com/a/34092072 | |
------------------------------------------------- | |
You can't detect that the frontend is a notebook with perfect precision, | |
because an IPython Kernel can have one or more different Jupyter frontends | |
with different capabilities (terminal console, qtconsole, notebook, etc.). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyspark import SparkContext | |
from pyspark.sql import HiveContext | |
from graphframes.examples import Graphs | |
sc = SparkContext() | |
sc.setLogLevel("ERROR") | |
sqlContext = HiveContext(sc) | |
g = Graphs(sqlContext).friends() # Get example graph |