Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View exceedsystem's full-sized avatar

Y.Sakamoto exceedsystem

View GitHub Profile
@exceedsystem
exceedsystem / KanaToHepburnRomaji.js
Created February 23, 2024 03:45
Convert Kana to Hepburn romanization
const vscode = require('vscode');
/**
* マクロコンフィギュレーション(環境に合わせてお好みで設定)
*/
module.exports.macroCommands = {
'カナ→ヘボン式ローマ字': {
no: 1,
func: toHepburn
},
@exceedsystem
exceedsystem / UserDirCleaner.cs
Created August 19, 2023 22:23
Sample tool for cleaning up the temporary directory under the Windows user directory in .NET 7(C#)
amespace UserTempCleaner
{
internal class Program
{
// Threshold of elapsed time since the last use of the file/folder
private const int ELAPSED_HOURS = 168;
private static readonly string LOG_FILE = $"UserTempCleaner_{DateTime.Now:yyyyMMddHHmmss}.log";
private static void Main(string[] args)
@exceedsystem
exceedsystem / OpenAI.js
Last active March 23, 2024 07:58
Sample of a VSCode Macros to call OpenAI (ChatGPT) from VSCode
// License:MIT
// https://www.exceedsystem.net/2023/04/07/vscode-macros-macro-that-calls-chat-gpt-api-from-vscode
const vscode = require('vscode');
const process = require('process');
const { Configuration, OpenAIApi, OpenAI } = require('openai');
// Completion API result class
class RunCompletionResult {
constructor(status, content, model, cost) {
this.status = status;
@exceedsystem
exceedsystem / StdDevExtension.cs
Last active November 21, 2022 08:57
Samples of calculating standard deviation in .NET(C#/VB.NET).
static class Extensions
{
public static double StdDev(this IEnumerable<double> src)
{
IList<double> lst = src is IList<double> ? (IList<double>)src : src.ToArray();
int n = lst.Count();
double ave = lst.Average();
double s = 0;
for (int i = 0; i < n; ++i)
s = s + (lst[i] - ave) * (lst[i] - ave);
@exceedsystem
exceedsystem / TorchSharpTest220910.cs
Last active September 12, 2022 10:05
How to implement XOR gate nural network with torch in .NET 6
// EXCEEDSYSTEM Sample of the XOR gate neural network with the TorchSharp
// https://www.exceedsystem.net/2022/09/12/how-to-implement-xor-gate-neural-network-with-torch-in-dotnet-6
// License: MIT
using TorchSharp;
using static TorchSharp.torch;
using static TorchSharp.torch.nn;
using static TorchSharp.torch.nn.functional;
// Fix the random number seed to be used for weight and bias
torch.random.manual_seed(1);
@exceedsystem
exceedsystem / FirestoreTest220903.cs
Created September 4, 2022 06:23
Cloud Firestore auth and CRUD sample in C#(.NET 6)
using Firebase.Auth;
using Google.Apis.Auth.OAuth2;
using Google.Cloud.Firestore;
using Google.Cloud.Firestore.V1;
// Create a Firebase authentication provider with your Firebase project API key
var fbAuthProv = new FirebaseAuthProvider(new FirebaseConfig("{API key for your Firebase project}"));
try
@exceedsystem
exceedsystem / EmoCheckUpdater.cs
Created May 25, 2022 14:48
EmoCheck automatic update tool
// EXCEEDSYSTEM EmoCheckUpdater
// https://www.exceedsystem.net/2022/05/26/how-to-update-emocheck-automatically
// License: MIT
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Json;
using System.Reflection;
@exceedsystem
exceedsystem / AWSCognitoTestApp.csproj
Last active June 4, 2022 03:36
AWS Cognito SignUp/Confirm/SignIn example .NET 6(C#)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
@exceedsystem
exceedsystem / ts2jsonschema.js
Last active July 3, 2022 23:01
VS Code Macros extension macro that generates json schema from typescript
// [VSCode Macros] extension
// https://marketplace.visualstudio.com/items?itemName=EXCEEDSYSTEM.vscode-macros
// License:MIT
const vscode = require('vscode');
const tsjsg = require('ts-json-schema-generator');
const tmpp = require('tmp-promise');
module.exports.macroCommands = {
TS2JsonSchema: {
no: 1,
// License:MIT
local buttonNum = 4 -- Left small button is 3, Right small button is 4
local scrolling = false
local scrollSteps = -2 -- When negative, it scrolls in reverse.
hooksMouseUp = hs.eventtap.new({hs.eventtap.event.types.otherMouseUp}, function(e)
if (e:getProperty(hs.eventtap.event.properties.mouseEventButtonNumber) == buttonNum and scrolling) then
scrolling = false
return true
end