Skip to content

Instantly share code, notes, and snippets.

@gnugat
Last active August 29, 2015 14:01
Show Gist options
  • Save gnugat/e4de3886ed1a9c1177da to your computer and use it in GitHub Desktop.
Save gnugat/e4de3886ed1a9c1177da to your computer and use it in GitHub Desktop.
Redaktilo in a tweet

Redaktilo in a tweet

An extreme minification of Redaktilo.

Usage:

<?php
require_once __DIR__.'/r.php';

r(__DIR__.'/life-of-brian.txt', "[Both guards snigger]\n", "Pontius Pilate: '...Dickus?'\n");

Limitations

Redaktilo manages the line break for you (in v0.3 it even detects it) and saves cursor to a current line.

Imagine that our file life-of-brian.txt only contained multiple [Sniggering], it means that we should jump down to the 4th occurence:

$line = '[Sniggering]';
$editor->jumpDownTo($file, $line);
$editor->jumpDownTo($file, $line);
$editor->jumpDownTo($file, $line);
$editor->jumpDownTo($file, $line);

Redaktilo also allows you to insert a new line aboe or under the current one.

Pontius Pilate: 'I will not have my fwends widiculed by the common soldiewy. Anybody else feel like a little... giggle... when I mention my fwiend... Biggus...'
[A guard sniggers]
Pontius Pilate: '...Dickus?'
[More sniggering]
Pontius Pilate: 'What about you? Do you find it... wisible... when I say the name... Biggus...'
[Sniggering]
[Both guards snigger]
Pontius Pilate: 'He has a wife, you know. You know what she's called? She's called... Incontinentia... Incontinentia Buttocks.'
<?php
function r($n,$l,$a){$c=file($n);$i=array_search($l,$c,true);array_splice($c,$i,0,$a);file_put_contents($n,implode($c));}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment