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 / 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 / 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
@railsgem
railsgem / soft_jaccard.py
Created October 17, 2017 04:03 — forked from mhluongo/soft_jaccard.py
An implementation of a "soft Jaccard" set similarity measure
>>> import jellyfish
>>> from soft_jaccard import soft_jaccard
>>> c1 = set(['CL Isbell','C. L. Isbell'])
>>> c2 = set(['C Isbell','C Isbell, Jr.'])
>>> soft_jaccard(c1, c2, jellyfish.jaro_winkler)
0.75848950260673509
@railsgem
railsgem / dqn.py
Created October 19, 2017 04:47 — forked from floodsung/dqn.py
DQN
# -------------------------------
# DQN for CartPole in OpenAI Gym
# Author: Flood Sung
# Date: 2016.6.27
# All rights reserved
# -------------------------------
import gym
import tensorflow as tf
import numpy as np
@railsgem
railsgem / dqn_mountaincar.py
Created October 22, 2017 12:28 — forked from floodsung/dqn_mountaincar.py
DQN for MountainCar
# -------------------------------
# DQN for CartPole in OpenAI Gym
# Author: Flood Sung
# Date: 2016.6.27
# All rights reserved
# -------------------------------
import gym
import tensorflow as tf
import numpy as np
@railsgem
railsgem / php-interview.md
Created May 8, 2019 11:59 — forked from messified/php-interview.md
PHP Engineer Interview: What you should know

PHP Developer Interview: What you should know

###1. What’s the difference between " self " and " this " ?

Use $this to refer to the current object. Use self to refer to the current class. In other words, use $this->member for non-static members, use self::$member for static members.

Source: When to use self vs this -stackoverflow