博文

make vim like source insight, a effective c/c++ ide

图片
IDEsetup latest vimgit clone https://github.com/vim/vim.git cd vim/src ./configure --enable-cscope --enable-terminal make sudo make install https://www.vim.org/git.phpuse universal ctagsgit clone https://github.com/universal-ctags/ctags.git cd ctags ./autogen.sh ./configure make sudo make instahttps://www.tamacom.com/global/global-6.6.3.tar.gzll setup gnu tagswget https://www.tamacom.com/global/global-6.6.3.tar.gz tar -xvf global-6.6.3.tar.gz cd global-6.6.3 sh reconf.sh sudo apt install ncurses-dev ./configure --with-universal-ctags=/usr/local/bin/ctags make sudo make install https://www.tamacom.com/global/global-6.6.3.tar.gz
http://www.gnu.org/software/global/download.htmlinstall gtags as vim plugincp gtags.vim ~/.vim/plugin/ cp gtags-cscope.vim ~/.vim/plugin/ config gtags as cscope in ~/.vimrc" gtags configure " To use the default key/mouse mapping: let GtagsCscope_Auto_Map = 1 " To ignore letter case when searching: let GtagsCscope_Ignore_Case = 1 " To use ab…

set up java spring boot "hello world" web application on ubuntu from zero.

图片
install JDK 8 $ sudo apt-get install openjdk-8-jdk
install Gradle $ curl -s "https://get.sdkman.io" | bash
$ source "$HOME/.sdkman/bin/sdkman-init.sh"
$ sdk install gradle 5.1.1
Spring Initializrstart.spring.io
get your "demo.zip" and unzip it.
choose "Gradle Project",
please remember add "Web" as dependence,
otherwise there will be compile errors.

Create a simple web application
$ cat src/main/java/com/example/demo/HelloController.java
package com.example.demo; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RequestMapping; @RestController public class HelloController { @RequestMapping("/") public String index() { return "Greetings from Spring Boot!"; } } Run the Application $ ./gradlew bootRun
Check out the service. $ curl localhost:8080
Greetings from Spring Boot!
Generate IDE profile add two plugin in build.gradle
apply plugin &…

AWS : how to play a video file from s3 bucket in browser

URI all you have to do is to sign a request like:

https://s3.amazonaws.com/yourbucket/key?response-content-disposition=inline&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJWWH7EGSUBWE34IQ/20181228/us-east-1/s3/aws4_request&X-Amz-Date=20181228T074135Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=b3143f8442812e176fd61838813a33f53cfd7e198e1c6e68fab5d03d4a642403 and set it as src attribue to a video element.
Player componentimport React, { Component } from 'react'; import PropTypes from 'prop-types'; const AWS_SERVICE = 's3'; const crypto = require('crypto'); Date.prototype.toYMDString = function() { let year = this.getFullYear().toString(); let month = this.getUTCMonth() + 1; if (month < 10) month = "0" + month; let day = this.getUTCDate(); if (day < 10) day = "0" + day; return String(year) + String(month) + String(day); } Date.prot…

WebRTC recording via Kurento media server

Official guideI encountered some errors while following the Official guide.
Lucky, I fixed all the errors and make it work finally.
Notes my workaround here, hope it work for you if you have the same problem.gpg: keyserver receive failed: keyserver errorlocal install guidesolution from stackoverflowsudo apt-key adv --keyserver hkp://keys.gnupg.net:80 --recv-keys 5AFA7A83WebSocket connection to 'wss://<local_ip>:8433/kurento' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSEDcausethe application server is started with https if you follow the guide:http-server -p 8443 -S -C keys/server.crt -K keys/server.key but kurento media server start without ssl by default config.
You can get from the config and the default port is 8888.
/etc/kurento/kurento.conf.jsonsolutionmodify kurento media server config to enable ssl and use the same cert that used for your application server. it is a little complex.
but we have a easy solution, just start your application wi…

AWS: how to upload file to your s3 bucket via EvaporateJS in browser

图片
Evaporate and config s3 bucket and IAM userEvaporateJS
Config AWS s3 bucket
Managing Access Permissions to Your Amazon S3 Resources
User Access Key
In summary, create a s3 bucket, set up CORS settings and bucket policy.
<CORSConfiguration> <CORSRule> <AllowedOrigin>https://*.yourdomain.com</AllowedOrigin> <AllowedOrigin>http://*.yourdomain.com</AllowedOrigin> <AllowedMethod>PUT</AllowedMethod> <AllowedMethod>POST</AllowedMethod> <AllowedMethod>DELETE</AllowedMethod> <AllowedMethod>GET</AllowedMethod> <ExposeHeader>ETag</ExposeHeader> <AllowedHeader>*</AllowedHeader> </CORSRule> </CORSConfiguration> { "Version": "2012-10-17", "Id": "Policy145337ddwd", "Statement": [ { "Sid": "", …

AWS : how to get cognito user attributes in Lambda/cloud logic

图片
Lambda function(js)const AWS = require('aws-sdk'); const cognito = new AWS.CognitoIdentityServiceProvider(); function getUser(Username) { return new Promise((resolve, reject) => { cognito.adminGetUser({ UserPoolId: process.env.COGNITO_USER_POOL_ID, Username: Username }, (err, data) => { if (err) reject(err.stack); else resolve(data.UserAttributes[2].Value); }); }); } async function getEmail(Username) { return await getUser(Username); } exports.handler = async (event) => { console.log(await getEmail('abcdef')); console.log(await getEmail('hijklmn')); console.log('done'); return 'ok'; }; set Execution role with correct policy as below descripted.
set an environment 'COGNITO_USER_POOL_ID' with the user pool id.
Role policy{ "Version": "2012-10-17", "Statement": […

node.js download file from aws s3 bucket via http request with AWS Signature Version 4

图片
Main codesfunction getYMD(d) { let r = d.getFullYear().toString(); let m = d.getUTCMonth() + 1; if (m < 10) m = "0" + m.toString(); else m = m.toString(); r = r + m; let day = d.getUTCDate(); if (day < 10) day = "0" + day.toString(); else day = day.toString(); r = r + day; return r; } function getTZ(d) { let r = d.getFullYear().toString(); let m = d.getUTCMonth() + 1; if (m < 10) m = "0" + m.toString(); else m = m.toString(); r = r + m; let day = d.getUTCDate(); if (day < 10) day = "0" + day.toString(); else day = day.toString(); r = r + day + "T"; let h = d.getUTCHours(); if (h < 10) h = "0" + h.toString(); else h = h.toString(); r = r + h; let min = d.getUTCMinutes(); if (min < 10) min = "0" + min.toString(); else min = m…