Skip to content

Instantly share code, notes, and snippets.

View tzach's full-sized avatar

Tzach Livyatan tzach

View GitHub Profile
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(let ((default-directory "~/emacs/"))
(normal-top-level-add-subdirs-to-load-path))
(require 'better-defaults)
@tzach
tzach / sync-upstream.sh
Created October 11, 2020 07:46
Automated Github sync with upstream
#!/bin/bash
git fetch upstream
git checkout master
git merge upstream/master
@tzach
tzach / CDC example
Last active March 26, 2020 17:39
Scylla CDC Example
docker run --name some-scylla-night -d scylladb/scylla-nightly --experimental 1
docker exec -it some-scylla-night cqlsh
cqlsh>
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
CREATE TABLE ks.t (pk int, ck int, v int, PRIMARY KEY (pk, ck, v)) WITH cdc = {'enabled':true};
INSERT INTO ks.t (pk,ck,v) VALUES (1,2,3);
INSERT INTO ks.t (pk,ck,v) VALUES (1,2,4);
# Installing Guile on Fedoa 30 from source file does not work as documented
# here are the extra steps I did
# Download tar from https://ftp.gnu.org/gnu/guile/
tar -xvf guile-3.0.0.tar.gz
# install missing libs
sudo dnf install libffi-devel
sudo dnf install gc-devel
CREATE KEYSPACE mykeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
USE mykeyspace;
CREATE TABLE tbl (
k int,
v int,
x int,
PRIMARY KEY (k,v)
);
INSERT INTO tbl (k,v,x) VALUES (1,2,0);
INSERT INTO tbl (k,v,x) VALUES (1,2,3) IF NOT EXISTS;
CREATE KEYSPACE mykeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
USE mykeyspace;
CREATE TABLE tbl (
k int,
v int,
x int,
PRIMARY KEY (k,v)
);
INSERT INTO tbl (k,v,x) VALUES (1,2,0);
INSERT INTO tbl (k,v,x) VALUES (1,2,3) IF NOT EXISTS;
@tzach
tzach / calcInterest.clj
Created December 1, 2019 14:12
calcInterest
(defn round100 [n] (-> n (* 100) (Math/floor) (/ 100)))
(defn calcInterest [& {:keys [initialAmount interestRate years roundInterestYearly]}]
(nth (iterate
(fn calcInterestOneYear [amount]
(cond-> (* interestRate amount)
roundInterestYearly round100))
initialAmount) years))
@tzach
tzach / core.clj
Last active June 14, 2019 13:21
create a large cell in Scylla using Clojure alia
(ns cassandra-project.core
(:require [qbits.alia :as alia]))
(def cluster (alia/cluster {:contact-points ["172.17.0.2"]}))
(def session (alia/connect cluster))
(alia/execute session "USE mykeyspace;")
(dotimes [n 2000000]
(alia/execute session (str "UPDATE mykeyspace.gr SET link = link + {" n " : 'ABC'} WHERE id=1 AND r=1;")))
# install emacs
sudo yum install emacs -y
# run emacs as a daemon
emacs --daemon
# connect
export TERM=xterm-color
emacsclient -nw
# run shell
c-x shell
# reconnect after connection drop
@tzach
tzach / Demo Scylla Manager with Docker
Last active July 5, 2020 13:33
Running a demo of a 3 node Scylla cluster, Scylla Manager and Monitoring
# Start a Scylla cluster
########################
docker run --name some-scylla -d scylladb/scylla --smp 1 --memory 750M --overprovisioned 1 --api-address 0.0.0.0
# Do not use the above --api-address for production. Exposing API IP is not secure.
SEED=$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' some-scylla)
echo $SEED
docker run --name some-scylla2 -d scylladb/scylla --smp 1 --memory 750M --overprovisioned 1 --api-address 0.0.0.0 --seeds="$SEED"
docker run --name some-scylla3 -d scylladb/scylla --smp 1 --memory 750M --overprovisioned 1 --api-address 0.0.0.0 --seeds="$SEED"