Skip to content

Commit 174867b

Browse files
committed
some rounding tests, tabby, q3, vidmaker, clipmaker
1 parent d64798a commit 174867b

File tree

7 files changed

+270
-9
lines changed

7 files changed

+270
-9
lines changed

cfg/q3.cfg

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
seta name Functora
2+
3+
seta cl_autoRecordDemo 1
4+
seta cl_aviFrameRate 60
5+
seta com_maxfps 333
6+
seta g_synchronousClients 0
7+
seta s_useOpenAL 0
8+
seta sv_fps 333
9+
10+
set cg_autoswitch 0
11+
set cg_draw3dicons 0
12+
set cg_drawcrosshair 1
13+
set cg_drawfps 1
14+
set cg_drawstatus 0
15+
set cg_drawtimer 0
16+
set cg_gunZ -1.1
17+
set cg_lagometer 0
18+
set cg_scorePlums 0
19+
set s_musicvolume 0
20+
set xp_drawScores 0
21+
set xp_drawSpeed 0
22+
set xp_drawStats 0
23+
set xp_drawTime 0
24+
set xp_drawWeaponSelect 0
25+
set cg_draw2D 1
26+
set cg_drawAmmoWarning 0
27+
set cg_drawAttacker 0
28+
set cg_drawFriend 0
29+
set cg_drawIcons 0
30+
set cg_drawRewards 0
31+
set cg_drawTeamOverlay 0
32+
33+
set l1 "echo GAUNTLET"
34+
set l2 "echo MINIGUN"
35+
set l3 "echo SHOTGUN"
36+
set l4 "echo GRENADE"
37+
set l5 "echo PLASMA"
38+
set l6 "echo LIGHTNING"
39+
set l7 "echo ROCKET"
40+
set l8 "echo RAILGIN"
41+
set l9 "echo BFG"
42+
43+
set w1 "weapon 1"
44+
set w2 "weapon 2"
45+
set w3 "weapon 3"
46+
set w4 "weapon 4"
47+
set w5 "weapon 8"
48+
set w6 "weapon 6"
49+
set w7 "weapon 5"
50+
set w8 "weapon 7"
51+
set w9 "weapon 9"
52+
53+
set l "vstr l2"
54+
set w "vstr w2"
55+
56+
bind 1 "vstr l1; vstr w1; set l vstr l1; set w vstr w1; set fast vstr best"
57+
bind 2 "vstr l2; vstr w2; set l vstr l2; set w vstr w2; set fast vstr best"
58+
bind 3 "vstr l3; vstr w3; set l vstr l3; set w vstr w3; set fast vstr best"
59+
bind 4 "vstr l4; vstr w4; set l vstr l4; set w vstr w4; set fast vstr best"
60+
bind 5 "vstr l5; vstr w5; set l vstr l5; set w vstr w5; set fast vstr best"
61+
bind 6 "vstr l6; vstr w6; set l vstr l6; set w vstr w6; set fast vstr best"
62+
bind 7 "vstr l7; vstr w7; set l vstr l7; set w vstr w7; set fast vstr best"
63+
bind 8 "vstr l8; vstr w8; set l vstr l8; set w vstr w8; set fast vstr best"
64+
bind 9 "vstr l9; vstr w9; set l vstr l9; set w vstr w9; set fast vstr best"
65+
66+
set best "echo BEST; vstr w1; vstr w2; vstr w3; vstr w4; vstr w5; vstr w6; vstr w7; vstr w8; vstr w9; weapnext; weapprev; set fast vstr prev"
67+
set prev "vstr l; vstr w; weapprev; weapnext; set fast vstr best"
68+
set fast "vstr best"
69+
bind q "vstr fast"
70+
71+
set slot2 "vstr l2; vstr w2; set l vstr l2; set w vstr w2; set fast vstr best; bind MWHEELUP vstr slot3; bind MWHEELDOWN vstr slot9"
72+
set slot3 "vstr l3; vstr w3; set l vstr l3; set w vstr w3; set fast vstr best; bind MWHEELUP vstr slot4; bind MWHEELDOWN vstr slot2"
73+
set slot4 "vstr l4; vstr w4; set l vstr l4; set w vstr w4; set fast vstr best; bind MWHEELUP vstr slot5; bind MWHEELDOWN vstr slot3"
74+
set slot5 "vstr l5; vstr w5; set l vstr l5; set w vstr w5; set fast vstr best; bind MWHEELUP vstr slot6; bind MWHEELDOWN vstr slot4"
75+
set slot6 "vstr l6; vstr w6; set l vstr l6; set w vstr w6; set fast vstr best; bind MWHEELUP vstr slot7; bind MWHEELDOWN vstr slot5"
76+
set slot7 "vstr l7; vstr w7; set l vstr l7; set w vstr w7; set fast vstr best; bind MWHEELUP vstr slot8; bind MWHEELDOWN vstr slot6"
77+
set slot8 "vstr l8; vstr w8; set l vstr l8; set w vstr w8; set fast vstr best; bind MWHEELUP vstr slot9; bind MWHEELDOWN vstr slot7"
78+
set slot9 "vstr l9; vstr w9; set l vstr l9; set w vstr w9; set fast vstr best; bind MWHEELUP vstr slot2; bind MWHEELDOWN vstr slot8"
79+
80+
bind MWHEELDOWN "vstr slot9"
81+
bind MWHEELUP "vstr slot3"
82+
83+
bind e "+button2"
84+
bind r "set l vstr l2; set w vstr w2; bind MWHEELUP vstr slot3; bind MWHEELDOWN vstr slot9; vstr best;"
85+
bind CTRL "+movedown"

