Skip to content

Instantly share code, notes, and snippets.

View rashidkpc's full-sized avatar
🚲

Rashid Khan rashidkpc

🚲
View GitHub Profile
@rashidkpc
rashidkpc / js_unicode_sparklines.js
Last active August 29, 2015 14:05
Javascript unicode sparklines
var sparkline = function(input) {
var numbers = input.split(/[\s,]+/);
var bar = [0,1,2,3,4,5,6].map(function (n) { return String.fromCharCode(9601+n);});
var min = Math.min.apply(Math, numbers);
var max = Math.max.apply(Math, numbers);
var div = (max - min) / (bar.length - 1)
if (min === max) return Array(numbers.length).join(_.last(bar))
return numbers.map(function (p) {return bar[Math.round(((p - min) / div))]}).join('');
}
@rashidkpc
rashidkpc / digital_transmit.cpp
Created March 21, 2015 04:58
AM digital transmission + wiringPi
// This uses those super cheap 433mhz modules to receive a 32 bit integer
// You should be able to implement many 315 & 433mhz protocols in this, though more complex lock logic may be required
#include <wiringPi.h>
#include <time.h>
#include <iostream>
#include <bitset>
using namespace std;
@rashidkpc
rashidkpc / durations.cpp
Created March 21, 2015 19:22
Pulse based signal debugger
/*
This is useful for debugging systems that use low/high durations for communicating digital information.
I wrote this specific one for figuring out a wireless temperature/humidity gauge, thus to the 352+1
*/
#include <iostream>
#include <time.h>
#include <string.h>
@rashidkpc
rashidkpc / tx7nu.cpp
Last active August 29, 2015 14:17
La Crosse TX7NU decoder
/*
This takes in bits over 433mhz from a La Crosse TX7NU temp sensor and prints on the humidity and temp.
It does not currently validate the parity bit, nor the repetition of the ten and one parts of the BCD data, nor the checksum
*/
#include <wiringPi.h>
#include <time.h>
#include <iostream>
#include <bitset>
@rashidkpc
rashidkpc / Sensor_samples.txt
Last active August 29, 2015 14:17
TX7NU decoded
== Pulse duration samples ==
6780
1329 1086 1314 1067 1329 1071 1329 1068 577 1046 1330 1068 547 1076 1320 1006 1336 1066 1322 1116 1282 1071
1326 1009 547 1067 1323 1072 1336 1077 545 1001 541 1074 1323 1073 544 1076 544 1017 1325 1071 541 1078
540 1077 542 1009 1332 1072 566 1054 543 1073 1322 1009 1328 1073 539 1078 1327 1070 540 1017 1322 1076
537 1086 534 1079 541 1020 1316 1084 537 1072 542 1077 1321 1012 540 1098 532 1073 1316 1079 539
31787
{
"took": 14,
"timed_out": false,
"_shards": {
"total": 35,
"successful": 35,
"failed": 0
},
"hits": {
"total": 14268,
http://localhost:5601/app/kibana#/dashboard?_g=(filters:!((meta:(disabled:!f,index:INDEX_PATTERN_HERE,key:auth,negate:!f,value:VALUE_HERE),query:(match:(FIELD_HERE:(query:VALUE_HERE,type:phrase))))),refreshInterval:(display:Off,pause:!f,section:0,value:0),time:(from:now-7d,mode:quick,to:now))
filter {
mutate {
replace => [ "@tags", "" ]
type => "syslog"
}
}
@rashidkpc
rashidkpc / gist:3794465
Created September 27, 2012 14:55
Kibana on Passenger
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.11
PassengerRuby /usr/bin/ruby
<VirtualHost *:80>
ServerName logs.example.com
ServerAlias logs.example.com
DocumentRoot /home/httpd/Kibana/static
#!/usr/bin/ruby
queue_list = `rabbitmqctl list_queues`.split("\n")
queue_list.pop
queue_list.shift
queues = Hash.new
queue_list.each do |queue|
queue = queue.strip.split(/\s+/).collect(&:strip)
queue_stat = queue.pop
queue_name = queue.pop