Skip to content

Instantly share code, notes, and snippets.

View jgarte's full-sized avatar
🎯
Focusing

Jorge Gomez jgarte

🎯
Focusing
View GitHub Profile
(define-syntax ->
(syntax-rules ()
((_ x) x)
((_ x (form more ...)) (form x more ...))
((_ x form) (form x))
((_ x form more ...) (-> (-> x form) more ...))))
(define-syntax ->>
(syntax-rules ()
double_it : IO ()
double_it = do
input <- getLine
let n = the Int (cast input)
printLn (n * 2)
Idris> :t [1 .. 10]
enumFromTo 1 10 : List Integer
Idris> :t [1 ..]
enumFrom 1 : Stream Integer
for x in range(12):
print(x)
@jgarte
jgarte / pex.md
Created January 9, 2024 05:11 — forked from simeonf/pex.md
Creating a PEX from a python script

So you want to create a pex that packages your script and its dependencies?

Ok - first to make our script! Call it foo.py:

import requests

if __name__ == '__main__':
  req = requests.get("https://raw.githubusercontent.com/pantsbuild/pex/master/README.rst")
  print req.text.split("\n")[0]
@jgarte
jgarte / permutations_ins_into_all_positions.ml
Created November 27, 2023 04:10 — forked from MassD/permutations_ins_into_all_positions.ml
A implementation for generating all permutations of a list, written in OCaml
(* note that in order to preserve certain order
and also show the conciseness of the implementation,
no tail-recursive is used *)
let ins_all_positions x l =
let rec aux prev acc = function
| [] -> (prev @ [x]) :: acc |> List.rev
| hd::tl as l -> aux (prev @ [hd]) ((prev @ [x] @ l) :: acc) tl
in
aux [] [] l
@jgarte
jgarte / eglot-rust-analyzer.el
Created May 5, 2023 06:43 — forked from casouri/eglot-rust-analyzer.el
Configuring eglot for rust-analyzer
;; How to translate LSP configuration examples into Eglot’s format:
;;
;; Usually LSP servers will say something like
;;
;; rust-analyzer.procMacro.attributes.enable (default: true)
;;
;; Translate that into a JSON LSP configuration, you get
;;
;; {
;; "rust-analyzer": {
@jgarte
jgarte / chatgpt.el
Created January 22, 2023 01:52 — forked from Gavinok/chatgpt.el
chatgpt client for emacs WIP (Now Async!)
;;; chatgpt.el --- Simple ChatGPT frontend for Emacs -*- lexical-binding: t -*-
;; Copyright (C) Gavin Jaeger-Freeborn
;; This package is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This package is distributed in the hope that it will be useful,
@jgarte
jgarte / AOC-d1.el
Created December 21, 2022 05:32 — forked from Gavinok/AOC-d1.el
Emacs lisp solution for day one of advent of code 2022
(defun cals-per-elf ()
(with-temp-buffer
(progn (insert "((")
(insert-file-contents "~/res.txt")
(while (re-search-forward "^$" nil t)
(replace-match ")(" nil nil))
(end-of-buffer)(insert "))")
(goto-char 0))
(mapcar (lambda (food-carried)
(cl-reduce #'+ food-carried))
{ pkgs }:
let
lib = pkgs.lib;
in
# list of additional packages to add to the packageset
additionalPackages:
# source path of the package (derivation or (filtered) nix path)
assert (lib.all (pkg: pkg ? src) additionalPackages);
# dhall file of that package