Spickzettel

Mein persönlicher Spickzettel: so Zeugs, das ich immer wieder vergesse…

PostgreSQL

Zugriff über psql locally:

rschumm@kassandra:~$ psql --username=find --host=localhost

Metadaten über psql:

\c explic   connect (to DB explic)
\l          List of Databases
\dx         Display extensions
\d          Display tables etc. 
\du         Display User 

Grant-Things:

ALTER USER find SUPERUSER; 
create extension postgis; 

grant all privileges on table video to "userJaJa";

grant all privileges on sequence video_id_seq to "userJaJa";

Abkürzung:

psql -d explic -c "select experiment from video";

macOS

Auch der Mac hat seinen Bildschirm-Sperrer, gut versteckt:

ctrl-shift-power

iOS

Beim Umstieg von iOS auf Android iMessage ausschalten. So kommen Nachrichten auch von iMessage-Users wieder an.

Web

Apache Benchmarking Tool ab

Umleitungen etc:

Redirect /essen https://docs.google.com/document/d/1KpvxW5Pn5wtA_d7zTkBPHpS4r_dpPEFsTyfFCLy7o64
RedirectMatch .*/find/(.*)$ https://schufi.herokuapp.com/find/$1
RedirectMatch .*/find$ https://schufi.herokuapp.com/find
RedirectMatch .*/qr/(.*)$ https://schufi.herokuapp.com/qr/$1
#RedirectMatch 301 (.*)\.html$ http://www.domain.com$1.php
ErrorDocument 404 /error.html

Deployment auf Hostpoint

Hostpoint unterstützt Zugriff auf sftp mit ssh-Zertifikaten.

Deployment via rsync:

#(verbose, recursive, preserving dates and times, zip)
rsync -vrtz _site/* xxx@xxx.web.hostpoint.ch:~/www/public_html/schumm/

(host siehe Notizen)

git

git remote -v
git remote remove origin
git remote add origin ssh.... / https... 

Linux

rpm on ubuntu:

alien -i bla.rpm

distribution:

cat /etc/*release*

Kleinzeugs Netzwerk:

nmap -p 5000 172.30.1.1
[luna:~] rschumm% sudo nmap -PR 192.168.1.0/24 -sn

alternatives

update-alternatives --list java
update-alternatives --config java
update-alternatives --install ... 
update-java-alternatives -l | -s 

quick and dirty manual install of JDK 11 on Ubuntu 18.04

% sudo sh -c 'for bin in /usr/lib/jvm/jdk-11.0.2+9/bin/*; do update-alternatives --install /usr/bin/$(basename $bin) $(basename $bin) $bin 100; done'

% sudo sh -c 'for bin in /usr/lib/jvm/jdk-11.0.2+9/bin/*; do update-alternatives --set $(basename $bin) $bin; done'

then choose the installation with update-alternatives --config java

tcsh

set path = ($path $HOME/.gem/ruby/2.3.0/bin/ .)
setenv  M2_HOME /Applications/maven/apache-maven-3.x.x
alias mvn $M2_HOME/bin/mvn

bash

export PATH="/home/rschumm/minis/minishift-1.18.0-linux-amd64/:$PATH"
alias schummsync='rsync -vrtz _site/* xxx@xxx.xxx.hostpoint.ch:~/www/public_html/schumm/'
#!/bin/bash

java Generator.java
#(needs JDK 11)

for file in $(find . -iname '*.yml'); do 
     echo "$file"
     #ls -l "$file"
     oc create -f "$file"
done

Java

shebang support

#!/usr/bin/java --source 11
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hallo Java shebang");
    }
}

find files

File directory = new File("rschumm/");

Optional<Path> foundFile = Files.find(
        directory.toPath(), 
        3,
        (path, basicFileAttributes) -> path.toFile().getName().matches("blabla.*.yml")
        )
.sorted(Comparator.comparing(Path::getFileName))
.findFirst(); 

quick and dirty sort:

List<Auto> sortiert = agenturenListe.stream()
        .sorted(Comparator.comparing(Auto::getType).reversed())
        .sorted(Comparator.comparing(Auto::getPs))
        .collect(Collectors.toList());

quick File as String:

String s = Files.lines(Paths.get("jekyll.md")).collect(Collectors.joining()); 

very quick and dirty templating find- and replace

String template = Files.lines(Paths.get("../nfs/pv-nfs.yml")).collect(Collectors.joining("\n")); 
String out = template.replaceAll("0001", ""+i).replaceAll("general", "general/"+i); 	
Files.write(Paths.get("pv"+i+".yml"), out.getBytes(), StandardOpenOption.CREATE); 

DotNet

create new application:

dotnet new web 
dotnet build 
dotnet run 

Windows

after booting into a Linux, the Windows clock will be screwed up. To fix it, add following Registry:

Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
DWORD (32 bit)
RealTimeIsUniversal
Value: 1 

spick


zurück zum Seitenanfang