Code covered by the BSD License  

Highlights from
Annoy-a-tron

image thumbnail

Annoy-a-tron

by

 

Annoy and confound fellow MATLAB users.

annoyatron
function annoyatron
% Slowly drive Matlab users insane by doing something annoying at random
% intervals. The variables below set the min and max time interval. Customize
% the annoy() subfunction to deploy your own personal brand of evil.
%
% To run this function automatically when Matlab starts, call annoyatron() from
% startup.m. See 'startup' in Matlab's help for more info.
%
% Inspired by the Annoy-a-tron. www.thinkgeek.com

% by Steve Hoelzer
% 2011-04-01

% min and max time interval between calls to annoy()
mininterval = 2; % minutes
maxinterval = 22; % minutes

% start the deviousness
tcb([],[], mininterval, maxinterval)


% ------------------------------------------------------------------------------
function annoy
% Customize this function to do something annoying to your unsuspecting target.
%
% Note: Subtlety is often best.  :)
%
% A few ideas:
%   >> beep on, beep        % make noise
%   >> disp('Why?'), why    % display nonsense
%   >> disp(datestr(now))   % display date and time
%   >> calendar             % display calendar
%   >> figure               % open a figure
%   >> fprintf('\n')        % insert blank line
%   >> fprintf('>')         % growing prompt
%   >> disp('<<')           % reverse prompt
%   >> disp('>>>')          % triple prompt
%   >> fprintf(2, '>>\n');  % prompt in error message color
%   >> exit                 % exit Matlab (truly, truly evil)

fprintf('>')


% ------------------------------------------------------------------------------
function tcb(obj, event, mininterval, maxinterval) %#ok<INUSL>
% Timer callback that runs the annoy() function and schedules the next call.

if ~isempty(obj)
    
    % stop & delete the timer that made this callback
    stop(obj)
    delete(obj)
    
    % don't be Google, be evil!
    annoy()
    
end

% choose random delay (in seconds) within bounds
% need to round to avoid a warning about the timer's timing precision
delay = round((mininterval + rand*(maxinterval - mininterval)) * 60);

% create a new timer
t = timer( ...
    'TimerFcn', {@tcb, mininterval, maxinterval}, ...
    'StartDelay', delay, ...
    'ExecutionMode', 'singleShot' );

% start the timer
start(t)

Contact us