nix/clipmaker.nix

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
let
2+
pkgs = import ./nixpkgs.nix;
3+
in
4+
pkgs.writeShellApplication {
5+
name = "clipmaker";
6+
text = ''
7+
# Check if there are at least two arguments (video and at least one audio file)
8+
if [ "$#" -lt 2 ]; then
9+
echo "Usage: $0 <video_file> <audio_file1> [audio_file2 ...]"
10+
exit 1
11+
fi
12+
13+
# The first argument is the video file
14+
VIDEO_FILE="$1"
15+
shift # Remove the first argument (video file) from the list
16+
17+
# The rest are audio files
18+
AUDIO_FILES=("$@")
19+
20+
# Get the video duration
21+
VID_LEN_RAW="$(${pkgs.ffmpeg}/bin/ffprobe -v error -select_streams v:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 "$VIDEO_FILE")"
22+
VID_LEN_INT="$(LC_NUMERIC=C printf "%.0f\n" "$VID_LEN_RAW")"
23+
24+
# Construct the filter_complex dynamically based on the number of audio files
25+
FILTER_COMPLEX=""
26+
27+
# Create the concat filter part for audio
28+
for i in "''${!AUDIO_FILES[@]}"; do
29+
FILTER_COMPLEX+="[$((i+1)):a]"
30+
done
31+
32+
# Concatenate the audio files and apply fade-out
33+
FILTER_COMPLEX+="concat=n=''${#AUDIO_FILES[@]}:v=0:a=1[a]; [a]atrim=end=''${VID_LEN_RAW},afade=t=out:st=$((VID_LEN_INT - 5)):d=5[vout]"
34+
35+
# Construct the ffmpeg command, creating the input arguments in a safe manner
36+
INPUT_ARGS=("-i" "$VIDEO_FILE")
37+
for audio in "''${AUDIO_FILES[@]}"; do
38+
INPUT_ARGS+=("-i" "$audio")
39+
done
40+
41+
${pkgs.ffmpeg}/bin/ffmpeg "''${INPUT_ARGS[@]}" \
42+
-filter_complex "$FILTER_COMPLEX" \
43+
-map 0:v -map "[vout]" -c:v copy -y output.mp4
44+
'';
45+
}

