Search For Fun

A blog for collecting diverse useful information


  • Home

  • Tags

  • Categories

  • Archives

  • Search

Hello World

Posted on 2018-09-27 | Edited on 2018-07-05

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

Google Home links to Local Host through localtunnel

Posted on 2018-09-27 | Edited on 2018-07-14 | In nodejs

nodejs localhost

Google home request -> index.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var express = require('express'),
app = express(),
bodyparser = require('body-parser'),
assistant = require('./assistant.js'),
util = require('util');
app.use(bodyparser.json())

// GET method route
app.all('/', function (req, res) {
console.log('index.js/');
assistant.assistantHandler(req,res)
})

app.all('/test', function(req,res) {
console.log('index.js/test');
res.send('helloworld')
})

app.listen(3000)

index.js -> Google actions sdk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';

const ActionsSdkApp = require('actions-on-google').ActionsSdkApp;

exports.assistantHandler = (req, res) => {
console.log('assistantHandler');
const app = new ActionsSdkApp({
request: req,
response: res
});
var str = 'Sorry. I don\'t understand what you say';

// Create functions to handle requests here
function mainIntent(app) {
console.log('assistant.js/mainIntent');
voiceResponse('welcome')
}

function respond(app) {
console.log('assistant.js/respond');

if (app.getRawInput() == 'hello') {
str = 'hello'
}
voiceResponse(str)
}

function voiceResponse(strIn) {
let inputPrompt = app.buildInputPrompt(false,strIn);
app.ask(inputPrompt);
}

let actionMap = new Map();
actionMap.set(app.StandardIntents.MAIN, mainIntent);
actionMap.set(app.StandardIntents.TEXT, respond);

app.handleRequest(actionMap);
}

localtunnel

acquire the URL to access localhost : https://localtunnel.github.io/www/
-> installation: npm install -g localtunnel
-> running: lt --port 8000
-> copy the url

Google Actions SDK

  1. Apply for account: https://developers.google.com/actions/sdk/
    -> Add project
    -> fill the form
    -> get the update code as follow

    `gactions update --action_package PACKAGE_NAME --project PROJECT_NAME`
    
  2. gactions Cli : https://developers.google.com/actions/tools/gactions-cli
    -> download
    -> Run chmod +x gactions to make the binary executable
    -> get the actions json sample gactions init
    -> change the actions:add the url in the json file
    -> update

    `gactions update --action_package PACKAGE_NAME --project PROJECT_ID`
    
  3. test google actions:https://developers.google.com/actions/tools/simulator


more on http://searchfor.space

Git Switch between ssh and HTTPS

Posted on 2018-09-27 | Edited on 2018-07-22 | In git

description: git change remote from https to ssh

change from HTTPS into ssh

1
2
git remote set-url origin git@github.com:kelfan/kelfan.github.io.git
git remote -v

more on search4fan.github.io

TortoiseGit set ssh for github

Posted on 2018-09-27 | Edited on 2018-07-22 | In git

description: tortoisegit ssh key windows

tortoisegit ssh key setup

  1. open Puttygen
    1. click “Generate”
    2. need move mouse to Generate key
    3. save public key and private key
  2. go to repository and right click -> tortoiseGit -> settings
    1. remote -> origin -> puttyKey -> add the .ppk file

more on search4fan.github.io

docker

Posted on 2018-09-27 | Edited on 2018-07-15 | In docker

description: solve problem of unauthorized username or password in terminal

problem of unauthorized incorrect username or password

1
2
3
C:\Users\Administrator>docker pull alpine
# Using default tag: latest
# Error response from daemon: Get https://registry-1.docker.io/v2/library/alpine/manifests/latest: unauthorized: incorrect username or password

solve solution

1
2
3
4
5
C:\Users\Administrator>docker login
# Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
# Username (findhill@gmail.com): vifonk
# Password:
# Login Succeeded

more on search4fan.github.io

connect sql server from Microsoft Sql Server Management Studio

Posted on 2018-09-27 | Edited on 2018-07-18 | In sql server

description: codes for connecting sql server from Microsoft sql server management studio

start sql server

Asdfgh123 is default password

