Tuesday, December 5, 2017

Friday, November 24, 2017

Java JSP FN Functions

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<c:set var = "normalizedStateName" value = "${fn:toLowerCase(fn:replace(state.name, ' ', '-'))}"/>

Friday, November 17, 2017

Watching Lecture: Setting up an EC2 Instance with IAM Roles and the Python Boto3 SDK

sudo yum update
sudo yum install python-pip
sudo pip install boto3
vi dev.py


Tuesday, October 3, 2017

Display UTC Date in User's Local Time with .toString()

$('.publishedDateString').each(function(){
$(this).text(new Date($(this).text()).toString());
});

Friday, September 8, 2017

MusicEvent JSON-LD

<script type="application/ld+json">{
    "@context": "http://schema.org",
    "@type": "MusicEvent",
    "location":{
        "@type": "MusicVenue",
        "name": "Rachel M. Schlesinger Concert, Alexandria, VA 22302, USA",
        "address": "Rachel M. Schlesinger Concert, Alexandria, VA 22302, USA"
    },
    "name": "Lam Phương 68 Năm - Tình Người & Tình Quê",
    "description": "Show Ca Nhạc Lam Phương 68 Năm - Tình Người & Tình Quê is at Rachel M. Schlesinger Concert, Alexandria, VA 22302, USA on 2017-10-15 13:00 with Anh Dũng,Diễm Liên,Hà Thanh Xuân,Hồ Hoàng Yến,Mạnh Quỳnh,Ngọc Hạ,Thanh Tuyền,Thế Sơn,Ban Nhạc Hoàng Thi Thi.",
    "image": "https://lh3.googleusercontent.com/VYYZ0POhoRg09EMJMvbpDB5ZpmtSgGJYb0RZFioX2QKeyiB6KpvhSvaEXoAZugRJhLZia34ebbe7wOeSNqne38mM=s0",
    "startDate": "2017-10-15 13:00",
    "endDate": "2017-10-15 16:00",  
    "performer": [        
        {
            "@type": "Person",
            "name": "Anh Dũng",
            "sameAs": "https://showcanhac.com/shows?q=Anh+Dũng"
        },      
        {
            "@type": "Person",
            "name": "Ban Nhạc Hoàng Thi Thi",
            "sameAs": "https://showcanhac.com/shows?q=Ban+Nhạc+Hoàng+Thi+Thi"
        },      
        {
            "@type": "Person",
            "name": "Diễm Liên",
            "sameAs": "https://showcanhac.com/shows?q=Diễm+Liên"
        },      
        {
            "@type": "Person",
            "name": "Hà Thanh Xuân",
            "sameAs": "https://showcanhac.com/shows?q=Hà+Thanh+Xuân"
        },      
        {
            "@type": "Person",
            "name": "Hồ Hoàng Yến",
            "sameAs": "https://showcanhac.com/shows?q=Hồ+Hoàng+Yến"
        },      
        {
            "@type": "Person",
            "name": "Mạnh Quỳnh",
            "sameAs": "https://showcanhac.com/shows?q=Mạnh+Quỳnh"
        },      
        {
            "@type": "Person",
            "name": "Ngọc Hạ",
            "sameAs": "https://showcanhac.com/shows?q=Ngọc+Hạ"
        },      
        {
            "@type": "Person",
            "name": "Thanh Tuyền",
            "sameAs": "https://showcanhac.com/shows?q=Thanh+Tuyền"
        },      
        {
            "@type": "Person",
            "name": "Thế Sơn",
            "sameAs": "https://showcanhac.com/shows?q=Thế+Sơn"
        }                  
    ]  
}
</script>

Google Search Gallery

The search gallery shows how structured data can produce rich results in Google Search. In addition to single Rich Card results, host lists can feature a carousel from a single site. Host lists require markup on list pages.

https://developers.google.com/search/docs/guides/search-gallery

Thursday, September 7, 2017

Download the App Engine SDK for Java

There is a new version of the SDK available.
-----------
Latest SDK:
Release: 1.9.55
Timestamp: Wed Aug 30 16:42:17 EDT 2017
API versions: [1.0]

-----------
Your SDK:
Release: 1.9.34
Timestamp: Thu Feb 11 14:36:15 EST 2016
API versions: [1.0]

