Skip to content

Instantly share code, notes, and snippets.

View clausd's full-sized avatar

Claus Dahl clausd

View GitHub Profile
@clausd
clausd / x
Created March 10, 2009 18:33
/* Convert selection to HTML entitites - danish chars only */
CmdUtils.CreateCommand({
name: "entitize",
icon: "http://www.classy.dk/favicon.ico",
homepage: "http://www.classy.dk/",
author: { name: "Claus Dahl", email: "dee@classy.dk"},
license: "GPL",
description: "Translates danish characters to html entities",
help: "select text and apply to replace with entitized text",
@clausd
clausd / gist:2370833
Created April 12, 2012 20:39
Find the line corresponding to a single projected point in Processing (P3D assumed)
/*
Find the 3D coordinates at depth z that project onto planar coordinates (x,y).
Screen position is at z-1 in the screen coordinate system, so z should be less than -1
(basically inverse for screenX/screenY)
*/
PVector screenToDepth(float x, float y, float z) {
// first get the transforms in place
PMatrix3D M = (PMatrix3D) g.getMatrix();
PMatrix3D P = (PMatrix3D) ((PGraphics3D) g).getProjection();
P.apply(M);
@clausd
clausd / printmycode.pl
Last active December 15, 2015 12:18
Selfreproducing perl program
$program = <<'EOP';
$program = <<'EOC';
EXPANDME
EOC
$program = substr($program,0,-1);
$outer = $program;
$outer =~ s/EOC(..)$/EOP$1/m;
$outer =~ s/EOC$/EOP/m;
$outer =~ s/EXPANDME/$program/;
print $outer;
@clausd
clausd / fifo.rb
Created September 2, 2013 19:28
Nonblocking writes, blocking reads
`mkfifo fifotest`
Process.fork do
puts "We're going to write a message to a process who will pick it up later"
nonblocking = open('fifotest', 'w+')
nonblocking.puts "A message for you, Rudy\r\n"
nonblocking.flush
nonblocking.close
puts "Done writing"
end
@clausd
clausd / gist:7267304
Created November 1, 2013 15:42
The Interval - a Library of Babel
def text_to_number(text, n=1000)
'0.' + text[0..n].unpack('C*').map{ |i| "%02d" % i}.join('')
end
@clausd
clausd / clear cache
Created June 14, 2014 08:53
Fix run amok Mediaserver on Android that's depleting data quota and battery
We're sorry to hear that you're experiencing problems with your data usage on your Nexus 5 device after updating to the latest Android version.
Troubleshooting for Nexus 5
To try and resolve the issue at hand, I have some troubleshooting steps I would like you to try:
Conduct a forced shut off by holding Power button and shutting phone down and restarting the device
Then, try clearing the cache partition. Here's how:
Hold power button for 2 seconds and select 'Power Off'
Press and hold the Volume Up and the Volume Down and Power keys at the same time for about 10 seconds.
An image of an Android lying on its back will appear.
Press the Volume Down key twice until "Recovery mode" appears on the screen.
@clausd
clausd / limiter.js
Created September 26, 2014 10:30
Form submission management - Coderdojo
FORM_OPEN_DATE = "2014-03-14 08:00";
FORM_CLOSE_DATE = "2014-11-09 23:30";
RESPONSE_COUNT = "30";
/* Web tutorial: http://labnol.org/?p=20707 */
/* Initialize the form, setup time based triggers */
function Initialize() {
deleteTriggers_();
@clausd
clausd / gist:67825a3ff0b3567e5dbe
Created January 9, 2015 10:47
Ruby 1.8.7 på Mavericks, rails 2.3.* på mavericks
https://github.com/wayneeseguin/rvm/issues/1975#issuecomment-20223263 fixede
løste Error running requirements_osx_brew_libs_install openssl098
løsning på The requested url does not exist(22): 'http://production.cf.rubygems.org/rubygems/rubygems-2.0.15.tgz'
er
wget
mv
nu ka man installere de rigtige rubygems versioner også...
@clausd
clausd / octavehowto
Created February 9, 2015 22:03
Octave properly on Mavericks
Homebrew is fine
but ALWAYS
brew install octave --with-docs
or no packages will install inside octave (if you don't need packages, never mind the docs)
that in turn requires tex
you can
brew install Caskroom/cask/mactex
which builds a text installer that you can then run
- or download a binary, prolly much faster
After that you should be pretty golden and packages should install
@clausd
clausd / gist:e205a151e3b354a4d7f1
Created February 13, 2015 12:58
Hive OECD data fra EVM
// på http://www.evm.dk/arbejdsomraader/vaekst-og-konkurrenceevne/redegoerlse-om-vaekst-og-konkurrenceevne
// åben dev console
data = []
$.ajaxSetup({complete: function(something) {obj = JSON.parse(something.response); data.push(JSON.parse(obj.d);}})
// og nu fanger man alle data hent på siden, i data - de kan så jsonificers og gemmes elsewhere