Skip to content

Instantly share code, notes, and snippets.

View ccfontes's full-sized avatar
💭

Carlos Fontes ccfontes

💭
  • Tokyo, Japan
View GitHub Profile
@ccfontes
ccfontes / search_no_tests.shs
Created October 4, 2023 05:22
Report untested shards
@wire(check-shard-no-tests {
= shard
"." | FS.Iterate(Recursive: true) >= filepaths
Remove(
filepaths
Predicate: {
Regex.Match(""".*(test|samples).*(\.shs|\.edn|\.clj)""") | Is([])
Or
FS.Read | ExpectString | String.Contains(shard) | Not })
When(Is([]) {
.error-bg {
color-background: #FFCCCC;
}
@ccfontes
ccfontes / prepare-commit-msg.hy
Created March 21, 2018 09:46
On git commit, adds message with JIRA ticket name and time spent working on commit to the commit editor
#!/usr/bin/env hy
(import sys)
(import subprocess)
(import [pathlib [Path]])
(import [functools [partial]])
(setv current-branch-name (subprocess.check_output ["git" "symbolic-ref" "--short" "HEAD"] :encoding "utf-8"))
(setv work-time (subprocess.check_output ["glass" "-s" "status" "--commit-template"] :encoding "utf-8"))
@ccfontes
ccfontes / change-datomic-schema-fulltex-idx.clj
Last active January 16, 2024 12:06
Change datomic schema by adding a fulltext index to :url/path attribute
; 1. rename attribute: :url/path → :legacy/url-path-v1
(do (require '[datomic.api :as datomic] '[kanasubs.db :as db])
(datomic/transact @db/connection
[{:db/id :url/path, :db/ident :legacy/url-path-v1}]))
; 2. repurpose :url/path
(do (in-ns 'kanasubs.db)
(transact @connection
[{:db/id #db/id[:db.part/db]
:db/ident :url/path
@ccfontes
ccfontes / cljs
Created August 23, 2014 01:55
Runs 'lein cljsbuild auto' (non blocking) when there are changes in the cljs files. Accepts other commands as arguments to execute after the daemon is launched. Example: 'script/with/cljs lein run' (script has problems with messages printing to several terminals)
#!/usr/bin/env hy
; Author: <Carlos C. Fontes> ccfontes@gmail.com
(import [sh [touch ls lein sleep]]
[glob [glob]]
sys
[subprocess [call Popen PIPE STDOUT]]
[thread [start_new_thread]])
(defn with-print-call [exe]
@ccfontes
ccfontes / readme-append
Created August 23, 2014 01:38
Formats lein-notes and then appends them to README.md
#!/usr/bin/env hy
; Author: <Carlos C. Fontes> ccfontes@gmail.com
(import [sh [cat lein echo tee rm]])
(import [script.hy-lib.hyclops.hyclops [comp]]) ; you must provide this your own
(setv irrelevant-note-patterns
["/.repl/" "/out/" "/README.md" "/target/" "/script/hy_lib/"])
(defn irrelevant-note?
@ccfontes
ccfontes / is-cljs-modified.hy
Created August 23, 2014 01:14
Verifies if the Clojurescript sources were modified since last build.
#!/usr/bin/env hy
; Author: <Carlos C. Fontes> ccfontes@gmail.com
(defn cljs-modified?
"""Verifies if the Clojurescript sources were modified since last build."""
[]
(let [ls-by-time-modified (partial ls "-t")]
(-> (glob "src-cljs/app/*.cljs")
(ls-by-time-modified "resources/public/js/main.js")
.split
@ccfontes
ccfontes / custom_tags_bt_example
Last active August 29, 2015 14:02
Definition and usage example of custom tags for Twitter Bootstrap
(ns custom-tags-bt-example
(:require [hiccup.core :refer [deftag]]))
(defn accordion-panel-tag [{:keys [title collapse class] :as attrs} body]
(let [collapse-id (str (string/replace title #"\s+" "-") (rand-int 999999999))]
[:div (merge {:class (str "panel panel-default " class)}
(dissoc attrs :title :collapse :class))
[:div {:class "panel-heading"}
[:h4 {:class "panel-title"}
[:a {:data-toggle "collapse"
(defn insert
"Insert user registration invitation."
[to_email]
(let [invite-id (make-random)]
(db/insert :invites
{:id invite-id
:to_email to_email
:created_at (to-sql-date (now))
:users_id (app.session/get :id)})
(.toString invite-id)))
(defn foo
(let [eggs #(str %)]
([x y] (println (eggs x) y))
([x] (println (eggs x)))))