Skip to content

Instantly share code, notes, and snippets.

@afhammad
afhammad / authorized_introspection.ex
Last active July 8, 2024 16:33
Disable GraphQL schema introspection in Elixir Absinthe using a plugin
defmodule MyAppWeb.Schema.Middleware.AuthorizedIntrospection do
@moduledoc """
Disable or restrict schema introspection to authorized requests
"""
@behaviour Absinthe.Plugin
@impl Absinthe.Plugin
def before_resolution(%{context: %{admin: true}} = exec), do: exec
def before_resolution(exec) do
@hiracchi
hiracchi / brew-install-ghostscript-9.26.sh
Last active December 18, 2023 04:41
install ghostscript 9.26 on MacOS by using homebrew
#!/bin/bash
brew unlink ghostscript
cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
git checkout 6ec0c1a03ad789b6246bfbbf4ee0e37e9f913ee0 ghostscript.rb
brew install ghostscript
brew pin ghostscript
@olivergeorge
olivergeorge / shred.clj
Last active June 28, 2016 00:34
WIP of clojure.walk approach to translating pull query into simple SQL query plan.
(ns shred
(:require [schema.core :as s]
[om.next.impl.parser :refer [expr->ast]]
[clojure.walk :refer [prewalk postwalk]]
[clojure.pprint :refer [pprint]]
[clojure.string :refer [lower-case]]
[clojure.test :refer :all]))
; TODO: Perhaps don't split if params are present since they are select query modifiers.
; TODO: Not currently adding the joining keys necesary to stitch up data.
@olivergeorge
olivergeorge / relational_mapper.clj
Last active June 28, 2016 00:30
zipper solution for splitting nested relational query (pull spec) into flat select queries which can be stiched together
(ns om-starter.relational-mapper
(:require [om.next.impl.parser :as parser]
[om.next.server :as om]
[clojure.zip :as zip :refer [zipper]]
[clojure.test :refer [deftest is]])
(:use clojure.pprint))
(defn make-node
"Build new om.next ast node making sure query and children match."
[old-node children]
@bsergean
bsergean / curl-format.txt
Last active August 4, 2023 02:29
Profiling with curl
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
@mprokopov
mprokopov / gist:d283a060c40252dc247b
Created June 22, 2015 12:47
One-liner for fetching nested item from hash-map by link value
(def sidebar-items [{ :name "Dashboard" :color "red" :icon "dashboard" :link "/dashboard" }
{ :name "Обращения" :color "blue" :icon "comments-2" :link "/ticket" }
{ :submenu [
{ :name "Инциденты" :icon "bug" :link "/incidents" }
{ :name "Запросы на обслуж" :icon "basket" :link "/requests" }
{ :name "Запросы на изм" :icon "cog" :link "/rfcs" }
{ :name "Фидбеки" :icon "comments" :link "/feedbacks" }]}
{ :name "Изменения" :icon "cog" :link "/changes" }
{ :name "Проблемы" :icon "shit" :color "green" :link "/problems" }
{ :name "Знания" :icon "book" :link "/knowledges" }
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` or `git checkout` if a specified file was changed
# Run `chmod +x post-checkout` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2"

This document is my personal writeup of trying to make sense of all the clojure(script) tooling chain. It might contain errors and it actually contains a few questions

Tooling:

Nomenclature/Terminology

REPL: A prompt in its simples form.

  1. Waits for and Reads input,
@john2x
john2x / 00_destructuring.md
Last active August 23, 2024 07:45
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences