Skip to content

Instantly share code, notes, and snippets.

View init.el
(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 Oct 11, 2020
Automated Github sync with upstream
View sync-upstream.sh
#!/bin/bash
git fetch upstream
git checkout master
git merge upstream/master
@tzach
tzach / CDC example
Last active Mar 26, 2020
Scylla CDC Example
View 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);
View install-guile on Fedora 30 - the missing parts
# 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
View LWT example
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;
View LWT example
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;
View calcInterest.clj
(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 Jun 14, 2019
create a large cell in Scylla using Clojure alia
View core.clj
(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;")))
View Use emacs as Tmux
# 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 Jul 5, 2020
Running a demo of a 3 node Scylla cluster, Scylla Manager and Monitoring
View Demo Scylla Manager with Docker
# 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"
You can’t perform that action at this time.