Skip to content

Instantly share code, notes, and snippets.

View lilingxi01's full-sized avatar
😆
Be creative.

Lingxi Li lilingxi01

😆
Be creative.
View GitHub Profile
@ArthurZucker
ArthurZucker / mamba_peft.py
Created March 7, 2024 09:32
Mamba peft finetuning
from datasets import load_dataset
from trl import SFTTrainer
from peft import LoraConfig
from transformers import AutoTokenizer, AutoModelForCausalLM, TrainingArguments
tokenizer = AutoTokenizer.from_pretrained("state-spaces/mamba-130m-hf")
model = AutoModelForCausalLM.from_pretrained("state-spaces/mamba-130m-hf")
dataset = load_dataset("Abirate/english_quotes", split="train")
training_args = TrainingArguments(
output_dir="./results",
num_train_epochs=3,
@domske
domske / safari-fix-overflow-border-radius.md
Last active April 28, 2024 00:15
Bugfix (Workaround) for Safari (iOS): Border radius with overflow hidden does not work as expected.

There is a bug in Safari when using border-radius and overflow: hidden. Especially when applying transform to a child. In this case, overflow: hidden does not always work. The child ignores the border radius and overflows. It's a very old bug. And sadly it seems that it will never be fixed. Anyway, we can't wait for it.

There are some workaround. We need to place the element with the overflow attribute into a stacking context. I've tested the following workarounds on the latest version of iOS (14.4). You can choose what you want. But you should search the web for the particular attribute. (e.g. will-change should be rarely used. See docs)

Use this on the element with overflow: hidden and border-radius:

@BrunoQuaresma
BrunoQuaresma / nextapimock.ts
Last active July 18, 2023 17:12
NextApiResponse and NextApiRequest mocks
import { IncomingMessage } from 'http'
import {
NextApiRequestCookies,
NextApiRequestQuery,
} from 'next/dist/next-server/server/api-utils'
import { Socket } from 'net'
import { ServerResponse } from 'http'
import { NextApiRequest, NextApiResponse } from 'next'
import { Env } from 'next/dist/lib/load-env-config'
@jfuellert
jfuellert / ScrollableView.swift
Last active April 11, 2024 17:57
A scrollable SwiftUI view, UIScrollView wrapper. ScrollableView lets you read and write content offsets for scrollview in SwiftUI, with and without animations.
import SwiftUI
struct ScrollableView<Content: View>: UIViewControllerRepresentable, Equatable {
// MARK: - Coordinator
final class Coordinator: NSObject, UIScrollViewDelegate {
// MARK: - Properties
private let scrollView: UIScrollView
var offset: Binding<CGPoint>
@rdinse
rdinse / Google_Colaboratory_backup.py
Created March 13, 2018 22:55
Simple Google Drive backup script with automatic authentication for Google Colaboratory (Python 3)
# Simple Google Drive backup script with automatic authentication
# for Google Colaboratory (Python 3)
# Instructions:
# 1. Run this cell and authenticate via the link and text box.
# 2. Copy the JSON output below this cell into the `mycreds_file_contents`
# variable. Authentication will occur automatically from now on.
# 3. Create a new folder in Google Drive and copy the ID of this folder
# from the URL bar to the `folder_id` variable.
# 4. Specify the directory to be backed up in `dir_to_backup`.