Skip to content

Instantly share code, notes, and snippets.

View BananaAcid's full-sized avatar

Nabil Redmann BananaAcid

View GitHub Profile
@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 / .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
}
@BananaAcid
BananaAcid / install-nodejs-docker.sh
Last active October 4, 2018 00:43
nvm nodejs and modules apt-get ubuntu for all users
# install
#
# $ curl -o- https://gist.githubusercontent.com/BananaAcid/93c319ada91c30ed904e9bc93d324a19/raw/install-nodejs-docker.sh | bash
#
# installing:
# 1. git,
# 2. nvm for all users centralized,
# 3. nodejs through nvm,
# 4. nodejs packages thorugh npm
#
@BananaAcid
BananaAcid / index.php
Created October 29, 2018 02:23
simple basic auth for gateway index.php
<?php
/*
in case you got a server config, that routes all calls through this index.php
will not protect files, except you check the header with the server and re route to this script for validation.
... used this on IIS server. Apache, Nginx, Lightttpd, ... have simple onboard means.
*/
// simple auth
@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();
#!/bin/sh
':' //; exec "`command -v node`" "--experimental-modules" "--no-warnings" "$0" "$@"
import fsOrig from 'fs'; const fs = fsOrig.promises;
import path from 'path';
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
@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 / precompile pug with normal php - pug file src
Last active April 19, 2019 21:54
Working with PUG (Jade) and PHP to generate HTML with PHP (Pug2PHP)
//-
using the PUGjs pre-compiler, ($ npm i -g pug )
HTML with included PHP will be generated as .php -
then served using the webserver as any other PHP file
note:
lines starting with `<` will be handled as if they were prefixed
with `|` (pipe) == that is: as text.
indented lines are not inheriting the text-content-mode.
/*
* User: BananaAcid
* Date: 09.02.2011
* Type: Commandline
* Note: Form data extraction to csv from email (*.eml) files
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;