Skip to content

Instantly share code, notes, and snippets.

@hughpearse
hughpearse / lin_sever_golang_ide.sh
Last active September 10, 2024 08:56
Instant Development Environments
#!/bin/bash
##########
# Usage:
# foo@bar$ rm run.pid; rm nohup.out; fuser -k 8080/tcp; nohup bash ./lin_sever_golang_ide.sh 2>&1 & echo $! > run.pid
# foo@bar$ disown
# foo@bar$ cat nohup.out | grep "Password:"
# foo@bar$ cat run.pid | xargs kill
##########
@hughpearse
hughpearse / README.md
Last active January 3, 2024 13:56
Task Tracker

Stopwatch Task Tracker

The application is a simple stopwatch task tracker built using the Tkinter library in Python. It was tested in Python 3.10.11. It has the following features:

Display

When the application is first opened, it displays the initial time as 00:00 at the top of the window. The title of the window is set to "Stopwatch task tracker".

Task Name Input

In the middle of the window, there's a label "Task Name:" to the left of a text input box where users can enter the name of their task.

@hughpearse
hughpearse / HughCoin.sol
Last active December 15, 2023 12:37
Openzeppelin solidity smart contract for HughCoin tokens pegged to ETH
// SPDX-License-Identifier: MIT
// Author: Hugh Pearse
pragma solidity ^0.8.20;
import {ERC20} from "@openzeppelin/[email protected]/token/ERC20/ERC20.sol";
/// @custom:security-contact [email protected]
contract HughCoin is ERC20 {
address public owner;

Run local LLM OpenAI Compatible Inference Server (llama.cpp)

Here I describe how to quickly get set up with a local LLM OpenAI compatible inference server.

Install Docker (RHEL 7)

Docker is a prerequisite. Complete the following instructions to set up docker

dc-user@devcloud$ sudo yum update
dc-user@devcloud$ sudo yum install -y yum-utils

Oobabooga with LLM on CPU

Here I describe how to quickly get set up with Llama-2-7B model trained with chat data using Docker. Below instructions launch Oobabooga container which includes an inference server and front-end web application for interactive chat. These instructions avoid requirements for Nvidia GPU.

Install Docker (RHEL 7)

Docker is a prerequisite for running Oobabooga. Complete the following instructions to set up Docker.

dc-user@devcloud$ sudo yum update
dc-user@devcloud$ sudo yum install -y yum-utils
dc-user@devcloud$ sudo yum-config-manager --add-repo http://yum.oracle.com/public-yum-ol7.repo
dc-user@devcloud$ sudo yum-config-manager --enable *addons
@hughpearse
hughpearse / simplified-page-chrome-android.md
Last active July 31, 2023 13:00
Android Bookmarklet - Reader View (Simplified Page)

Android Bookmarklet - Reader View (Simplified Page)

In chrome on android the "Simplified Page" feature does not have a button. If for some reason the browser decides not to display the layover toast message to access this feature, then the user is unable to enter "simplified view". The solution to this problem has been discussed before on Stack Overflow here, where they suggest opening a url to access a local resource on the browser cache. The local resource URL is formatted as follows:

chrome-distiller://<UUID>_<HASH>/?url=<URL>

It is not permitted to perform a javascript redirect to a local resource in the browser, however it is possible to display the URL as text.

Hello world in typescript

  1. foo@bar$ npm init -y
  2. foo@bar$ npm install typescript --save-dev
  3. foo@bar$ npm install @types/node --save-dev
  4. foo@bar$ npx tsc --init --rootDir src --outDir build --esModuleInterop --resolveJsonModule --lib es6 --module commonjs --allowJs true --noImplicitAny true
  5. foo@bar$ mkdir src
  6. foo@bar$ echo 'console.log("Hello world!")' > src/index.ts
  7. foo@bar$ npx tsc
  8. foo@bar$ node ./build/index.js
@hughpearse
hughpearse / app.py
Last active January 30, 2023 14:32
desktop webcam app
#python37
# Author: Hugh Pearse
# Description: display webcam with background removal (body segmentation) in transparant window and follow mouse cursor
#
# Setup instructions:
# python -m venv sandbox
# sandbox\Scripts\activate
# pip install absl-py==1.4.0 astunparse==1.6.3 cachetools==5.3.0 certifi==2022.12.7 charset-normalizer==3.0.1 flatbuffers==23.1.21 gast==0.4.0 google-auth==2.16.0 google-auth-oauthlib==0.4.6 google-pasta==0.2.0 grpcio==1.51.1 h5py==3.8.0 idna==3.4 importlib-metadata==6.0.0 keras==2.11.0 libclang==15.0.6.1 Markdown==3.4.1 MarkupSafe==2.1.2 numpy==1.23.5 oauthlib==3.2.2 opencv-python==4.7.0.68 opt-einsum==3.3.0 packaging==20.9 Pillow==9.4.0 protobuf==3.19.6 pyasn1==0.4.8 pyasn1-modules==0.2.8 pyfakewebcam==0.1.0 pyparsing==3.0.9 PyQt5==5.15.8 PyQt5-Qt5==5.15.2 PyQt5-sip==12.11.1 requests==2.28.2 requests-oauthlib==1.3.1 rsa==4.9 six==1.16.0 tensorboard==2.11.2 tensorboard-data-server==0.6.1 tensorboard-plugin-wit==1.8.1 tensorflow==2.11.0 tensorflow-estimator==2.11.0 tensorflow-hub==0.12
<!DOCTYPE html>
<html>
<head>
<title>Image Transform with TensorFlow.js</title>
<!-- Load TensorFlow.js library -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>
</head>
<body>
<h1>Image Transform with TensorFlow.js</h1>
<!-- Load the image to be rotated -->
<!DOCTYPE html>
<html>
<head>
<title>Image Transform with TensorFlow.js</title>
<!-- Load TensorFlow.js library -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf-tflite.min.js"></script>
</head>
<body>
<h1>Image Transform with TensorFlow.js</h1>