text stringlengths 0 601k |
|---|
let rec calc_of_query ( ? query_name = None ) ( tables : Sql . table_t list ) ( query : Sql . select_t ) : ( string * C . expr_t ) list = let re_hv_query = Sql . rewrite_having_query tables query in let agg_query = cast_query_to_aggregate tables re_hv_query in Debug . print " LOG - SQL - TO - CALC " ( fun ( ) -> " Cast... |
let extract_sql_schema ( db : Schema . t ) ( tables : Sql . table_t list ) = List . iter ( fun ( reln , relsch , reltype , ( relsource , reladaptor ) ) -> Schema . add_rel db ~ source : relsource ~ adaptor : reladaptor ( reln , List . map var_of_sql_var relsch , reltype ) ) ( List . rev tables ) |
let _ = let creds = { Creds . aws_access_key_id = Keys . k ; Creds . aws_secret_access_key = Keys . c } in Lwt_main . run ( SQS . receive_message ~ encoded : false ~ max_number_of_messages : 2 creds queue_url >>= function | ` Ok l -> Printf . printf " We read % d messages from the queue \ n " ( List . length l ) ; Lwt_... |
module Make = functor ( HC : Aws_sigs . HTTP_CLIENT ) -> struct module C = CalendarLib . Calendar module P = CalendarLib . Printer . CalendarPrinter module X = My_xml open Lwt open Creds module Util = Aws_util exception Error of string let sprint = Printf . sprintf let print = Printf . printf |
let signed_request ? region ( ? http_method ` = POST ) ( ? http_uri " " ) =/ ? expires_minutes creds params = let http_host = match region with | Some r -> sprint " sqs . % s . amazonaws . com " r | None -> " sqs . us - east - 1 . amazonaws . com " in let params = ( " Version " , " 2009 - 02 - 01 " ) :: ( " SignatureVe... |
let fire vs in_planes squeeze_planes exp1_planes exp3_planes = let squeeze = Layer . conv2d_ ( Var_store . sub vs " squeeze " ) ~ ksize : 1 ~ stride : 1 ~ input_dim : in_planes squeeze_planes in let exp1 = Layer . conv2d_ ( Var_store . sub vs " expand1x1 " ) ~ ksize : 1 ~ stride : 1 ~ input_dim : squeeze_planes exp1_pl... |
let squeezenet vs ~ version ~ num_classes = let features = let sub_vs i = Var_store . ( vs / " features " / Int . to_string i ) in match version with | ` v1_0 -> Layer . sequential [ Layer . conv2d_ ( sub_vs 0 ) ~ ksize : 7 ~ stride : 2 ~ input_dim : 3 96 ; Layer . of_fn Tensor . relu_ ; Layer . of_fn ( Tensor . max_po... |
let squeezenet1_0 vs ~ num_classes = squeezenet vs ~ version ` : v1_0 ~ num_classes |
let squeezenet1_1 vs ~ num_classes = squeezenet vs ~ version ` : v1_1 ~ num_classes |
type ' a t = { ev_q : ' a Queue . t ; maxsize : int ; mutex : ( Mutex . t [ @ sexp . opaque ] ) ; not_empty : ( Condition . t [ @ sexp . opaque ] ) ; not_full : ( Condition . t [ @ sexp . opaque ] ) ; finally : unit -> unit } |
let create maxsize = let ev_q = Queue . create ( ) in let mutex = Mutex . create ( ) in let not_empty = Condition . create ( ) in let not_full = Condition . create ( ) in { ev_q ; mutex ; not_empty ; not_full ; maxsize ; finally = ( fun ( ) -> let len = Queue . length ev_q in if len <> 0 then Condition . signal not_emp... |
let wrap q run = Mutex . lock q . mutex ; protect ~ f : run ~ finally : q . finally ; ; |
let clear q = let run ( ) = Queue . clear q . ev_q in wrap q run ; ; |
let wait_not_full q = while Queue . length q . ev_q >= q . maxsize do Condition . wait q . not_full q . mutex done ; ; |
let wait_not_empty q = while Queue . is_empty q . ev_q do Condition . wait q . not_empty q . mutex done ; ; |
let push q x = let run ( ) = wait_not_full q ; Queue . enqueue q . ev_q x in wrap q run ; ; |
let push_uncond q x = let run ( ) = Queue . enqueue q . ev_q x in wrap q run ; ; |
let push_or_drop q x = let run ( ) = if Queue . length q . ev_q < q . maxsize then ( Queue . enqueue q . ev_q x ; true ) else false in wrap q run ; ; |
let length q = let run ( ) = Queue . length q . ev_q in wrap q run ; ; |
let pop q = let run ( ) = wait_not_empty q ; Queue . dequeue_exn q . ev_q in wrap q run ; ; |
let lpop q = let run ( ) = wait_not_empty q ; let el = Queue . dequeue_exn q . ev_q in let len = Queue . length q . ev_q in el , len in wrap q run ; ; |
let transfer_queue_in_uncond q in_q = if not ( Queue . is_empty in_q ) then ( let run ( ) = Queue . transfer ~ src : in_q ~ dst : q . ev_q in wrap q run ) ; ; |
let transfer_queue_in q in_q = if not ( Queue . is_empty in_q ) then ( let run ( ) = wait_not_full q ; Queue . transfer ~ src : in_q ~ dst : q . ev_q in wrap q run ) ; ; |
let transfer_queue_nowait_nolock sq q = Queue . transfer ~ src : sq . ev_q ~ dst : q |
let transfer_queue_nowait sq q = if not ( Queue . is_empty sq . ev_q ) then ( let run ( ) = transfer_queue_nowait_nolock sq q in wrap sq run ) ; ; |
let transfer_queue sq q = let run ( ) = wait_not_empty sq ; transfer_queue_nowait_nolock sq q in wrap sq run ; ; |
let wait_not_empty sq = let run ( ) = wait_not_empty sq in wrap sq run ; ; |
let img = [ docker_image ~ account " : pegi3s " ~ name " : sratoolkit " ~ tag " : 2 . 10 . 0 " ( ) ] |
type ' a output = | Fasta | Fastq | Fastq_gz |
type library_type = SE | PE |
let sra_of_input = function | ` id id -> string id | ` idw w -> string_dep w | ` file w -> dep w |
let q s = quote ~ using ' ' ' :\ ( string s ) |
let call ? minReadLen ? defline_seq ? defline_qual ? _N_ ? _X_ se_or_pe output input = let stdout = match se_or_pe with | SE -> Some dest | PE -> None in let _O_ = match se_or_pe with | SE -> None | PE -> Some dest in cmd " fastq - dump " ? stdout [ option ( opt " - M " int ) minReadLen ; option ( opt " -- defline - se... |
let fastq_dump ? minReadLen ? _N_ ? _X_ ? defline_qual ? defline_seq output input = let fastq_dump_call = call ? minReadLen ? _N_ ? _X_ ? defline_seq ? defline_qual in let descr = " sratoolkit . fastq_dump " in Workflow . shell ~ descr ~ img [ fastq_dump_call SE output input ] |
let fastq_dump_pe ? minReadLen ? _N_ ? _X_ ? defline_qual ? defline_seq output input = let fastq_dump_call = call ? minReadLen ? _N_ ? _X_ ? defline_seq ? defline_qual in let descr = " sratoolkit . fastq_dump " in let dir = Workflow . shell ~ descr ~ img [ mkdir_p dest ; fastq_dump_call PE output input ; mv ( dest // "... |
let test_load_file ( ) = let load_file data = let file , oc = Filename . open_temp_file " ocaml - tree - sitter - core - test " " " in Fun . protect ( fun ( ) -> Fun . protect ( fun ( ) -> output_string oc data ) ~ finally ( : fun ( ) -> close_out_noerr oc ) ; Src_file . load_file file ) ~ finally ( : fun ( ) -> Sys . ... |
let test_get_region ( ) = let open Loc in let input = " 012 \ n45 \ r \ n89 \ n " in let src = Src_file . load_string input in let pos0 = { row = 0 ; column = 0 } in let pos1 = { row = 0 ; column = 1 } in let _pos2 = { row = 0 ; column = 2 } in let pos3 = { row = 0 ; column = 3 } in let pos4 = { row = 1 ; column = 0 } ... |
let test = " Src_file " , [ " load_file " , ` Quick , test_load_file ; " get_region " , ` Quick , test_get_region ; ] |
let img = [ docker_image ~ account " : pveber " ~ name " : srst2 " ~ tag " : 0 . 2 . 0 " ( ) ] |
let run_gen_cmd ? mlst_db ? mlst_delimiter ? mlst_definitions ? mlst_max_mismatch ? gene_db ? no_gene_details ? gene_max_mismatch ? min_coverage ? max_divergence ? min_depth ? min_edge_depth ? prob_err ? truncation_score_tolerance ? other ? max_unaligned_overlap ? mapq ? baseq ? samtools_args ? report_new_consensus ? r... |
let run_se ? mlst_db ? mlst_delimiter ? mlst_definitions ? mlst_max_mismatch ? gene_db ? no_gene_details ? gene_max_mismatch ? min_coverage ? max_divergence ? min_depth ? min_edge_depth ? prob_err ? truncation_score_tolerance ? other ? max_unaligned_overlap ? mapq ? baseq ? samtools_args ? report_new_consensus ? report... |
let run_pe ? mlst_db ? mlst_delimiter ? mlst_definitions ? mlst_max_mismatch ? gene_db ? no_gene_details ? gene_max_mismatch ? min_coverage ? max_divergence ? min_depth ? min_edge_depth ? prob_err ? truncation_score_tolerance ? other ? max_unaligned_overlap ? mapq ? baseq ? samtools_args ? report_new_consensus ? report... |
let sse2_support lst = match List . assoc_opt _m_amd64 lst , List . assoc_opt _m_x64 lst , List . assoc_opt _m_ix86_fp lst , List . assoc_opt __sse2__ lst with | Some ( Switch true ) , _ , _ , _ -> true | _ , Some ( Switch true ) , _ , _ -> true | _ , _ , Some ( Int 2 ) , _ -> true | _ , _ , _ , Some ( Switch true ) ->... |
let ssse3_support lst = match List . assoc_opt __ssse3__ lst with | Some ( Switch v ) -> v | _ -> false |
let neon_support lst = match List . assoc_opt __aarch64__ lst , List . assoc_opt __arm_neon lst with | Some ( Switch true ) , _ -> true | _ , Some ( Switch true ) -> true | _ -> false |
let _ = let c = Configurator . V1 . create " sse " in let defines = Configurator . V1 . C_define . import c ~ includes [ ] : [ ( _m_amd64 , Switch ) ; ( _m_x64 , Switch ) ; ( __i386__ , Switch ) ; ( _msc_ver , Switch ) ; ( __sse2__ , Switch ) ; ( __ssse3__ , Switch ) ; ( __aarch64__ , Switch ) ; ( __arm_neon , Switch )... |
type pkt_hdr = { pkt_len : uint32_t ; pad_len : uint8_t ; |
let max_pkt_len = 512 * 1024 |
let max_len = 256 * 1024 |
let channel_win_len = Int32 . of_int ( 4 * 1024 * 1000 ) |
let channel_win_adj_threshold = Int32 . of_int ( 2 * 1024 * 1000 ) |
let channel_max_pkt_len = Int32 . of_int ( 64 * 1024 ) |
let min_dh , n , max_dh = 2048l , 3072l , 8192l |
let guard_sshlen len = guard ( len >= 0 && len <= max_len ) ( sprintf " Bad length : % d " len ) |
let guard_sshlen_exn len = match guard_sshlen len with Ok ( ) -> ( ) | Error e -> invalid_arg e [ %% cenum |
type message_id = | MSG_DISCONNECT [ @ id 1 ] | MSG_IGNORE [ @ id 2 ] | MSG_UNIMPLEMENTED [ @ id 3 ] | MSG_DEBUG [ @ id 4 ] | MSG_SERVICE_REQUEST [ @ id 5 ] | MSG_SERVICE_ACCEPT [ @ id 6 ] | MSG_KEXINIT [ @ id 20 ] | MSG_NEWKEYS [ @ id 21 ] | MSG_KEX_0 [ @ id 30 ] | MSG_KEX_1 [ @ id 31 ] | MSG_KEX_2 [ @ id 32 ] | MSG_K... |
type kexinit = { cookie : Cstruct_sexp . t ; kex_algs : string list ; server_host_key_algs : string list ; encryption_algs_ctos : string list ; encryption_algs_stoc : string list ; mac_algs_ctos : string list ; mac_algs_stoc : string list ; compression_algs_ctos : string list ; compression_algs_stoc : string list ; lan... |
type disconnect_code = | DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT [ @ id 1 ] | DISCONNECT_PROTOCOL_ERROR [ @ id 2 ] | DISCONNECT_KEY_EXCHANGE_FAILED [ @ id 3 ] | DISCONNECT_RESERVED [ @ id 4 ] | DISCONNECT_MAC_ERROR [ @ id 5 ] | DISCONNECT_COMPRESSION_ERROR [ @ id 6 ] | DISCONNECT_SERVICE_NOT_AVAILABLE [ @ id 7 ] | DISCO... |
let int_to_disconnect_code code = match int_to_disconnect_code code with | Some disc -> disc | None -> DISCONNECT_PROTOCOL_ERROR [ %% cenum |
type channel_open_code = | OPEN_ADMINISTRATIVELY_PROHIBITED [ @ id 1 ] | OPEN_CONNECT_FAILED [ @ id 2 ] | OPEN_UNKNOWN_CHANNEL_TYPE [ @ id 3 ] | OPEN_RESOURCE_SHORTAGE [ @ id 4 ] [ @@ uint32_t ] [ @@ sexp ] ] |
let sexp_of_mpint mpint = sexp_of_string ( Z . to_string mpint ) |
type global_request = | Tcpip_forward of ( string * int32 ) | Cancel_tcpip_forward of ( string * int32 ) | Unknown_request of string |
type channel_request = | Pty_req of ( string * int32 * int32 * int32 * int32 * string ) | X11_req of ( bool * string * string * int32 ) | Env of ( string * string ) | Shell | Exec of string | Subsystem of string | Window_change of ( int32 * int32 * int32 * int32 ) | Xon_xoff of bool | Signal of string | Exit_status of ... |
type channel_open = | Session | X11 of ( string * int32 ) | Forwarded_tcpip of ( string * int32 * string * int32 ) | Direct_tcpip of ( string * int32 * string * int32 ) | Raw_data of Cstruct_sexp . t |
let sexp_of_password _ = sexp_of_string " " ???? |
let password_of_sexp _ = failwith " password_of_sexp : TODO " |
type auth_method = | Pubkey of ( Hostkey . pub * ( Hostkey . alg * Cstruct_sexp . t ) option ) | Password of ( password * password option ) | Hostbased of ( string * Cstruct_sexp . t * string * string * Cstruct_sexp . t ) | Authnone |
let auth_method_equal a b = match a , b with | Pubkey ( key_a , signature_a ) , Pubkey ( key_b , signature_b ) -> let signature_match = match signature_a , signature_b with | Some ( alga , sa ) , Some ( algb , sb ) -> alga = algb && Cstruct . equal sa sb | None , None -> true | _ -> false in key_a = key_b && signature_... |
type message = | Msg_disconnect of ( disconnect_code * string * string ) | Msg_ignore of string | Msg_unimplemented of int32 | Msg_debug of ( bool * string * string ) | Msg_service_request of string | Msg_service_accept of string | Msg_kexinit of kexinit | Msg_newkeys | Msg_kexdh_reply of Hostkey . pub * mpint * ( Host... |
let message_to_string msg = Sexplib . Sexp . to_string_hum ( sexp_of_message msg ) |
let message_to_id = function | Msg_disconnect _ -> MSG_DISCONNECT | Msg_ignore _ -> MSG_IGNORE | Msg_unimplemented _ -> MSG_UNIMPLEMENTED | Msg_debug _ -> MSG_DEBUG | Msg_service_request _ -> MSG_SERVICE_REQUEST | Msg_service_accept _ -> MSG_SERVICE_ACCEPT | Msg_kexinit _ -> MSG_KEXINIT | Msg_newkeys -> MSG_NEWKEYS | M... |
let message_to_int msg = message_id_to_int ( message_to_id msg ) |
let disconnect_msg code s = Msg_disconnect ( code , s , " " ) |
let is_extension_request ( type a ) ( req : a ssh_agent_request ) = match req with | Ssh_agentc_extension _ -> true | _ -> false |
let unpack_any_response ( type a ) ( request : a ssh_agent_request ) ( response : any_ssh_agent_response ) : ( a ssh_agent_response , string ) result = let success_or_fail ( resp : any_ssh_agent_response ) : ( [ ` Ssh_agentc_successable ] ssh_agent_response , string ) result = match resp with | Any_response ( Ssh_agent... |
let sign priv ( sign_flags : Protocol_number . sign_flag list ) blob = match priv with | Privkey . Ssh_rsa key | Privkey . Ssh_rsa_cert ( key , _ ) -> let alg_string , to_sign = if List . mem Protocol_number . SSH_AGENT_RSA_SHA2_512 sign_flags then let digest = Mirage_crypto . Hash . SHA512 . digest ( Cstruct . of_stri... |
let string_of_tbs tbs = Serialize . with_faraday ( fun t -> Serialize . write_ssh_rsa_cert_tbs t tbs ) |
type identity = { privkey : Privkey . t ; comment : string ; } |
let state : identity list ref = ref [ ] |
let pubkey_of_privkey = function | Privkey . Ssh_rsa priv -> Ok ( Pubkey . Ssh_rsa ( Mirage_crypto_pk . Rsa . pub_of_priv priv ) ) | Privkey . Ssh_rsa_cert ( _priv , cert ) -> Ok ( Pubkey . Ssh_rsa_cert cert ) | Privkey . Ssh_dss priv -> Ok ( Pubkey . Ssh_dss ( Mirage_crypto_pk . Dsa . pub_of_priv priv ) ) | Privkey . ... |
let is_pubkey pubkey { privkey ; _ } = pubkey_of_privkey privkey |> Result . fold ~ error ( : Fun . const false ) ~ ok ( : Pubkey . equal pubkey ) |
let handle ( type req ) ( request : req ssh_agent_request ) : req ssh_agent_response = match request with | Ssh_agentc_request_identities -> let identities = List . filter_map ( fun { privkey ; comment } -> Result . to_option ( pubkey_of_privkey privkey ) |> Option . map ( fun pubkey -> { comment ; pubkey } ) ) ! state... |
let accept ( ic , oc ) = let rec loop = function | Angstrom . Buffered . Done ( u , Any_request req ) -> let resp = handle req in let buf = Faraday . create 4096 in Serialize . write_ssh_agent_response buf resp ; output_string oc ( Faraday . serialize_to_string buf ) ; flush oc ; let s = Angstrom . Buffered . parse Par... |
let ( ) = let sock = Unix . socket Unix . PF_UNIX Unix . SOCK_STREAM 0 in Unix . bind sock ( Unix . ADDR_UNIX " ocaml - ssh - agent . sock " ) ; Unix . listen sock 1 ; while true do let client , _client_addr = Unix . accept sock in let ic = Unix . in_channel_of_descr client and oc = Unix . out_channel_of_descr client i... |
type t = | Transport of Transport . o | Auth of Auth . o | DHGroupSHA1 of Dhgroupsha1 . o | DHGexSHA1 of Dhgexsha1 . o | Channel of Channel . o | Unknown of int32 |
type c = | TransportGeneric | AlgorithmNegotiation | KeyExchangeSpecific | UserAuthGeneric | UserAuthSpecific | ChannelGeneric | ChannelSpecific | Reserved | LocalExtensions |
let global_recv ( x : Channel . o ) = match x with ` | GlobalRequest x -> Some ( Channel . GlobalRequest . recv_statecall x ) ` | RequestSuccess x -> Some Channel . RequestSuccess . recv_statecall ` | RequestSuccessPort x -> Some Channel . RequestSuccessPort . recv_statecall ` | RequestFailure x -> Some Channel . Reque... |
let recv_statecall x = match x with | Transport x -> Some ( Transport . recv_statecall x :> Ssh_statecalls . t ) | Auth x -> Some ( Auth . recv_statecall x :> Ssh_statecalls . t ) | DHGroupSHA1 x -> Some ( Dhgroupsha1 . recv_statecall x :> Ssh_statecalls . t ) | DHGexSHA1 x -> Some ( Dhgexsha1 . recv_statecall x :> Ssh... |
let prettyprint x = match x with | Transport x -> Transport . prettyprint x | Auth x -> Auth . prettyprint x | DHGroupSHA1 x -> Dhgroupsha1 . prettyprint x | DHGexSHA1 x -> Dhgexsha1 . prettyprint x | Channel x -> Channel . prettyprint x | Unknown x -> Printf . printf " Unknown packet ( #% lu ) \ n " x |
let peek env = let module M = Mpl_stdlib in match M . Mpl_byte . to_int ( M . Mpl_byte . at env 0 ) with | x when x >= 0 && x <= 19 -> TransportGeneric | x when x >= 20 && x <= 29 -> AlgorithmNegotiation | x when x >= 30 && x <= 49 -> KeyExchangeSpecific | x when x >= 50 && x <= 59 -> UserAuthGeneric | x when x >= 60 &... |
let handler _sock ic oc = Reader . pipe ic |> fun rd -> Writer . pipe oc |> fun wr -> Pipe . transfer_id rd wr |
let determine_mode cert_file_path key_file_path = match ( cert_file_path , key_file_path ) with | Some c , Some k -> ` OpenSSL ( ` Crt_file_path c , ` Key_file_path k ) | None , None -> ` TCP | _ -> failwith " Error : must specify both certificate and key for TLS " |
let start_server port host cert_file key_file ( ) = let mode = determine_mode cert_file key_file in let mode_str = match mode with ` OpenSSL _ -> " OpenSSL " | ` TCP -> " TCP " in printf " Listening for % s requests on : % s % d \ n " %! mode_str host port ; Unix . Inet_addr . of_string_or_getbyname host >>= fun host -... |
let ( ) = Command . async_spec ~ summary " : Echo server over SSL " Command . Spec . ( empty +> flag " - p " ( optional_with_default 8080 int ) ~ doc " : port TCP port to listen on " +> flag " - s " ( optional_with_default " 0 . 0 . 0 . 0 " string ) ~ doc " : address IP address to listen on " +> flag " - cert - file " ... |
let ( ) = Ssl . init ( ) |
let readf socket = fun _fd buffer -> Lwt . catch ( fun ( ) -> Buffer . put buffer ~ f ( : fun bigstring ~ off ~ len -> Lwt_unix . blocking ( Lwt_ssl . get_fd socket ) >>= fun _ -> Lwt_ssl . read_bytes socket bigstring off len ) ) ( function | Unix . Unix_error ( Unix . EBADF , _ , _ ) as exn -> Lwt . fail exn | exn -> ... |
let writev socket _fd = fun iovecs -> Lwt . catch ( fun ( ) -> Lwt_list . fold_left_s ( fun acc { Faraday . buffer ; off ; len } -> Lwt_ssl . write_bytes socket buffer off len >|= fun written -> acc + written ) 0 iovecs >|= fun n -> ` Ok n ) ( function | Unix . Unix_error ( Unix . EBADF , " check_descriptor " , _ ) -> ... |
let make_client ? client socket = match client with | Some client -> Lwt . return client | None -> let client_ctx = Ssl . create_context Ssl . SSLv23 Ssl . Client_context in Ssl . disable_protocols client_ctx [ Ssl . SSLv23 ] ; Ssl . honor_cipher_order client_ctx ; Lwt_ssl . ssl_connect socket client_ctx |
let make_server ? server ? certfile ? keyfile socket = match server , certfile , keyfile with | Some server , _ , _ -> Lwt . return server | None , Some cert , Some priv_key -> let server_ctx = Ssl . create_context Ssl . SSLv23 Ssl . Server_context in Ssl . disable_protocols server_ctx [ Ssl . SSLv23 ] ; Ssl . use_cert... |
module type Stable = Stable_module_types . S0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.