Skip to content

Instantly share code, notes, and snippets.

View wongyouth's full-sized avatar

Ryan Wang wongyouth

View GitHub Profile
@wongyouth
wongyouth / traefik.yml
Last active June 24, 2019 03:25
Docker Swarm mode with reverse proxy traefik config example
version: '3.3'
services:
reverse-proxy:
image: traefik:v1.7
ports:
- target: 80
published: 80
mode: host
- target: 8080
published: 8080
@wongyouth
wongyouth / install-docker-ce.sh
Last active July 15, 2019 13:33
Install docker-ce into Ubuntu
# install docker-ce on ubuntu
sudo apt-get update && \
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && \
@wongyouth
wongyouth / docker-compose.yml
Last active May 26, 2019 07:04
docker-compose.yml of Jenkins with nginx as reverse proxy
version: '2'
services:
jenkins:
image: jenkinsci/blueocean
user: root
restart: always
volumes:
- jenkins-data:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- $HOME/jenkins:/home
@wongyouth
wongyouth / format.sh
Created September 27, 2018 16:14
用于 nideshop-mpvue 原生转mpvue用
sed -i '' \
-e 's/that\.data/that/' \
-e 's/this\.data/this/' \
-e 's/that\.setData(/Object.assign(that.$data, /' \
-e 's/this\.setData(/Object.assign(this.$data, /' \
-e 's!//\([^ ]\)!// \1!' \
-e 's/function(/function (/' \
-e 's/^\( *\)\([^ (.]\{1,\}\)(/\1\2 (/' \
-e 's/ == / === /' \
-e 's/ *;? *$//' \
@wongyouth
wongyouth / gist:2390e5e511040cb6a512cb1416773e07
Created August 10, 2018 06:02 — forked from sartak/a.md
Anki 2 annotated schema
-- see https://github.com/ankidroid/Anki-Android/wiki/Database-Structure for a more maintained version of this
-- cards are what you review. easy!
CREATE TABLE cards (
id integer primary key,
-- the epoch milliseconds of when the card was created
nid integer not null,
-- notes.id
did integer not null,
-- deck id (available in col table)
@wongyouth
wongyouth / getQueryParams.js
Created July 26, 2018 03:32
getQueryParams
// https://github.com/nuxt/example-auth0/blob/master/utils/auth.js
const getQueryParams = () => {
const params = {}
window.location.href.replace(/([^(?|#)=&]+)(=([^&]*))?/g, ($0, $1, $2, $3) => {
params[$1] = $3
})
return params
}
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "scope": "javascript,typescript",
{
// Place your snippets for vue here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
@wongyouth
wongyouth / mongo-memo.md
Created June 20, 2018 06:42
Some memo to use mongodb

Mongodb

Mongo Console Shell

db.coll.find().forEach(doc => {})

loop all documents and update

db.coll.find().forEach(doc => { // ... change doc

// update

@wongyouth
wongyouth / fab.js
Created May 4, 2018 07:23
Use generator to calc fabonacci in javascript
function * fab (max) {
let [n, a, b] = [0, 0, 1]
while (n++ < max) {
[a, b] = [b, a + b]
yield b
}
}
for (let n of fab(5)) {
console.log(n)