Showing posts with label Mac OSX. Show all posts
Showing posts with label Mac OSX. Show all posts

24 December 2020

curl cheat sheet

 Curl, the wget with steroids. https://curl.se/

1. response headers

curl -I http://localhost:8081/customers

HTTP/1.1 302
Set-Cookie: KC_REDIRECT=/customers; Path=/; HttpOnly
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Location: http://localhost:8081/sso/login
Transfer-Encoding: chunked
Date: Sun, 27 Dec 2020 15:38:57 GMT

2.  gzip call

curl -v -H "Content-Type: application/json" -H "Accept-Encoding: gzip" -I http://127.0.0.1:8080/example/fourkb 

Content-Encoding: gzip
Content-Type: application/json

curl -v -H "Content-Type: application/json" -H "Accept-Encoding: gzip" http://127.0.0.1:8080/fourkb -o four.json.gz

curl -v --compressed
-verbose

3.  curl get

curl -k --max-time 30 -X GET 'https://10.10.10.31:8080/rest/accounts?user=test&password=test&channel=1&client-ID=1020'
 --request GET

 
 
4. curl post body:

curl -k --request POST 'https://10.10.10.31:8080/rest/num-accounts' --header 'Content-Type: application/json' --data-raw '{"user":{"user":"testuser","password":"welcome1","request-channel":1},"client-ID":"12345"}'

-d '{"query":{"match_all":{}}}'
-d, --data <data>



5. ssl

to avoid self-signed cert:

-k

curl --cacert cacert.pem https://self-signed.badssl.com


6. cookie

--cookie "jsessionid=123"


7. timeout

--max-time 30


8. header

curl -H "Authorization: Basic YXBpdXNlcjphcGlwd2Q=" http://devweb.cl/status


9.  basic user?

--basic --user "redemption-br:GUkboMIZ"

 
10. for brackets

curl -g

otherwise:
curl: (3) bad range in URL position 47:

11. download

-O -J

curl -k -O -J https://www.devweb.cl/file.txt

 
12. linux/windows

linux:

curl -X POST http://172.18.235.19:8773/api/v1/publishEvent --header 'Content-Type: application/json' --data-raw '{"user":{"user":"testuser","team":"welcome1","request-channel":1},"client-ID":"12345"}'


windows:

curl -X POST http://127.0.0.1:8773/api/v1/publishEvent --header "Content-Type: application/json" --data-raw  "{\"user\":{\"user\":\"testuser\",\"team\":\"welcome1\",\"request-channel\":1},\"client-ID\":\"12345\"}"

 

13 June 2018

tzupdater Mac OS X (offline)

wget https://www.iana.org/time-zones/repository/tzdata-latest.tar.gz

gsha512sum /Users/German/bin/tzupdater-2.1.2/tzdata-latest.tar.gz |awk '{print $1}' > /Users/German/bin/tzupdater-2.1.2/tzdata-latest.tar.gz.sha512

sudo java -jar tzupdater.jar -f -v -l file:///Users/German/bin/tzupdater-2.1.2/tzdata-latest.tar.gz 


Note: gsha512sum from brew coreutils

Password:
Using file:///Users/German/Downloads/tzupdater-2.1.2/tzdata-latest.tar.gz as source for tzdata bundle.
java.home: /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre
java.vendor: Oracle Corporation
java.version: 1.7.0_80
tzupdater version 2.1.2-b01
JRE tzdata version: tzdata2018e
Downloaded file to /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/tz.tmp/tzdata.tar.gz
javazic: warning: found last rules for Eire inconsistent.
tzupdater tool would update with tzdata version: tzdata2018e
Downloaded file to /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/tz.tmp/sha512hash
Extracting files... done.
Renaming /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre/lib/zi to /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre/lib/zi.tzdata2018e_2
Renaming /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre/lib/zi.tzdata2018e to /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre/lib/zi
Validating for : tzdata2018e
Validation complete
JRE updated to version : tzdata2018e


just in case,for online:

$ sudo java -jar tzupdater.jar -f -v

UPDATE:

There is a known bug with new format:

Using file:///Users/German/bin/tzupdater-2.1.2/tzdata-latest.tar.gz as source for tzdata bundle.
java.home: /Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/jre
java.vendor: Oracle Corporation
java.version: 1.8.0_191
tzupdater version 2.2.0-b01
JRE tzdata version: tzdata2018e
Downloaded file to /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/tz.tmp_2/tzdata.tar.gz
tzupdater tool would update with tzdata version: tzdata2019b
Compiling TZDB version 2019b
Parsing file: /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/tz.tmp_2/africa
Parsing file: /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/tz.tmp_2/antarctica
Parsing file: /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/tz.tmp_2/asia
Failed: java.lang.Exception: Failed while parsing file '/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/tz.tmp_2/asia' on line 1865 'Rule    Japan    1948    1951    -    Sep    Sat>=8    25:00    0    S'
java.lang.Exception: Failed while parsing file '/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/tz.tmp_2/asia' on line 1865 'Rule    Japan    1948    1951    -    Sep    Sat>=8    25:00    0    S'
    at tools.tzdb.TzdbZoneRulesCompiler.parseFile(TzdbZoneRulesCompiler.java:377)
    at tools.tzdb.TzdbZoneRulesCompiler.compile(TzdbZoneRulesCompiler.java:191)
    at tools.tzdb.TzdbZoneRulesCompiler.(TzdbZoneRulesCompiler.java:307)
    at com.sun.tools.tzupdater.ExternalModule.compileToJSRBinary(ExternalModule.java:153)
    at com.sun.tools.tzupdater.TimezoneUpdater.run(TimezoneUpdater.java:230)
    at com.sun.tools.tzupdater.TimezoneUpdater.main(TimezoneUpdater.java:634)
