Skip to content

Instantly share code, notes, and snippets.

View chrishuan9's full-sized avatar
🎯
Focusing

Chris Huang chrishuan9

🎯
Focusing
View GitHub Profile
import asyncio, asyncssh, sys
async def run_client():
#async with asyncssh.connect('localhost',kex_algs=["diffie-hellman-group1-sha1"],known_hosts=None,username='ridgeline',password='47e4b27ad353033a6c2fc969a7beddaf',signature_algs=['ssh-dss']) as conn:
async with asyncssh.connect('10.28.8.1',kex_algs=['diffie-hellman-group-exchange-sha256','diffie-hellman-group-exchange-sha1','diffie-hellman-group1-sha1','diffie-hellman-group14-sha1','diffie-hellman-group14-sha256','diffie-hellman-group15-sha512','diffie-hellman-group16-sha512','diffie-hellman-group17-sha512','diffie-hellman-group18-sha512'],known_hosts=None,username='ridgeline',password='47e4b27ad353033a6c2fc969a7beddaf',signature_algs=['ssh-dss']) as conn:
result = await conn.run('ls', check=True)
print(result.stdout, end='')
def main():
try:
@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)