Skip to content

Instantly share code, notes, and snippets.

View thieunguyenhung's full-sized avatar

Thiều Nguyên Hưng thieunguyenhung

View GitHub Profile
@thieunguyenhung
thieunguyenhung / qrcode_to_svg_testing.java
Created August 8, 2019 04:13
Testing class for QR code to SVG
public File generate() throws IOException, WriterException {
BitMatrix bitMatrix = createBitMatrix("https://medium.com/@thieunguyenhung", 100);
File outputFileSVG = File.createTempFile("example", "qr.svg");
bitMatrixToSVG(bitMatrix, outputFileSVG);
return outputFileSVG;
}
// .....
public class TestQrCodeGenerator {
@thieunguyenhung
thieunguyenhung / qrcode_to_svg_bit_matrix_to_svg.java
Last active August 7, 2019 08:23
Example how to convert BitMatrix to SVG file
import com.google.zxing.common.BitMatrix;
import org.jfree.graphics2d.svg.SVGGraphics2D;
import org.jfree.graphics2d.svg.SVGUtils;
import java.awt.*;
import java.io.File;
import java.io.IOException;
//.....
private void bitMatrixToSVG(BitMatrix bitMatrix, File outputFileSVG) throws IOException {
int matrixWidth = bitMatrix.getWidth();
@thieunguyenhung
thieunguyenhung / qrcode_to_svg_bit_matrix.java
Last active August 6, 2019 08:36
Example how to create BitMatrix of QR code with Google ZXing
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import java.util.HashMap;
import java.util.Map;
//.......
@thieunguyenhung
thieunguyenhung / qrcode_to_svg_pom.xml
Created August 6, 2019 07:10
pom.xml file example
<dependencies>
<!-- https://mvnrepository.com/artifact/com.google.zxing/core -->
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jfree/jfreesvg -->
<dependency>
@thieunguyenhung
thieunguyenhung / 3 Ways_dynamically_form_validation_angular.md
Last active February 19, 2022 12:50
3 Ways to Dynamically Alter your Form Validation in Angular

3 Ways to Dynamically Alter your Form Validation in Angular

Sometimes, we need to add, remove or modify controls in a form in run time. For example, when user click on a check box control then an input apprear example

The basic way

In the class code we just add 3 form controls as normal.

form: FormGroup;

ngOnInit() {
@thieunguyenhung
thieunguyenhung / 3_ways_to_bind_value_w_angular_forms.md
Last active March 14, 2025 10:43
3 ways to bind value with @angular/forms

3 Ways to bind value with @angular/forms

Binding directly in HTML code

Assume that we have a FormGroup called myForm and it hold another FormGroups called addresses (since one person can have more than one address). Each address have addressKind to determine its kind. In the class code, it should be like this

public myForm: FormGroup;
constructor(private formBuilder: FormBuilder) {}

ngOnInit() {
@thieunguyenhung
thieunguyenhung / sublime_text.desktop.md
Last active January 13, 2019 03:09
Example to create a custom .desktop file in Linux

How to create a custom .desktop file in Linux

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Sublime Text 3
Comment=Sublime Text 3
Exec=/opt/sublime_text_3/sublime_text
Icon=/opt/sublime_text_3/Icon/48x48/sublime-text.png
Terminal=false
@thieunguyenhung
thieunguyenhung / Apply_multiple_form_with_javascript.md
Last active January 13, 2019 03:10
How to apply multiple form in a page with Javascript in Google Chrome

How to apply multiple from with JS

First we need to analyze the page source code. Fortunately, the page call a Javascript function inside a form to apply it, so we can run a Javascript script in Google Chrome Console in Developer mode to apply all the form in this page.

The steps are:

  • Get all the forms in the page and parse them to Javascript array.
  • Filter out the form that not match your need.
  • Finally, loop through the array of forms to apply it.
var htmlForms = document.getElementsByTagName("form");
var tempForms = Array.from(htmlForms);
@thieunguyenhung
thieunguyenhung / How_to_install_VMWare_Tools_on_RHEL_7.4.md
Last active September 13, 2018 08:33
Guideline to install VMWare Tools on RHEL 7.4

How to install VMWare Tools on RHEL 7.4

Please register your RHEL version with RedHat first
First open Terminal and change permission to root then enter you password.

su -

Then update your system.

yum -y update