Skip to content

Instantly share code, notes, and snippets.

David Raviv davidraviv

Block or report user

Report or block davidraviv

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@davidraviv
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;
Promise.race([
promise,
new Promise((resolve, reject) => {
@davidraviv
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
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
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;
server_name domain.com;
auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/htpasswd.users;
location / {
proxy_pass http://localhost:5601;
@davidraviv
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.auto.c: appinfo.json -> build/appinfo.auto.c
[ 2/29] menu_icon.png.pbi: resources/images/menu_icon.png ../../app/sdk2/Pebble/tools/bitmapgen.py -> build/resources/images/menu_icon.png.pbi
[ 3/29] logo_splash.png.pbi: resources/images/logo_splash.png ../../app/sdk2/Pebble/tools/bitmapgen.py -> build/resources/images/logo_splash.png.pbi
View .gitconfig
[user]
name = David Raviv
email = david.raviv@worldmate.com
[core]
autocrlf = input
[credential]
helper = osxkeychain
[color]
ui = auto
@davidraviv
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"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>locationchanger</string>
<key>ProgramArguments</key>
<array>
<string>/Users/davidraviv/bin/locationchanger</string>
@davidraviv
davidraviv / ip.sh
Created Jun 9, 2014
Get a list of your ip's on macosx using ifconfig (no external service)
View ip.sh
#! /bin/bash
ip_lines=`ifconfig | grep "inet "`
prefix="*inet "
suffix=" net*"
while read -r line; do
ip=${line##$prefix}
ip=${ip%%$suffix}
echo "$ip"
done <<< "$ip_lines"
@davidraviv
davidraviv / HTTPMessage.java
Created May 22, 2014
Simple HTTP sender using java.net
View HTTPMessage.java
package com.x.proxy.http;
import java.io.Serializable;
import java.util.Map;
/**
* Created by davidraviv on 7/5/14.
*/
public class HTTPMessage implements Serializable {
public String url;
You can’t perform that action at this time.