Skip to content

Instantly share code, notes, and snippets.

@nthe
nthe / ScreenRec.cs
Last active January 16, 2023 04:33
Screen recording app using ffmpeg with pause / resume support.
using System;
using System.IO;
using System.Net;
using System.Diagnostics;
using System.IO.Compression;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace ScreenRec
{
@nthe
nthe / inflections.py
Last active January 15, 2023 13:06
Find inflection points in the array.
from typing import Any, Iterator
def yield_unique_in_order(array: list) -> Iterator[tuple[Any, int]]:
"""Yields unique value and their respective indices in order.
Args:
array: Array of values.
Returns:
Iterator over unique values and their indices.
@nthe
nthe / uia-edge-perf-test.ps1
Created February 7, 2022 12:52
UI Automation Performance Test
Add-Type –AssemblyName UIAutomationClient
Add-Type –AssemblyName UIAutomationTypes
Write-Output "===== UI automation and accessibility test ====="
# start an instance of Microsoft Edge and wait for it to load
Write-Output "Starting an instance of Microsoft Edge"
Start-Process msedge "-inprivate https://en.wikipedia.org/wiki/Main_Page"
Start-Sleep –s 2
@nthe
nthe / Option.py
Last active April 15, 2022 18:45
from typing import Callable, Generic, TypeVar
T = TypeVar("T")
class Option(Generic[T]):
def __init__(self, value: T) -> None:
self._value: T = value
self._binds: list[Callable] = []
ndarray = list[list[int]]
def is_safe(board: ndarray, row: int, col: int) -> bool:
n: int = len(board)
# check cols
if any(board[row][i] for i in range(n)):
return False
# check up left diagonal
@nthe
nthe / memoization.py
Created May 3, 2022 11:22
Dynamic Programming Study
from typing import Optional
from functools import lru_cache
@lru_cache
def fib(n: int) -> int:
""" Return n-th fibonacci number.
>>> fib(50)
12586269025
[
{
"instruction": "Give three tips for staying healthy.",
"input": "",
"output": "1. Eat a balanced and nutritious diet: Make sure your meals are inclusive of a variety of fruits and vegetables, lean protein, whole grains, and healthy fats. This helps to provide your body with the essential nutrients to function at its best and can help prevent chronic diseases.\n\n2. Engage in regular physical activity: Exercise is crucial for maintaining strong bones, muscles, and cardiovascular health. Aim for at least 150 minutes of moderate aerobic exercise or 75 minutes of vigorous exercise each week.\n\n3. Get enough sleep: Getting enough quality sleep is crucial for physical and mental well-being. It helps to regulate mood, improve cognitive function, and supports healthy growth and immune function. Aim for 7-9 hours of sleep each night."
},
{
"instruction": "What are the three primary colors?",
"input": "",
"output": "The three primary colors are red, blue,
[
{
"instruction": "Remember the question",
"input": "",
"output": "From the book fo PQ-GSP-O questions. Is the general lighting sufficient in the premises?"
},
{
"instruction": "Remember the question",
"input": "",
"output": "From the book of PQ-GSP-O questions. Is daylight available ?"
The title
---------
The 12345 TEST SURVEY FROM CUSTOM STORE document
The list of manufacture question
---------------------------------
Is the general lighting sufficient in the premises?
Are the lighting fixtures cleaned and are they intact?
Is there location lighting for those workers (e.g. the elderly) who feel that the lighting in the work area is insufficient?
@nthe
nthe / run.py
Last active September 6, 2023 06:21
from langchain.document_loaders import TextLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.vectorstores import Chroma
from langchain.embeddings import HuggingFaceEmbeddings
from langchain.llms import LlamaCpp
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from langchain import PromptTemplate, LLMChain