Skip to content

Instantly share code, notes, and snippets.

View digash's full-sized avatar
🐽
digging

Dig Gashinsky digash

🐽
digging
View GitHub Profile
@digash
digash / get-latest-meta-data-json.clj
Last active December 2, 2021 17:45
Read all meta-data on AWS EC2
#!/bin/env bb
(let [cgb #(->> % (cons "http://169.254.169.254/latest") (str/join "/") curl/get :body)
try-json #(try (json/parse-string %) (catch Exception _ %))
dir? #(str/ends-with? (last %) "/")
paths (fn [p] (->> (cgb p)
str/split-lines
(map #(->> (str/split % #"=") first (conj p)))))
trimlslash #(str/replace % #"/$" "")]
(json/generate-stream
(ns hw1 (:refer-clojure :exclude [eval]))
(defrecord StringLit [s])
(defrecord Concat [l r])
(defrecord RestAfter [l r])
(defn parse [sexp]
(cond (symbol? sexp) (StringLit. (str sexp))
(sequential? sexp)
(case (second sexp)
@digash
digash / figlet.el
Created May 6, 2010 20:14
figlet emacs
;;;; Copyright (c) 2007 Martin Giese. All rights reserved.
;;;;
;;;; Author: Martin Giese
;;;; Author: Dimitry Gashinsky
;;;; Id: 295eb73b-9e95-46a6-9cce-366436f9712f
;;;;
;;;; FIGlet definitions for Emacs.
;;;;
;;;; Use this to separate sections in TeX files, Program source, etc.
;;;;
(defn startparse-tagsoup [s ch]
(.parse (doto (org.ccil.cowan.tagsoup.Parser.)
(.setContentHandler ch))
(org.xml.sax.InputSource. s)))
(xml/parse "http://bla" startparse-tagsoup)
(defun slime-repl-emit-result (string &optional bol)
;; insert STRING and mark it as evaluation result
(with-current-buffer (slime-output-buffer)
(save-excursion
(slime-save-marker slime-output-start
(slime-save-marker slime-output-end
(goto-char slime-repl-input-start-mark)
(when (and bol (not (bolp))) (insert-before-markers "\n"))
(slime-propertize-region `(face slime-repl-result-face
rear-nonsticky (face))
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>Conkeror</string>
<key>CFBundleIdentifier</key>
<string>org.mozdev.conkeror</string>
#!/usr/bin/env bash
# # Copyright (c) 2009 Dimitry Gashinsky. No rights reserved.
# #
# # Author: Dimitry Gashinsky (dimitry :at gashinsky :dot com)
# # Id: 2C189717-816D-49E4-B244-1CBEFF623889
set -eux
cd ~/src/xul
xulrunner-bin --install-app conkeror
cp -f conkeror/Info.plist /Applications/conkeror.mozdev.org/conkeror.app/Contents/
package com.polarsparc.clojure;
import java.util.Random;
import clojure.lang.RT;
import clojure.lang.Var;
public class CompiledFilter {
private static int[] nums;
private static Var filterEvenGt500;
(ns filters)
(defn filter-even-gt-500 [num]
(and (> num 500) (even? num)))
(defn filter-odd-gt-500 [num]
(and (> num 500) (odd? num)))
(ns l-cache)
(set! clojure.core/*warn-on-reflection* true)
(defmacro with-time
"Evaluates expr and returns a vector of expression value and the
time it took to evaluate it in milliseconds."
[expr]
`(let [start# (System/nanoTime)
ret# ~expr