博文

目前显示的是 四月, 2017的博文

Underscore.js and Angular

Reference: http://underscorejs.org/ Installation and Import Node.js > npm install underscore import * as _from 'underscore';  Example : In app.component.ts import * as _ from 'underscore'; import { Component } from '@angular/core' ; import * as _ from 'underscore' ; @ Component ({ selector: 'app-root' , template: `<h1>even: {{even}}</h1>` }) export class AppComponent { even : any ; constructor (){ this . test ();}    test (){ this . even = _ . find ([ 1 , 2 , 3 , 4 , 5 , 6 ], function ( num ){ return num % 2 == 0 ; }); }}

site shorten url

1.  in classic sites https://www.youtube.com/watch?v=TYcLGK90hmc https://goo.gl/ 2. in new Sites https://www.youtube.com/watch?v=Yhij2Enj-qY&spfreload=5 www.google.com/addurl https://www.bing.com/toolbox/submit-site-url https://www.google.com/analytics Create your QR code generater https://sites.google.com/site/sites/system/app/pages/meta/dashboard

Angular/CLI stories

1. From: https://github.com/angular/angular-cli/blob/master/docs/documentation/stories/proxy.md We create a file next to projects package.json called proxy.conf.json with the content { " /api " : { " target " : " http://localhost:3000 " , " secure " : false } } You can read more about what options are available here webpack-dev-server proxy settings and then we edit the package.json file's start script to be " start " : " ng serve --proxy-config proxy.conf.json " , now run it with npm start   Ref: https://webpack.github.io/docs/webpack-dev-server.html#proxy  // Multiple entry proxy: [ { context: [ '/api-v1/**' , '/api-v2/**' ], target: 'https://other-server.example.com' , secure: false } ]   import {Http} from '@anuglar/http'; import 'rxjs/Rx' data:any; ngOnInit(){ this.http.get('api/getSrc').map (res=> res.json()).subs

color picker

Open browser-standard colorpicker with javascript without type=color https://stackoverflow.com/questions/29676017/open-browser-standard-colorpicker-with-javascript-without-type-color 1 ==================== document.getElementById("xxx").addEventListener("click", function() {   document.getElementById("c").focus();   document.getElementById("c").value = "#FFCC00";   document.getElementById("c").click(); }); .hidden {   position: absolute;   left: -10000px;   top: auto;   width: 1px;   height: 1px;   overflow: hidden; } <input type="color" id="c" tabindex=-1 class="hidden"> <input type="button" id="xxx" value="Click Me!"> 2 ================================= Works in browsers that support input type=color (firefox, chrome, and opera) <input type = "file" id = "filepicker" style = " display : none "

Cross-origin resource sharing (CORS) in java and in .net C#

Resource: 1.Cross-origin resource sharing https://en.wikipedia.org/wiki/Cross-origin_resource_sharing#How_CORS_works 2.https://www.w3.org/TR/cors/ 3. Example:  3.1.Servlet - CORS: http://www.logicbig.com/tutorials/java-ee-tutorial/java-servlet/servlet-cors/  3.2.Spring CORS support: http://www.logicbig.com/tutorials/spring-framework/spring-web-mvc/spring-cors/ 3.3.Servlet - Servlet with Tomcat CorsFilter example:http://www.logicbig.com/tutorials/java-ee-tutorial/java-servlet/servlet-with-tomcat-cors-filter/ //for Preflight @Override protected void doOptions ( HttpServletRequest req , HttpServletResponse resp ) throws ServletException , IOException { setAccessControlHeaders ( resp ); resp . setStatus ( HttpServletResponse . SC_OK ); } private void setAccessControlHeaders ( HttpServletResponse resp ) { resp . setHeader ( " Access-Control-Allow-Origin " , "http://localhost:9000" ); resp . setHe