Skip to content

Instantly share code, notes, and snippets.

View tzach's full-sized avatar

Tzach Livyatan tzach

View GitHub Profile
console.log('Loading function');
var aws = require('aws-sdk');
var region = 'us-west-2';
var ec2 = new aws.EC2({region: region});
var topicArn = "arn:aws:sns:us-west-2:797456418907:cloudius_running_ec2_instances";
function push(payload, context) {
var sns = new aws.SNS();
# Even Fibonacci numbers
# https://projecteuler.net/problem=2
# Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
# By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
(defn fib
([] (fib 1))
([a] (fib 1 a))
@tzach
tzach / collect-info.sh
Created December 14, 2015 11:22
collect information from a server, compress and upload to s3
mkdir report
rpm -qa > ./report/rpm.txt
journalctl -b > ./report/journalctl.txt
df -k > ./report/df.txt
netstat > ./report/netstat.txt
export report_uuid=$(uuidgen)
tar c report | xz > report.tar.xz
curl --request PUT --upload-file report.tar.xz "scylladb-users-upload.s3.amazonaws.com/$report_uuid/report.tar.xz"
echo $report_uuid
@tzach
tzach / create-github-issue.el
Created June 14, 2016 10:15
replace an issue number with a markdown link to github issue
(setq github-project-prefix "https://github.com/scylladb/scylla/issues/")
(defun create-github-issue (string &optional from to)
"replace a #xxx with [#xxx](https://github.com/scylladb/scylla/issues/xxx)"
(interactive
(if (use-region-p)
(list nil (region-beginning) (region-end))
(let ((bds (bounds-of-thing-at-point 'paragraph)) )
(list nil (car bds) (cdr bds)) ) ) )
(let (workOnStringP inputStr outputStr)
/***************************/
/* simple root car */
/***************************/
// engine part from
// http://www.instructables.com/id/Control-DC-and-stepper-motors-with-L298N-Dual-Moto/?ALLSTEPS
// sndor part from
// http://www.instructables.com/id/Simple-Arduino-and-HC-SR04-Example/?ALLSTEPS
/*
## Presto
$ cd etc
etc$ ls -la
total 28
drwxrwxr-x 3 tzach tzach 4096 Jun 27 10:24 .
drwxr-xr-x 8 tzach tzach 4096 Jun 27 10:24 ..
drwxrwxr-x 2 tzach tzach 4096 Jun 27 10:19 catalog
-rw-rw-r-- 1 tzach tzach 203 Jun 27 10:19 config.properties
-rw-rw-r-- 1 tzach tzach 176 Jun 27 10:18 jvm.config
cqlsh>
CREATE KEYSPACE mykeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
use mykeyspace ;
CREATE TABLE users (user_id int PRIMARY KEY, fname text, lname text);
insert into users (user_id , fname, lname) values (1, 'tzach', 'livyatan');
insert into users (user_id , fname, lname) values (2, 'dor', 'laor');
insert into users (user_id , fname, lname) values (3, 'shlomi', 'laor');
insert into users (user_id , fname, lname) values (4, 'shlomi', 'livne');
insert into users (user_id , fname, lname) values (6, 'avi', 'kivity');
@tzach
tzach / provision-ec2-volume.yaml
Created July 19, 2016 20:49
Ansible playbook to start a Scylla cluster, with 10 EBS attached to each node
## This Ansible script start a cluster of 3 nodes on EC2
## And attach 10 ESB, 100G each
- name: Provision voulums
hosts: localhost
connection: local
vars:
region: us-east-1
cluster_nodes: 3
user_data: "--clustername test-cluster --totalnodes {{cluster_nodes}}"
@tzach
tzach / scyllatop-to-list.sh
Created July 21, 2016 08:24
Extract a sorted list of metrics from scyllatop
cat scylla.1.2.1.metrics.txt | sed 's/.$//' | sed 's/^.//' | cut -d"/" -f2- | sed 's/.$//' | sort
#!/bin/bash -e
mkdir report
rpm -qa > ./report/rpm.txt
journalctl -b > ./report/journalctl.txt
df -k > ./report/df.txt
netstat > ./report/netstat.txt
sar -P ALL > ./report/sar.txt
iostat -d 1 10 > ./report/iostat.txt