Skip to content

Instantly share code, notes, and snippets.

View shubhamkumar13's full-sized avatar
๐Ÿ˜‘
is existing

shubham shubhamkumar13

๐Ÿ˜‘
is existing
View GitHub Profile
@shubhamkumar13
shubhamkumar13 / assignment.lean
Created October 31, 2022 14:43
Implement a simple stack machine and prove things about it in lean4
section
abbrev Stack := List Int
def nAdd (s : Stack) (pc : Nat) : Stack ร— Nat :=
match s with
| [] => ([], pc)
| x :: [] => ([x], pc)
| x :: y :: xs => ((x + y) :: xs, pc + 1)
def nSub (s : Stack) (pc : Nat) : Stack ร— Nat :=
@shubhamkumar13
shubhamkumar13 / after_improved_code.rs
Created October 5, 2022 10:45
rest of code after improved code
// update cab destination and person_id
nearest_cab.update_destination(Some(person.location.clone()));
nearest_cab.update_person_id(ObjectId::parse_str(person_id).ok());
// update cab by using `assign_person`
let cab_id = match nearest_cab.id {
Some(obj_id) => obj_id.to_hex(),
None => panic!("cannot get the cab id"),
};
let update_result = db.assign_person(&cab_id, nearest_cab.clone());
// return result as person and cab tuple
@shubhamkumar13
shubhamkumar13 / improved_code.rs
Last active October 5, 2022 10:49
after_improved_code
// find the nearest cab in the fleet from the person
let mut nearest_cab = fleet
.into_iter()
.filter(|x| is_free((*x).clone()).is_ok())
.reduce(|c1, c2| person.nearest_cab(&c1, &c2))
.and_then(|x| Some(x.clone()))
.expect("Unable to get the nearest cab");
@shubhamkumar13
shubhamkumar13 / wrong_code.rs
Created October 5, 2022 10:41
before_wrong_code
// find the nearest cab in the fleet from the person
let mut nearest_cab = fleet
.into_iter()
.reduce(|c1, c2| person.nearest_cab(&c1, &c2))
.and_then(|x| Some(x.clone()))
.expect("Unable to get the nearest cab");
// check if the cab is assigned or not
match is_free(nearest_cab.clone()) {
Ok(_) => {
@shubhamkumar13
shubhamkumar13 / subgoal.md
Created June 21, 2022 15:24
subgoal for recursive definition
(let
 '(init_value, reachable) :=
  match entrypoints.(Script_typed_ir.entrypoints_node.at_node) with
  | Some e =>
      ((Map.Make Alpha_context.Entrypoint.T).(S.singleton)
       e.(Script_typed_ir.entrypoint_info.name) tt, true)
  | None => ((Map.Make Alpha_context.Entrypoint.T).(S.empty), false)
  end in
  let? ' (first_unreachable, all)
@shubhamkumar13
shubhamkumar13 / works.patch
Created January 4, 2022 10:22
this patch works
diff --git a/src/sexp_conv.ml b/src/sexp_conv.ml
index ed2becf..406ee73 100644
--- a/src/sexp_conv.ml
+++ b/src/sexp_conv.ml
@@ -110,7 +110,7 @@ module Exn_converter = struct
end
let exn_id_map
- : (Obj.Extension_constructor.t, Registration.t) Ephemeron.K1.t Exn_ids.t ref
+ : (Obj.Extension_constructor.t * Registration.t) Exn_ids.t ref
@shubhamkumar13
shubhamkumar13 / example.service
Created September 27, 2021 21:41
example service to make services
# /etc/systemd/system/minecraft-server.service
[Unit]
Description=Minecraft Server
[Service]
WorkingDirectory=/root/minecraft-server
ExecStart=/usr/bin/java -Xmx6G -Xms4G -jar /root/minecraft-server/server.jar nogui
Restart=on-failure
RestartSec=5
diff --git a/ast/supported_version/supported_version.ml b/ast/supported_version/supported_version.ml
index b90d7e8..1cd4373 100644
--- a/ast/supported_version/supported_version.ml
+++ b/ast/supported_version/supported_version.ml
@@ -13,6 +13,7 @@ let all =
; 4, 11
; 4, 12
; 4, 13
+ ; 4, 14
]
@shubhamkumar13
shubhamkumar13 / sdf_help.scm
Created August 17, 2021 06:20
biwascheme shenanigans
(define (append* . args)
(map (lambda (x) (if (list? x) (car x) x)) (apply append args))
)
(define (append-map proc lst) (apply append (map proc lst)))