echo <<<EOLThis is outputAnd this is a new lineblah blah blah and this following $var will actually say Howdy as well and now the output endsEOL;

HTML Day2 JS with jQuery

Als erstes fügen wir jQuery von einem Externen CDN ein ein CDN ist ein Content Delivery Network und liefert häufig verwendete Dateien und Bilder aus. Wir geben dazu jQuery CDN in Google ein und klicken auf die slim minified version. Hier wird uns der folgende Code gezeigt: Als Nächstes erstellen wir die document ready Funktion Weiterlesen…

HTML Basics Day1

Wir fangen an mit dem Seitenaufbau einer HTML Seite es gibt den Kopf <head> und den <body> im Kopf ist der Titel Favicon Stylesheets und JavaScripts vermerkt wärend im body der klassische Seiten Aufbau mit Überschriften <h1> <h2> <h3> … und den Paragraphen <p> nahezu jeder TAG der aufgemacht wird muss auch geschlossen werden mit Weiterlesen…

Node JS Socket.IO

//—————- HTTPS Server —————————————- var fs = require(‘fs’); var https = require(‘https’); var express = require(‘express’); var app = express(); var options = { key: fs.readFileSync(‘/etc/letsencrypt/live/hg-system.com/privkey.pem’), cert: fs.readFileSync(‘/etc/letsencrypt/live/hg-system.com/fullchain.pem’) }; var server = https.createServer(options, app); var port = 3000; server.listen(port, function() { log(‘listening on *:’ + port); }); app.use(express.static(‘public’)); app.get(‘/’, (req, res) => { res.sendFile(‘index.html’); }); Weiterlesen…

NodeJS DB Connection

//—————- SQL Server —————————————- var mysql = require(‘mysql’); var db = mysql.createConnection({ host : ‘localhost’, user : ‘dbuser’, password : ‘dbpass’, database: ‘dbname’ }); db.connect(); db.query(‘SELECT 1 + 1 AS solution‘, function(err, rows, fields) { if (err) throw err; console.log(‘The solution is: ‘, rows[0].solution); }); process.on(‘exit’, function (){ db.end(); console.log(‘Goodbye!’); });

NodeJS HTTP/HTTPS – Server (with Let’s Encrypt SSL Cert)

Basic HTTP-Server var fs = require(‘fs’); var http = require(‘http’); var express = require(‘express’); var app = express(); var server = http.createServer(app); var port = 3000; server.listen(port, function() { log(‘listening on *:’ + port); }); app.use(express.static(‘public’)); app.get(‘/’, (req, res) => { res.sendFile(‘index.html’); }); Extend your Server to HTTPS with Free SSL Cert var fs = Weiterlesen…

Usefull JavaScript’s & jQuery Code

#1 create a prototype function for e.g. a replaceAll function for strings: String.prototype.replaceAll = function(search, replacement) { var target = this; return target.replace(new RegExp(search, ‘g’), replacement); }; Useage: var test1, test2; var str = “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa” test = str .replaceAll(“a”, “c”) “cccccccccccccccccccccccccccccc” //combineable test2 = str.replace(“a”, “b”) .replaceAll(“a”, “c”) “bccccccccccccccccccccccccccccc” jQuery Example: $(“body”).find(“div”).each(function() { $(this).setRandomColor(); }); Weiterlesen…

Usefull Python Scripts

Remove lines from File containing: bad_words import sysbad_words = [‘one bad word’,’ another bad word’]scriptname = sys.argv[0]for _old in sys.argv:if _old == scriptname:continue_new = _old + ‘_filter_x.log’print(“processing ‘” + _old + “‘\n\noutput: ” + _new + “\n\n\n\n”)with open(_old) as oldfile, open(_new, ‘w’) as newfile:for line in oldfile:if any(bad_word in line for bad_word in bad_words):newfile.write(line) Combine Weiterlesen…