1
2
3
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Asdfgh123" `
-p 1433:1433 --name sql1 `
-d microsoft/mssql-server-linux:2017-latest

connect from external tools

under Windows, open Powershell to test service can be accessed from Windows

1
sqlcmd -S 10.3.2.4,1433 -U SA -P "Asdfgh123"

connect from sql server management studio

server name is the ip address for docker computer. can use commend ipconfig to get the IPv4 Address

1
2
3
4
5
server type: database engine 
server name: 192.168.11.11
authentication: sql server authentication
login: SA
password: Asdfgh123


more on search4fan.github.io

run sql server through docker in Windows

Posted on 2018-09-27 | Edited on 2018-07-19 | In sql server

description: run sql server through docker

start

  • open and start docker service
  • open Powershell

download sql server image

put following commend in powerhell

1
docker pull microsoft/mssql-server-linux:2017-latest

start sql server

Asdfgh123 is default password

1
2
3
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Asdfgh123" `
-p 1433:1433 --name sql1 `
-d microsoft/mssql-server-linux:2017-latest

if get following error:

1
2
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: Conflict. The container name "/sql1" is already in use by container "1da5029c71ab937a25acdb4fadf44f4065c2fea4f6a4f157c1a07516558757bb". You have to remove (or rename) that container to be able to reuse that name.
See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.

restart the server

1
docker start sql1

connect to server

1
docker exec -it sql1 "bash"

start sqlcmd tool

1
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'Asdfgh123'

test create database

1
2
3
CREATE DATABASE TestDB
SELECT Name from sys.Databases
GO

test acquire database

1
2
3
4
5
6
USE TestDB
Create new table named Inventory:
CREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT)
INSERT INTO Inventory VALUES (1, 'banana', 150); INSERT INTO Inventory VALUES (2, 'orange', 154);
SELECT * FROM Inventory WHERE quantity > 152;
GO

connect from external tools

outside the container

1
sqlcmd -S 10.3.2.4,1433 -U SA -P "Asdfgh123"

Stop and remove container

1
2
docker stop sql1
docker rm sql1

run sql server with external folder

1
2
3
4
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Asdfgh123" `
-v $PWD/:/data `
-p 1433:1433 --name sql2 `
-d microsoft/mssql-server-linux:2017-latest

more on search4fan.github.io

docker change port of an exist image container

Posted on 2018-09-27 | Edited on 2018-07-16 | In docker

description: Docker Change Port Mapping for an Existing Container

Stop the running image

1
docker Stop image1

save the previous image

1
docker commit image1 image2

image2 is the name of new image

start the new image with a new mapped port

1
docker run -p 8080:8080 -td image2

more on search4fan.github.io

Error response from daemon driver failed programming external connectivity on endpoint sql1

Posted on 2018-09-27 | Edited on 2018-07-16 | In docker

description:

error description 1

1
2
3
PS C:\Users\Administrator> docker start sql1
Error response from daemon: driver failed programming external connectivity on endpoint sql1 (5738a464113f88069be0239c3fd73eaa58fc4d5a7fc63d83d912e3d9424f6b55): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:1433:tcp:172.17.0.2:1433: input/output error
Error: failed to start containers: sql1

error description 2

1
2
3
PS C:\Users\Administrator> docker run -p 1443:1443 -d sql2
90d3d1f460f1dfd11a684a37a9278db78f345c1a85cc55d68e1f3c313721c2e0
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint sad_ritchie (b5a71d797addfd55b7683151e8a6b9fbacbd35792dbe1f020170190b500778b6): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:1443:tcp:172.17.0.2:1443: input/output error.

solution

restart system and docker then restart service


more on search4fan.github.io

docker frequent used commends

Posted on 2018-09-27 | Edited on 2018-07-18 | In docker

description: docker commends - not finished yet

check all running proceses/containers

1
docker ps -a

delete a container

1
docker rm container_name

see all images

1
docker images

remove an image

1
docker rmi image_name

Stop all running containers

1
docker stop $(docker ps -a -q)

commit container as a new image

1
2
docker commit new_image_name
docker commit old_image new_image

mount host directory in docker container

1
2
# mount code folder under current folder into the html folder within the Nginx image
docker run -v $PWD/code:/var/www/html Nginx

more on search4fan.github.io

1…4567

killfun

Personal blog for collecting useful information

64 posts
14 categories
38 tags
RSS
© 2018 killfun
Powered by Hexo v3.7.1
|
Theme — NexT.Muse v6.3.0