Skip to content

Instantly share code, notes, and snippets.

View AndiSHFR's full-sized avatar
💭
Designing and Coding...

Andreas Schaefer AndiSHFR

💭
Designing and Coding...
View GitHub Profile
@AndiSHFR
AndiSHFR / md5.js
Created March 24, 2016 13:24
Create MD5 hash in javascript
var MD5 = function(s) {
function L(k,d) { return(k<<d)|(k>>>(32-d))}
function K(G,k){var I,d,F,H,x;F=(G&2147483648);H=(k&2147483648);I=(G&1073741824);d=(k&1073741824);x=(G&1073741823)+(k&1073741823);if(I&d){return(x^2147483648^F^H)}if(I|d){if(x&1073741824){return(x^3221225472^F^H)}else{return(x^1073741824^F^H)}}else{return(x^F^H)}}
function r(d,F,k){return(d&F)|((~d)&k)}
function q(d,F,k){return(d&k)|(F&(~k))}
function p(d,F,k){return(d^F^k)}
function n(d,F,k){return(F^(d|(~k)))}
function u(G,F,aa,Z,k,H,I){G=K(G,K(K(r(F,aa,Z),k),I));return K(L(G,H),F)}
function f(G,F,aa,Z,k,H,I){G=K(G,K(K(q(F,aa,Z),k),I));return K(L(G,H),F)}
@AndiSHFR
AndiSHFR / ReadPlantiTMva.vbs
Last active December 13, 2023 11:43
Visual Basic Script to read measure value data from a ProLeiT Plant iT System.
' This visual basic script is a very basic example
' how to retrieve measure values from a ProLeiT plant it system.
'
' It will create a csv style output for all measure
' datapoints with the latest timestamp of data and value.
'
' Before running this script you need to change the username,
' password, database server/instance and database to
' point at your system.
'
@AndiSHFR
AndiSHFR / WiFiAutoSelector.h
Last active February 13, 2023 06:23
ESP8266 : WiFiAutoSelector - Pick wifi with best signal from a list and connect to it.
/**
* WiFiAutoSelector.h - Include file for class WiFiAutoSelector
* Copyright (c) 2016 Andreas Schaefer <asc@schaefer-it.net>
*
* A class to pick a wifi network from a list, based on the
* highest receive signal strength, and connect to it.
* Inspired by "WiFiMulti"
*
* This source code is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@AndiSHFR
AndiSHFR / CalculateUptimeSeconds.c
Created March 20, 2016 13:54
Calculate uptime in seconds on adruino from millis().
/**
* CalculateUptimeSeconds()
*
* Handle millis() rollover and calculate the total uptime in seconds.
* This function must be called at least once for every 50 days to be
* able to see the rollover.
*/
unsigned long CalculateUptimeSeconds(void) {
static unsigned int _rolloverCount = 0; // Number of 0xFFFFFFFF rollover we had in millis()
@AndiSHFR
AndiSHFR / script-database-users-and-permissions.sql
Last active March 8, 2020 07:46
Script Sql Server Database Users and Permissions
/**
* script-database-users-and-permissions.sql
*
* Copyright (C) 2020 by Andreas Schaefer <asc@schaefer-it.net>
*
* Create a t-sql script that can be used to restore users and
* persmissions on a sql server database
*
* Notes:
* - The script will not script built-in accounts or accounts like '##MS%##'
@AndiSHFR
AndiSHFR / time-range.html
Created December 3, 2019 10:06
IDEA: How to handle relative time ranges in query selection parameters
<!DOCTYPE html>
<!--
IDEA: How to handle relative time ranges in query selection parameters
-->
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
@AndiSHFR
AndiSHFR / basic-jquery-widget-example.js
Created October 21, 2019 12:48
Basic jQuery Widget Example
/**
* Minimal jQuery Widget Example
* Author: Andreas Schaefer <asc@schaefer-it.net>
*
* Usage:
*
* <div id="myCoolWidget"></div>
*
* ...
*
/**
* PulseHeartbeat
*
* Blink the onboard LED to signal "Yepp, we are still runnning".
* The onbaord LED is on pin 13 and so pin 13 will be set to OUTPUT.
*
* Call this at the beginning of your loop() function.
* Caution: Will only work if millis() if functional and no one else
* did hook up timer0.
*/
@AndiSHFR
AndiSHFR / GetOnboardTemperature.c
Last active May 3, 2019 13:16
Read internal ATmega cpu temperature sensor.
/**
* GetOnboardTemperature
*
* Read temperature from the onbaord sensor. Check specs if sensor exist for your cpu. ;-)
*
* Example:
* char buff[10];
* Serial.print("CPU temp.: " );
* Serial.print(dtostrf(GetOnboardTemperature(), 5, 2, buff));
@AndiSHFR
AndiSHFR / HumanReadableDuration.c
Last active May 3, 2019 13:15
Converts a duration in seconds into a human readable string.
/**
* HumanReadableDuration
*
* Retruns a human readable duration for totalSeconds.
* Make sure outputBuffer is big enough to hold the
* complete string incl. temrinate '\0' character.
*/
char* HumanReadableDuration(unsigned long totalSeconds, char* outputBuffer ) {
if(outputBuffer) {