Skip to content

Instantly share code, notes, and snippets.

View shaharke's full-sized avatar

Shahar Kedar shaharke

  • RiseUp
  • Tel Aviv, Israel
View GitHub Profile
@shaharke
shaharke / .block
Last active October 13, 2019 17:11
roughViz Pie Demo
license: mit
@shaharke
shaharke / whisper max archive
Last active February 10, 2018 10:30 — forked from amosshapira/whisper max archive
Example (untested) of tracking maximum value of metric in the past year.
Ref: http://graphite.readthedocs.io/en/latest/config-carbon.html#storage-schemas-conf
storage-schemas.conf:
[year_max]
pattern = yearMax$
retentions = 1m:1d,1d:1y
storage-aggregation.conf:
# update packages
sudo apt-get update
# install python and graphite dependencies
sudo apt-get install -y python python-dev python-virtualenv libevent-dev python-pip python-cairo python-django-tagging python-twisted python-memcache python-pysqlite2
# install web server
sudo apt-get install -y nginx uwsgi uwsgi-plugin-python
# install postgresql and dependencies
@shaharke
shaharke / outdated.js
Last active August 29, 2015 13:57
Outputs all outdated node.js packages
#!/usr/bin/env node
var spawn = require('child_process').spawn
var outdated = spawn('npm', ['outdated']);
outdated.stdout.on('data', function (data) {
var out = data.toString();
var lines = out.split('\n');
if (lines.length > 1) {
lines = lines.slice(1);
var packages = [];
@shaharke
shaharke / ec2_protect.yml
Created March 15, 2014 17:12
Protecting your production EC2 instanced from termination with Ansible
---
- hosts: all
tasks:
- name: Gather EC2 facts
action: ec2_facts
- name: Turning on termination protection
local_action: command aws ec2 modify-instance-attribute --region {{ ansible_ec2_placement_region }} --instance-id {{ ansible_ec2_instance_id }} --attribute disableApiTermination --value true
@shaharke
shaharke / killp.sh
Created March 14, 2014 09:49
Kill by port
#! /bin/bash
PORT=$1
if [[ -z "$PORT" ]]; then
echo "Usage: killp <port>"
exit 1
fi
PID=`lsof -i :$PORT -t`
@shaharke
shaharke / socket-io-auth.html
Last active December 10, 2015 13:29
socket-io session bases authorization
<html>
<head>
<script src="http://localhost:3000/socket.io/socket.io.js" type="text/javascript"></script>
<script type="text/javascript">
tick = io.connect('http://localhost:3000/');
tick.on('data', function (data) {
console.log(data);
});
tick.on('error', function (reason){