-----------
Please visit https://developers.google.com/appengine/downloads for the latest SDK.

Saturday, September 2, 2017

How to link to Google Maps

<c:if test="${not empty show.locationName }">
<div>
    <span class="glyphicon glyphicon-map-marker" aria-hidden="true" title="Location"></span> <a href='http://maps.google.com/maps?q=${show.locationLatitude},${show.locationLongitude }&ll=${show.locationLatitude},${show.locationLongitude }&z=17' title='View location in Google Maps'><c:out value="${show.locationName }"></c:out></a>
</div>
</c:if>

Tuesday, August 29, 2017

product-list.component.ts

import { Component } from '@angular/core';

@Component({
   selector: 'pm-products',
   templateUrl: './product-list.component.html'
})

export class ProductListComponent {
   pageTitle: string = 'Product List';
}

Thursday, August 24, 2017

app.component.ts

import { Component } from '@angular/core';

@Component({
   selector: 'pm-root',
   template: `
   <div><h1>{{pageTitle}}</h1>
      <pm-products></pm-products>
   </div>
   `
})

export class AppComponent {
   pageTitle: string  = 'Product Management';
}

Thursday, July 13, 2017

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { ProductListComponent } from './products/product-list.component';

@NgModule({
   declarations: [
      AppComponent,
      ProductListComponent
   ],
   imports: [
      BrowserModule
   ],
   providers: [],
   bootstrap: [AppComponent]
})

export class AppModule { }

Thursday, July 6, 2017

index.html

<!doctype html>
<html lang="en">
  <head>
    <title>ProductManagement</title>
    <base href="/">
  </head>
  <body>
    <pm-root></pm-root>
  </body>
</html>

Friday, May 5, 2017

Saturday, February 11, 2017

Sunday, January 29, 2017

Jcache vs Memcache

Jcache

import javax.cache.Cache;
import javax.cache.CacheException;
import javax.cache.CacheFactory;
import javax.cache.CacheManager;

try {
    CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
    Cache cache = cacheFactory.createCache(Collections.emptyMap());
    key = "p";
    if (cache.containsKey(key)) {
        pList = (List<p>) cache.get(key);
    } else {
        pList = ofy().load().type(p.class).list();
        cache.put(key, pList);
    }
} catch (CacheException e) {
}

Memcache

import com.google.appengine.api.memcache.ErrorHandlers;
import com.google.appengine.api.memcache.MemcacheService;
import com.google.appengine.api.memcache.MemcacheServiceFactory;

MemcacheService cache = MemcacheServiceFactory.getMemcacheService();
cache.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO));
key = "p";
if (cache.contains(key)) {
    pList = (List<p>) cache.get(key);
} else {
    pList = ofy().load().type(p.class).list();
    cache.put(key, pList);
}


Sunday, December 4, 2016

XCOPY

Copy new/updated files from source folder on D to destination folder on K

xcopy D:\Documents\Pictures K:\Documents\Pictures /s /d

Thursday, December 1, 2016

Linux Notes

uname -r: shows kernel version
lsb_release -a: shows operating system/distribution
free -m: shows memory
Ubuntu/Lubuntu/Centos/Raspberry Pi (Raspbian, Debian based distribution)

Thursday, November 17, 2016

Joda-Time DateTimeFormat

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss");
DateTime showDate = formatter.parseDateTime("02/02/2016 08:02:00");

facebook4j Events

import facebook4j.Event;
import facebook4j.Facebook;
import facebook4j.FacebookException;
import facebook4j.FacebookFactory;
import facebook4j.ResponseList;
import facebook4j.auth.AccessToken;

Facebook facebook = new FacebookFactory().getInstance();
facebook.setOAuthAppId(appId, appSecret);
facebook.setOAuthPermissions(commaSeparetedPermissions);
facebook.setOAuthAccessToken(new AccessToken(accessToken, null));

ResponseList<Event> events;
int count;
try {
events = facebook.getEvents();
count = events.size();
} catch (FacebookException e) {
e.printStackTrace();
}

Saturday, October 29, 2016

Installing MobaXterm

Enhanced terminal for Windows with X11 server, tabbed SSH client, network tools and much more