Skip to content

Instantly share code, notes, and snippets.

@trillerpfeife
trillerpfeife / check.js
Created March 2, 2016 01:07
super crasy function checks whether n is dividable by 2 or subtractable by 5
function check(n) {
var history = "(" + n;
var number = n;
while (number > 3) {
if ((number % 2)=== 0) {
number = number / 2;
history += ")/2"
}
else {
number = number - 5;
@trillerpfeife
trillerpfeife / togeojson.js
Last active April 13, 2016 19:55
Convert crap to GeoJSON
//map for objects
Object.defineProperty(Object.prototype, 'map', {
value: function(f, ctx) {
ctx = ctx || this;
var self = this, result = {};
Object.keys(self).forEach(function(k) {
result[k] = f.call(ctx, self[k], k, self);
});
return result;
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@trillerpfeife
trillerpfeife / germany.geojson
Last active April 13, 2016 19:54
source: http://maps.rast.de/ converted with togeojson.js
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@trillerpfeife
trillerpfeife / oeamttogeojson.js
Created April 15, 2016 01:37
geojson converter for oeamtc.at array
var oldGeo = [{
'name': 'Wels',
'address': '',
'number': '',
'zip': '4600',
'city': 'Wels',
'lat': '48.19043815',
'lon': '14.07081485',
'urls': [{
'cat': 'Raststationen',
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Every 2,0s: cat /proc/mdstat Thu Apr 21 15:57:58 2016
Personalities : [raid1]
md0 : active raid1 sdb1[0] sda1[1]
312438784 blocks super 1.2 [2/2] [UU]
[=================>...] resync = 88.7% (277137600/312438784) finish=15.4min speed=38042K/sec
bitmap: 1/3 pages [4KB], 65536KB chunk
unused devices: <none>
@trillerpfeife
trillerpfeife / gist:e698950e8620fe9f3b760de3c41f0970
Last active May 31, 2016 20:21
How To Configure SSH Key-Based Authentication on a Linux Server
on client:
ssh-keygen
ssh-copy-id username@remote_host
Disabling password authentication on server:
edit /etc/ssh/sshd_config
-> PasswordAuthentication no
service ssh restart
voilá
@trillerpfeife
trillerpfeife / extendmethod.js
Last active June 6, 2016 14:21
Extends a object method with a function, requires underscore.js
var obj = {
init: function() {
console.log("init old");
}
};
var old_obj = {};
_.extend(old_obj, obj);
@trillerpfeife
trillerpfeife / game.js
Created June 9, 2016 12:55
game shissel
var currentMap = new Image(),
mrBrown = new Image();
lastMap = new Image();
currentMap.src = 'res/010/010-010.png';
mrBrown.src = "res/mr_brown.gif";
var canvas = document.createElement('canvas');
canvas.width = 320;