Skip to content

Instantly share code, notes, and snippets.

View daimor's full-sized avatar

Dmitry Maslennikov daimor

View GitHub Profile
@daimor
daimor / ccontrol
Last active August 19, 2021 04:56
bash completions for InterSystems cache
#!/bin/bash
# bash completions for InterSystems ccontrol
_instances()
{
if [ $# == 0 ] || [ $1 == "all" ]; then
echo $(ccontrol qlist | cut -d'^' -f1 | tr '\n' ' ')
else
echo $(ccontrol qlist | grep "\^$1\," | cut -d'^' -f1 | tr '\n' ' ')
fi
@daimor
daimor / clock.mac
Created September 15, 2023 08:03
clock
ROUTINE clock
#; https://stackoverflow.com/questions/4151554/need-mumps-sample-code
Q N R,Q,C,D,E,W,B,G,H,S,T,U,V,F,L,P,N,J,A S N=$G(N),Q='N,F=Q+Q,P=F+F,W=$L($T(Q))
S W=$E(W,Q),S='N_+N,W=W-F*S,L=$G(L),R=$C(Q_F_P),R(F)=$C(F+Q_F),R(P)=$C(W-F) W #
S T=$E($T(Q+F),F,W\S)_$C(W+S+F) X T S B=$P(T,$C(P_P),F),C=B\(W*W),D=B-(C*W*W)\W
F G=S-Q:F:S+F+Q S E=B-(C*W*W+(D*W)),H=$E($T(Q),G),@H=$S(@H<S:'Q,Q:N)_@H,T=C_D_E
F A=Q:Q:W\S S J=$E(T,A),C(F)=$S(J>(F+Q)&(J<(S-F)):Q,Q:+N),C(P)=$S(J#F:Q,Q:+N) D
.S C(Q)=$S(J<(S-F):+N,Q:Q),C(F+Q)=$S(J>Q&(J<(S-F))&(J'=(P+'L))&(J'=(P)):Q,Q:+N)
.S H('L)=L F S H(N?.E)=$O(C(H('$G(N)))) Q:H('+L)=L S F(A,H('L))=C(H(W[(W\S)))
F U=Q:Q:P W !,R F V=Q:Q:P+F W $S(F(V,U):'Q,Q:$C(P_(W\S))) W:'(V#F) $C('N_F_F+F)