Skip to content

Instantly share code, notes, and snippets.

View AndreasMadsen's full-sized avatar

Andreas Madsen AndreasMadsen

View GitHub Profile
@AndreasMadsen
AndreasMadsen / gist:2693051
Created May 14, 2012 10:04
base64 shim [atob, btoa]
// Source: http://code.google.com/p/gflot/source/browse/trunk/flot/base64.js?r=153
/* Copyright (C) 1999 Masanao Izumo <iz@onicos.co.jp>
* Version: 1.0
* LastModified: Dec 25 1999
* This library is free. You can redistribute it and/or modify it.
*/
/*
* Interfaces:
@AndreasMadsen
AndreasMadsen / WhatIHaveDone.md
Last active February 13, 2022 16:15
Playing with smartos
@AndreasMadsen
AndreasMadsen / README.md
Last active July 23, 2021 14:35
Escape-from-xp

From twitter I was told of escape-from-xp ( https://twitter.com/sylwia_erhardt/status/489554167120527360 ). Obiusly I had to hack this an discovered that the code ( https://escapefromxp.azurewebsites.net/game.min.js ) besides not being very compressed, also contained easter eggs for any JavaScript enthusiast. This is how you enable them all:

  1. Go to: https://escapefromxp.azurewebsites.net/#arcade . https://www.modern.ie/en-us/virtualization-tools#escape-from-xp just contain an iframe to this location and #arcade makes sure no redict back to www.modern.ie occurre. #arcade also enables a few other things, you will notice the text have changed a little. Also you now change weapon on F.

  2. Open the JavaScript console in your browser and type:

event = { source: { postMessage: function () {}} };
["hardcoreMode", "originalHacker", "tanksTanksTanks", "IDDQD"].forEach(
  window.ig.game.installServicePack.bind(window.ig.game)
)
//
// Copyright 2010, 2011, Chris Winberry <chris@winberry.net>. All rights reserved.
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
<pad>
<EOS>
<OOV>
.
?x0
?x1
M1
}
{
WHERE
@AndreasMadsen
AndreasMadsen / hackTheDom.js
Created October 29, 2012 13:57
size of TextNode - DOM Hack
// This is the coolest code snippet I (Mr. Mad) have every created
// It will magicly get the size of a textnode, by createing a context
// range and get the client rects of that range.
// It will then combine the rects to one rect, and thereby get the size
// of the text node.
// Note that by any standarts a TextNode has no size.
var range = document.createRange();
range.selectNode(node);
var rect = range.getBoundingClientRect();
@AndreasMadsen
AndreasMadsen / readme.md
Last active December 10, 2018 06:02
MKL numpy and scikit on Mac OS X
def ilog256_speed(original_num):
# Exponential search to find upper bound
ilog_upper = 8
while (original_num >> ilog_upper) > 0:
ilog_upper = ilog_upper << 1
# The lower bound is the previuse step
ilog_lower = ilog_upper >> 1
@AndreasMadsen
AndreasMadsen / README.md
Last active October 12, 2017 18:49
Install python and friends on DTUs shared user system.

PLEASE NOTE: this setup guide have moved to https://github.com/AndreasMadsen/my-setup/tree/master/dtu-hpc-python2 so it is easier to find. PLEASE DO NOT USE THIS GUIDE.

Install python and friends on DTUs shared user system. In particually with OpenCL and CUDA support.

Note the install part only works when using hpc-fe.gbar.dtu.dk as the ssh host! So ThinLinc and login.gbar.dtu.dk won't work. This is because k40sh is needed to compile the OpenCL and CUDA parts. The SSH guide can be found here: http://gbar.dtu.dk/faq/53-ssh (just be sure to replace login.gbar.dtu.dk with hpc-fe.gbar.dtu.dk).

Type or copy this after connecting with SSH, using time this have been messured to take 37 minutes:

k40sh
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/stream_executor/cuda/cuda_driver.cc:590] creating context when one is currently active; existing: 0x118af890
W tensorflow/stream_executor/cuda/cuda_driver.cc:590] creating context when one is currently active; existing: 0x118b36a0
W tensorflow/stream_executor/cuda/cuda_driver.cc:590] creating context when one is currently active; existing: 0x118b74e0
INFO:tensorflow:0314:14:49:41.625:sg_train.py:312] Training started from epoch[001]-step[0].
W tensorflow/core/common_runtime/bfc_allocator.cc:274] **************************************************************************************_**********xxx
W tensorflow/core/co