Skip to content

Instantly share code, notes, and snippets.

View easierbycode's full-sized avatar

▓▒░ ♔ Daniel ♔ ░▒▓ easierbycode

View GitHub Profile
function rgb2hex(rgb) {
var components = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
function hex(x) {
return ("0" + parseInt(x).toString(16)).slice(-2);
}
return "#" + hex(components[1]) + hex(components[2]) + hex(components[3]);
}
<div class="col-xs-6"><div class="panel panel-info"><div class="media panel-heading">
<div class="media-left media-middle">
<img class="media-object" src="http://icons.wxug.com/i/c/k/mostlycloudy.gif">
</div>
<div class="media-body">
<h4 class="media-heading">29 ℉</h4>Muncie, IN</div>
</div></div></div>
@easierbycode
easierbycode / muncie.json
Created January 21, 2016 21:21
sample Weather Underground response
{
response: {
version: "0.1",
termsofService: "http://www.wunderground.com/weather/api/d/terms.html",
features: {
conditions: 1
}
},
current_observation: {
image: {
myBluetoothDevice = {
adData: BluetoothAdvertisingData,
deviceClass: 7936,
id: "1gvrYl6VYpirzC34RDT8YA==",
instanceID: "1gvrYl6VYpirzC34RDT8YA==",
name: "Mip-89062",
productID: 0,
productVersion: 0,
uuids: Array[2],
vendorID: 0,
{
"lights": {
"1": {
"state": [null],
"type": "Extended color light",
"name": "Living Room 1",
"modelid": "LCT001",
"manufacturername": "Philips",
"uniqueid": "00:17:88:01:00:b4:28:11-0b",
"swversion": "66013452"
@easierbycode
easierbycode / dynamic-property-name-in-getter-and-setter.js
Created April 26, 2016 19:45
dynamic properties within an object
'use strict';
var ident = 'productId';
var productView = {
get [ident] () { return true; },
set [ident] (value) { }
};
console.log( productView.productId )
@easierbycode
easierbycode / dynamic-object-method.js
Last active April 26, 2016 19:57
dynamic object properties
'use strict';
var method = 'doIt';
var productView = {
[method + "-001"]() {
console.log( "it's done!" );
}
};
'use strict';
let salary = ['32000', '50000'];
[low, average, high = '90000'] = salary;
console.log( high )
// 90000
function reviewSalary([low, average], high = '90000') {
console.log( average );
@easierbycode
easierbycode / destructure-to-renamed-var.js
Created April 26, 2016 21:33
destructuring and renaming from previously declared variables
'use strict';
let salary = {
low: '32000',
average: '50000',
high: '90000'
};
let newLow, newAverage, newHigh;
({ low: newLow, average: newAverage, high: newHigh } = salary);
'use strict';
let [letter1, letter2] = 'AZ';
console.log( letter2 );
// 'Z'