This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Scanner = struct | |
(* attempt to open a port and return an option *) | |
let open_port host port timeout = fun () -> | |
let open Lwt.Infix in | |
let sockaddr = Unix.ADDR_INET (Unix.inet_addr_of_string host, port) in | |
let socket = Lwt_unix.socket Unix.PF_INET Unix.SOCK_STREAM 0 in | |
Lwt.catch | |
(* Port is open *) | |
(fun () -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module UserModel = struct | |
module DB = Sqlite3 | |
module JSON = Yojson.Basic | |
let create_table db = | |
let create_sql = | |
"CREATE TABLE IF NOT EXISTS users (" ^ | |
"id INTEGER PRIMARY KEY, " ^ | |
"name TEXT, " ^ | |
"age INTEGER, " ^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
compile with: | |
`ocamlfind ocamlopt -thread -o downloader -linkpkg -package lwt,cohttp-lwt-unix downloader.ml` | |
*) | |
module Downloader = struct | |
(* download a single file *) | |
let dl_file url filename = | |
let open Lwt.Infix in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io" | |
"log" | |
"os" | |
"time" | |
"github.com/charmbracelet/bubbles/viewport" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <expression ::= <term> { ("+" | "-") <term> } | |
// <term> ::= <factor> { ("*" | "/") <factor> } | |
// <factor> ::= <number> | "(" <expression> ")" | |
// <number> ::= <digit> { <digit> } | |
// <digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | |
use std::str::FromStr; | |
#[derive(Debug, PartialEq, Clone)] | |
pub enum Token { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TOTAL CHUNKS: 5 | |
// - chunk: 5242880 | |
// - chunk: 5242880 | |
// - chunk: 5242880 | |
// - chunk: 5242880 | |
// - chunk: 1974756 | |
use tokio::{fs::File, io, io::AsyncReadExt, io::AsyncSeekExt}; | |
pub async fn read_chunk(file_path: &str, start: u64, end: u64) -> io::Result<Vec<u8>> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use inquire::{validator::Validation, CustomType}; | |
use std::path::{self, Path}; | |
fn full_path(p: String) -> String { | |
path::absolute(p.as_str()) | |
.unwrap() | |
.canonicalize() | |
.unwrap() | |
.to_str() | |
.unwrap() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fs::File; | |
enum ComeWith<T, E> { | |
YouBetcha(T), | |
Ope(E), | |
} | |
impl<T, E> From<std::result::Result<T, E>> for ComeWith<T, E> { | |
fn from(r: std::result::Result<T, E>) -> Self { | |
match r { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import pandas as pd | |
def getDataframe(url_table, ind): | |
df = pd.read_html(url_table)[ind] | |
return df | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// rust has pretty print support for printing structures. this is how rust's proc_macros | |
// parse the following struct: | |
// | |
// pub struct Book { | |
// id: u64, | |
// title: String, | |
// pages: u64, | |
// author: String, | |
// } | |
// |
NewerOlder