Skip to content

Instantly share code, notes, and snippets.

View tebriel's full-sized avatar

Chris M tebriel

View GitHub Profile
@tebriel
tebriel / message.js
Created January 31, 2012 02:41
Silly way to show an error message
var errorMessage =Titanium.UI.createAlertDialog({
title:L('err_communication_title'),
message:L('err_communication_text'),
});
errorMessage.show();
@tebriel
tebriel / a.js
Created January 31, 2012 02:54
function formatJSONTime(jsonTime){
var aa = jsonTime.substr(6);
var bb = parseInt(aa, 10);
var cc = new Date(bb);
var dd = formatTime(cc);
return dd;
}
@tebriel
tebriel / formattime.js
Created January 31, 2012 03:17
format time
function formatTime(e)
{
var hour_value = e.getHours();
var minutes_value = '00';
minute_value = e.getMinutes();
if (minute_value == 0)
{
minute_value = '00';
}
else if (minute_value < 10)
@tebriel
tebriel / currency.js
Created January 31, 2012 03:19
currency!
function formatCurrency(amount)
{
var i = parseFloat(amount);
if (isNaN(i)) { i = 0.00; }
var minus = '';
if (i < 0) { minus = '-'; }
i = Math.abs(i);
i = parseInt((i + 0.005) * 100, 10);
i = i / 100;
s = '';
function IsNumeric(e) {
var numericExpression = /^[0-9]+$/;
if(e.match(numericExpression))
{
return true;
} else {
return false;
@tebriel
tebriel / keyboard.pas
Created February 3, 2012 22:18
How to not be efficient
btnA: TConcButton;
btnB: TConcButton;
btnC: TConcButton;
btnD: TConcButton;
btnE: TConcButton;
btnF: TConcButton;
btnG: TConcButton;
btnH: TConcButton;
btnI: TConcButton;
btnJ: TConcButton;
if (thisThing())
doThat();
else
doThis();
alsoThat();
// Is not the same as:
if (thisThing()) {
@tebriel
tebriel / DarkenColor.cs
Created April 3, 2012 15:18
Darken Color
namespace DevToolWPF.Utils
{
public class RadioColorConverter
{
private static int RsNormalized(int a, int b)
{
return ((a*(((1 << (b)) - 1))/100));
}
private static int RsRgbValue(int r, int g, int b)
@tebriel
tebriel / errors.txt
Created April 10, 2012 03:21
C++ STL Stuff
1>------ Build started: Project: Cheetah, Configuration: Debug Win32 ------
1> BoxOfficeFile.cpp
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\algorithm(2944): error C2664: 'bool perf_itr_number_pred::operator ()(std::_Vector_iterator<_Myvec>,std::_Vector_iterator<_Myvec>)' : cannot convert parameter 1 from 'CPerformance *const ' to 'std::_Vector_iterator<_Myvec>'
1> with
1> [
1> _Myvec=std::_Vector_val<std::_Simple_types<CPerformance>>
1> ]
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\algorithm(2968) : see reference to function template instantiation 'std::pair<_Ty1,_Ty2> std::_Equal_range<std::_Vector_iterator<_Myvec>*,_Ty,__w64 int,_Pr>(_FwdIt,_FwdIt,const _Ty &,_Pr,_Diff *)' being compiled
1> with
@tebriel
tebriel / desaturatecolor.cpp
Created May 9, 2012 20:43
DesaturateColor
int DesaturateColor(int seatColor, int remainingSaturation, int targetColor)
{
int justR = (seatColor & 0xFF0000);
justR -= (targetColor << 16);
int r = ((justR * remainingSaturation) / 100) + (targetColor << 16);
r &= 0xFF0000;
int justG = (seatColor & 0x00FF00);
justG -= (targetColor << 8);
int g = (justG * remainingSaturation) / 100 + (targetColor << 8);
g &= 0x00FF00;