mirror of
https://github.com/kuhyx/testsAndMisc-archive.git
synced 2026-11-26 14:47:23 +01:00
feat: great beautiful fixes
This commit is contained in:
parent
67da5c4fb9
commit
ac7d678007
@ -39,11 +39,14 @@ void pauseForGivenTime(float given_time)
|
|||||||
|
|
||||||
float calculateVelocity(float starting_velocity, unsigned int physics_time, int *acceleration)
|
float calculateVelocity(float starting_velocity, unsigned int physics_time, int *acceleration)
|
||||||
{
|
{
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
return (*acceleration) * physics_time + starting_velocity;
|
return (*acceleration) * physics_time + starting_velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
int calculateDisplacement(float starting_velocity, int *acceleration, unsigned int physics_time)
|
int calculateDisplacement(float starting_velocity, int *acceleration, unsigned int physics_time)
|
||||||
{
|
{
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
// cppcheck-suppress ctunullpointer
|
||||||
return starting_velocity * physics_time + ((1 / 2) * (*acceleration) * (physics_time ^ 2));
|
return starting_velocity * physics_time + ((1 / 2) * (*acceleration) * (physics_time ^ 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +58,7 @@ void printXPosition(int position)
|
|||||||
|
|
||||||
void printClock(unsigned int *time)
|
void printClock(unsigned int *time)
|
||||||
{
|
{
|
||||||
printf("%d seconds passed\n", *time);
|
printf("%u seconds passed\n", *time);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# Clang-format configuration for imageViewer project
|
# Clang-format configuration for imageViewer project
|
||||||
---
|
---
|
||||||
Language: C
|
Language: Cpp
|
||||||
# Base style
|
# Base style
|
||||||
BasedOnStyle: LLVM
|
BasedOnStyle: LLVM
|
||||||
|
|
||||||
|
|||||||
@ -447,6 +447,7 @@ static void find_longest_excerpt(int max_vocab)
|
|||||||
rarest_word = word_sequence[i]->word;
|
rarest_word = word_sequence[i]->word;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
printf("Rarest word used: %s (#%d)\n", rarest_word, max_rank_used);
|
printf("Rarest word used: %s (#%d)\n", rarest_word, max_rank_used);
|
||||||
|
|
||||||
/* Count unique words in excerpt */
|
/* Count unique words in excerpt */
|
||||||
|
|||||||
@ -63,6 +63,7 @@ bool validInput(const std::string s) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cppcheck-suppress missingReturn
|
||||||
std::vector<int> requiredShoots(const int pointsLeft) {}
|
std::vector<int> requiredShoots(const int pointsLeft) {}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|||||||
@ -43,14 +43,14 @@ bool errorUserInput(std::string userInput) {
|
|||||||
|
|
||||||
std::string convertToTier(float nominator, float denominator) {
|
std::string convertToTier(float nominator, float denominator) {
|
||||||
float fraction = nominator / denominator;
|
float fraction = nominator / denominator;
|
||||||
int tierIndex;
|
int tierIndex = 0;
|
||||||
for (int i = TIER_BASE; i > 0; i--) {
|
for (int i = TIER_BASE; i > 0; i--) {
|
||||||
if (fraction >= (i / TIER_BASE)) {
|
if (fraction >= (i / TIER_BASE)) {
|
||||||
tierIndex = i - 1;
|
tierIndex = i - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tierIndex == 0 & fraction > (1.1 / 10.0))
|
if (tierIndex == 0 && fraction > (1.1 / 10.0))
|
||||||
return TIERS[1];
|
return TIERS[1];
|
||||||
return TIERS[tierIndex];
|
return TIERS[tierIndex];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ const API_BASE = 'https://api.football-data.org/v4';
|
|||||||
const API_TOKEN = process.env.FOOTBALL_DATA_API_KEY;
|
const API_TOKEN = process.env.FOOTBALL_DATA_API_KEY;
|
||||||
|
|
||||||
if (!API_TOKEN) {
|
if (!API_TOKEN) {
|
||||||
|
|
||||||
console.warn('[server] FOOTBALL_DATA_API_KEY is not set. Live data will not work until you set it.');
|
console.warn('[server] FOOTBALL_DATA_API_KEY is not set. Live data will not work until you set it.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ app.use((req, res, next) => {
|
|||||||
return originalSend(body);
|
return originalSend(body);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
console.log(`[#${id}] -> ${req.method} ${req.originalUrl}` + (Object.keys(req.query || {}).length ? ` query=${JSON.stringify(req.query)}` : ''));
|
console.log(`[#${id}] -> ${req.method} ${req.originalUrl}` + (Object.keys(req.query || {}).length ? ` query=${JSON.stringify(req.query)}` : ''));
|
||||||
|
|
||||||
res.on('finish', () => {
|
res.on('finish', () => {
|
||||||
@ -65,7 +65,7 @@ app.use((req, res, next) => {
|
|||||||
bodyPreview = ` body=${clip(str)}`;
|
bodyPreview = ` body=${clip(str)}`;
|
||||||
}
|
}
|
||||||
} catch { /* ignore */ }
|
} catch { /* ignore */ }
|
||||||
|
|
||||||
console.log(`[#${id}] <- ${req.method} ${req.originalUrl} ${res.statusCode} ${durMs.toFixed(1)}ms${bodyPreview}`);
|
console.log(`[#${id}] <- ${req.method} ${req.originalUrl} ${res.statusCode} ${durMs.toFixed(1)}ms${bodyPreview}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -77,12 +77,12 @@ axios.interceptors.request.use(
|
|||||||
(config) => {
|
(config) => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
(config as any).metadata = { start: Date.now() };
|
(config as any).metadata = { start: Date.now() };
|
||||||
|
|
||||||
console.log(`[axios ->] ${String(config.method || 'GET').toUpperCase()} ${config.url}`);
|
console.log(`[axios ->] ${String(config.method || 'GET').toUpperCase()} ${config.url}`);
|
||||||
return config;
|
return config;
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
|
|
||||||
console.warn('[axios req error]', error?.message || error);
|
console.warn('[axios req error]', error?.message || error);
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ axios.interceptors.response.use(
|
|||||||
const size = dataStr?.length || 0;
|
const size = dataStr?.length || 0;
|
||||||
const MAX_LOG_BODY = 2000;
|
const MAX_LOG_BODY = 2000;
|
||||||
const clip = (s: string) => (s && s.length > MAX_LOG_BODY ? `${s.slice(0, MAX_LOG_BODY)}…(+${s.length - MAX_LOG_BODY})` : s);
|
const clip = (s: string) => (s && s.length > MAX_LOG_BODY ? `${s.slice(0, MAX_LOG_BODY)}…(+${s.length - MAX_LOG_BODY})` : s);
|
||||||
|
|
||||||
console.log(`[axios <-] ${response.status} ${String(response.config.method || 'GET').toUpperCase()} ${response.config.url} ${dur}ms ~${size}B data=${clip(dataStr)}`);
|
console.log(`[axios <-] ${response.status} ${String(response.config.method || 'GET').toUpperCase()} ${response.config.url} ${dur}ms ~${size}B data=${clip(dataStr)}`);
|
||||||
return response;
|
return response;
|
||||||
},
|
},
|
||||||
@ -117,7 +117,7 @@ axios.interceptors.response.use(
|
|||||||
} catch { /* ignore */ }
|
} catch { /* ignore */ }
|
||||||
const MAX_LOG_BODY = 2000;
|
const MAX_LOG_BODY = 2000;
|
||||||
const clip = (s: string) => (s && s.length > MAX_LOG_BODY ? `${s.slice(0, MAX_LOG_BODY)}…(+${s.length - MAX_LOG_BODY})` : s);
|
const clip = (s: string) => (s && s.length > MAX_LOG_BODY ? `${s.slice(0, MAX_LOG_BODY)}…(+${s.length - MAX_LOG_BODY})` : s);
|
||||||
|
|
||||||
console.warn(`[axios ! ] ${status ?? 'ERR'} ${String(cfg.method || 'GET').toUpperCase()} ${cfg.url} ${dur}ms data=${dataStr ? clip(dataStr) : (error?.message || 'error')}`);
|
console.warn(`[axios ! ] ${status ?? 'ERR'} ${String(cfg.method || 'GET').toUpperCase()} ${cfg.url} ${dur}ms data=${dataStr ? clip(dataStr) : (error?.message || 'error')}`);
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
@ -211,6 +211,6 @@ app.get('/api/matches', async (req: Request, res: Response) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.listen(PORT, () => {
|
app.listen(PORT, () => {
|
||||||
|
|
||||||
console.log(`[server] Listening on http://localhost:${PORT}`);
|
console.log(`[server] Listening on http://localhost:${PORT}`);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#include "my_application.h"
|
#include "my_application.h"
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char **argv) {
|
||||||
g_autoptr(MyApplication) app = my_application_new();
|
g_autoptr(MyApplication) app = my_application_new();
|
||||||
return g_application_run(G_APPLICATION(app), argc, argv);
|
return g_application_run(G_APPLICATION(app), argc, argv);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,20 +9,20 @@
|
|||||||
|
|
||||||
struct _MyApplication {
|
struct _MyApplication {
|
||||||
GtkApplication parent_instance;
|
GtkApplication parent_instance;
|
||||||
char** dart_entrypoint_arguments;
|
char **dart_entrypoint_arguments;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
|
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
|
||||||
|
|
||||||
// Called when first Flutter frame received.
|
// Called when first Flutter frame received.
|
||||||
static void first_frame_cb(MyApplication* self, FlView* view) {
|
static void first_frame_cb(MyApplication *self, FlView *view) {
|
||||||
gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view)));
|
gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements GApplication::activate.
|
// Implements GApplication::activate.
|
||||||
static void my_application_activate(GApplication* application) {
|
static void my_application_activate(GApplication *application) {
|
||||||
MyApplication* self = MY_APPLICATION(application);
|
MyApplication *self = MY_APPLICATION(application);
|
||||||
GtkWindow* window =
|
GtkWindow *window =
|
||||||
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
|
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
|
||||||
|
|
||||||
// Use a header bar when running in GNOME as this is the common style used
|
// Use a header bar when running in GNOME as this is the common style used
|
||||||
@ -34,16 +34,16 @@ static void my_application_activate(GApplication* application) {
|
|||||||
// if future cases occur).
|
// if future cases occur).
|
||||||
gboolean use_header_bar = TRUE;
|
gboolean use_header_bar = TRUE;
|
||||||
#ifdef GDK_WINDOWING_X11
|
#ifdef GDK_WINDOWING_X11
|
||||||
GdkScreen* screen = gtk_window_get_screen(window);
|
GdkScreen *screen = gtk_window_get_screen(window);
|
||||||
if (GDK_IS_X11_SCREEN(screen)) {
|
if (GDK_IS_X11_SCREEN(screen)) {
|
||||||
const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
|
const gchar *wm_name = gdk_x11_screen_get_window_manager_name(screen);
|
||||||
if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
|
if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
|
||||||
use_header_bar = FALSE;
|
use_header_bar = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (use_header_bar) {
|
if (use_header_bar) {
|
||||||
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
|
GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
|
||||||
gtk_widget_show(GTK_WIDGET(header_bar));
|
gtk_widget_show(GTK_WIDGET(header_bar));
|
||||||
gtk_header_bar_set_title(header_bar, "pomodoro_app");
|
gtk_header_bar_set_title(header_bar, "pomodoro_app");
|
||||||
gtk_header_bar_set_show_close_button(header_bar, TRUE);
|
gtk_header_bar_set_show_close_button(header_bar, TRUE);
|
||||||
@ -58,7 +58,7 @@ static void my_application_activate(GApplication* application) {
|
|||||||
fl_dart_project_set_dart_entrypoint_arguments(
|
fl_dart_project_set_dart_entrypoint_arguments(
|
||||||
project, self->dart_entrypoint_arguments);
|
project, self->dart_entrypoint_arguments);
|
||||||
|
|
||||||
FlView* view = fl_view_new(project);
|
FlView *view = fl_view_new(project);
|
||||||
GdkRGBA background_color;
|
GdkRGBA background_color;
|
||||||
// Background defaults to black, override it here if necessary, e.g. #00000000
|
// Background defaults to black, override it here if necessary, e.g. #00000000
|
||||||
// for transparent.
|
// for transparent.
|
||||||
@ -79,10 +79,10 @@ static void my_application_activate(GApplication* application) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Implements GApplication::local_command_line.
|
// Implements GApplication::local_command_line.
|
||||||
static gboolean my_application_local_command_line(GApplication* application,
|
static gboolean my_application_local_command_line(GApplication *application,
|
||||||
gchar*** arguments,
|
gchar ***arguments,
|
||||||
int* exit_status) {
|
int *exit_status) {
|
||||||
MyApplication* self = MY_APPLICATION(application);
|
MyApplication *self = MY_APPLICATION(application);
|
||||||
// Strip out the first argument as it is the binary name.
|
// Strip out the first argument as it is the binary name.
|
||||||
self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
|
self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ static gboolean my_application_local_command_line(GApplication* application,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Implements GApplication::startup.
|
// Implements GApplication::startup.
|
||||||
static void my_application_startup(GApplication* application) {
|
static void my_application_startup(GApplication *application) {
|
||||||
// MyApplication* self = MY_APPLICATION(object);
|
// MyApplication* self = MY_APPLICATION(object);
|
||||||
|
|
||||||
// Perform any actions required at application startup.
|
// Perform any actions required at application startup.
|
||||||
@ -109,7 +109,7 @@ static void my_application_startup(GApplication* application) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Implements GApplication::shutdown.
|
// Implements GApplication::shutdown.
|
||||||
static void my_application_shutdown(GApplication* application) {
|
static void my_application_shutdown(GApplication *application) {
|
||||||
// MyApplication* self = MY_APPLICATION(object);
|
// MyApplication* self = MY_APPLICATION(object);
|
||||||
|
|
||||||
// Perform any actions required at application shutdown.
|
// Perform any actions required at application shutdown.
|
||||||
@ -118,13 +118,13 @@ static void my_application_shutdown(GApplication* application) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Implements GObject::dispose.
|
// Implements GObject::dispose.
|
||||||
static void my_application_dispose(GObject* object) {
|
static void my_application_dispose(GObject *object) {
|
||||||
MyApplication* self = MY_APPLICATION(object);
|
MyApplication *self = MY_APPLICATION(object);
|
||||||
g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
|
g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
|
||||||
G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
|
G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void my_application_class_init(MyApplicationClass* klass) {
|
static void my_application_class_init(MyApplicationClass *klass) {
|
||||||
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
|
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
|
||||||
G_APPLICATION_CLASS(klass)->local_command_line =
|
G_APPLICATION_CLASS(klass)->local_command_line =
|
||||||
my_application_local_command_line;
|
my_application_local_command_line;
|
||||||
@ -133,9 +133,9 @@ static void my_application_class_init(MyApplicationClass* klass) {
|
|||||||
G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
|
G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void my_application_init(MyApplication* self) {}
|
static void my_application_init(MyApplication *self) {}
|
||||||
|
|
||||||
MyApplication* my_application_new() {
|
MyApplication *my_application_new() {
|
||||||
// Set the program name to the application ID, which helps various systems
|
// Set the program name to the application ID, which helps various systems
|
||||||
// like GTK and desktop environments map this running application to its
|
// like GTK and desktop environments map this running application to its
|
||||||
// corresponding .desktop file. This ensures better integration by allowing
|
// corresponding .desktop file. This ensures better integration by allowing
|
||||||
|
|||||||
@ -3,10 +3,7 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE(MyApplication,
|
G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
|
||||||
my_application,
|
|
||||||
MY,
|
|
||||||
APPLICATION,
|
|
||||||
GtkApplication)
|
GtkApplication)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,6 +13,6 @@ G_DECLARE_FINAL_TYPE(MyApplication,
|
|||||||
*
|
*
|
||||||
* Returns: a new #MyApplication.
|
* Returns: a new #MyApplication.
|
||||||
*/
|
*/
|
||||||
MyApplication* my_application_new();
|
MyApplication *my_application_new();
|
||||||
|
|
||||||
#endif // FLUTTER_MY_APPLICATION_H_
|
#endif // FLUTTER_MY_APPLICATION_H_
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user