Skip to content

Instantly share code, notes, and snippets.

View chrishuan9's full-sized avatar
🎯
Focusing

Chris Huang chrishuan9

🎯
Focusing
View GitHub Profile
@chrishuan9
chrishuan9 / excel_hex2dec_float.vba
Created November 29, 2018 06:59
VBA Makro for converting a hex number to decimal float
Function HEX2DECFL(strHexVal As String) As Double
'
' Function to convert 4 byte (32 bit) Hex value
' to a floating point decimal number
' using IEE 754
'
' Dave Stow
'
' Lookup array of hex digits to binary digits
Dim strBinaryDigits() As Variant
@chrishuan9
chrishuan9 / excel_hex_string_reverse.vba
Created November 29, 2018 06:54
Hex String Big to Little Endian in Excel
' VBA function which changes big to little endian
' reverses 1 byte (2 hex number pair)
' e.g changes 480000074B26E42D to 2DE4264B07000048
'
Public Function strReverse_Character_Pairs(ByVal strValue As String) As String
Dim lngLoop As Long
Dim strReturn As String
strReturn = ""
@chrishuan9
chrishuan9 / README.MD
Created November 23, 2018 18:37
Marello-OMS-Installation

Marello Application

Marello is an Open Source ERP for Commerce tool.

This document contains information on how to download, install, and start using Marello.

Requirements

@chrishuan9
chrishuan9 / README-reverse-proxy-in-haproxy.md
Created October 22, 2018 16:44 — forked from drmalex07/README-reverse-proxy-in-haproxy.md
Perform simple reverse-proxying in HAProxy. #reverse-proxy #proxy #haproxy #proxypass

A more complete example (with rewriting cookie domains/paths) can be found at http://blog.haproxy.com/2014/04/28/howto-write-apache-proxypass-rules-in-haproxy/

We will try something roughly equivalent to the following ProxyPass directives in Apache2:

ServerName www.example.com
...
ProxyPass        /foo/  http://foo.local
ProxyPassReverse /foo/  http://foo.local

In haproxy.cfg we define a backend, say foo, to reverse-proxy to foo.local backend server.

@chrishuan9
chrishuan9 / puma.service
Created July 26, 2018 09:57 — forked from arteezy/puma.service
Manage Puma with systemd on Ubuntu 16.04 and rbenv
[Unit]
Description=Puma Rails Server
After=network.target
[Service]
Type=simple
User=deploy
WorkingDirectory=/home/deploy/app/current
ExecStart=/home/deploy/.rbenv/bin/rbenv exec bundle exec puma -C /home/deploy/app/shared/config/puma.rb
ExecStop=/home/deploy/.rbenv/bin/rbenv exec bundle exec pumactl -S /home/deploy/app/shared/tmp/pids/puma.state stop
@chrishuan9
chrishuan9 / cron-monitor.sh
Created January 23, 2018 07:22
cron-monitor for lorawan kerlink iot station
#!/bin/bash
#
# Description: Script that checks if LoRaWAN packet forwarder is running
# On a Kerlink Wirnet Station
#
# author: Chris Yereaztian <[email protected]>
# last-changed: 2017-08-08
PIDFILE=/var/run/firefly.pid
@chrishuan9
chrishuan9 / Script_Template.ps1
Created January 21, 2018 10:03 — forked from 9to5IT/Script_Template.ps1
PowerShell: Script Template
#requires -version 2
<#
.SYNOPSIS
<Overview of script>
.DESCRIPTION
<Brief description of script>
.PARAMETER <Parameter_Name>
<Brief description of parameter input required. Repeat this attribute if required>
@chrishuan9
chrishuan9 / nginx.conf
Created March 29, 2017 06:04
nginx reverse proxy configuration for node-red
server {
listen 80;
listen 443 ssl http2;
server_name node-red.securise.com;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+$
ssl_prefer_server_ciphers On;
ssl_session_cache shared:SSL:128m;
Thanks JamesC for pointing me in the right direction!
For anyone trying the same in the future, this is (simplified) how I got it working with node.js:
// mqtt_msg is retrieved from MQTT tcp://croft.thethings.girovito.nl:1883
var decoded_data = new Buffer(mqtt_msg.data, 'base64');
// manually extract 24-bit latitude
var lat_val = decoded_data[8] << 16 | decoded_data[9] << 8 | decoded_data[10];
var lat = !(lat_val&0x800000) ? lat_val : ((0xffffff-lat_val+1)*-1)
@chrishuan9
chrishuan9 / gist:e56b58ba3a703cb97b6f0d0133afee86
Last active December 12, 2016 16:22
LoraWAN - xDot Box - NodeJS Function Node
var decoded_data = new Buffer(msg.payload.payload,’base64′);
var lat_val = decoded_data[3] << 16 | decoded_data[4] << 8 | decoded_data[5];
var lat = !(lat_val&0×800000) ? lat_val : ((0xffffff-lat_val+1)*-1)
var latitude = lat/Math.pow(2,23)*90;
var lon_val = decoded_data[7] << 16 | decoded_data[8] << 8 | decoded_data[9];
var lon = !(lon_val&0×800000) ? lon_val : ((0xffffff-lon_val+1)*-1);
var longitude = lon/Math.pow(2,23)*180;