Skip to content

Instantly share code, notes, and snippets.

View below9k's full-sized avatar

Chris Daniel below9k

  • SAVI iQ Inc
  • Carrollton, Tx
View GitHub Profile
const maxPerc = maxP || (_.isNumber(maxDb) && getPerc(maxDb)) || 100
// OR
const maxPerc
if (!maxP) {
maxPerc = maxP
} else if (!(_.isNumber && getPerc(maxDb))) {
maxPerc = getPerc(maxDb)
@below9k
below9k / scale_db.js
Created January 18, 2017 15:33
Convert range of decibel to percentage and back again
// I wrote this to convert dB to percentage with a weird scale.
// For instance, a user may set an amplifier's min-max dB limits to -50 - 10.
// The UI they use only increments by 1 and dB does not (properly) scale linearly.
// Having to work around these issues I wrote this based on the script I found here www.redwirez.com/pcalc.jsp
// =-=-=-=-=-=-=-=
// Calcs dB to percent with a non-standard dB range
// it does this by getting a new percentage range using min/max dB
// defaults to the standard range of -80 ~ 0 if no min or max is provided
const calcDb = (perc, minDb, maxDb, minP, maxP) => {
const allEncodings = ['utf8','ucs2','utf16le','ascii','binary','base64','hex','utf-16be','utf-16','ISO-8859-1','ISO-8859-16','koi8-r','koi8-u','koi8-ru',
'koi8-t','armscii8', 'rk1048', 'tcvn', 'georgianacademy', 'georgianps', 'pt154', 'viscii', 'iso646cn', 'iso646jp', 'hproman8', 'tis620', 'cp437',
'cp737', 'cp775', 'cp808', 'cp850', 'cp852', 'cp855', 'cp856', 'cp857', 'cp858', 'cp860', 'cp861', 'cp862', 'cp863' , 'cp864', 'cp865', 'cp866', 'cp869',
'cp922', 'cp1046', 'cp1124', 'cp1125', 'cp1129', 'cp1133', 'cp1161', 'cp1162', 'cp1163',
'ibm437', 'ibm737', 'ibm775', 'ibm808', 'ibm850', 'ibm852', 'ibm855', 'ibm856', 'ibm857', 'ibm858', 'ibm860', 'ibm861', 'ibm862', 'ibm863' ,
'ibm864', 'ibm865', 'ibm866', 'ibm869', 'ibm922', 'ibm1046', 'ibm1124', 'ibm1125', 'ibm1129', 'ibm1133', 'ibm1161', 'ibm1162', 'ibm1163',
'cp874', 'cp1250', 'cp1251', 'cp1252', 'cp1253', 'cp1254', 'cp1255', 'cp1256', 'cp1257', 'cp1258',
'win874', 'win1250', 'win1251', 'win1252', 'win1253', 'win1254', 'win1255',
import {_} from 'meteor/underscore'
import BaseComponent from './base_component'
import classNames from 'classnames'
import React from 'react'
class Button extends BaseComponent {
static propTypes = {
type : React.PropTypes.oneOf(['color', 'date', 'email', 'file', 'number', 'radio', 'range', 'search', 'tel', 'text', 'url']).isRequired,
name : React.PropTypes.string.isRequired,
className : React.PropTypes.string,
'use strict';
var Promise = require('bluebird'),
request = require('request'),
_ = require('underscore'),
jsP = require('../package.json'),
chalk = require('chalk');
console.log(chalk.styles.green.open + '\n-------------------------------------------------------\n' +
'\t\t SAVI-ROVI: v' + jsP.version + '\n' +
'use strict';
/*
* This script is designed to be ran from console.
* Designed By: Chris Daniel
* Company: SAVI Controls LLC
* Authored: 11-2-2015
* Purpose: Get ROVI TV data for displaying to end-users.
*/
<template name="TvGuide">
<div class="SAVI tv-guide">
<div class="listings">
<div class="timeslots">
{{#each getTimeslotLabels}}
<div class="time" style="width: {{width}}%">{{timeslot}}</div>
{{/each}}
</div>
<div class="now-marker" style="left: calc({{getNowMarkerPosition}}% - 2rem);">
<label>NOW</label>
{
"LinearScheduleResult": {
"RequestId": "f5d66d90-e847-4cd1-8c84-58c7fcfbde61",
"TimeStamp": "2015-11-03T14:53:04.784Z",
"Status": "PNE",
"Errors": [],
"EndTimestamp": "2015-11-03T14:53:05.128Z",
"Build": "Development-v9-dev-9.15.08-173-r34606-34606",
"Schedule": {
"Locale": "en-US",
@below9k
below9k / timeSince.js
Created September 14, 2015 17:15
Function that gives you friendly time since..
Template.registerHelper('timeSinceUpdate', function(previous) {
previous = parseInt(previous);
var current = new Date().getTime();
var msPerMinute = 60 * 1000;
var msPerHour = msPerMinute * 60;
var msPerDay = msPerHour * 24;
var msPerMonth = msPerDay * 30;
var msPerYear = msPerDay * 365;
var elapsed = current - previous;
var tenKey = SAVIComponents.define(templateName, function(props) {
this.addProps({
name: 'tenKeyButtons',
defaultValue: [{
text: '1',
value: 1
}, {
text: '2',
value: 2
}, {