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 / 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 / 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()
/**
* 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) {
@AndiSHFR
AndiSHFR / string-extension-_toBool.js
Created March 24, 2016 13:23
Javascript: String.prototype._toBool
// We extend the string object with a little helper function
// to convert a boolean value from a string to bool.
// var flag = "true"._toBool
Object.defineProperty(String.prototype, "_toBool", {
get : function() {
return (/^(true|1)$/i).test(this);
}
});
@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)}
use mysql;
update user set password=PASSWORD("UlE3x:rtRt$12") where User='vhost_4711';
flush privileges;
@AndiSHFR
AndiSHFR / RemoveBT.cmd
Created April 5, 2016 19:20
Remove $WINDOWS.~BT
// go inside that folder:
cd /d "C:\$Windows.~BT"
// take over ownership
takeown /f *.* /R /D Y
// (go for coffee, takes a minute)
// grant full rights to everyone
icacls *.* /grant Everyone:(OI)(CI)F /T
@AndiSHFR
AndiSHFR / sqlserver-opentrans.sql
Created April 7, 2016 09:27
Sql Server Open Trans
SELECT
GETUTCDATE() AS [DateTime],
[s_tst].[session_id],
[s_es].[login_name] AS [Login Name],
DB_NAME (s_tdt.database_id) AS [Database],
[s_tdt].[database_transaction_begin_time] AS [Begin Time],
[s_tdt].[database_transaction_log_bytes_used] AS [Log Bytes],
[s_tdt].[database_transaction_log_bytes_reserved] AS [Log Rsvd],
[s_est].text AS [Last T-SQL Text],
[s_eqp].[query_plan] AS [Last Plan]