Skip to content

Instantly share code, notes, and snippets.

View 7effrey89's full-sized avatar

Jeffrey Lai 7effrey89

  • Microsoft
  • Denmark
View GitHub Profile
@7effrey89
7effrey89 / tm1637noedmcu_Test.ino
Created May 10, 2018 20:12
TM1637 on NodeMCU
/*
Basic usage example
Demonstrated some of the basic functionality of the library. Initialize the display, set the backlight brightness, print some text, count from 0 to 100 and print on display and blink some text.
Note: make sure to set your serial monitor to line end: NEW LINE!
The circuit:
* connect TM1637 pin CLK to NodeMCU pin D4
* connect TM1637 pin DIO to NodeMCU pin D5
@7effrey89
7effrey89 / alarmtest.ino
Created May 13, 2018 21:47
WIP - alarm nodemcu
/*
* TimeAlarmExample.pde
*
* This example calls alarm functions at 8:30 am and at 5:45 pm (17:45)
* and simulates turning lights on at night and off in the morning
* A weekly timer is set for Saturdays at 8:30:30
*
* A timer is called every 15 seconds
* Another timer is called once only after 10 seconds
*
@7effrey89
7effrey89 / printer.cfg
Last active April 8, 2026 21:12
My Klipper config for Ramps 1.4 using TMC2130 SPI and DRV8825, LCD
# This file contains common pin mappings for RAMPS (v1.3 and later)
# boards. RAMPS boards typically use a firmware compiled for the AVR
# atmega2560 (though other AVR chips are also possible).
# See docs/Config_Reference.md for a description of parameters.
[stepper_x]
step_pin: ar54
dir_pin: !ar55
@7effrey89
7effrey89 / Program.cs
Last active August 22, 2023 13:40
Uploading files to ADLS Gen 2 and OneLake using C#
using Azure;
using Azure.Storage.Files.DataLake;
using Azure.Storage.Files.DataLake.Models;
using Azure.Storage;
using System.IO;
using Azure.Identity;
using System.IO.Enumeration;
using System.Net.Http.Headers;
using Azure.Identity;
using Azure.Storage.Files.DataLake;
@7effrey89
7effrey89 / Program.cs
Last active May 22, 2024 20:24
C# Azure Cognitive Search REST API demo - Insert and search for documents in the index
using Newtonsoft.Json.Linq;
namespace CognitiveSearchIndexDemo
{
internal class Program
{
const string searchServiceName = "YouCognitiveServiceName";
const string apiKey = "YouCognitiveServicePIKey";
const string indexName = "YouCognitiveServiceIndexName";
const string apiVersion = "2023-07-01-Preview";
@7effrey89
7effrey89 / gpt4o-feats-dalle3.py
Created May 22, 2024 20:28
GPT-4o describes an image, and feeds that description into DALL-E3
#Documentation:
#https://learn.microsoft.com/en-us/azure/ai-services/openai/chatgpt-quickstart?tabs=command-line%2Cpython-new&pivots=programming-language-python
#https://medium.com/@alexandre.tkint/dall-e-3-api-getting-started-guide-d945a2249823
#https://platform.openai.com/docs/guides/vision?lang=python
import os
from openai import AzureOpenAI
import webbrowser
#STEP1A: Have GPT4 generate a description of the ring
@7effrey89
7effrey89 / Sharepoint_web_Scraper.py
Last active September 20, 2024 10:33
Python web automation using Selenium and Edge to interact and print sharepoint webpage.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.edge.service import Service
from selenium.webdriver.edge.options import Options as EdgeOptions
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
#selenium 4.23.1 was used for this code
#edge browser: Version 127.0.2651.105 (Official build) (64-bit)
#edge driver: Version 127.0.2651.105 (Stable Channel) (64-bit)
@7effrey89
7effrey89 / app.py
Last active September 3, 2024 19:28
Azure Document Translation using Access Token Authentication
# Pre-requisites:
# 1. Create a service princple in Azure AD
# 2. Create a new client secret for it (note down the client-id, tenant-id, and secret-value)
# 3. Go to the Azure portal and find the Translator service among the Azure AI Services.
# 4. In the Access Control (IAM) tab, assign the service principle the "Cognitive Services User" role
# 5. In the Resource management tab, enable a System assigned Identity.
# 6. under Azure Role Assignment, choose scope: Storage, Resource: your blob storage (where your documents reside), Role: "Storage Blob Data Contributor"
# 7- Run the code below to get the service to translate all documents in one container to another container
from azure.core.credentials import AccessToken, AzureKeyCredential, TokenCredential
@7effrey89
7effrey89 / app.py
Created October 29, 2024 10:38
GPT4o/mini translation sample that translate an input and calculates the costs based on Sweden Central
import os
import requests
import json
################################## Facts ######################################################
#GPT costs for GPT-4o and GPT-4o-Mini for Sweden Central per 1000 tokens
#https://azure.microsoft.com/en-us/pricing/calculator
GPT4O_GLOBAL_DEPLOYMENT_INPUT = 0.0025
GPT4O_GLOBAL_DEPLOYMENT_OUTPUT = 0.0100
@7effrey89
7effrey89 / Notebook.ipynb
Last active March 7, 2025 09:12
Microsoft Fabric - Notebook Ai Functions
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.