Skip to content

Commit

Permalink
2024-07-16 17:11:31.119487 new snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardocerqueira committed Jul 16, 2024
1 parent 9cd6cc8 commit 76093b9
Show file tree
Hide file tree
Showing 14 changed files with 1,995 additions and 0 deletions.
24 changes: 24 additions & 0 deletions seeker/report.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
--------------------------------------------------------------------------------
2024-07-16 17:11:31.119487
--------------------------------------------------------------------------------
On branch main
Your branch is up to date with 'origin/main'.

Untracked files:
(use "git add <file>..." to include in what will be committed)
snippet/405b_fp8_dyquant_cpu.py
snippet/api.go
snippet/fixdd
snippet/iter_sieve.py
snippet/main.go
snippet/matplotlib-custom.py
snippet/matplotlib-example.py
snippet/module_2_4.py
snippet/module_2_5.py
snippet/setup-debian.sh
snippet/setup-ubuntu.sh
snippet/shapekey2basis.py
snippet/txtai-textractor.py

nothing added to commit but untracked files present (use "git add" to track)

--------------------------------------------------------------------------------
2024-07-15 17:11:39.721584
--------------------------------------------------------------------------------
Expand Down
22 changes: 22 additions & 0 deletions seeker/snippet/405b_fp8_dyquant_cpu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#date: 2024-07-16T17:06:17Z
#url: https://api.github.com/gists/600b22689fce917c6e8934f81ef55385
#owner: https://api.github.com/users/cli99

# https://github.com/neuralmagic/AutoFP8
from auto_fp8 import AutoFP8ForCausalLM, BaseQuantizeConfig

pretrained_model_dir = "databricks/llama-405b-instruct"
activation_scheme = "dynamic"
quantized_model_dir = pretrained_model_dir + "-FP82-" + activation_scheme

quantize_config = BaseQuantizeConfig(
quant_method="fp8", activation_scheme=activation_scheme
)
model = AutoFP8ForCausalLM.from_pretrained(
pretrained_model_dir,
quantize_config=quantize_config,
device_map="cpu",
)

model.quantize()
model.save_quantized(quantized_model_dir)
26 changes: 26 additions & 0 deletions seeker/snippet/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//date: 2024-07-16T16:45:33Z
//url: https://api.github.com/gists/3ee51664f79b21e06fec83818856da26
//owner: https://api.github.com/users/BK1031

package api

import (
"bookstore/config"
"net/http"

"github.com/gin-gonic/gin"
)

func StartServer() {
r := gin.Default()
RegisterRoutes(r)
r.Run(":" + config.Port)
}

func RegisterRoutes(r *gin.Engine) {
r.GET("/ping", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "pong",
})
})
}
40 changes: 40 additions & 0 deletions seeker/snippet/fixdd
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#date: 2024-07-16T16:49:15Z
#url: https://api.github.com/gists/d0a4b0e59233f3ae6f1c598bac218077
#owner: https://api.github.com/users/bagger288

#!/bin/sh

# run while loop for boot_completed status & sleep 10 needed for magisk service.d
while [ "$(getprop sys.boot_completed | tr -d '\r')" != "1" ]; do sleep 1; done
sleep 10

# save currently active function name
echo "$(ls -al /config/usb_gadget/g1/configs/b.1/)" | grep -Eo f1.* | awk '{print $3}' | cut -d/ -f8 > /data/adb/.fixdd

# loop
# run every 0.5 seconds
while true
do
# check the app is active
chkapp="$(pgrep -f drivedroid | wc -l)"
# check currently active function
chkfn=$(echo "$(ls -al /config/usb_gadget/g1/configs/b.1/)" | grep -Eo f1.* | awk '{print $3}' | cut -d/ -f8)
# load previous active function
chkfrstfn="$(cat /data/adb/.fixdd)"
if [ "$chkapp" -eq "1" ] && [ "$chkfn" != "mass_storage.usb0" ]; then
# add mass_storage.usb0 config & function and remove currently active function
rm /config/usb_gadget/g1/configs/b.1/f*
mkdir -p /config/usb_gadget/g1/functions/mass_storage.usb0/lun.0/
ln -s /config/usb_gadget/g1/functions/mass_storage.usb0 /config/usb_gadget/g1/configs/b.1/f1
elif [ "$chkapp" -eq "0" ] && [ "$chkfn" = "mass_storage.usb0" ]; then
# remove mass_storage.usb0 function & restore previous function
rm /config/usb_gadget/g1/configs/b.1/f*
ln -s /config/usb_gadget/g1/functions/"$chkfrstfn" /config/usb_gadget/g1/configs/b.1/f1
if [ "$chkfrstfn" = "ffs.adb" ]; then
setprop sys.usb.config adb
elif [ "$chkfrstfn" = "ffs.mtp" ]; then
setprop sys.usb.config mtp
fi
fi
sleep 0.5
done
33 changes: 33 additions & 0 deletions seeker/snippet/iter_sieve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#date: 2024-07-16T16:53:32Z
#url: https://api.github.com/gists/a89be36f99ce0ecc5bbdc2fc027b6bbd
#owner: https://api.github.com/users/ptmcg

