2020 m. kovo 15 d., sekmadienis

Kaip atvaizduojamas tekstas


image source *The Tech Train

A simbolis UTF-8 , koduojamas vienu bitu A:'1000001' 


$ echo "A" > failas.txt
$ ll failas.txt 
-rw-r--r-- 1 sup sup 2 kov.   15 09:05 failas.tx

Matome, kad failas užima 2 baitus bet kodėl? Įrašėme tik vieną simbolį, 'A' vieną baitą informacijos.

Toliau tikrinant galime pastebėti, kad

$ od -A o -t u1c failas.txt
0000000  65  10
          A  \n
0000002


Po 'A' simbolio, buvo įterptas naujos eilutės simbolis. Taigi `echo` komandą, automatiškai prideda '\n\' simbolį ir todėl failo dydis 2baitai. Panaudokime specialią `echo` vėlėvėlę

-n     do not output the trailing newline

$ echo -n "A" > failas.txt 
1 ✗ sup /tmp $ od -A o -t cd failas.txt
0000000   A
                     65
0000001


$ ls -la failas.txt 
-rw-r--r-- 1 sup sup 1 kov.   15 09:10 failas.txt


Pirmieji baitai nurodo kokio ilgio bus bitas.

0xxxxxxx - vienas bitas (maximali reikšmė 127 = 64+32+16+8+4+2+1)
110xxxxx 10xxxxx - du baitai (max reikšmė 16191)
...

(Source: https://en.wikipedia.org/wiki/UTF-8)


Tam kad naršyklėse tekstas butų teisingai atvaizduotas, reikia nustatytų žymę:
<meta charset="UTF-8">


2020 m. kovo 6 d., penktadienis

Spring boot

Guides: https://spring.io/guides
Spring initializer: https://start.spring.io/
Docs: https://docs.spring.io/
HttpStatus Status values

REST - Representational State Transfer
DAO - Data access object (ryšys su duombaze)
model?
JSON - Javascript Object Notation
POJOS - Plain Old Java Objects
JAR - Java Archive
ORM - Object relation mapping
ODBC - Object Database Connectivity
JDBC - Java Database Connectivity

@RestController = @Controller + @ResponseBody 
 
@Service or @Component or @Repository

Running with maven
$ mvn clean package
$ mvn spring-boot:run

$ mvn clean
$ mvn install #target direktorijoje atsiras .jar failiukas
Autowiring@Autowired




GET

@GetMapping
@RequestMapping(method = RequestMethod.GET)

@GetMapping(path="/hello")
@RequestMapping(method = RequestMethod.GET, path="/hello"))

@GetMapping(path="/{name}")
public String getName(@PathVariable String name)

POST

@PostMapping()
@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)


DELETE

@DeleteMapping(path = "/{username}")
@RequestMapping(path = "/{username}", method = RequestMethod.DELETE)
public void deleteUser(@PathVariable final String username) {}

application.properies

logging.level.org.springframework.web: DEBUG
logging.level.org.springframework: DEBUG
server.port=9090

spring.jackson.serialization.write-dates-as-timestamps=false





Links

Lombok in Eclipse.
Project auto refresh with devtools
Java validation annotations:
Jwt security


2020 m. vasario 20 d., ketvirtadienis

Installing Java

How to find where java sdk is located?

$ update-java-alternatives -l

If there is multiple java versions, configuration can be done by:

$ sudo update-alternatives --config java

How to check java version?

$ javac -version


2020 m. sausio 30 d., ketvirtadienis

Unicode

Website for automagicaly detecting unicode:
Python encoding fixer ftty

Encoding tricks

Joining multiple mp3 files

$ sudo apt-get install mp3wrap

$ mp3wrap output file1.mp3 file2.mp3 file3.mp3

$ sox file* output.mp3

Problem:
sox FAIL sox: Input files must have the same sample-rate

Fixing sample rate with sox

$ sox CD1.mp3 -r 41000 CD1.mp3

2020 m. sausio 19 d., sekmadienis

Disabling Ubuntu 19.10 screenshot sound effect

mkdir -p ~/.local/share/sounds/__custom
touch ~/.local/share/sounds/__custom/screen-capture.disabled