nix/configuration.nix

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,8 @@ in {
743743
exe = ''
744744
${pkgs.openarena}/bin/openarena \
745745
+set fs_homepath ~/.firejail/q3/.openarena \
746-
+set fs_game omega
746+
+set fs_basegame omega \
747+
+set fs_game excessiveplus
747748
'';
748749
}
749750
// fj.mkFirejailCustom {
@@ -783,7 +784,7 @@ in {
783784
}
784785
// fj.mkFirejailCustom {
785786
pkg = "tabby-download-embed";
786-
dir = "tabby";
787+
dir = "tabby-download";
787788
net = true;
788789
exe = ''
789790
${import ./tabby.nix}/bin/tabby \
@@ -792,13 +793,22 @@ in {
792793
}
793794
// fj.mkFirejailCustom {
794795
pkg = "tabby-download-qwen";
795-
dir = "tabby";
796+
dir = "tabby-download";
796797
net = true;
797798
exe = ''
798799
${import ./tabby.nix}/bin/tabby \
799800
download --model Qwen2.5-Coder-0.5B
800801
'';
801802
}
803+
// fj.mkFirejailCustom {
804+
pkg = "tabby-download-deepseek";
805+
dir = "tabby-download";
806+
net = true;
807+
exe = ''
808+
${import ./tabby.nix}/bin/tabby \
809+
download --model DeepSeekCoder-1.3B
810+
'';
811+
}
802812
// fj.mkFirejailCustom {
803813
pkg = "tabby-agent";
804814
dir = "tabby";
@@ -859,7 +869,7 @@ in {
859869
pciutils
860870
docker-client
861871
docker-compose
862-
btop
872+
btop-rocm
863873
lsof
864874
wget
865875
#
@@ -910,6 +920,8 @@ in {
910920
simple-scan
911921
system-config-printer
912922
pulsemixer
923+
(import ./vidmaker.nix)
924+
(import ./clipmaker.nix)
913925
];
914926
programs.git = {
915927
enable = true;

nix/tabby-services.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ in [
1616
${import ./tabby-socat.nix}/bin/tabby-socat \
1717
serve \
1818
--device vulkan \
19-
--model Qwen2.5-Coder-0.5B
19+
--model DeepSeekCoder-1.3B
2020
'';
2121
}
2222
)

nix/vidmaker.nix

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
let
2+
pkgs = import ./nixpkgs.nix;
3+
in
4+
pkgs.writeShellApplication {
5+
name = "vidmaker";
6+
text = ''
7+
# Check if at least the output file argument is provided
8+
if [ "$#" -lt 1 ]; then
9+
echo "Usage: $0 output_file.mp4 [video1.mp4 video2.mp4 ...]"
10+
exit 1
11+
fi
12+
13+
# The first argument is the output file
14+
OUTPUT_FILE=$1
15+
shift # Shift to get the video files
16+
17+
# If no video files are specified, use all files in the current directory
18+
if [ "$#" -eq 0 ]; then
19+
FILES=(*)
20+
else
21+
FILES=("$@")
22+
fi
23+
24+
# Check if there are any files found
25+
if [ ''${#FILES[@]} -eq 0 ]; then
26+
echo "No video files found to concatenate."
27+
exit 1
28+
fi
29+
30+
# Generate the file list dynamically
31+
TEMP_FILE="./vidmaker.cfg"
32+
for file in "''${FILES[@]}"; do
33+
echo "file '$file'" >> "$TEMP_FILE"
34+
done
35+
36+
# Run ffmpeg with the generated file list
37+
${pkgs.ffmpeg}/bin/ffmpeg -f concat -safe 0 -i "$TEMP_FILE" -c copy "$OUTPUT_FILE"
38+
39+
# Clean up the temporary file
40+
rm "$TEMP_FILE"
41+
'';
42+
}

pub/functora/src/test/Functora/RoundSpec.hs

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
module Functora.RoundSpec (spec) where
22

3+
import Data.Fixed (E12, Fixed)
34
import Functora.Prelude (throw, throwString, try)
45
import Functora.Round (dpRound, sdRound)
6+
import Numeric.Natural (Natural)
57
import System.Exit (ExitCode (..))
68
import Test.DocTest (doctest)
7-
import Test.Hspec (Spec, it)
9+
import Test.Hspec
810
import Test.Tasty (TestTree, defaultMain, testGroup)
911
import Test.Tasty.HUnit as HU (testCase, (@?=))
10-
import Test.Tasty.QuickCheck as QC
12+
import qualified Test.Tasty.QuickCheck as QC
1113
import Prelude
1214

1315
spec :: Spec
@@ -24,6 +26,14 @@ spec = do
2426
"src/round/Functora/Round.hs"
2527
]
2628

29+
mkRoundSpec @(Fixed E12) "dpRound/Fixed" dpRound dpRoundTestData
30+
mkRoundSpec @Rational "dpRound/Rational" dpRound dpRoundTestData
31+
mkRoundSpec @Double "dpRound/Double" dpRound dpRoundTestData
32+
33+
mkRoundSpec @(Fixed E12) "sdRound/Fixed" sdRound sdRoundTestData
34+
mkRoundSpec @Rational "sdRound/Rational" sdRound sdRoundTestData
35+
mkRoundSpec @Double "sdRound/Double" sdRound sdRoundTestData
36+
2737
--
2838
-- Tasty
2939
--
@@ -104,3 +114,70 @@ qcProps =
104114
dpIdempotent :: Integer -> Rational -> Bool
105115
dpIdempotent dp x =
106116
let y = dpRound dp x in dpRound dp y == y
117+
118+
mkRoundSpec ::
119+
(Show a, RealFrac a) => String -> (b -> a -> a) -> [(b, a, a)] -> Spec
120+
mkRoundSpec label f =
121+
it label . mapM_ (\(x, prev, next) -> f x prev `shouldBe` next)
122+
123+
-- | Every element is a tuple (decimalPlaces, beforeRound, afterRound)
124+
dpRoundTestData :: (RealFrac a) => [(Integer, a, a)]
125+
dpRoundTestData =
126+
[ (2, 123456789.0, 123456789.0),
127+
(2, 1234.56789, 1234.57),
128+
(2, 123.456789, 123.46),
129+
(2, 12.3456789, 12.35),
130+
(2, 1.23456789, 1.23),
131+
(2, 0.123456789, 0.12),
132+
(2, 0.0123456789, 0.01),
133+
(2, 0.00123456789, 0.00),
134+
(3, 123456789.0, 123456789.0),
135+
(3, 1234.56789, 1234.568),
136+
(3, 123.456789, 123.457),
137+
(3, 12.3456789, 12.346),
138+
(3, 1.23456789, 1.235),
139+
(3, 0.123456789, 0.123),
140+
(3, 0.0123456789, 0.012),
141+
(3, 0.00123456789, 0.001),
142+
(3, 0.000123456789, 0.000),
143+
(4, 123456789.0, 123456789.0),
144+
(4, 1234.56789, 1234.5679),
145+
(4, 123.456789, 123.4568),
146+
(4, 12.3456789, 12.3457),
147+
(4, 1.23456789, 1.2346),
148+
(4, 0.123456789, 0.1235),
149+
(4, 0.0123456789, 0.0123),
150+
(4, 0.00123456789, 0.0012),
151+
(4, 0.000123456789, 0.0001),
152+
(4, 0.0000123456789, 0.0000)
153+
]
154+
155+
-- | Every element is a tuple (significantDigits, beforeRound, afterRound)
156+
sdRoundTestData :: (RealFrac a) => [(Natural, a, a)]
157+
sdRoundTestData =
158+
[ (4, 123456789.0, 123500000.0),
159+
(4, 1234.56789, 1235.0),
160+
(4, 123.456789, 123.5),
161+
(4, 12.3456789, 12.35),
162+
(4, 1.23456789, 1.235),
163+
(4, 0.123456789, 0.1235),
164+
(4, 0.0123456789, 0.01235),
165+
(4, 0.00123456789, 0.001235),
166+
(4, 0.000123456789, 0.0001235),
167+
(5, 123456789.0, 123460000.0),
168+
(5, 1234.56789, 1234.6),
169+
(5, 123.456789, 123.46),
170+
(5, 12.3456789, 12.346),
171+
(5, 1.23456789, 1.2346),
172+
(5, 0.123456789, 0.12346),
173+
(5, 0.0123456789, 0.012346),
174+
(5, 0.00123456789, 0.0012346),
175+
(5, 0.000123456789, 0.00012346),
176+
(6, 123456789.0, 123457000.0),
177+
(6, 1234.56789, 1234.57),
178+
(6, 123.456789, 123.457),
179+
(6, 12.3456789, 12.3457),
180+
(6, 1.23456789, 1.23457),
181+
(6, 0.123456789, 0.123457),
182+
(6, 0.0123456789, 0.0123457)
183+
]

pub/vi/vimrc.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,6 @@ let g:neoformat_toml_prettier = {
780780
" => Tabby
781781
"
782782

783-
let g:tabby_agent_start_command = ["tabby-agent", "--stdio"]
784-
let g:tabby_inline_completion_trigger = "auto"
783+
let g:tabby_agent_start_command = ["tabby-agent", "--stdio"]
784+
let g:tabby_inline_completion_trigger = "manual"
785785
let g:tabby_inline_completion_keybinding_accept = '<C-CR>'

0 commit comments

Comments
 (0)