Skip to content

Instantly share code, notes, and snippets.

View BananaAcid's full-sized avatar

Nabil Redmann BananaAcid

View GitHub Profile
@BananaAcid
BananaAcid / index.html
Last active May 24, 2018 15:56
cookie msg - infoo popup in js/html only + jquery
<!-- 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 / index.php
Last active May 27, 2018 11:08
cookie msg (php) + analytics opt-out (js) - no message in html if it was seen allready - tracking by opt out - no jquery
<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 / index.html
Last active May 24, 2018 15:28
cookie info - no jQuery needed - all-in-one drop in code
<!--
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 / D: ˫ GitHub Clients ˫ xampp-vhost.Template_Basic_Project-Pug_Less.conf
Last active May 31, 2018 14:55
apache / xampp load configs from given dir for multiple projects (for OSX / Linux as well)
# 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
@BananaAcid
BananaAcid / install_nvm_and_latest_node.sh
Created July 12, 2018 01:48
Installs NVM and latest nodeJS (one liner)
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash && export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && nvm install ` nvm ls-remote | tail -1`
@BananaAcid
BananaAcid / electron_paths_compared_win_osx.txt
Last active July 14, 2023 08:20
electron paths compared - win + osx
Test App:
https://github.com/BananaAcid/Simple-Electron-Kiosk/blob/master/PATH%20RESULTS
------------------------------------------------------------------------------------
electron paths
__dirname refers to index.mjs (parallel to loader.babel.js)
Be aware of globally installed modules - for unpacked.
@BananaAcid
BananaAcid / nodejs_is_url_ok.js
Last active August 9, 2018 00:07
check if url is ok - my awaitable async solution
let options = {
host: 'eposthub.de',
//port: 80, optional
//path: '/' optional
}
const http = require('http');
let isOk = await new Promise(resolve => {
http.request({method:'HEAD', host:options.host, port:options.port, path: options.path}, r =>
@BananaAcid
BananaAcid / murmurhash.pipe.mjs
Last active February 10, 2019 04:04
super fast file hashing, as ESM, all awaitable (parallel, no thread blocking)
// npm install murmurhash-native fs-extra -P
import path from 'path';
/* experimental (node v10, v11): */
import fsOrig from 'fs'; const fs = fsOrig.promises;
// import fs from 'fs-extra'; // awaitable fs for node < v10
import murmur from 'murmurhash-native/stream'; // super fast HASHING ! https://github.com/royaltm/node-murmurhash-native
const sPath = process.pwd();
@BananaAcid
BananaAcid / .babelrc
Last active August 27, 2018 19:22
murmurhash-native with electron & babel (anything works, but murmurhash)
{
"presets": [
"electron"
]
}
@BananaAcid
BananaAcid / url-exists-head-es6.node.js
Last active August 31, 2018 16:38
url exists in node - awaitable async ES6 solution, doing a HEAD request
//** https://stackoverflow.com/questions/26007187/node-js-check-if-a-remote-url-exists/51757188#51757188
// options for the http request
let options = {
host: 'google.de',
//port: 80, optional
//path: '/' optional
}