Skip to content

Instantly share code, notes, and snippets.

View ichramm's full-sized avatar

Juan Ramirez ichramm

View GitHub Profile
@ichramm
ichramm / Makefile
Created April 2, 2022 04:24
makefile list objs for binary
$(shell $(MAKE) -qp -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | grep $(shell echo $(OUTPUT_FILE) | sed 's|./||') | awk '{ for ( n=1; n<=NF; n++ ) if($$n ~ "[.]o$$") print $$n }') \
@ichramm
ichramm / log.clj
Created February 16, 2022 14:44
clojure log wrappers
(ns ichramm.log
(:require [clojure.tools.logging :as log]))
(def ^:macro trace #'log/trace)
(def ^:macro debug #'log/debug)
(def ^:macro info #'log/info)
(def ^:macro warn #'log/warn)
(def ^:macro error #'log/error)
(def ^:macro fatal #'log/fatal)
@ichramm
ichramm / pca_animation.m
Created November 4, 2021 18:13 — forked from anonymous/pca_animation.m
Matlab code to produce PCA animations
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Matlab code to produce PCA animations shown here:
% http://stats.stackexchange.com/questions/2691
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Static image
clear all
rng(42)
@ichramm
ichramm / datomic-erasing-data-migration.clj
Created June 14, 2021 14:08 — forked from vvvvalvalval/datomic-erasing-data-migration.clj
Erasing data from Datomic via a manual data migration
;; # EMULATING DATOMIC EXCISION VIA MANUAL DATA MIGRATION
;; *************************************
;; ## Introduction
;; *************************************
;; This Gist demonstrates a generic way to migrate an entire Datomic database
;; from an existing 'Origin Connection' to a clean 'Destination Connection',
;; while getting rid of some undesirable data and otherwise preserving history.
@ichramm
ichramm / diff-maps.clj
Created February 6, 2021 03:28
Compute common factor of multiple maps in Clojure
;; manually
(defn compute-common-factor
[maps]
(if (empty? (rest maps))
;; only one
(first maps)
(let [head (first maps)
maps (rest maps)]
(letfn [(reducer [path obj]
(reduce-kv (fn [m k v]
@ichramm
ichramm / datomic_registry.clj
Last active September 16, 2022 14:22
datomic registry
(ns components.datomic-registry.service
(:require [datomic.api :as d]
[components.lifecycle.protocol :as lifecycle]
[components.datomic.service :refer [make-uri]]
[components.datomic-registry.protocol :as protocol]))
(defrecord DatomicRegistryService [db ns-name state]
lifecycle/Lifecycle
(start [this system]
(let [db (lifecycle/handler db)
@ichramm
ichramm / dissector.cpp
Created October 10, 2020 13:21
wireshark dissector
/*!
* \file wireshark_dissector.cpp
* \author ichramm
*
* \date 2020-09-08
*/
#include <iostream>
#include "config.h"
@ichramm
ichramm / sleep_random_decimal.sh
Created October 3, 2020 01:21
bash sleep random decimal
sleep $(awk "BEGIN{print 1 + 1 / $(($RANDOM % 5 + 1))}")
@ichramm
ichramm / index-of.clj
Created August 28, 2020 14:47
clojure index of element matching predicate
(defn index-of
[pred coll]
(first (keep-indexed #(when (pred %2) %1) coll)))
; or
(defn indices
[pred coll]
(keep-indexed #(when (pred %2) %1) coll))
@ichramm
ichramm / windows-port-forwarding.sh
Last active July 24, 2020 17:00
Port Forwarding in Windows
netsh interface portproxy add v4tov4 listenport=10022 listenaddress=0.0.0.0 connectport=22 connectaddress=192.168.1.1
netsh interface portproxy show all
#netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=10022