Skip to content

Instantly share code, notes, and snippets.

View railsgem's full-sized avatar
🎯
Focusing

Ying Chen railsgem

🎯
Focusing
View GitHub Profile
@railsgem
railsgem / tensorflow_word2vec_cbow_basic.py
Created September 28, 2017 11:51 — forked from yxtay/tensorflow_word2vec_cbow_basic.py
Basic implementation of CBOW word2vec with TensorFlow. Minimal modification to the skipgram word2vec implementation in the TensorFlow tutorials.
# References
# - https://www.tensorflow.org/versions/r0.10/tutorials/word2vec/index.html
# - https://github.com/tensorflow/tensorflow/blob/r0.10/tensorflow/examples/tutorials/word2vec/word2vec_basic.py
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import collections
import math
val f = sc.textFile("file:///root/pg100.txt")
# add line number
val f2 = f.zipWithIndex().map { case (line, i) => i.toString + ", " + line }
var one_line = "The Project Gutenberg EBook of The Complete Works of William Shakespeare, by"
var words = one_line.split(" ")
var line_no = 1
val pairs = words.map(word => (word, line_no))
def line_func(line: String, line_no: Long): String = {
# https://hub.docker.com/r/p7hb/docker-spark/
docker pull p7hb/docker-spark:2.2.0
# run spark
docker run -it -p 4040:4040 -p 8080:8080 -p 8081:8081 -h spark --name=spark p7hb/docker-spark:2.2.0
docker start -ai spark
# Spark commands
@railsgem
railsgem / run-python-file-on-jupyter.md
Created August 26, 2017 07:54
Run python file on jupyter

##To write/save

%%writefile myfile.py

write/save cell contents into myfile.py (use -a to append). Another alias: %%file myfile.py

##To run

%run myfile.py

@railsgem
railsgem / Tensorflow-on-docker.sh
Last active August 27, 2017 07:18
Tensorflow on Docker
# download tensorflow python3 version from dockerhub
docker pull tensorflow/tensorflow:latest-py3
# add tag to your own repo
docker tag tensorflow/tensorflow:latest-py3 yingchendocker/tensorflow:latest-py3
#push image to your docker repo
docker push yingchendocker/tensorflow:latest-py3
#For persistent storage:
@railsgem
railsgem / multiple-php-versions-on-ubuntu-16.04.md
Created March 4, 2017 11:51 — forked from aaronbloomfield/multiple-php-versions-on-ubuntu-16.04.md
Running multiple PHP versions on Apache2 and Ubuntu 16.04

Setting up multiple apache2 instances on Ubuntu 16.04

PHP handling on apache is done via modules of one sort or another, and running multiple version is problematic on a single instance. The solution is to run two instances of apache on the same machine. This allows one instance to run PHP 7 (the default on 16.04), and another can run PHP 5. Since normal http/https is on ports 80 and 443, the second instance will run on ports 81 and 444. Since it is running on the same machine, all file system and database access is the exact same.

All the commands herein have to be run as root, or with sudo prefixed to the command.

  1. Read /usr/share/doc/apache2/README.multiple-instances

  2. Run sh ./setup-instance php5 from /usr/share/doc/apache2/examples, where php5 is the suffix for the second site; all commands for the second site will have that suffix. This will keep all of the same configuration for all sites on the new instance, including SSL certif

@railsgem
railsgem / laravel常见问题.md
Last active August 10, 2016 00:11
开发笔记

#Error 404

$ chmod -R 777 storage/ $ chmod -R 777 vendor/ $ chmod -R 777 bootstrap/