Skip to content

Instantly share code, notes, and snippets.

View hanrw's full-sized avatar
🎯
Focusing

itshan hanrw

🎯
Focusing
View GitHub Profile
@hanrw
hanrw / fast_speech_text_speech.py
Created February 15, 2024 16:20 — forked from thomwolf/fast_speech_text_speech.py
speech to text to speech
""" To use: install LLM studio (or Ollama), clone OpenVoice, run this script in the OpenVoice directory
git clone https://github.com/myshell-ai/OpenVoice
cd OpenVoice
git clone https://huggingface.co/myshell-ai/OpenVoice
cp -r OpenVoice/* .
pip install whisper pynput pyaudio
"""
from openai import OpenAI
import time
@hanrw
hanrw / VirtualKeyboard.swift
Created January 31, 2024 12:37 — forked from ethanhuang13/VirtualKeyboard.swift
MacBook Air M1 Zhuyin Keyboard written with SwiftUI ~=300 LOC, < 4hrs
//
// VirtualKeyboard.swift
// MacBook Air M1 Zhuyin Keyboard
// Written with SwiftUI ~=300 LOC, < 4hrs
// Created by Ethan Huang on 2021/1/13.
// Twitter: @ethanhuang13
import SwiftUI
struct VirtualKeyboard: View {
import SwiftUI
struct RefreshControl: View {
var coordinateSpace: CoordinateSpace
var onRefresh: ()->Void
@State var refresh: Bool = false
var body: some View {
GeometryReader { geo in
if (geo.frame(in: coordinateSpace).midY > 50) {
Spacer()
@hanrw
hanrw / WeatherView.swift
Created November 7, 2023 14:09 — forked from unixzii/WeatherView.swift
A demo of implementing iOS Weather card in SwiftUI.
import SwiftUI
struct HeaderView: View {
var body: some View {
HStack {
Image(systemName: "info.circle.fill")
.resizable()
.frame(width: 12, height: 12)
Text("Section Header")
.font(.system(size: 13))
import Foundation
import SwiftUI
// MARK: - Custom Button Style
struct MobileMeButtonStyle: ButtonStyle {
// MARK: Metrics
@ScaledMetric private var cornerRadius = 12
@ScaledMetric private var horizontalLabelPadding = 12
@ScaledMetric private var verticalLabelPadding = 8
@hanrw
hanrw / semantic-commit-messages.md
Created November 25, 2022 07:32 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@hanrw
hanrw / README.md
Created July 28, 2022 03:41 — forked from noamtamim/README.md
Markdown with PlantUML

How to use PlantUML with Markdown

PlantUML is a really awesome way to create diagrams by writing code instead of drawing and dragging visual elements. Markdown is a really nice documentation tool.

Here's how I combine the two, to create docs with embedded diagrams.

Step 0: Setup

Get the command-line PlantUML from the download page or your relevant package manager.

@hanrw
hanrw / ECDSA-secp256k1-example.java
Created May 1, 2022 13:27 — forked from nakov/ECDSA-secp256k1-example.java
ECDSA with secp256k1 in Java: generate ECC keys, sign, verify
import org.bouncycastle.util.encoders.Hex;
import org.web3j.crypto.*;
import java.math.BigInteger;
public class ECCExample {
public static String compressPubKey(BigInteger pubKey) {
String pubKeyYPrefix = pubKey.testBit(0) ? "03" : "02";
String pubKeyHex = pubKey.toString(16);
String pubKeyX = pubKeyHex.substring(0, 64);

Mastering Programming - by Kent Beck

From years of watching master programmers, I have observed certain common patterns in their workflows. From years of coaching skilled journeyman programmers, I have observed the absence of those patterns. I have seen what a difference introducing the patterns can make. Here are ways effective programmers get the most out of their precious 3e9 seconds on the planet. The theme here is scaling your brain. The journeyman learns to solve bigger problems by solving more problems at once. The master learns to solve even bigger problems than that by solving fewer problems at once. Part of the wisdom is subdividing so that integrating the separate solutions will be a smaller problem than just solving them together.

Time

Slicing - Take a big project, cut it into thin slices, and rearrange the slices to suit your context. I can always slice projects finer and I can always find new permutations of the slices that meet different needs

@hanrw
hanrw / .bash_profile
Last active March 17, 2022 03:49 — forked from donchesworth/.bash_profile
switch between java versions
# Simple way ============================
function setjdk() {
if [ $# -ne 0 ]; then
if [ -n "${JAVA_HOME+x}" ]; then
removeFromPath "$JAVA_HOME/bin"
fi
export JAVA_HOME=`/usr/libexec/java_home -v $@`
export PATH=$JAVA_HOME/bin:$PATH
fi