Skip to content

Instantly share code, notes, and snippets.

View rageandqq's full-sized avatar

Sameer Chitley rageandqq

View GitHub Profile
@rageandqq
rageandqq / operating_system_predefined_macros.c
Created February 28, 2018 20:49
Operating System Specific Predefined Macros for GCC
// 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"
@rageandqq
rageandqq / cow.obj
Created July 30, 2017 19:07
Wavefront model of a cow
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
@rageandqq
rageandqq / token_gen.rb
Created February 13, 2017 19:12
Generate an alphanumeric token of specified length
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
@rageandqq
rageandqq / atom-tab-multiline.less
Created August 17, 2016 21:27
atom multiline tab styling
// Make tabs multi-row
.tab-bar {
height: auto;
flex-wrap: wrap;
.tab,
.tab.active {
flex: 1 0 auto;
height: 30px;
line-height: 27px;
}
@rageandqq
rageandqq / ng-recursive-directive.js
Last active February 13, 2017 19:35
Angular Recursive Directive compiler
.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
};
}
@rageandqq
rageandqq / css-property-check.js
Created March 25, 2015 14:16
Check if a browser supports a specific CSS property
//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(' ');
@rageandqq
rageandqq / angular-percent-filter.js
Created March 25, 2015 05:21
AngularJS Percentage Filter
//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) + '%';
};
}]);
@rageandqq
rageandqq / avg_accel.c
Created December 27, 2014 07:54
Pebble - Average AccelData for an array of Accelerometer Inputs
// 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;
@rageandqq
rageandqq / itoa.c
Last active August 29, 2015 14:12
Pebble - Integer to Char Array (i.e. String)
/*
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.
*/