User Tools

Site Tools


linux:scribble

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
linux:scribble [2015/11/26 04:40] – how to resize loop-AES partition styblalinux:scribble [2018/07/27 01:54] – How to change encoding of MySQL DB and tables stybla
Line 167: Line 167:
 ''git checkout --track origin/daves_branch'' ''git checkout --track origin/daves_branch''
  
 +
 +===== Go =====
 +
 +Aka golang
 +
 +==== JSON ====
 +
 +Remember that struct attributes/members must begin with capital letter/character. Otherwise you'll get an empty JSON. It took me very long time to figure this one out :-(
 +
 +<file golang json_test.go>
 +package main
 +
 +import (
 +  "encoding/json"
 +  "fmt"
 +)
 +
 +// Attributes, eg. Name, must begin with capital letter/character, otherwise it won't work.
 +// Also, JSON mapping is shown.
 +type Message struct {
 +    Name string `json:"name"`
 +    Body string `json:"body"`
 +    Time int64  `json:"unix_time"`
 +}
 +
 +func main() {
 +  m := Message{"Alice", "Hello", 1294706395881547000}
 +  b, err := json.Marshal(m)
 +  fmt.Println(err)
 +  fmt.Println(string(b))
 +}
 +</file>
  
 ===== iconv ===== ===== iconv =====
Line 174: Line 206:
 <code> <code>
 iconv --from-code=cp1250 --to-code=UNICODE -o $out_file $in_file iconv --from-code=cp1250 --to-code=UNICODE -o $out_file $in_file
 +</code>
 +===== Jenkins =====
 +
 +<code>
 +Jenkins.instance.getItemByFullName("JobName").getBuildByNumber(JobNumber).finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build"));
 +</code>
 +
 +<code>
 +Thread.getAllStackTraces().keySet().each() {
 +    if (it.name.contains('YOUR JOBNAME')) {  
 +      println "Stopping $it.name"
 +      it.stop()
 +    }
 +}
 </code> </code>
  
Line 255: Line 301:
  
 Funny thing is, it seems much harder to resize encrypted partition via cryptsetup/dm-crypt. Funny thing is, it seems much harder to resize encrypted partition via cryptsetup/dm-crypt.
 +
 +===== MySQL =====
 +
 +==== Convert database to UTF-8 encoding ====
 +
 +Originally found at [[https://www.a2hosting.com/kb/developer-corner/mysql/convert-mysql-database-utf-8|a2hosting.com]]
 +
 +Run mysql and check the encoding:
 +
 +<code>
 +SELECT default_character_set_name FROM information_schema.SCHEMATA S WHERE schema_name = "DBNAME";
 +SELECT CCSA.character_set_name FROM information_schema.`TABLES` T,information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA WHERE CCSA.collation_name = T.table_collation AND T.table_schema = "DBNAME" AND T.table_name = "TABLENAME";
 +</code>
 +
 +Change encoding of tables:
 +
 +<code>
 +cat > ~/.my.cnf <<EOF
 +[client]
 +user=USER
 +password=PASSWORD
 +EOF
 +mysql --database=DBNAME -B -N -e "SHOW TABLES" | awk '{print "SET foreign_key_checks = 0; ALTER TABLE", $1, "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; SET foreign_key_checks = 1; "}' | mysql --database=DBNAME
 +</code>
 +
 +Change encoding of DB itself:
 +<code>
 +ALTER DATABASE DBNAME CHARACTER SET utf8 COLLATE utf8_general_ci;
 +</code>
 +
 +Remove ''~/.my.cnf'' or edit out username and password.
 +
  
 ===== OpenOffice/LibreOffice ===== ===== OpenOffice/LibreOffice =====
linux/scribble.txt · Last modified: 2022/07/06 17:27 by stybla