Skip to content

Instantly share code, notes, and snippets.

View superjojo140's full-sized avatar

Johannes Schnirring superjojo140

View GitHub Profile
@superjojo140
superjojo140 / chroot_arch.md
Created December 13, 2019 20:13
Chroot into installed arch linux with arch installer usb stick

Start from Archlinux USB Stick

Load german keyboard layout

$ loadkeys de

Enable Wifi (optional but usefull)

$ wifi-menu
@superjojo140
superjojo140 / server.js
Last active February 10, 2020 14:57
Serve compiled angular files
const express = require('express');
const app = express();
// Serve the static files from the angular build
app.use(express.static(`${__dirname}/dist/PROJECT_NAME`));
app.get('/*',(req,res) => {
res.sendFile(`${__dirname}/dist/PROJECT_NAME/index.html`);
});
@superjojo140
superjojo140 / content_type_http.md
Last active March 5, 2020 16:37
Content Type in HTTP Requests

The Content-Type header is used to specify how the data in the body of a HTTP request or response is formatted.

Possible Values

There are really a lot of possible values. The most common values for HTTP Requests are listed here. For a more completely list see MDN - MIME types

application/json

@superjojo140
superjojo140 / promise.js
Last active March 22, 2020 16:48
JS returning a promise - Syntax
function myCoolPromise() {
return new Promise(function (resolve, reject) {
//do some async things
const data = "this_is_so_async";
//if successfull
resolve(data);
//if not
reject("error");
});
}
@superjojo140
superjojo140 / captcha.js
Created April 2, 2020 19:31
Captcha Solutions
let dummyInput = [
"Was ergibt 28 plus 9?",
"Bitte addieren Sie 6 und 38.",
"Bitte geben Sie den ersten, vierten und fünften Buchstaben von 'JEWELL' ein.",
"Wie viele Buchstaben hat MADRID?",
"Bitte subtrahieren Sie 22 von 3.",
"Zählen Sie die Buchstaben: THIN",
"Bitte ziehen Sie 2 von 9 ab.",
"Was ergibt 11 minus 36?"
]
@superjojo140
superjojo140 / workflow.md
Last active April 24, 2020 12:35
Microservices workflow

Microservices - Deployment on heroku

Setup

Enviroment Variables

Use enviroment variables for ports and urls!

@superjojo140
superjojo140 / cors-fetch-express.md
Last active June 14, 2020 14:59
CORS fetch-request with credentials

This sounds easy but... it isn't!

Client side

Use this fetch options:

fetch('superUnsecureCorsUrl',{
   credentials: 'include'
})
@superjojo140
superjojo140 / mysql_cheatsheet.md
Last active September 9, 2020 09:53
Mysql Cheatsheet

Use mysql CLI

mysql --user=my_username --password

Create a new user

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
@superjojo140
superjojo140 / chmod_basics.md
Last active September 10, 2020 09:53
chmod for dummies

Using chmod...

Examples

chmod a+rwx path/to/file    # Everybody can read, write and execute the file
chmod u+rwx path/to/file    # The owner of the file can read, write and execute the file
chmod o-wx path/to/file     # All other users can no longer write or execute the file
chmod ug+x path/to/file     # The owner and the group can now execute the file
@superjojo140
superjojo140 / child_process_node.js
Created December 16, 2020 14:02
[Node] Executes a shell command as Promise.
import * as child_process from 'child_process'
/**
* Executes a shell command and return it as a Promise.
*/
export function exec(cmd: string): Promise<string> {
return new Promise((resolve, reject) => {
child_process.exec(cmd, (error, stdout, stderr) => {
if (error) {
reject({ error: error, stderr: stderr });