Welcome
2025年2月4日 星期二
Fix Module can only be default-imported using the ‘allowSyntheticDefaultImports’ flag issue
2024年9月30日 星期一
Install Eclipse JBoss plugin without visiting market
1. Download Eclipse Jboss plugin here. Choose "Update site (including sources) bundle of all JBoss Core Tools".
https://tools.jboss.org/downloads/jbosstools/2023-09/4.29.1.Final.html#zips
2. Open eclipse > Help > Install new software... > Click "add" on top right corner > Archive... > Choose the zip file in step 1
Using Node Version Manager without admin right
- Install nvm (e.g. C:\Apps\nvm)
- Create settings.txt (e.g. C:\Apps\nvm\settings.txt) with below content
root: C:\Apps\nvm
path: C:\Apps\nvm\nodejs
arch: 64
proxy: [your company's proxy, username / password of proxy may be required]
originalpath: .
originalversion:
node_mirror:
npm_mirror:
Each time when "nvm use" is called, "C:\Apps\nvm\nodejs" will be recreated.
2023年9月26日 星期二
[Angular] Material Date Picker Custom Date Format
1. Create a class that extends NativeDateAdapter
import { NativeDateAdapter, DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE } from '@angular/material/core';
import { formatDate } from '@angular/common';
export const MY_FORMATS = {
parse: {
dateInput: 'yyyy-MM-dd', // date format used by the text field
},
display: {
dateInput: 'yyyy-MM-dd', // date format used by the text field
monthYearLabel: 'MMM-YYYY', // the date on the top left of the date picker
dateA11yLabel: 'LL',
monthYearA11yLabel: 'MM-yyyy',
}
};
export class MyDateAdaper extends NativeDateAdapter {
override format(date: Date, displayFormat: Object): string {
return formatDate(date, displayFormat+'', this.locale);
}
}
2023年9月6日 星期三
CSS values and units
https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
Unit | Name | Equivalent to |
---|---|---|
cm | Centimeters | 1cm = 37.8px = 25.2/64in |
mm | Millimeters | 1mm = 1/10th of 1cm |
Q | Quarter-millimeters | 1Q = 1/40th of 1cm |
in | Inches | 1in = 2.54cm = 96px |
pc | Picas | 1pc = 1/6th of 1in |
pt | Points | 1pt = 1/72nd of 1in |
px | Pixels | 1px = 1/96th of 1in |
2023年8月24日 星期四
[Java] Partition equal subset sum
class Solution {
[Java] Next Permutation
class Solution {
public boolean nextPermutation(int[] nums) {
int ind1=-1;
int ind2=-1;
// step 1 find breaking point
for(int i=nums.length-2;i>=0;i--){
if(nums[i]<nums[i+1]){
ind1=i;
break;
}
}
// if there is no breaking point
if(ind1==-1){
reverse(nums,0);
return false;
}
// step 2 find next greater element and swap with ind2
for(int i=nums.length-1;i>=0;i--){
if(nums[i]>nums[ind1]){
ind2=i;
break;
}
}
swap(nums,ind1,ind2);
// step 3 reverse the rest right half
reverse(nums,ind1+1);
return true;
}
void swap(int[] nums,int i,int j){
int temp=nums[i];
nums[i]=nums[j];
nums[j]=temp;
}
void reverse(int[] nums,int start){
int i=start;
int j=nums.length-1;
while(i<j){
swap(nums,i,j);
i++;
j--;
}
}
}