Spickzettel

Mein persönlicher Spickzettel: so Zeugs, das ich immer wieder vergesse und nicht in die anderen Spickzettel passen…

PostgreSQL

Zugriff über psql locally:

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

Schnell alles neu:

sudo su - postgres
psql

create user holzdemo password 'blablabla';
create database holz with owner holzdemo; 
alter user holzdemo password 'blablabla'; 

hard stuff:

yum (etc.) install @postgresql 
sudo rm -rf /var/lib/pgsql/data
sudo postgresql-setup initdb

sudo systemctl restart postgresql

jdbc

jdbc:postgresql://localhost:5432/holz?sslmode=disable
org.postgresql.Driver

Metadaten über psql:

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

Abkürzung:

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

config files:

IP listen_address Zugriff von überall * zulassen, wenn nötig:

vi /etc/postgresql/10/main/postgresql.conf  
vi /etc/postgresql/10/main/pg_hba.conf 
vi /var/lib/pgsql/data/.... 
systemctl status postgres (to find out where the files are)




host all all 0.0.0.0/0 trust

als sysdamin:

sudo systemctl restart postgresql.service

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";

Geo

Breite - lat - Nord-Süd (47°…)
Länge - long - West-Ost (8°…)
meistens lat/long, bei PostGIS verkehrt.

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.

Design etc.

Bilder: Unsplash

Webserver

Apache Benchmarking Tool ab quick and dirty:

ab -k -c 30 -n 200 https://www.schumm.ch

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... 
git push -u ... (--set-upstream)
git push --tags ... --all 
git remote set-url origin (new url...)

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); 

Framework-Blueprints

Rest-Client UniRest - super easy Rest-Client
Rest-assured used by Quarkus
Database Migration flyway
Spark Java WebApp Framework
HTML Parser jsoup

JavaScript

Quick and dirty Json-Load:

 <script src="https://code.jquery.com/jquery-3.3.1.min.js"
  integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
  crossorigin="anonymous"></script>

///... 

<script>

function load(){
  $.ajax({
    url: '/hallo/logbuch',
    type: 'GET',
    success: function (response) {
        var trHTML = '';
        $.each(response, function (i, item) {
            trHTML += '<tr><th scope="row">' + item.id + '</th><td>' + item.text + '</td></tr>';
        });
        $('#nt').empty();
        $('#nt').append(trHTML);
    }
  });
}

load(); 

</script>

Quick and dirty Intercooler-Stuff:


<script src="https://intercoolerjs.org/release/intercooler-1.2.2.js"></script>

...  


<form>
    <div class="input-group">
      <input type="text" class="form-control" placeholder="Nachricht an Rémy" aria-label="Input group example" aria-describedby="btnGroupAddon" name="textinput">
      <button type="submit" class="btn btn-primary btn-default" ic-post-to="/hallo/sali" ic-target="#nachricht" ic-on-success="load();">
        Click Me!
      </button>
    </div>
</form>

and Quarkus Backend

@POST
@Transactional
@Produces(MediaType.TEXT_PLAIN)
@Path("/sali")
public String saliPost(@FormParam("textinput") String name) {
    Message message = new Message();
    message.text = name;
    message.date = LocalDate.now();
    message.persist();
    return service.sagHallo(name);
}

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 

zurück zum Seitenanfang