Caused by: tools.tzdb.DateTimeException: Invalid value for SecondOfDay value: 90000
    at tools.tzdb.ChronoField.checkValidValue(ChronoField.java:173)
    at tools.tzdb.LocalTime.ofSecondOfDay(LocalTime.java:210)
    at tools.tzdb.TzdbZoneRulesCompiler.parseMonthDayTime(TzdbZoneRulesCompiler.java:475)
    at tools.tzdb.TzdbZoneRulesCompiler.parseRuleLine(TzdbZoneRulesCompiler.java:399)
    at tools.tzdb.TzdbZoneRulesCompiler.parseFile(TzdbZoneRulesCompiler.java:354)
    ... 5 more


This is solved by using:

sudo java -jar tzupdater.jar -l https://web.cs.ucla.edu/~eggert/tz/release/2019a/tzdata2019a-rearguard.tar.gz

https://bugs.openjdk.java.net/browse/JDK-8213085

11 May 2018

ag Cheat Sheet

A hidden gem, replace of grep:

Find exact string (not regexp)
ag -Q "forEach(i -> map.put(i,"

Find files containing "foo", and print the line matches in context:
ag foo

 Find files containing "foo", but only list the filenames:
ag -l foo

 Find files containing "FOO" case-insensitively, and print only the match, rather than the whole line:
ag -i -o FOO

 Find "foo" in files with a name matching "bar":
ag foo -G bar
ag "perfil-usuario" -G java

Find files whose contents match a regular expression:
(double quotes are better, in particular when there is a double or single quote inside of regexp)
ag "^ba(r|z)$"

Find files with a name matching "foo":
ag -g foo

ag hola$

-z --search-zip: Search contents of compressed files. Currently, gz and xz are supported. This option requires that ag is built with lzma and zlib.


http://conqueringthecommandline.com/book/ack_ag

https://www.mankier.com/1/ag


13 April 2018

inspectIT

Interesting Open Source APM: https://github.com/inspectIT

To run it on Mac is necessary:

WLS:
startWebLogic.sh

-javaagent:/Applications/inspectIT/agent/inspectit-agent.jar -Dinspectit.repository=localhost:9070 -Dinspectit.agent.name=test1


inspectIT Server: (nothing, just run it)
/Applications/inspectIT/CMR/startup.sh

InspectIT Client:
(eclipse)
/Applications/inspectIT/inspectit/run.sh
(some modifications are necessary)

$ cat /Applications/inspectIT/inspectit/run.sh
xattr -r -d com.apple.quarantine inspectIT.app
./inspectIT.app/Contents/MacOS/inspectIT -vm /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin -data /Users/German/tmp/workspace-inspectit -debug

Issue:

I hit a bug when using a JDK newer than 1.8.0_131 (on Mac)

https://inspectit-performance.atlassian.net/browse/INSPECTIT-2560?focusedCommentId=33865&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-33865



TODO:

- https://blog.novatec-gmbh.de/can-opentracing-scene-benefit-new-tracer-implementations/


25 August 2017

Sed cheat sheet

Sometimes we need to clean-up a file (ie: log prod file).

(or gsed for gnu-sed in macosx

* delete a match and backup of original file:

sed -i.bak '/<ConnectionEnv.cleanup, jconn=oracle.jdbc.driver.T4CConnection/d' ./infile

sed -i.bak '/INFO: true/d' ./infile

gsed -i.bak '/INFORMACIÓN: true> /d' ./infile


* delete two lines and the match string

gsed -i -e '/match1/,+2d'

* delete one line and the match string

gsed -i -e '/OPTIONS/,+1d' *uml*.puml

* execute more than one command in sed (use -e flag)

sed -i -e 's/File//g' -e 's/MINvac.pdb//g'

* recursive find and replace

find . -type f -print0 | xargs -0 sed -i 's/MYSQL_USER/MYSQL_ROOT_USER/g'

* no lookups by default

use: -E o -r ( -E, -r, --regexp-extended )


14 October 2015

WebLogic Server 10.3.6 for Mac OSX

If you are trying to install WLS 10.3.6 in OS X Yosemite 10.10.5 then a couple error you may face:

1) Download generic installer; if you choose cocoa mac installer, then you'll get:

(or using system property: -Dos.name=unix  )
(or -Dos.name="OS X")
Exception in thread "chmodFile" java.lang.Error: unix is not a supported OS platform.
    at java.lang.UNIXProcess$Platform.get(UNIXProcess.java:164)
    at java.lang.UNIXProcess.(UNIXProcess.java:168)
    at java.lang.ProcessImpl.start(ProcessImpl.java:130)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    at java.lang.Runtime.exec(Runtime.java:620)
    at java.lang.Runtime.exec(Runtime.java:485)
    at com.bea.plateng.common.util.Chmod.chmod(Chmod.java:71)
    at com.bea.plateng.common.util.Chmod.wildcardChmod(Chmod.java:110)
    at com.bea.plateng.common.util.Chmod.wildcardChmod(Chmod.java:104)
    at com.bea.plateng.wizard.installer.utils.chmod.ChmodHelper.chmodFromDefinition(ChmodHelper.java:98)
    at com.bea.plateng.wizard.installer.silent.tasks.ChmodFileTask.execute(ChmodFileTask.java:80)
    at com.bea.plateng.wizard.installer.silent.tasks.ChmodFileTask.run(ChmodFileTask.java:75)
    at java.lang.Thread.run(Thread.java:745)


2) If you receive the message "Insufficient disk space!" , although you know you have enough space, the use the following parameter:

 i.e.:

java -Dspace.detection=false -Xmx1024m -jar wls1036_generic.jar


(also, a small installer window could appear, and it is from the same reason).

Blog Archive

Disclaimer

Qux