Skip to content

Instantly share code, notes, and snippets.

View sebgod's full-sized avatar

Sebastian Godelet sebgod

View GitHub Profile
@sebgod
sebgod / bluetooth_serial_server_sw.py
Last active November 25, 2023 08:02
Starts a Bluetooth SPP server that forwards traffic to a locally connected serial device that uses the SkyWatcher serial protocol
#!/usr/bin/python3
import os
import dbus
import dbus.service
import dbus.mainloop.glib
import serial
from gi.repository import GLib
# replace Octopus variables in host.json
$octoVariableRegEx = [regex]"#\{([A-Za-z0-9_]+)\}"
$matchEvaluator = {
$varName = $args[0].Groups[1]
$octoValue = $global:OctopusParameters[$varName]
if ($null -ne $octoValue) { $octoValue } else { "$varName NOT DEFINED!" }
}
$hostJsonFiles = Get-ChildItem -Recurse $functionPackage -Filter 'host.json'
if ($hostJsonFiles.Count -gt 0) {
$hostJsonFile = $hostJsonFiles[0].FullName
Import-Module PowerHTML -Cmdlet ConvertFrom-Html
Add-Type -AssemblyName System.Web
# Constants
Set-Variable S_IAUName 'IAU Name' -Option Constant
Set-Variable S_IAUNameId 'IAUName' -Option Constant
Set-Variable S_ConstId 'ID' -Option Constant
Set-Variable S_ConstName 'Const.' -Option Constant
Set-Variable S_ConstNameId 'Constellation' -Option Constant
Set-Variable S_StarComp '#' -Option Constant
@sebgod
sebgod / Invoke-MercuryCompiler.ps1
Last active May 4, 2019 09:17
Invoke Mercury compiler using PowerShell. Discovers MSVC compiler as well.
function Invoke-MercuryCompiler {
param (
[String] $mercuryHome
)
$env_Orig = Get-Environment
try {
@sebgod
sebgod / wsl-wrapper.c
Created January 1, 2019 13:47
A wrapper executable to wrap Linux executable files on WSL to be callable from Windows.
#define __STDC_WANT_LIB_EXT1__ 1
#include <stdio.h>
#include <stdlib.h>
#define _GNU_SOURCE
#include <string.h>
#if _WIN32 || _WIN64
# define CDECL __cdecl
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
@sebgod
sebgod / HMAT.md
Created November 4, 2014 07:51
Articles about HMAT
@sebgod
sebgod / popcount.cs
Created November 4, 2014 07:48
Population count in C#
static int BitCount(uint value)
{
value = value - ((value >> 1) & 0x55555555); // reuse input as temporary
value = (value & 0x33333333) + ((value >> 2) & 0x33333333); // temp
value = ((value + (value >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; // count
return unchecked((int)value);
}
@sebgod
sebgod / popcount.c
Created November 4, 2014 07:43
Population count in C
#if defined(__POPCNT__) && defined(__GNUC__) && (__GNUC__> 4 || (__GNUC__== 4 && __GNUC_MINOR__> 1))
#define HAVE_BUILTIN_POPCOUNTLL
#endif
static uint64_t bitcount64(uint64_t b) {
b -= (b >> 1) & 0x5555555555555555;
b = (b & 0x3333333333333333) + ((b >> 2) & 0x3333333333333333);
b = (b + (b >> 4)) & 0x0f0f0f0f0f0f0f0f;
return (b * 0x0101010101010101) >> 56;
}
/* For 32-bit, an 8-bit table may or may not be a little faster */
@echo off
rem
rem ****************************************************************************
rem
rem Copyright (c) Microsoft Corporation. All rights reserved.
rem This code is licensed under the Microsoft Public License.
rem THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
rem ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
rem IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
rem PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
Here a solution without using negation, instead the universe of seasons is
specified.
<!-- language-all: prolog -->
season(summer).
season(winter).
now(winter).