work git oeasse

This commit is contained in:
Goren Barak 2023-12-05 18:04:03 -05:00
commit 5af858caee
7 changed files with 3240 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

3120
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

8
Cargo.toml Normal file
View file

@ -0,0 +1,8 @@
[package]
name = "kilos"
version = "0.1.0"
edition = "2021"
[dependencies]
chrono = "0.4.31"
eframe = "0.24.1"

10
LICENSE Normal file
View file

@ -0,0 +1,10 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>

3
README.md Normal file
View file

@ -0,0 +1,3 @@
# kilos
A small program hacked together in around 0.3 kiloseconds to count kiloseconds since 12:00 AM. Has like 100 dependencies because this isn't a professional project, I just hacked something together as fast as possible.

49
src/main.rs Normal file
View file

@ -0,0 +1,49 @@
use eframe::egui::{self, Context, CentralPanel, RawInput, FontDefinitions, FontFamily, FontData};
use chrono::prelude::*;
fn main() -> Result<(), eframe::Error> {
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
..Default::default()
};
eframe::run_native(
"Kiloseconds",
options,
Box::new(|cc| {
Box::<App>::default()
})
)
}
struct App {
time: DateTime<Local>
}
impl Default for App {
fn default() -> Self {
Self {
time: Local::now()
}
}
}
impl eframe::App for App {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
let mut fonts = FontDefinitions::default();
fonts.font_data.insert("JBMono".to_owned(),
FontData::from_static(include_bytes!("/usr/share/fonts/TTF/JetBrainsMonoNerdFontMono-Regular.ttf"))); // .ttf and .otf supported
fonts.families.get_mut(&FontFamily::Proportional).unwrap()
.insert(0, "JBMono".to_owned());
ctx.set_fonts(fonts);
let midnight = self.time.date().and_hms(0, 0, 0);
let duration_since_midnight = self.time - midnight;
let seconds_since_midnight = duration_since_midnight.num_seconds() as f64;
self.time = Local::now();
ui.centered_and_justified(|ui| {
ui.label(egui::RichText::new((seconds_since_midnight / 1000.0).to_string()).size(50.0).color(egui::Color32::WHITE));
});
ui.ctx().request_repaint();
});
}
}

49
src/main.rs~ Normal file
View file

@ -0,0 +1,49 @@
use eframe::egui::{self, Context, CentralPanel, RawInput, FontDefinitions, FontFamily, FontData};
use chrono::prelude::*;
fn main() -> Result<(), eframe::Error> {
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
..Default::default()
};
eframe::run_native(
"appy",
options,
Box::new(|cc| {
Box::<App>::default()
})
)
}
struct App {
time: DateTime<Local>
}
impl Default for App {
fn default() -> Self {
Self {
time: Local::now()
}
}
}
impl eframe::App for App {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
let mut fonts = FontDefinitions::default();
fonts.font_data.insert("JBMono".to_owned(),
FontData::from_static(include_bytes!("/usr/share/fonts/TTF/JetBrainsMonoNerdFontMono-Regular.ttf"))); // .ttf and .otf supported
fonts.families.get_mut(&FontFamily::Proportional).unwrap()
.insert(0, "JBMono".to_owned());
ctx.set_fonts(fonts);
let midnight = self.time.date().and_hms(0, 0, 0);
let duration_since_midnight = self.time - midnight;
let seconds_since_midnight = duration_since_midnight.num_seconds() as f64;
self.time = Local::now();
ui.centered_and_justified(|ui| {
ui.heading((seconds_since_midnight/1000.0).to_string());
});
ui.ctx().request_repaint();
});
}
}