Skip to content

Instantly share code, notes, and snippets.

@saga
saga / finetune_llama2.py
Created March 24, 2024 13:16 — forked from mlabonne/finetune_llama2.py
Easy Llama 2 fine-tuning script (📝 Article: https://tinyurl.com/finetunellama2)
# Based on younesbelkada/finetune_llama_v2.py
# Install the following libraries:
# pip install accelerate==0.21.0 peft==0.4.0 bitsandbytes==0.40.2 transformers==4.31.0 trl==0.4.7 scipy
from dataclasses import dataclass, field
from typing import Optional
import torch
from datasets import load_dataset
from transformers import (
@saga
saga / charles-proxy-android.md
Created December 23, 2021 03:22 — forked from twaddington/charles-proxy-android.md
How to set up Charles Proxy for the Android Emulator.

Charles Proxy Android

Steps

1. Add the Network Security Configuration to your app

<network-security-config>
   <debug-overrides>
 
@saga
saga / TaskConcurrencyManifesto.md
Created September 27, 2021 07:21 — forked from yxztj/TaskConcurrencyManifesto.md
Swift Concurrency Manifesto 中文翻译
@saga
saga / React-Hooks.js
Created September 25, 2020 14:46 — forked from craigtaub/React-Hooks.js
Nested React Hooks
// Engine
const React = {
index: 0,
state: [],
useEffect: (callback, dependencies) => {
const cachedIndex = React.index;
const hasChanged = dependencies !== React.state[cachedIndex];
if (dependencies === undefined || hasChanged) {
callback();
#!/usr/bin/env python
# coding: utf-8
import pysubs2
import re
from stardict import DictCsv
# depend on https://github.com/skywind3000/ECDICT/
dict_filename="ecdict.csv"
sub_filename="01sub.srt"
@saga
saga / keyup_event.js
Created January 29, 2019 23:17 — forked from sukima/keyup_event.js
This is how I managed to facilitate keyboard events in multiple browsers
// <input id="my-input-element" type="text" value="foo"/>
var evt, node = document.getElementById('my-input-element');
// Have to use dispatchEvent/fireEvent because jQuery.trigger will not
// fire an event attached via addEventListener. Each environment has an
// unusual way to trigger a keyup event.
if (node.dispatchEvent) {
// Sane browsers
try {
// Chrome, Safari, Firefox
@saga
saga / Free O'Reilly Books.md
Created May 30, 2018 14:25 — forked from augbog/Free O'Reilly Books.md
Free O'Reilly Books

Free O'Reilly books and convenient script to just download them.

Thanks /u/FallenAege/ and /u/ShPavel/ from this Reddit post

How to use:

  1. Take the download.sh file and put it into a directory where you want the files to be saved.
  2. cd into the directory and make sure that it has executable permissions (chmod +x download.sh should do it)
  3. Run ./download.sh and wee there it goes. Also if you do not want all the files, just simply comment the ones you do not want.
{
// Controls the font family.
"editor.fontFamily": "Fira Code Light, Consolas, monospace",
"http.proxy": "",
"window.restoreWindows": "none",
"editor.fontSize": 15,
"editor.accessibilitySupport": "off",
"editor.tabCompletion": true,
@saga
saga / UserValidator.cs
Created September 13, 2017 16:22 — forked from GrantByrne/UserValidator.cs
Using Fluent Validation with WPF - Dead Simple
using System.Text.RegularExpressions;
using FluentValidation;
using WpfFluentValidationExample.ViewModels;
namespace WpfFluentValidationExample.Lib
{
public class UserValidator : AbstractValidator<UserViewModel>
{
public UserValidator()
{
@saga
saga / compile_stdlib.py
Created July 26, 2016 16:36 — forked from madebyjazz/compile_stdlib.py
Compile all Python scripts into single StdLib.dll .NET assembly
# Script below is based on following post:
# IronPython: EXE compiled using pyc.py cannot import module "os" - Stack Overflow
# http://stackoverflow.com/questions/6195781/ironpython-exe-compiled-using-pyc-py-cannot-import-module-os
import sys
sys.path.append('d:/projects/SomeProject/Libs/IronPython')
sys.path.append('d:/projects/SomeProject/Libs/IronPython/Lib')
sys.path.append('d:/projects/SomeProject/Libs/IronPython/Tools/Scripts')
import clr