{"id":27019048,"url":"https://github.com/jabbalaci/jabba-lib","last_synced_at":"2025-04-04T17:18:46.886Z","repository":{"id":57710557,"uuid":"512260335","full_name":"jabbalaci/jabba-lib","owner":"jabbalaci","description":"A utility library for Rust.","archived":false,"fork":false,"pushed_at":"2022-08-18T09:15:23.000Z","size":53,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-28T01:20:59.142Z","etag":null,"topics":["clipboard","library","python","rust","utility","utils"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/jabba-lib","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jabbalaci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-09T18:39:50.000Z","updated_at":"2023-07-04T12:35:34.000Z","dependencies_parsed_at":"2022-08-25T13:02:20.721Z","dependency_job_id":null,"html_url":"https://github.com/jabbalaci/jabba-lib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabbalaci%2Fjabba-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabbalaci%2Fjabba-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabbalaci%2Fjabba-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabbalaci%2Fjabba-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jabbalaci","download_url":"https://codeload.github.com/jabbalaci/jabba-lib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217217,"owners_count":20903009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clipboard","library","python","rust","utility","utils"],"created_at":"2025-04-04T17:18:46.316Z","updated_at":"2025-04-04T17:18:46.880Z","avatar_url":"https://github.com/jabbalaci.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jabba-lib\n\nA general-purpose utility library for Rust. Its API was mainly inspired by the\nPython programming language.\n\n## Some examples\n\nThis is just a teaser. The library has many more modules\nand --in most cases-- the modules contain more functions than shown below.\n\n### console\n\nRead from the stadandard input.\n\n```rust\nuse jabba_lib::jconsole;\n\nfn main() {\n    let name = jconsole::input(\"Name: \");\n    let name = name.trim();\n    println!(\"Hello {}!\", name);\n}\n```\n\n### process\n\nCall an external command.\n\n```rust\nuse jabba_lib::jprocess as jproc;\n\nfn main() {\n    let cmd = \"ls -al\";\n    jproc::exec_cmd(cmd);\n}\n```\n\n### fs\n\nRead a text file line by line.\n\n```rust\nuse jabba_lib::jfs;\nuse std::io::BufRead;\n\nfn main() {\n    let f = jfs::open(\"Cargo.toml\").unwrap();\n    for line in f.lines() {\n        let line = line.unwrap();\n        println!(\"{}\", line);\n    }\n}\n```\n\n### math\n\n```rust\nuse jabba_lib::jmath;\n\nfn main() {\n    assert_eq!(jmath::is_palindrome(101), true);\n    assert_eq!(jmath::is_prime(97), true);\n    assert_eq!(jmath::get_divisors(28), [1, 2, 4, 7, 14, 28]);\n    assert_eq!(jmath::factorial(5), 120);\n    assert_eq!(jmath::factorial_bigint(33).to_string(), \"8683317618811886495518194401280000000\");\n}\n```\n\n### string\n\n```rust\nuse jabba_lib::jstring;\n\nfn main() {\n    let name = \"Dave\";\n    let reversed = jstring::str_rev(name); // evaD\n    println!(\"{} \u003c-\u003e {}\", name, reversed);\n\n    let name = \"anna\";\n    println!(\"{} is palindrome: {}\", name, jstring::is_palindrome(name));\n}\n```\n\n### random\n\n```rust\nuse jabba_lib::jrandom;\n\nfn main() {\n    let number = jrandom::randrange(1, 10); // 10 is excluded\n    println!(\"random number from [1, 10): {}\", number);\n\n    let number = jrandom::randint(1, 100); // 100 is included\n    println!(\"random number from [1, 100]: {}\", number);\n\n    let mut numbers = vec![1, 2, 3, 4, 5];\n    jrandom::shuffle(\u0026mut numbers);\n    println!(\"shuffled: {:?}\", numbers); // could be [3, 5, 1, 4, 2]\n}\n```\n\n### clipboard\n\nSupported platforms: Linux (with X server), Windows.\n\nUnder Linux you must have the program `xsel` installed.\nYou can install it with your package manager.\n\nUnder Linux, the text is pasted on both clipboards (to \"primary\" and \"clipboard\").\n\n```rust\nuse jabba_lib::jclipboard;\n\nfn main() {\n    let text = \"hello\";\n\n    jabba_lib::jclipboard::check(); // verify if your platform is supported\n\n    jabba_lib::jclipboard::set_text(text).unwrap();\n    println!(\"The text {:?} was pasted on the clipboard\", text);\n\n    let read = jabba_lib::jclipboard::get_text().unwrap();\n    println!(\"Contents of the clipboard: {:?}\", read);\n\n    assert_eq!(read, text);\n}\n```\n\n### spell\n\nSpell a number (write out in words).\n\n```rust\nuse jabba_lib::jspell;\n\nfn main() {\n    assert_eq!(jspell::spell_number(5), \"five\");\n    assert_eq!(jspell::spell_number(11), \"eleven\");\n    assert_eq!(jspell::spell_number(101), \"one hundred and one\");\n    assert_eq!(jspell::spell_number(999), \"nine hundred and ninety-nine\");\n}\n```\n\n### time\n\n```rust\nuse jabba_lib::jtime;\n\nfn main() {\n    let wait = 1.5;\n\n    println!(\"Waiting for {:.2} seconds...\", wait);\n    jtime::sleep(wait);\n    println!(\"Done.\");\n}\n```\n\nSee the folder [examples/](https://github.com/jabbalaci/jabba-lib/tree/main/examples)\nfor more examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabbalaci%2Fjabba-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjabbalaci%2Fjabba-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabbalaci%2Fjabba-lib/lists"}