This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Pebble Doesn't support the default itoa included in the standard library. | |
Here is a working implementation, allowing you to easily use an integer where a "string" is needed. | |
Added from : http://forums.getpebble.com/discussion/comment/29591/ | |
Written by Pebble Forum User: FlashBIOS | |
Gathered and Edited by: Sameer Chitley | |
NOTE: It seems like it only supports positive numbers, so be sure to pass in the absolute value. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Returns the mathematical mean (average) of a number of samples of accelerometer data. | |
// Sets the x, y, and z values as a mean. | |
// Sets 'did_vibrate' to true if the pebble vibrated during any of the samples. | |
// Time stamp is set to the time stamp of the first sample. | |
AccelData accel_data_mean(AccelData *data, uint32_t num_samples) { | |
// Declare the struct | |
AccelData average_data; | |
// Time taken is set to the first sample's time | |
average_data.timestamp = data[0].timestamp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//take in decimal b/w 0 and 1, display as face value (b/w 0 and 100%) with a specified # decimal places | |
angular.module('myModule', []).filter('percentage', ['$filter', function($filter) { | |
return function(input, decimalPlaces) { | |
return $filter('number')(100 * input, decimals) + '%'; | |
}; | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Taken from SpinKit (https://github.com/tobiasahlin/SpinKit) | |
function browserSupportsCSSProperty(propertyName) { | |
var elm = document.createElement('div'); | |
propertyName = propertyName.toLowerCase(); | |
if (elm.style[propertyName] != undefined) | |
return true; | |
var propertyNameCapital = propertyName.charAt(0).toUpperCase() + propertyName.substr(1), | |
domPrefixes = 'Webkit Moz ms O'.split(' '); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.factory('RecursionHelper', ['$compile', function($compile) { | |
return { | |
//Manually compiles the element, fixing the recursion loop. | |
compile: function(element, link) { | |
// Normalize the link parameter | |
if (angular.isFunction(link)) { | |
link = { | |
post: link | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make tabs multi-row | |
.tab-bar { | |
height: auto; | |
flex-wrap: wrap; | |
.tab, | |
.tab.active { | |
flex: 1 0 auto; | |
height: 30px; | |
line-height: 27px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_token(length) | |
token = '' | |
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'.split('') | |
rndGen = Random.new | |
(1..length).each do | |
token << chars[(rndGen.rand * chars.length).floor] # memory efficient concatenation | |
end | |
token | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
v 3.716360 2.343387 0.000000 | |
v 4.126565 0.642027 0.000000 | |
v 3.454971 2.169877 0.000000 | |
v 3.929251 0.411689 0.000000 | |
v 3.247406 2.073333 0.000000 | |
v 3.731689 0.186391 0.000000 | |
v 2.985371 1.982663 0.000000 | |
v 3.486028 -0.141683 0.000000 | |
v 2.723503 1.898839 0.000000 | |
v 3.335210 -0.375755 0.000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Taken from https://stackoverflow.com/a/5920028/3133680 | |
#ifdef _WIN32 | |
//define something for Windows (32-bit and 64-bit, this part is common) | |
#ifdef _WIN64 | |
//define something for Windows (64-bit only) | |
#else | |
//define something for Windows (32-bit only) | |
#endif | |
#elif __APPLE__ | |
#include "TargetConditionals.h" |