Skip to content

Instantly share code, notes, and snippets.

View ttristan's full-sized avatar

Tristan Schlötel ttristan

  • Düsseldorf
View GitHub Profile
// JS
function request() {
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE ) {
console.log("xhr response", xhr.response)
if (xhr.status == 200) { // success
}
<?php
// open connection
$con = mysqli_connect('host', 'user', 'pass', 'db');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}
// get post data
$data = json_decode(file_get_contents('php://input'), true);
/* lightbox css */
.lightbox {
display: none;
position: fixed;
z-index: 999;
width: 100%;
height: 100%;
text-align: center;
top: 0;
Client
# create public key
ssh-keygen
# copy public key
pbcopy < ~/.ssh/id_rsa.pub
Server:
#install openssh
sudo apt install openssh-server
const GoogleMapsLoader = require('google-maps');
GoogleMapsLoader.KEY = '<KEY>';
GoogleMapsLoader.LANGUAGE = 'en';
GoogleMapsLoader.REGION = 'DE';
GoogleMapsLoader.VERSION = '1';
GoogleMapsLoader.LIBRARIES = ['geometry', 'places'];
// init the map
GoogleMapsLoader.load(function(google) {
const id = document.getElementById('googleMap');
// HTML
<button data-tooltip="example">Example</button>
// CSS
[data-tooltip] {
position: relative;
z-index: 2;
cursor: pointer;
}
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title>Performing Maintenance</title>
<style type="text/css">
body {
text-align: center;
const express = require("express");
const bodyParser = require("body-parser");
const path = require("path");
const cors = require("cors");
// Initialize http server
const app = express();
// setup
app.use(express.static(path.resolve(__dirname, "../build")));
const express = require("express");
const bodyParser = require("body-parser");
const path = require("path");
const cors = require("cors");
// Initialize http server
const app = express();
// setup
app.use(express.static(path.resolve(__dirname, "../build")));
exports.fetchGet = ({ endpoint }) => {
return new Promise((resolve, reject) => {
console.log("Requesting:", endpoint);
require("node-fetch")(endpoint)
.then(response => {
if (response.status === 200) return response.json();
else
return reject({
error: {