text stringlengths 12 786k |
|---|
let decode_public_key key file path logger = match Or_error . try_with ( fun ( ) -> Public_key . of_base58_check_decompress_exn key ) key with | Ok pk -> Some pk | Error e -> [ % log error ] error " Error decoding public key at $ path /$ file : $ error " ~ metadata : [ ( " file " , ... |
let reload ~ logger { cache ; path } : unit Deferred . t = let logger = Logger . extend logger [ ( " wallets_context " , ` String " Wallets . get ) " ] in Public_key . Compressed . Table . clear cache ; let % bind ( ) = File_system . create_dir path in let % bind files = Sys ... |
let load ~ logger ~ disk_location = let t = { cache = Public_key . Compressed . Table . create ( ) ; path = disk_location ^/ " store " } in let % map ( ) = reload ~ logger t in t |
let import_keypair_helper t keypair write_keypair = let compressed_pk = Public_key . compress keypair . Keypair . public_key in let privkey_path = get_path t compressed_pk in let % bind ( ) = write_keypair privkey_path in let % map ( ) = Unix . chmod privkey_path ~ perm : 0o600 in ignore ( Public... |
let import_keypair t keypair ~ password = import_keypair_helper t keypair ( fun privkey_path -> Secret_keypair . write_exn keypair ~ privkey_path ~ password ) |
let import_keypair_terminal_stdin t keypair = import_keypair_helper t keypair ( fun privkey_path -> Secret_keypair . Terminal_stdin . write_exn keypair ~ privkey_path ) |
let generate_new t ~ password : Public_key . Compressed . t Deferred . t = let keypair = Keypair . create ( ) in import_keypair t keypair ~ password |
let create_hd_account t ~ hd_index : ( Public_key . Compressed . t , string ) string Deferred . Result . t = let open Deferred . Result . Let_syntax in let % bind public_key = Hardware_wallets . compute_public_key ~ hd_index in let compressed_pk = Public_key . compress public_key in let index_path ... |
let delete ( { cache ; _ } as t : t ) t ( pk : Public_key . Compressed . t ) t : ( unit , [ ` Not_found ] ) Deferred . Result . t = Hashtbl . remove cache pk ; Deferred . Or_error . try_with ~ here [ :% here ] here ( fun ( ) -> Unix . remove ( get_path t pk ) pk... |
let pks ( { cache ; _ } : t ) t = Public_key . Compressed . Table . keys cache |
let find_unlocked ( { cache ; _ } : t ) t ~ needle = Public_key . Compressed . Table . find cache needle |> Option . bind ~ f ( : function | Locked _ -> None | Unlocked ( _ , kp ) kp -> Some kp | Hd_account _ -> None ) |
let find_identity ( { cache ; _ } : t ) t ~ needle = Public_key . Compressed . Table . find cache needle |> Option . bind ~ f ( : function | Locked _ -> None | Unlocked ( _ , kp ) kp -> Some ( ` Keypair kp ) kp | Hd_account index -> Some ( ` Hd_index index ) index ) |
let check_locked { cache ; _ } ~ needle = Public_key . Compressed . Table . find cache needle |> Option . map ~ f ( : function | Locked _ -> true | Unlocked _ -> false | Hd_account _ -> true ) |
let unlock { cache ; path } ~ needle ~ password = let unlock_keypair = function | Locked file -> Secret_keypair . read ~ privkey_path ( : path ^/ file ) file ~ password |> Deferred . Result . map_error ~ f ( : fun e -> ` Key_read_error e ) e |> Deferred . Result . map ~ f ( : fun k... |
let lock { cache ; _ } ~ needle = Public_key . Compressed . Table . change cache needle ~ f ( : function | Some ( Unlocked ( file , _ ) _ ) _ -> Some ( Locked file ) file | k -> k ) |
let get_tracked_keypair ~ logger ~ which ~ read_from_env_exn ~ conf_dir pk = let % bind wallets = load ~ logger ~ disk_location ( : conf_dir ^/ " wallets ) " in let sk_file = get_path wallets pk in read_from_env_exn ~ which sk_file ( module struct let logger = Logger . create ( ) let passwo... |
type presence = | No | Yes | Eye |
module Side = struct type t = Wall . t Map . M ( Int ) . t [ @@ deriving scad_jane ] type config = int -> Wall . config option end |
module Sides = struct type t = { west : Side . t ; north : Side . t ; east : Side . t ; south : Side . t } [ @@ deriving scad ] let manual_body ( ? spacing = 1 . ) ~ west ~ north ~ east ~ south ( columns : _ Columns . t ) = { west = Map . filter_mapi ~ f ( : f... |
let auto_body ? d1 ? d2 ? z_off ? thickness ? index_thickness ? north_clearance ? south_clearance ? side_clearance ? n_steps ? n_facets ? north_lookup ? south_lookup ? west_lookup ? east_lookup ? eyelet_config Plate . { config = { spacing ; _ } ; body ; _ } = Sides . auto ? d1 ? d... |
let auto_thumb ( ? d1 = 1 . ) ( ? d2 = 3 . ) ( ? z_off = 0 . ) ( ? thickness = 3 . 5 ) ? index_thickness ( ? north_clearance = 2 . 5 ) ( ? south_clearance = 2 . 5 ) ( ? side_clearance = 3 . 0 ) ( ? n_steps = ` PerZ 4 . ) ( ? n_facets = 1... |
type t = { body : Sides . t ; thumb : Sides . t } |
let make ~ body ~ thumb = { body ; thumb } |
let manual ~ body_west ~ body_north ~ body_east ~ body_south ~ thumb_south ~ thumb_north ~ thumb_east ~ thumb_west Plate . { config = { spacing ; _ } ; body ; thumb ; _ } = { body = Sides . manual_body ~ west : body_west ~ north : body_north ~ east : body_east ~ south : body_s... |
let to_scad { body ; thumb } = Scad . union [ Sides . to_scad body ; Sides . to_scad thumb ] |
let collect_screws { body ; thumb } = Sides . collect_screws ~ init ( : Sides . collect_screws thumb ) body |
let test_check_walrus_operator context = let assert_type_errors = assert_type_errors ~ context in assert_type_errors { | ( x := True ) reveal_type ( x ) } | [ " Revealed type [ - 1 ] : Revealed type for ` x ` is ` typing_extensions . Literal [ True ] ` . " ] ; assert_t... |
let ( ) = " walrus " >::: [ " check_walrus_operator " >:: test_check_walrus_operator ] |> Test . run |
this is a comment ) * |
type t = Foo | Bar ; ; |
let f = function | Foo -> print_string " 1 " | _ -> print_string " other than 1 " |
let _ = print_string " hello " ; List . iter print_string ; print_string " world " |
let ( ) = let iter ' ~ f xs = List . iter f xs in iter ' print_endline [ " hello " ; " world " ] method m = print_endline " hello " end inherit c method m = print_endline " bye " end |
let g = function | true -> print_endline " hello " |
type r = { x : int ; y : int } |
let h = function | { x = 0 } -> 0 | { x = _ } -> 1 |
let f10 fd = let buf = Bytes . create 10 in Unix . read fd buf 0 10 ; buf |
let x11 x = match x with | Some true -> 1 | Some false -> 0 | None -> 0 | Some _ -> 2 |
let w12 = function | ( Some _ | Some _ ) -> 1 | None -> 0 val mutable x = 1 method get_x = x end val mutable x = 10 inherit c13 method get_x ' = x end |
let regexp = " ( [ \ A - Z ] [ + A - Za - z0 - 9 ] ) . " +\\ method private x = self # x + 1 end |
module type DEPRECATED = sig end [ @@ ocaml . deprecated ] |
module T = struct type deprecated [ @@ ocaml . deprecated ] end |
let _ = let x = 1 in ( ) |
module A = struct let _ = let x = 1 in ( ) end |
module rec B : sig type t end = struct type t = T . deprecated end |
module type T = sig type t = T . deprecated end |
module type S = sig val x : T . deprecated [ @@ ocaml . alert " - deprecated " ] module AA : sig type t = T . deprecated end [ @@ ocaml . alert " - deprecated " ] module rec BB : sig type t = T . deprecated end [ @@ ocaml . alert " - deprecated " ] module type T = sig ty... |
let foo ? x = ( ) [ %% expect { | ^ } ] | |
let foo ? x ~ y = ( ) [ %% expect { | ^ } ] | |
let foo ? x ( ) = ( ) [ %% expect { | } ] | |
let foo ? x ~ y ( ) = ( ) [ %% expect { | } ] | [ %% expect { | ^ } ] | [ %% expect { | ^ } ] | [ %% expect { | } ] | [ %% expect { | } ] | |
type loc = { loc_start : Lexing . position ; loc_end : Lexing . position ; loc_ghost : bool ; } |
type t = | Comment_start | Comment_not_end | Fragile_match of string | Partial_application | Labels_omitted of string list | Method_override of string list | Partial_match of string | Non_closed_record_pattern of string | Statement_type | Unused_match | Unused_pat | Instance_variable_override of string lis... |
type alert = { kind : string ; message : string ; def : loc ; use : loc } |
let number = function | Comment_start -> 1 | Comment_not_end -> 2 | Fragile_match _ -> 4 | Partial_application -> 5 | Labels_omitted _ -> 6 | Method_override _ -> 7 | Partial_match _ -> 8 | Non_closed_record_pattern _ -> 9 | Statement_type -> 10 | Unused_match -> 11 | Unused_pat ->... |
let last_warning_number = 67 ; ; |
let letter = function | ' a ' -> let rec loop i = if i = 0 then [ ] else i :: loop ( i - 1 ) in loop last_warning_number | ' b ' -> [ ] | ' c ' -> [ 1 ; 2 ] | ' d ' -> [ 3 ] | ' e ' -> [ 4 ] | ' f ' -> [ 5 ] | ' g ' -> [ ] | ' h ... |
type state = { active : bool array ; error : bool array ; alerts : ( Misc . Stdlib . String . Set . t * bool ) ; alert_errors : ( Misc . Stdlib . String . Set . t * bool ) ; } |
let current = ref { active = Array . make ( last_warning_number + 1 ) true ; error = Array . make ( last_warning_number + 1 ) false ; alerts = ( Misc . Stdlib . String . Set . empty , false ) ; alert_errors = ( Misc . Stdlib . String . Set . empty , true ) ; } ... |
let disabled = ref false |
let without_warnings f = Misc . protect_refs [ Misc . R ( disabled , true ) ] f |
let backup ( ) = ! current |
let restore x = current := x |
let is_active x = not ! disabled && ( ! current ) . active . ( number x ) |
let is_error x = not ! disabled && ( ! current ) . error . ( number x ) |
let alert_is_active { kind ; _ } = not ! disabled && let ( set , pos ) = ( ! current ) . alerts in Misc . Stdlib . String . Set . mem kind set = pos |
let alert_is_error { kind ; _ } = not ! disabled && let ( set , pos ) = ( ! current ) . alert_errors in Misc . Stdlib . String . Set . mem kind set = pos |
let mk_lazy f = let state = backup ( ) in lazy ( let prev = backup ( ) in restore state ; try let r = f ( ) in restore prev ; r with exn -> restore prev ; raise exn ) |
let set_alert ~ error ~ enable s = let upd = match s with | " all " -> ( Misc . Stdlib . String . Set . empty , not enable ) | s -> let ( set , pos ) = if error then ( ! current ) . alert_errors else ( ! current ) . alerts in let f = if enable = pos then Misc . Stdlib ... |
let parse_alert_option s = let n = String . length s in let id_char = function | ' a ' . . ' z ' | ' A ' . . ' Z ' | ' _ ' | ' ' ' \ | ' 0 ' . . ' 9 ' -> true | _ -> false in let rec parse_id i = if i < n && id_char s . [ i ] then parse_id ( i ... |
let parse_opt error active errflag s = let flags = if errflag then error else active in let set i = if i = 3 then set_alert ~ error : errflag ~ enable : true " deprecated " else flags . ( i ) <- true in let clear i = if i = 3 then set_alert ~ error : errflag ~ enable : false " deprecated " ... |
let parse_options errflag s = let error = Array . copy ( ! current ) . error in let active = Array . copy ( ! current ) . active in parse_opt error active errflag s ; current := { ( ! current ) with error ; active } |
let ( ) = parse_options false defaults_w ; ; |
let ( ) = parse_options true defaults_warn_error ; ; |
let ref_manual_explanation ( ) = let [ @ manual . ref " s : comp - warnings " ] chapter , section = 9 , 5 in Printf . sprintf " ( See manual section % d . % d ) " chapter section |
let message = function | Comment_start -> " this ` let sub_locs = if not alert . def . loc_ghost && not alert . use . loc_ghost then [ alert . def , " Definition " ; alert . use , " Expected signature " ; ] else [ ] in ` Active { id = alert . kind ; message ; is_e... |
let reset_fatal ( ) = nerrors := 0 |
let check_fatal ( ) = if ! nerrors > 0 then begin nerrors := 0 ; raise Errors ; end ; ; ; |
let descriptions = [ 1 , " Suspicious - looking start - of - comment mark . " ; 2 , " Suspicious - looking end - of - comment mark . " ; 3 , " Deprecated synonym for the ' deprecated ' alert " ; 4 , " Fragile pattern matching : matching that will remain complete even \... |
let help_warnings ( ) = List . iter ( fun ( i , s ) -> Printf . printf " % 3i % s \ n " i s ) descriptions ; print_endline " A all warnings " ; for i = Char . code ' b ' to Char . code ' z ' do let c = Char . chr i in match letter c with | [ ] -> ( ) | [ ... |
let err = T . err Warp_error |
type resample_t = | Nearest_neighbor | Bilinear | Cubic | Cubic_spline | Lanczos |
let int_of_resample = function | Nearest_neighbor -> 0 | Bilinear -> 1 | Cubic -> 2 | Cubic_spline -> 3 | Lanczos -> 4 |
module Options = struct module Raw = struct type warp_options_t type t = warp_options_t structure ptr let t : warp_options_t structure typ = structure " GDALWarpOptions " let f n k = field t n k let warp_options = f " warp_options " ( ptr string_opt ) let memory_limit = f " memory_limit " double... |
let reproject_image = Lib . c " GDALReprojectImage " ( Data_set . t @-> string_opt @-> Data_set . t @-> string_opt @-> int @-> double @-> double @-> ptr void @-> ptr void @-> ptr Options . Raw . t @-> returning err ) |
let reproject_image ( ? memory_limit = 0 . 0 ) ( ? max_error = 0 . 0 ) ? options ? src_wkt ? dst_wkt ~ src ~ dst alg = let options = match options with | None -> from_voidp Options . Raw . t null | Some { Options . o ; _ } -> o in reproject_image src src_wkt dst dst_wkt ( i... |
let create_and_reproject_image = Lib . c " GDALCreateAndReprojectImage " ( Data_set . t @-> string_opt @-> string @-> string_opt @-> Driver . t @-> ptr string_opt @-> int @-> double @-> double @-> ptr void @-> ptr void @-> ptr Options . Raw . t @-> returning err ) |
let create_and_reproject_image ( ? memory_limit = 0 . 0 ) ( ? max_error = 0 . 0 ) ? options ? src_wkt ? dst_wkt ( ? create_options = [ ] ) src ~ filename driver alg = let options = match options with | None -> from_voidp Options . Raw . t null | Some { Options . o ; _ }... |
let auto_create_warped_vrt = Lib . c " GDALAutoCreateWarpedVRT " ( Data_set . t @-> string_opt @-> string_opt @-> int @-> float @-> ptr Options . Raw . t @-> returning Data_set . t_opt ) |
let auto_create_warped_vrt ? src_wkt ? dst_wkt ( ? max_error = 0 . 0 ) ? options src alg = let options = match options with | None -> from_voidp Options . Raw . t null | Some { Options . o ; _ } -> o in let result = auto_create_warped_vrt src src_wkt dst_wkt ( int_of_resample alg ) ... |
type warp_output_t = { geo_transform : Geo_transform . t ; dims : int * int ; } |
let suggested_warp_output arg = Lib . c " GDALSuggestedWarpOutput " ( Data_set . t @-> Foreign . funptr ( Transform . transform_t arg ) @-> arg @-> ptr double @-> ptr int @-> ptr int @-> returning err ) |
let suggested_warp_output ds transform = let transform_t = Transform . get_transform_t transform in let transform_f = Transform . get_transform_c transform in let geo_transform = Geo_transform . make ~ origin ( : 0 . 0 , 0 . 0 ) ~ pixel_size ( : 0 . 0 , 0 . 0 ) ~ rotation ( ... |
module Operation = struct type raw_t = T . t let t = T . t type ' a t = { t : raw_t ; options : ' a Options . t ; } let create = Lib . c " GDALCreateWarpOperation " ( ptr Options . Raw . t @-> returning t ) let destroy = Lib . c " GDALDestroyWarpOperation " ( t @-> retu... |
let init ( ) = Gdal . Lib . init_dynamic ( ) ; Gdal . Lib . register_all ( ) ; ( ) |
let usage_and_exit ( ) = prerr_endline " Usage : warptut [ src ] [ dst ] " ; prerr_endline " [ src ] must exist " ; prerr_endline " [ dst ] must not exist " ; exit 1 |
let parse_args ( ) = try let s = Sys . argv . ( 1 ) in let d = Sys . argv . ( 2 ) in if Sys . file_exists s && not ( Sys . file_exists d ) then s , d else raise Exit with | _ -> usage_and_exit ( ) |
let ( ) = init ( ) ; let src_file , dst_file = parse_args ( ) in let src_ds = Gdal . Data_set . of_source_exn src_file in let dst_bands = Gdal . Data_set . get_count src_ds in let dst_dt = Gdal . Band . Data . Float32 in let driver = Gdal . Driver . get_by_name_exn " GTiff " ... |
let rec highest_timestamp ( ? highest = 0 . ) folders = match folders with | [ ] -> highest | file :: rest -> ( let is_dir = Sys . is_directory file in match is_dir with | ` Yes -> let inside_dirs = Sys . ls_dir file in let inside_dirs = List . map inside_dirs ~ f ( : fun x -> fil... |
let rec has_changed ( last_change : float ) ( folders : string list ) : float option = match folders with | [ ] -> None | file :: rest -> ( let is_dir = Sys . is_directory file in match is_dir with | ` Yes -> let inside_dirs = Sys . ls_dir file in let inside_dirs = List . map inside_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.