-
Save the following text:
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINESYSTEMWPAPosReady] "Installed"=dword:00000001
into a text file named xp.reg - double click the reg file to apply the patch.
Search This Blog
Re-enable Windows XP update by applying a registry patch
Java: convert int to unsigned
int toUnsigned(short i){ return Short.toUnsignedInt(); // i&0xffff; } long toUnsigned(int i){ return Integer.toUnsignedLong(); // i&0xffffffffl; }
Java: Regular expression to match dot separated numbers
The dot separated values look like below:
Java code:
1
1.2.3
1.2.3.4.5The regular expression to match: "^\\d+(\\d*.)*\\d+$"
Java code:
System.out.println(Pattern.matches("^\\d+(\\d*.)*\\d+$", "1")); // true System.out.println(Pattern.matches("^\\d+(\\d*.)*\\d+$", "1.2.3")); // true System.out.println(Pattern.matches("^\\d+(\\d*.)*\\d+$", "1.2.a")); // false System.out.println(Pattern.matches("^\\d+(\\d*.)*\\d+$", "1.2.3.")); // false
Java: Check if a year is leap year
public static boolean isLeapYear(int year) { assert year >= 1583; // not valid before this date. return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0); }
public static boolean isLeapYear(int year) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, year); return cal.getActualMaximum(DAY_OF_YEAR) > 365; }
Bash: for loop
#!/bin/bash # backup IFS IFSBAK=$IFS IFS=$(echo -en "\n\b") for f in $(ls) do echo "$f" done # restore IFS IFS=$IFSBAK
几个标点符号的英文翻译
小括号( ) parentheses
中括号[ ] square brackets
大括号{ } curly brackets
尖括号< > angle brackets
: colon
, comma
- hyphen
- - - dash
! Exclamation mark
; semicolon
/ slash
? question mark
. full stop/period
中括号[ ] square brackets
大括号{ } curly brackets
尖括号< > angle brackets
: colon
, comma
- hyphen
- - - dash
! Exclamation mark
; semicolon
/ slash
? question mark
. full stop/period
Github: fork a repository and sync the fork
- Fork a repository
- Clone the repository:
git clone https://github.com/ORIGINAL_OWNER/ORIGINAL_REPO.git
- Add the original repository as upstream:
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPO.git
- Check the status:
git remote -v
You will see:# origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch) # origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push) # upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPO.git (fetch) # upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPO.git (push)
- Clone the repository:
- Sync the fork with upstream(original):
- Fetch the branches and their respective commits from the upstream repository:
git fetch upstream
- Check out your fork's local master branch:
git checkout master
- Merge the changes from upstream/master into your local master branch. This brings your fork's master branch into sync with the upstream repository, without losing your local changes.
git merge upstream/master
- Push local repository:
git push --tags
- Fetch the branches and their respective commits from the upstream repository:
Subscribe to:
Posts (Atom)