Skip to content

Instantly share code, notes, and snippets.

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);
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();
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;
}
@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);
};
@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);
$("<input>").attr({id:'bpr', type:'text'}).appendTo("#cal_form");
$("<label>").attr({id:'dfsgdgsdg'}).appendTo("#bpr").text("bezeichnung");
@ydnax
ydnax / crawler.js
Created October 3, 2011 09:06
humble keycrawler.
var urllib=require("./urllib.js");
var sys=require("sys");
var urlparser=require("url");
var spawn = require('child_process').spawn;
var starturl="http://www.google.com/search?hl=en&q=http%3A%2F%2Fwww.humblebundle.com%2F%3Fkey%3D";
var regex=/www ?\. ?humblebundle ?\. ?com ?\/\?key ?\=\w{2,13}/ig;
var hit=function(url){
//console.log("newurl: "+url);
Request URL:http://longcat.de/ccc/28C3-r0ket-tr4cking/v2/debug/proxy.php?rnd=0.8968758655246347
Request Method:GET
Status Code:200 OK
Request Headers
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,de-DE;q=0.6,de;q=0.4
Connection:keep-alive
Host:longcat.de
@ydnax
ydnax / gist:1711116
Created January 31, 2012 15:37
basic template for django forms with twitter bootstrap style error messages
{% extends "base.html" %}
{% block title %}
{{ title }}
{% endblock %}
{% block content %}
<form action="{{ action }}" method="{% block method %}post{% endblock %}">
{% for field in form %}
<div>
void energy::update(ticks time){
const float angle=getAngle(start, target);
float fx, fy, tx, ty;
fx=start.x;
fy=-1*start.y;
tx=target.x;
ty=-1*target.y;
float dx,dy;
const float vert=getPointDistance(start, target);
const float addl=pxps*(time/1000);