import functools
import itertools
from collections.abc import Iterator


def is_multiple_of(p: int, x: int) -> bool:
# if x % p == 0:
# print("discarding", x, "multiple of", p)
return x % p == 0


def sieve_of_eratosthenes(n: int) -> Iterator[int]:
# start with list of all integers, starting with 2
ints: Iterator[int] = itertools.count(start=2)

for _ in range(n):
next_prime = next(ints)
yield next_prime

# wrap ints iterator in another filter, removing
# multiples of next_prime
ints = itertools.filterfalse(
functools.partial(is_multiple_of, next_prime),
ints,
)


# print the first 30 prime numbers
print(list(sieve_of_eratosthenes(30)))
9 changes: 9 additions & 0 deletions seeker/snippet/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//date: 2024-07-16T16:53:39Z
//url: https://api.github.com/gists/7dc25c2884d693b2d83e229187352447
//owner: https://api.github.com/users/BK1031

func main() {
fmt.Println("Hello, World!")
database.InitializeDB()
api.StartServer() // add this
}
23 changes: 23 additions & 0 deletions seeker/snippet/matplotlib-custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#date: 2024-07-16T17:09:18Z
#url: https://api.github.com/gists/2dc9d21036134946af5efb0f737cdeb1
#owner: https://api.github.com/users/docsallover

import matplotlib.pyplot as plt

# Sample data (same as previous example)
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
temperatures = [10, 15, 20, 25, 30, 28]

# Create the line chart with customization
plt.plot(months, temperatures, color='skyblue', marker='o', linestyle='dashed')

# Add labels and title (same as previous example)
plt.xlabel("Month")
plt.ylabel("Temperature (°C)")
plt.title("Average Monthly Temperatures")

# Add gridlines for better readability
plt.grid(True)

# Display the plot
plt.show()
20 changes: 20 additions & 0 deletions seeker/snippet/matplotlib-example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#date: 2024-07-16T16:53:46Z
#url: https://api.github.com/gists/83d8b29ab8ad3042608c1bfebfb3600f
#owner: https://api.github.com/users/docsallover

import matplotlib.pyplot as plt

# Sample data
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
temperatures = [10, 15, 20, 25, 30, 28]

# Create the line chart
plt.plot(months, temperatures)

# Add labels and title
plt.xlabel("Month")
plt.ylabel("Temperature (°C)")
plt.title("Average Monthly Temperatures")

# Display the plot
plt.show()
17 changes: 17 additions & 0 deletions seeker/snippet/module_2_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#date: 2024-07-16T17:10:01Z
#url: https://api.github.com/gists/606cf5dded3e5c724c950622dab237db
#owner: https://api.github.com/users/MaXVoLD

numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
primes = []
not_primes = []
for i in numbers:
if i == 1:
continue
for j in primes:
if i % j == 0:
not_primes.append(i)
break
else:
primes.append(i)
print(f'Простые числа: {primes} \nСоставные числа: {not_primes}')
15 changes: 15 additions & 0 deletions seeker/snippet/module_2_5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#date: 2024-07-16T17:08:15Z
#url: https://api.github.com/gists/0e6f3e88bf14b546482299c18ab83de2
#owner: https://api.github.com/users/MaXVoLD

def get_matrix(n, m, value):
matrix = []
for i in range(1, n + 1):
list_ = []
matrix.append(list_)
for j in range(1, m + 1):
list_.append(value)
print(matrix)


get_matrix(2, 4, 10)
Loading

0 comments on commit 76093b9

Please sign in to comment.