Skip to content

Instantly share code, notes, and snippets.

Avatar

Nabil Redmann BananaAcid

View GitHub Profile
@BananaAcid
BananaAcid / README.md
Last active Sep 21, 2016
Example: basic TCP messaging
View README.md

A simple TCP-server setup.

[Using Node-RED]

Easy to test your clients used. Like Telnet and others.

Contains:

  • Server
  • Client
  • Proxy (for clients not terminating their messages with \n)
@BananaAcid
BananaAcid / autoshrink.js
Last active Oct 20, 2016 — forked from andrewbranch/autoshrink.js
Responds to window resize events. Max font size taken from initial font size (specify with CSS). [no modifications, just forked to extend the example.]
View autoshrink.js
(function($) {
function getTextWidth($element) {
var tester = $("<div/>").text($element.text())
.css({ "position": "absolute", "float": "left", "white-space": "nowrap", "visibility": "hidden", "font": $element.css("font"), "text-transform": $element.css("text-transform"), "letter-spacing": $element.css("letter-spacing") })
.appendTo($element.parent()),
width = tester.innerWidth();
tester.remove();
return width;
}
@BananaAcid
BananaAcid / .htaccess
Created Jan 8, 2017
Subdomain mapping within htaccess
View .htaccess
# Nabil Redmann 2017
#
# assumed: this htaccess is within htdocs/
#
# dev.* mapping to ./dev/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
@BananaAcid
BananaAcid / result
Last active Aug 17, 2017
koa-better-router subdirs + includes
View result
// ˫ routes ˫ index.js
GET /
// ˫ routes ˫ api1 ˫ index.js
GET /api/v1/
GET /api/v1/x
// ˫ routes ˫ api1 ˫ a.js
PUT /api/v1/a/obj/:one/:two
View pug_mixins_PhpStorm_problem.pug
//-
PhpStorm 2018.1 shows multiple errors and is not able to handle this fully valid PUG mixin
mixin test(param1, param2 = "test", optionalParam3)
- var xOptionalParam3 = optionalParam3 || "is none";
<!{param1}> !{param2} => !{xOptionalParam3} </!{param1}>
@BananaAcid
BananaAcid / index.html
Last active May 24, 2018
cookie info - no jQuery needed - all-in-one drop in code
View index.html
<!--
NO jQuery needed
test: https://jsfiddle.net/BananaAcid/rz3h5kmx/
see the message later again, paste this as url into the nav bar of your browser:
javascript:document.getElementById('cookieMsgContainer').style.display='block';
-->
@BananaAcid
BananaAcid / index.html
Last active May 24, 2018
cookie msg - infoo popup in js/html only + jquery
View index.html
<!-- inlcude/reference jquery -->
<style>
#cookieMsgContainer {display: none;}
#cookieMsg + section {transition: .5s ease-out; z-index: 2000;}
#cookieMsg:not(:checked) + section {transform: translateY(100%);}
</style>
<input type="checkbox" checked id="cookieMsg" style="display: none" />
<section id="cookieMsgContainer" style="position: fixed; bottom: 0; left: 0; background: black; text-align: left; color: white; width: 100vw; padding: 25px; font-family: sans-serif;">
@BananaAcid
BananaAcid / RGB-blink-n-toggle.ino
Last active May 24, 2018
Toggle 3 leds (or an RGB) - mode 0 is switching pins 1-3 (Arduino / ESP32 / ESP8266)
View RGB-blink-n-toggle.ino
@BananaAcid
BananaAcid / index.php
Last active May 27, 2018
cookie msg (php) + analytics opt-out (js) - no message in html if it was seen allready - tracking by opt out - no jquery
View index.php
<script type="text/javascript">
// Use the same ID as the property on the site
var gaProperty = 'UA-XXXXXXXX-1';
// Disable tracking if the opt-out cookie exists.
var disableStr='ga-disable-'+gaProperty;if(document.cookie.indexOf(disableStr + '=true') > -1) { window[disableStr] = true; }
// Opt-out function
function gaOptout() { document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2100 23:59:59 UTC; path=/; domain=' + document.location.hostname; window[disableStr] = true; }
// check opt-out
if (window[disableStr] !== true) {
@BananaAcid
BananaAcid / D: ˫ GitHub Clients ˫ xampp-vhost.Template_Basic_Project-Pug_Less.conf
Last active May 31, 2018
apache / xampp load configs from given dir for multiple projects (for OSX / Linux as well)
View D: ˫ GitHub Clients ˫ xampp-vhost.Template_Basic_Project-Pug_Less.conf
# do not forget to add the server name to your /etc/hosts file
# 127.0.0.1 project1.test.local
#
# Note: 1. Test the config before reloading `httpd -t` or `apachectl configtest`!
# 2. You need to soft reload the config or restart apache.
# `apachectl -k graceful` or `httpd -k graceful` (idled threads will use the new config)
# `sudo /etc/init.d/apache2 reload` or `sudo service apache2 reload` (kills threads)
#
<VirtualHost project1.test.local:80>
ServerName project1.test.local