Skip to content

Instantly share code, notes, and snippets.

View shegeley's full-sized avatar
🍴
Fork you

Grigory Shepelev shegeley

🍴
Fork you
View GitHub Profile
@ruliana
ruliana / sane-extensions.scm
Last active June 14, 2023 07:42
Sprinkling some syntax sugar on Guile Scheme to make it more pratical. Let's say "better defaults" for my personal taste :)
(use-modules (srfi srfi-1) ;; list operations
(srfi srfi-11) ;; let-values
(srfi srfi-41) ;; streams
(srfi srfi-42) ;; list comprehension
(srfi srfi-88) ;; keyword as "this:", not only "#:this"
(oop goops) ;; function overloading ("OOP" is _not_ the main point)
((ice-9 format) #:prefix fmt.))
(define-syntax def (identifier-syntax define-method))
@divs1210
divs1210 / calculus.clj
Last active August 1, 2020 11:01
Calculus in Clojure
(ns calculus)
(defonce ^:const dx 0.00001M)
(defn df
"Returns the derivative of f."
[f]
(fn [x]
(/ (- (f (+ x dx)) (f x))
dx)))
@saboyutaka
saboyutaka / gist:47536cc370923fad8e6160120dbf2941
Created August 11, 2018 06:43
docker-compose for mitmproxy
version: '3'
services:
nginx:
image: nginx
ports:
- 80:80
mitmweb:
image: mitmproxy/mitmproxy
tty: true
ports:
@zelark
zelark / pg_test.types.clj
Last active February 2, 2024 19:47
Support json and jsonb Postgres types in Clojure.
;; For supporting more PG types, see https://github.com/remodoy/clj-postgresql
(ns pg-test.types
(:require [cheshire.core :as json]
[clojure.java.jdbc :as jdbc])
(:import [org.postgresql.util PGobject]
[java.sql PreparedStatement]))
;; Writing
(defn- to-pg-json [data json-type]
@oubiwann
oubiwann / pubsub_with_callbacks.clj
Last active June 13, 2024 13:24
Clojure core.async Pub/Sub Example (with callbacks)
(ns pubsub-with-callbacks
"Adapted from Timothy Baldridge's 2013 core.async examples:
* https://raw.githubusercontent.com/halgari/clojure-conj-2013-core.async-examples/master/src/clojure_conj_talk/core.clj"
(:require [clojure.core.async :as async]))
(def pub-channel (async/chan 1))
(def publisher (async/pub pub-channel :tag))
(def print-channel (async/chan 1))
(defn run-print-channel
@martinklepsch
martinklepsch / client.clj
Last active November 26, 2023 20:36
A minimal Clojure client for Airtable.com's HTTP API.
(ns oxygen.client
"A minimal Clojure client for Airtable.com's HTTP API.
Supports retrieval of whole tables as well as individual records.
Dependencies: [org.clojure/data.json \"0.2.6\"] [clj-http \"2.0.0\"]"
(:require [clojure.data.json :as json]
[clojure.string :as string]
[clojure.set :as set]
[clj-http.client :as client]))
(def api-base "https://api.airtable.com/v0")
@city41
city41 / gist:aab464ae6c112acecfe1
Last active January 19, 2021 12:51
ClojureScript secretary client side navigation without hashes

This is the example that comes with the reagent template converted to use HTML5 based history. This means there are no # in the urls.

I just got this working, so there might be better approaches

The changes are

  • use goog.history.Html5history instead of goog.History
  • listen to clicks on the page, extract the path from them, and push them onto the history
  • listen to history changes, and have secretary do its thing in response
@ojarjur
ojarjur / scmfmt.scm
Created October 10, 2013 19:22
Code formatter for Scheme using Guile's pretty-print method. This reads from stdin and writes to stdout.
(use-modules (ice-9 pretty-print))
;; Helper methods for maintaining comments and whitespace.
(define (copy-line-comment)
(let ((char (read-char)))
(if (not (eof-object? char))
(if (eq? char #\newline)
(newline)
(begin (write-char char) (copy-line-comment))))))
(define (maintain-empty-lines)
@shanecelis
shanecelis / convenience-lambda.scm
Created May 26, 2012 16:24
A succinct anonymous procedure syntax for Guile scheme
;; convenience-lambda.scm
;;
;; This syntax was inspired by arc and Clojure's anonymous procedure
;; syntax.
;;
;; #.\ (+ %1 %2) -> (lambda (%1 %2) (+ %1 %2))
;; #.\ (+ % %%) -> (lambda (% %%) (+ % %%))
;;
;; The .\ is supposed to approximate the lowercase lambda character in
;; ascii.