text stringlengths 12 786k |
|---|
module Fetch = Current_sesame . Make_watch ( Sesame . Utils . Dir ( C ) ) |
module Html = Current_sesame . Make ( Sesame . Utils . List ( H ) ) |
module Index = struct let to_html ( ts : C . t list Current . t ) = let open Current . Syntax in Current . component " Index File " |> let > ts = ts in let head = Components . simple_head ~ t " : Blog Posts " in let body = [ Components . navbar ; Components . section [ div ~ a... |
module State = struct module Clock_map = Map . Make ( Orx . Clock ) type t = Orx . Object . t Clock_map . t ref let state : t = ref Clock_map . empty let get ( ) = ! state let add ( clock : Orx . Clock . t ) ( o : Orx . Object . t ) : unit = state := Clock_map . add clo... |
let update ( clock_info : Orx . Clock . Info . t ) = Orx . Config . push_section " Main " ; if Orx . Config . get_bool " DisplayLog " then Orx . Log . log " <% s >: Time = . % 3f / DT = . % 3f " ( Orx . Clock . get_name ( Orx . Clock . Info . get_clock cl... |
let input_update ( _clock_info : Orx . Clock . Info . t ) = Orx . Config . push_section " Main " ; if Orx . Input . has_been_activated " Log " then Orx . Config . set_bool " DisplayLog " ( not ( Orx . Config . get_bool " DisplayLog " ) ) ; Orx . Config . pop_... |
let init ( ) = let get_name ( binding : string ) : string = let ( type_ , id , mode ) = Orx . Input . get_binding binding 0 |> Result . get_ok in Orx . Input . get_binding_name type_ id mode in Orx . Log . log ( " . @- Press ' % s ' to toggle log display . " @ ^^ "... |
let run ( ) = if Orx . Input . is_active " Quit " then Orx . Status . error else Orx . Status . ok |
let ( ) = Orx . Main . start ~ config_dir " : examples / tutorial / data " ~ init ~ run " 02_Clock " |
module State = struct type t = { soldier : Orx . Object . t ; music : Orx . Sound . t ; } let state : t option ref = ref None let get ( ) = Option . get ! state end |
let event_message ( event : Orx . Event . t ) ( sound_event_payload : Orx . Sound_event . payload ) kind = let sound = Orx . Sound_event . get_sound sound_event_payload in let recipient = Orx . Event . get_recipient_object event |> Option . get in Orx . Log . log " Sound [ % s ]... |
let event_handler ( event : Orx . Event . t ) ( sound_event : Orx . Sound_event . t ) ( payload : Orx . Sound_event . payload ) = let state = State . get ( ) in match Orx . Event . get_recipient_object event with | None -> Error ` Orx | Some recipient -> if Orx . Object . ... |
let update_state ( state : State . t ) ( clock_info : Orx . Clock . Info . t ) = if Orx . Input . has_been_activated " RandomSFX " then ( Orx . Object . add_sound_exn state . soldier " RandomBip " ; Orx . Config . push_section " Tutorial " ; Orx . Object . set_rgb ... |
let update ( clock_info : Orx . Clock . Info . t ) = let state = State . get ( ) in if Orx . Input . has_been_activated " ToggleMusic " then Orx . Object . enable state . soldier ( not ( Orx . Object . is_enabled state . soldier ) ) ; if Orx . Object . is_enabled sta... |
let init ( ) = let get_name ( binding : string ) : string = let ( type_ , id , mode ) = Orx . Input . get_binding binding 0 |> Result . get_ok in Orx . Input . get_binding_name type_ id mode in Orx . Log . log ( " . @- ' % s ' & ' % s ' will change the music volume... |
let run ( ) = if Orx . Input . is_active " Quit " then Orx . Status . error else Orx . Status . ok |
let ( ) = Orx . Main . start ~ config_dir " : examples / tutorial / data " ~ init ~ run " 06_Sound " |
module State = struct type t = { soldier : Orx . Object . t ; mutable soldier_fx_lock : bool ; box : Orx . Object . t ; mutable selected_fx : string ; } let state : t option ref = ref None let get ( ) = Option . get ! state end |
let input_event_handler ( _event : Orx . Event . t ) ( _input : Orx . Input_event . t ) ( _payload : Orx . Input_event . payload ) = Ok ( ) |
let fx_event_handler ( event : Orx . Event . t ) ( fx_event : Orx . Fx_event . t ) ( payload : Orx . Fx_event . payload ) = let state = State . get ( ) in let recipient = Orx . Event . get_recipient_object event |> Option . get in ( match fx_event with | Start -> Orx . L... |
let update ( _clock_info : Orx . Clock . Info . t ) = let state = State . get ( ) in let possible_fx_inputs = [ ( " SelectMultiFX " , " MultiFX " ) ; ( " SelectWobble " , " WobbleFX " ) ; ( " SelectCircle " , " CircleFX " ) ; ( " SelectFade " ... |
let init ( ) = let get_name ( binding : string ) : string = let ( type_ , id , mode ) = Orx . Input . get_binding binding 0 |> Result . get_ok in Orx . Input . get_binding_name type_ id mode in Orx . Log . log ( " . @- To select the FX to apply . " :@ ^^ " . ' % ... |
let run ( ) = if Orx . Input . is_active " Quit " then Orx . Status . error else Orx . Status . ok |
let ( ) = Orx . Main . start ~ config_dir " : examples / tutorial / data " ~ init ~ run " 07_FX " |
module State = struct type t = Orx . Camera . t let state : t option ref = ref None let get ( ) = Option . get ! state end |
let event_handler ( event : Orx . Event . t ) ( physics : Orx . Physics_event . t ) ( _payload : Orx . Physics_event . payload ) = ( match physics with | Contact_remove -> ( ) | Contact_add -> let sender = Orx . Event . get_sender_object event |> Option . get in let recipi... |
let update ( clock_info : Orx . Clock . Info . t ) = let camera = State . get ( ) in let delta_rotation = if Orx . Input . is_active " RotateLeft " then Some ( 4 . 0 . * Orx . Clock . Info . get_dt clock_info ) else if Orx . Input . is_active " RotateRight " then Som... |
let init ( ) = let ( type_ , id , mode ) = Orx . Input . get_binding " RotateLeft " 0 |> Result . get_ok in let input_rotate_left = Orx . Input . get_binding_name type_ id mode in let ( type_ , id , mode ) = Orx . Input . get_binding " RotateRight " 0 |> Result . get_... |
let run ( ) = if Orx . Input . is_active " Quit " then Orx . Status . error else Orx . Status . ok |
let ( ) = Orx . Main . start ~ config_dir " : examples / tutorial / data " ~ init ~ run " 08_Physics " |
module State = struct type t = Orx . Camera . t let state : t option ref = ref None let get ( ) = Option . get ! state end |
let update ( clock_info : Orx . Clock . Info . t ) = let camera = State . get ( ) in Orx . Config . push_section " Tutorial " ; let scroll_speed = Orx . Config . get_vector " ScrollSpeed " in Orx . Config . pop_section ( ) ; let scroll_speed = Orx . Vector . mulf scr... |
let init ( ) = let get_name ( binding : string ) : string = let ( type_ , id , mode ) = Orx . Input . get_binding binding 0 |> Result . get_ok in Orx . Input . get_binding_name type_ id mode in Orx . Log . log ( " . @- ' % s ' , ' % s ' , ' % s ' & ' % ... |
let run ( ) = if Orx . Input . is_active " Quit " then Orx . Status . error else Orx . Status . ok |
let ( ) = Orx . Main . start ~ config_dir " : examples / tutorial / data " ~ init ~ run " 09_Scrolling " |
let cautious f ppf arg = try f ppf arg with Ellipsis -> fprintf ppf " . . . " |
let rec print_ident ppf = function Oide_ident s -> pp_print_string ppf s | Oide_dot ( id , s ) s -> print_ident ppf id ; pp_print_char ppf ' . ' ; pp_print_string ppf s | Oide_apply ( id1 , id2 ) id2 -> fprintf ppf " % a ( a % a ) a " print_ident id1 print_ident id2 # else |
let rec print_ident ppf = function Oide_ident s -> ! Oprint . out_ident ppf s | Oide_dot ( id , s ) s -> print_ident ppf id ; pp_print_char ppf ' . ' ; ! Oprint . out_ident ppf s | Oide_apply ( id1 , id2 ) id2 -> fprintf ppf " % a ( a % a ) a " print_ident id1 print_ident id2 ... |
let parenthesized_ident name = ( List . mem name [ " or " ; " mod " ; " land " ; " lor " ; " lxor " ; " lsl " ; " lsr " ; " asr ] ) " || ( match name [ . 0 ] 0 with ' a ' . . ' z ' | ' A ' . . ' Z ' | ' \ 223 ' . . ' \ 246 ' | ' \ 248 '... |
let value_ident ppf name = if parenthesized_ident name then fprintf ppf ( " % s ) " ( Reason_syntax_util . ml_to_reason_swap name ) name else pp_print_string ppf name |
let valid_float_lexeme s = let l = String . length s in let rec loop i = if i >= l then s ^ " . " else match s [ . i ] i with | ' 0 ' . . ' 9 ' | ' - ' -> loop ( i + 1 ) 1 | _ -> s in loop 0 |
let float_repres f = match classify_float f with FP_nan -> " nan " | FP_infinite -> if f < 0 . 0 then " neg_infinity " else " infinity " | _ -> let float_val = let s1 = Printf . sprintf " . % 12g " f in if f = float_of_string s1 then s1 else let s2 = Printf . sprintf " . % 15g " f ... |
let parenthesize_if_neg ppf fmt v isneg = if isneg then pp_print_char ppf ' ( ' ' ; fprintf ppf fmt v ; if isneg then pp_print_char ppf ' ) ' ' |
let print_out_value ppf tree = let rec print_tree_1 ppf = function | Oval_constr ( name , [ Oval_constr ( ( Oide_ident ( ) ) " " , [ ] ) ] ) -> fprintf ppf [ " @< 1 >% a ( a ) a ] " @ print_ident name | Oval_constr ( name , [ param ] param ) param -> fprintf ppf [... |
let rec print_list_init pr sep ppf = function [ ] -> ( ) | a :: l -> sep ppf ; pr ppf a ; print_list_init pr sep ppf l |
let rec print_list pr sep ppf = function [ ] -> ( ) | [ a ] a -> pr ppf a | a :: l -> pr ppf a ; sep ppf ; print_list pr sep ppf l |
let pr_present = print_list ( fun ppf s -> fprintf ppf " ` % s " s ) s ( fun ppf -> fprintf ppf " @ ) " |
let pr_vars = print_list ( fun ppf s -> fprintf ppf " ' % s " s ) s ( fun ppf -> fprintf ppf " @ ) " |
type label = | Nonlabeled | Labeled of string | Optional of string |
let get_label lbl = if lbl = " " then Nonlabeled else if String . get lbl 0 = ' ? ' then Optional ( String . sub lbl 1 @@ String . length lbl - 1 ) 1 else Labeled lbl |
let rec print_out_type ppf = function | Otyp_alias ( ty , s ) s -> fprintf ppf [ " @% a @ as ' % s ] " @ print_out_type ty s | Otyp_poly ( sl , ty ) ty -> fprintf ppf [ " @< hov 2 >% a . @ % a ] " @ pr_vars sl print_out_type ty | ty -> print_out_type_1 ~ uncurried : false ppf ty... |
let out_type = ref print_out_type |
let type_parameter ppf ( ty , ( co , cn ) cn ) cn = fprintf ppf " % s % s " ( if not cn then " " + else if not co then " " - else ) " " ( if ty = " _ " then ty else " ' " ^ ty ) ty |
let print_out_class_params ppf = function [ ] -> ( ) | tyl -> fprintf ppf ( [ " @< 1 >% a ] ) @@ " ( print_list type_parameter ( fun ppf -> fprintf ppf " , @ ) ) " tyl |
let rec print_out_class_type ppf = function Octy_constr ( id , tyl ) tyl -> let pr_tyl ppf = function [ ] -> ( ) | tyl -> fprintf ppf [ " @< 1 > % a ] " @ ( print_typlist print_out_wrap_type ) " " tyl in fprintf ppf [ " @% a % a ] " @ print_ident id pr_tyl tyl | Octy_arrow ( ... |
let is_rec_next = function | Osig_class ( _ , _ , _ , _ , Orec_next ) Orec_next :: _ | Osig_class_type ( _ , _ , _ , _ , Orec_next ) Orec_next :: _ | Osig_module ( _ , _ , Orec_next ) Orec_next :: _ | Osig_type ( _ , Orec_next ) Orec_next :: _ -> true | _ ... |
let rec print_out_functor ppf = function Omty_functor ( _ , None , mty_res ) mty_res -> fprintf ppf ( ) " % a " print_out_functor mty_res | Omty_functor ( name , Some mty_arg , mty_res ) mty_res -> fprintf ppf ( " % s : % a ) a => % a " name print_out_module_type mty_arg print_o... |
let print_out_exception ppf exn outv = match exn with Sys . Break -> fprintf ppf " Interrupted . . " @ | Out_of_memory -> fprintf ppf " Out of memory during evaluation . . " @ | Stack_overflow -> fprintf ppf " Stack overflow during evaluation ( looping recursion ) . . " ?@ | _ -> fprintf ppf [ ... |
let rec print_items ppf = function [ ] -> ( ) | ( Osig_typext ( Osig_typextext , Oext_first ) Oext_first , None ) None :: items -> let rec gather_extensions acc items = match items with ( Osig_typext ( Osig_typextext , Oext_next ) Oext_next , None ) None :: items -> gather_extens... |
let print_out_phrase ppf = function Ophr_eval ( outv , ty ) ty -> fprintf ppf [ " @- : % a @ =@ % a ] . " @@ print_out_type ty print_out_value outv | Ophr_signature [ ] -> ( ) | Ophr_signature items -> fprintf ppf [ " @< v >% a ] . " @@ print_items items | Ophr_exception ( exn ,... |
module Fq = Make_fp ( N ) ( struct let order = N . of_string " 28948022309329048855892746252171976963322203655954433126947083963168578338817 " end ) |
module Fp = Make_fp ( N ) ( struct let order = N . of_string " 28948022309329048855892746252171976963322203655955319056773317069363642105857 " end ) |
module Dee = struct module Params = struct let a = Fq . of_string " 0 " let b = Fq . of_string " 5 " end include Elliptic_curve . Make ( N ) ( Fq ) ( Params ) let one = of_affine ( Fq . of_string " 1 " , Fq . of_string " 142401886431752511839856842554584192138351056451196... |
module Dum = struct module Params = struct let a = Fp . of_string " 0 " let b = Fp . of_string " 5 " end include Elliptic_curve . Make ( N ) ( Fp ) ( Params ) let one = of_affine ( Fp . of_string " 1 " , Fp . of_string " 385654983219305453067387443941241858913435815837190... |
let ( ) |> x f = f x |
let identity x = x |
module Make ( A : sig type ' a _r val ( ) >>= : ' a _r -> ( ' a -> ' b _r ) -> ' b _r val return : ' a -> ' a _r val account_sid : string val send : Http_client . http_call -> http_call_result _r module Request = Twilio_rest_request . Make ( struct type ' a _r = ' a... |
let set_event_system ( pipeline : Http_client . pipeline ) = pipeline # set_event_system |
module Make ( A : sig val account_sid : string val auth_token : string val timeout : float let pipeline = ref None include Twilio_rest . Make ( struct type ' a _r = ' a Lwt . t let ( ) >>= = Lwt . ( ) >>= let return = Lwt . return let account_sid = A . account_sid let auth_token =... |
let ( ) |> x f = f x |
let option_map f = function | Some x -> Some ( f x ) | None -> None |
let string_of_method = function | ` Get -> " GET " | ` Post -> " POST " |
let map_api_version = function | ` V2010_04_01 -> " 2010 - 04 - 01 " | ` V2008_08_01 -> " 2008 - 08 - 01 " |
let add ( name : string ) ( value : string option ) lst = match value with | Some s -> ( name , s ) :: lst | None -> lst |
let with_optional_args url args = match List . fold_left ( fun args ( name , optional_value ) -> add name optional_value args ) [ ] args with | [ ] -> url | args -> url ^ " " ? ^ Netencoding . Url . mk_url_encoded_parameters args |
let add_callback prefix ( url , meth ) lst = ( prefix ^ " Url " , url ) :: ( prefix ^ " Method " , string_of_method meth ) :: lst |
let add_fallback prefix ( callback , fallback ) lst = let lst = add_callback prefix callback lst in match fallback with | Some cb -> add_callback ( prefix ^ " Fallback " ) cb lst | None -> lst |
let add_handler prefix handler lst = match handler with | Some ( ` Application sid ) -> ( prefix ^ " ApplicationSid " , sid ) :: lst | Some ( ` Callback fallback ) -> add_fallback prefix fallback lst | None -> lst |
let url_sid url sid = url ^ " " / ^ sid |
module Make ( A : sig type ' a _r val return : ' a -> ' a _r val account_sid : string let url = " https :// api . twilio . com / 2010 - 04 - 01 / Accounts " / ^ A . account_sid let return_delete s = A . return s let return_get s = A . return ( s ^ " . json " ) let ret... |
let pi = 4 . 0 . * atan 1 . 0 |
let toid1_points = let arr = [ | ( - 1 . 1 , 0 . 0 ) ; ( - 1 . 0 , 0 . 0 ) ; ( 0 . 0 , 0 . 0 ) ; ( 1 . 0 , 0 . 0 ) ; ( 1 . 1 , 0 . 0 ) ; ] | in let arr = Array . map ( fun ( x , y ) -> [ | tscale . * ( x ) ; ... |
let toid1_colors = ba2_float32_of_array [ | [ | 0 . 8 ; 0 . 8 ; 0 . 5 ] ; | [ | 0 . 8 ; 0 . 4 ; 0 . 5 ] ; | [ | 0 . 8 ; 0 . 8 ; 0 . 3 ] ; | [ | 0 . 4 ; 0 . 4 ; 0 . 5 ] ; | [ | 0 . 8 ; 0 . 8 ; 0 . 5 ] ... |
let toid1_twists = ba1_glefloat_of_array [ | 0 . 0 ; 0 . 0 ; 0 . 0 ; 0 . 0 ; 0 . 0 ] | |
let tpts i ( x , y ) = toid1_points . { i , 0 } <- tscale . * ( x ) ; toid1_points . { i , 1 } <- tscale . * ( y ) ; toid1_points . { i , 2 } <- tscale . * ( 0 . 0 ) ; ; ; |
let twistation = ba2_glefloat_create num_twis_pts 2 |
let twist_normal = ba2_glefloat_create num_twis_pts 2 |
let twist i ( x , y ) = twistation . { i , 0 } <- scale . * ( x ) ; twistation . { i , 1 } <- scale . * ( y ) ; if i <> 0 then begin let ax = twistation . { i , 0 } . - twistation . { i - 1 , 0 } and ay = twistation . { i , 1 } . - twis... |
let init_tripples ( ) = for i = 0 to pred num_twis_pts do if i < 11 then begin let angle = pi . * ( float i ) . / 10 . 0 in let co = cos angle and si = sin angle in twist i ( ( - 7 . 0 . - 3 . 0 . * co ) , 1 . 8 . * si ) ; end else begin twist i ( ( - 10 ... |
let draw_stuff ( ) = toid1_twists . { 2 } <- ( float ! lastx . - 121 . 0 ) . / 8 . 0 ; tpts 3 ( 1 . 0 , . - ( float ! lasty . - 121 . 0 ) . / 200 . 0 ) ; tpts 4 ( 1 . 1 , - 1 . 1 . * ( float ! lasty . - 121 . 0 ) . / 20... |
let exclude v li = let rec aux acc = function | [ ] -> List . rev acc | x :: xs when x = v -> aux acc xs | x :: xs -> aux ( x :: acc ) xs in aux [ ] li ; ; |
let init_stuff ( ) = init_tripples ( ) ; ; ; |
type reconnect_policy = { max_tries : int ; initial_reconnect_interval : float ; } |
let url_of_stream_type = function | ` Firehose -> " http :// stream . twitter . com / 1 / statuses / firehose . json " | ` Sample -> " http :// stream . twitter . com / 1 / statuses / sample . json " | ` Custom url -> url |
let stream_of_channel chan = let lines = Lwt_io . read_lines chan in let map_line line = return ( Twitterstream_message . of_json_string line ) in Lwt_stream . map_s map_line lines |
let connect ( user , pass ) stream_type = let ( input , output ) = Lwt_io . pipe ( ) in let stream = stream_of_channel input in let t = begin let userpass_str = Base64 . str_encode ( user ^ " " : ^ pass ) in let headers = [ " Host " , " stream . twitter . com " ; "... |
let reconnect max_tries initial_reconnect_interval auth stream_type = let stream , push = Lwt_stream . create ( ) in let throttle = Twitterstream_throttle . make ~ initial_reconnect_interval ~ max_attempts : max_tries in let rec go throttle = try_lwt let ( t , stream ) = connect auth stream_type... |
let open_stream ( ? max_tries = 1 ) ( ? initial_reconnect_interval = 1 . ) auth stream_type = reconnect max_tries initial_reconnect_interval auth stream_type |
let ( << ) x y = left32 x y |
let ( >> ) x y = right32 x y |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.