Skip to content

Instantly share code, notes, and snippets.

View MaBecker's full-sized avatar

Mark Becker MaBecker

  • SBIT GmbH
  • Germany, Rauenberg
View GitHub Profile
@MaBecker
MaBecker / ApacheHTTPSConfig.md
Created April 4, 2020 19:57 — forked from nrollr/ApacheHTTPSConfig.md
Enable SSL in Apache for 'localhost' (OSX, El Capitan)

Enable SSL in Apache (OSX)

The following will guide you through the process of enabling SSL on a Apache webserver

  • The instructions have been verified with OSX El Capitan (10.11.2) running Apache 2.4.16
  • The instructions assume you already have a basic Apache configuration enabled on OSX, if this is not the case feel free to consult Gist: "Enable Apache HTTP server (OSX)"

Apache SSL Configuration

Create a directory within /etc/apache2/ using Terminal.app: sudo mkdir /etc/apache2/ssl
Next, generate two host keys:

@MaBecker
MaBecker / M5Stack_Espruino.js
Created March 12, 2020 16:11 — forked from vshymanskyy/M5Stack_Espruino.js
M5Stack Espruino initialization example
/*
Also, need to change in ILI9341pal.js:
var LCD_WIDTH = 320;
var LCD_HEIGHT = 240;
*/
BTN1 = D39
BTN2 = D38
BTN3 = D37
SPKR = D25
@MaBecker
MaBecker / test_thick_lines.js
Created December 5, 2019 19:52
extend line with thickness
function draw_line(x1,y1,x2,y2,thickness){
var p = [];
var angle = Math.atan2(y2-y1,x2-x1);
cosP = Math.cos(angle+Math.PI/2);
cosM = Math.cos(angle-Math.PI/2);
sinP = Math.sin(angle+Math.PI/2);
sinM = Math.sin(angle-Math.PI/2);
p[0] = (x1 + thickness*cosP +0.5)|0;
p[1] = (y1 + thickness*sinP +0.5)|0;
@MaBecker
MaBecker / complex_fillPoly.js
Created December 1, 2019 13:44
Sample for complex paths that are not rendered as expected in 2v04 build 250
var flake1 = [114,120,126,120,126,150,150,168,144,180,126,168,126,192,114,192,114,168,96,180,90,168,114,150,114,120];
var flake2 = [114,20,126,20,126,50,150,68,144,80,126,68,126,92,114,92,114,68,96,80,90,68,114,50,114,20];
g.clear();
g.drawPoly(flake1);
g.fillPoly(flake2);
@MaBecker
MaBecker / welcome.js
Created November 30, 2019 09:17
MySample
g.clear();
g.setFont("6x8",3);
g.setColor(0x07E0);
g.drawString("Welcome\nto the\nBangle.js\nEmulator",20,60);
@MaBecker
MaBecker / test_case_module_sbus.js
Created December 11, 2018 05:42
Special char in modules cause error when using require to load from storage
s = require('Storage');
s.write('SBUS',`exports.connect = function(uart, rxPin) {
var sbus = {
channels : new Uint16Array(18),
frameLoss : false,
failSafe : false
};
uart.setup(100000, {rx:rxPin, parity:"e",stopbits:2});
uart.removeAllListeners();
@MaBecker
MaBecker / using_font_from_storage.js
Created December 5, 2018 19:28
Espruino: store FontHaxorNarrow7x17 in storage and print single and double size without using any RAM for font and widths
var s = require('Storage');
/* use this code only once to save font and widths in Storage
s.write('fHN7x17',atob("AAAAAAAAAAAB/MAAAJAAcAAAABIADgAAAAACAAngB4AeeAHgB5AAQAAAAHEAREAiID/4CIgERAEcAAAAwMCQgEmAGTADJAISBgYAAAAHgHQgRBAjCA5kAAwAPQAAAkABwAAAAAfADBgIAggAgAACACCAIDBgB8AAAAEgAGAA/AAYABIAAAABAACAAEAB/AAQAAgABAAAAAAkABwAAAAgABAACAAEAAIAAAAADAAGAAAAAIABgAMABgAMABgAAAAB/AEBAQxAjCAgIA/gAAACAAIAAgAB/8AAACBwIMgQhAiCA4EAAACAgIAgQhAhCA94AAAAGAA0ACIAYQB/8ABAAAAPhARBAiCBEECHwAAAH/ARBAiCBEEBHwAAAIAAQPAhgBMADgAAAAHvAQhAhCBCEB7wAAAHhAQhAhCBCEB/wAAADDAGGAAAAYUAwwAAAAQABQAEQAQQBAQAAABEACIAEQAIgARAAiAAAAICAIIAIgAKAAIAAAAIAAgABBMCEAEQAHAAAAAf8BAECOIEiQJEgP4AAAAP8BiAEEAGIAD/AAAB/8CEIEIQIQgPeAAAA/4CAIEAQIAgICAAAB/8CAIEAQEBAH8AAAB/8CEIEIQIQgQBAAAB/8CIAEQAIgAQAAAAA/4CAIEAQIQgI+AAAB/8AEAAIAAQAf/AAABAED/4EAQAAAQGAgCBAECAIH/gAAAf/ABAAFAAxgGAwAAAf/AACAAEAAIAAQAAAf/AYAAMABgAH/wAAAf/AYAAMAAGAH/wAAAP+AgCBAECAID/gAAAf/AhABCACEADwAAAAP+AgCBAUCAQD/QAAAf/AhABCACHADxwAAAOCAiCBCECCICDgAAAQAAgAB/8CAAEAAAAAf+AACAAEAAIH/gAAAfAAB4AAMAHgHwAAAAf8
/*
function queue
based on
https://stackoverflow.com/questions/17528749/semaphore-like-queue-in-javascript/17528961#17528961
*/
@MaBecker
MaBecker / function: jswrap_wifi_restore
Last active May 2, 2018 11:31
jswrap_wifi_save.c
void jswrap_wifi_restore(void) {
DBG("Wifi.restore\n");
JsVar *name = jsvNewFromString(WIFI_CONFIG_STORAGE_NAME);
JsVar *o = jswrap_storage_readJSON(name);
if (!o) { // no data
jsvUnLock2(name,o);
return;
}
@MaBecker
MaBecker / jswrap_wifi_save.c
Last active May 2, 2018 11:29
function: jswrap_wifi_save.c
void jswrap_wifi_save(JsVar *what) {
DBGV("> Wifi.save\n");
JsVar *o = jsvNewObject();
if (!o) return;
if (jsvIsString(what) && jsvIsStringEqual(what, "clear")) {
JsVar *name = jsvNewFromString(WIFI_CONFIG_STORAGE_NAME);
jswrap_storage_erase(name);
jsvUnLock(name);
DBG("Wifi.save(clear)\n");