Skip to content

Instantly share code, notes, and snippets.

View vinhnx's full-sized avatar
🎯
focusing

Vinh Nguyen vinhnx

🎯
focusing
View GitHub Profile
@vinhnx
vinhnx / ollama_dspy.py
Created April 14, 2024 02:06 — forked from jrknox1977/ollama_dspy.py
ollama+DSPy using OpenAI APIs.
# install DSPy: pip install dspy
import dspy
# Ollam is now compatible with OpenAI APIs
#
# To get this to work you must include `model_type='chat'` in the `dspy.OpenAI` call.
# If you do not include this you will get an error.
#
# I have also found that `stop='\n\n'` is required to get the model to stop generating text after the ansewr is complete.
# At least with mistral.
@vinhnx
vinhnx / kitty.conf
Last active April 1, 2024 05:10
my Kitty Terminal config
# vim:fileencoding=utf-8:foldmethod=marker
# Include theme
include ./theme.conf
# ===== Config =====
font_family Menlo
font_size 15.0
@vinhnx
vinhnx / normcore-llm.md
Created March 28, 2024 05:03 — forked from veekaybee/normcore-llm.md
Normcore LLM Reads

Anti-hype LLM reading list

Goals: Add links that are reasonable and good explanations of how stuff works. No hype and no vendor content if possible. Practical first-hand accounts of models in prod eagerly sought.

Foundational Concepts

Screenshot 2023-12-18 at 10 40 27 PM

Pre-Transformer Models

@vinhnx
vinhnx / UIViewController+ContainerExtensions.swift
Created January 23, 2024 10:51
UIViewController container
import UIKit
extension UIViewController {
func nxv_addChildViewController(_ childVC: UIViewController, containerView: UIView) {
addChild(childVC)
containerView.addSubview(childVC.view)
containerView.translatesAutoresizingMaskIntoConstraints = false
childVC.view.translatesAutoresizingMaskIntoConstraints = false
@vinhnx
vinhnx / ios_toolbox.md
Last active August 26, 2023 08:06
my iOS development toolbox

http://www.mkdown.com/8704724

Prologue

Software development, especially mobile development has been improving rapidly. Nowadays, they are things that are unthinkable as of several years ago.

The world is moving to mobile. And as a (newbie) mobile software/iOS developer, I think there're always many thing for us to learn everyday.

Being able to keep track of what's new in technology today is really difficult, it's daunting, not to say an impossible task; but we can't help but have to keep being updated, unless we want to be left behind.

@vinhnx
vinhnx / uicollectionview+snap.md
Last active May 26, 2023 06:40
UICollectionView snap onto cell when scrolling horizontally

// reference: https://stackoverflow.com/a/43637969/1477298

While originally I was using Objective-C, I since switched so Swift and the original accepted answer did not suffice.

I ended up creating a UICollectionViewLayout subclass which provides the best (imo) experience as opposed to the other functions which alter content offset or something similar when the user has stopped scrolling.

class SnappingCollectionViewLayout: UICollectionViewFlowLayout {

    override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint {
@vinhnx
vinhnx / bump_build_version_with_timestamp
Created April 12, 2021 02:45
Xcode bump build version with current timestamp
agvtool new-version -all $(TZ="Asia/Ho_Chi_Minh" date +%Y%m%d.%H%M)
@vinhnx
vinhnx / SwiftUI_MVVM.swift
Created March 2, 2021 11:04
SwiftUI with MVVM example
// https://kean.blog/post/swiftui-data-flow
struct SearchView: View {
@ObservedObject var viewModel: SearchViewModel
var body: some View {
VStack {
TextField("Search", text: $viewModel.query)
List(viewModel.songs) {
Text($0.name)
}
@vinhnx
vinhnx / clean_code.md
Created June 27, 2022 03:18 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@vinhnx
vinhnx / Fastfile
Last active June 24, 2022 04:43
advanced Fastfile config
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane