Skip to content

Instantly share code, notes, and snippets.

$("<input>").attr({id:'bpr', type:'text'}).appendTo("#cal_form");
$("<label>").attr({id:'dfsgdgsdg'}).appendTo("#bpr").text("bezeichnung");
@ydnax
ydnax / gist:1088232
Created July 17, 2011 23:24
colours the string of a number red if negative and green for positive. for bg=1 the background.
var clc = require('cli-color');
var colkeys =new Array(2);
colkeys[0] =new Array();
colkeys[1] =new Array();
colkeys[0][0]=clc.red;
colkeys[0][1]=clc.green;
colkeys[1][0]=clc.bgRed;
colkeys[1][1]=clc.bgGreen;
exports.gCol=function(str, bg){
return mat[bg?1:0][str[0]=='-'?0:1](str);
@ydnax
ydnax / gist:1088080
Created July 17, 2011 21:26
very ugly and not 100% working fuction to print numbers with a fixed length. don't use this!
Number.prototype.fixedString=function(l){
var s=new String(this.toPrecision(l));
return s.substring(0, l);
};
template <class from, class to>
to* convertContainer(const from *in){
to* ret=new to();
ret->reserve(in->size());
ret->insert(ret->end(),in->begin(),in->end());
return ret;
}
struct rndgen{
boost::mt19937 rng;
rndgen(){
rng.seed(static_cast<unsigned int>(std::time(0)));
}
template<class t>
t operator()(t min, t max){
boost::uniform_real<t> u(min, max);
boost::variate_generator<boost::mt19937&, boost::uniform_real<t> > gen(rng, u);
return gen();
var todate=function locToUtc(timestring){
var time=new Date(timestring);
var ms=time.getMilliseconds();
var s=time.getSeconds();
var mi=time.getMinutes();
var h=time.getHours();
var mo=time.getMonth();
var yr=time.getYear();
var newtime=new Date();
newtime.setUtcMilliseconds(,s);