Skip to content

Instantly share code, notes, and snippets.


David Raviv davidraviv

View GitHub Profile
davidraviv / timeout.js
Created Feb 15, 2017
Execute a Promise with a timeout. If the timeout occurs before completing the Promise, it should reject.
View timeout.js
* Accepts a promise and a timeout. If the timeout reached while the promise is stil pending, it rejects with a timeout.
* @param timeout in milli
* @param promise
Promise.timeout = (timeout, promise) => {
let bombId;
new Promise((resolve, reject) => {
davidraviv / logstash.conf
Created Feb 17, 2016
Logstash configuration that accepts json file from filebeat. It overrides filebeat's additional fields and takes the type from the json rather than filebeat.
View logstash.conf
input {
beats {
port => 5044
filter {
if [type] == "beat" {
mutate {
remove_field => ["type", "beat", "input_type", "offset", "source", "fields"]
davidraviv / semanticVersionComparator.js
Created Feb 3, 2016
Compare two version numbers that follows the semantic version standard
View semanticVersionComparator.js
* Created by david on 17/1/16.
* Compares two version numbers that follow the semantic version standard.
* Compares only the first 3 elements (major, minor and patch).
* Separator can be '.' or '-'.
* If a>b, returns 1
* If a<b, returns -1
davidraviv / nginx-configuration
Last active Jan 24, 2016
/etc/nginx/sites-available/default Set Ngnix as reverse proxy for Kibana
View nginx-configuration
server {
listen 80;
auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/htpasswd.users;
location / {
proxy_pass http://localhost:5601;
davidraviv / logstash.conf
Last active Jan 21, 2016
Basic logstash config file that reads a json log file into elasticsearch. *Install logstash on mac:* brew install logstash mkdir /usr/local/etc/logstash subl /usr/local/etc/logstash/logstach.conf *Test config file* cd /usr/local/Cellar/logstash/2.1.1 bin/logstash -f /usr/local/etc/logstash/logstash.conf --configtest
View logstash.conf
input {
file {
path => "/var/log/kwik/kwik.log"
codec => json
start_position => beginning
output {
elasticsearch {
hosts => "localhost:9200"
View BuildLog
Setting top to : /tmp/tmpctNwIM
Setting out to : /tmp/tmpctNwIM/build
Checking for program gcc,cc : arm-none-eabi-gcc
Checking for program ar : arm-none-eabi-ar
Found Pebble SDK in : /app/sdk2/Pebble
'configure' finished successfully (0.052s)
Waf: Entering directory `/tmp/tmpctNwIM/build'
[ 1/29] appinfo.json -> build/
[ 2/29] menu_icon.png.pbi: resources/images/menu_icon.png ../../app/sdk2/Pebble/tools/ -> build/resources/images/menu_icon.png.pbi
[ 3/29] logo_splash.png.pbi: resources/images/logo_splash.png ../../app/sdk2/Pebble/tools/ -> build/resources/images/logo_splash.png.pbi
View .gitconfig
name = David Raviv
email =
autocrlf = input
helper = osxkeychain
ui = auto
davidraviv / LocationChanger.plist
Created Jul 14, 2014
Trigger a script on a network change in macosx 1. Move locationchanger to a location of your wish and make it executable. 2. Edit LocationChanger.plist with the location of locationchanger. 3. Move LocationChanger to ~/Library/LaunchAgents/LocationChanger.plist 4. Execute the following on a terminal: launchctl load ~/Library/LaunchAgents/Locatio…
View LocationChanger.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
<plist version="1.0">
davidraviv /
Created Jun 9, 2014
Get a list of your ip's on macosx using ifconfig (no external service)
#! /bin/bash
ip_lines=`ifconfig | grep "inet "`
prefix="*inet "
suffix=" net*"
while read -r line; do
echo "$ip"
done <<< "$ip_lines"
davidraviv /
Created May 22, 2014
Simple HTTP sender using
package com.x.proxy.http;
import java.util.Map;
* Created by davidraviv on 7/5/14.
public class HTTPMessage implements Serializable {
public String url;