Tag Archive for notification

Log4r: how to use RollingFileOutputter: automatically cycle stale logfiles

# How to use RollingFileOutputter 

$: << "../src"

require 'log4r'

include Log4r 

puts "this will take a while" 

# example of log file being split by time constraint 'maxtime'

config = {

  "filename" => "logs/TestTime.log",

  "maxtime" => 10,

  "trunc" => true

}

timeLog = Logger.new 'WbExplorer'

timeLog.outputters = RollingFileOutputter.new("WbExplorer", config)

timeLog.level = DEBUG 

# log something once a second for 100 seconds

100.times { |t|

  timeLog.info "blah #{t}"

  sleep(1.0)

} 

# example of log file being split by space constraint 'maxsize'

config = {

  "filename" => "logs/TestSize.log",

  "maxsize" => 16000,

  "trunc" => true

}

sizeLog = Logger.new 'WbExplorer'

sizeLog.outputters = RollingFileOutputter.new("WbExplorer", config)

sizeLog.level = DEBUG 

# log a large number of times

100000.times { |t|

  sizeLog.info "blah #{t}"

} 

puts "done! check the two sets of log files in logs/ (TestTime and TestSize)"

source

Growl support for Aquamacs Emacs

;; Growl support
;;; Requires growlnotify, source for which is included in the Growl disk image
;;; Note that the growlnotify --image option is not reliable on OSX 10.5
;;; see <a href="http://forums.cocoaforge.com/viewtopic.php?f=6&t=17526&p=114069" >http://forums.cocoaforge.com/viewtopic.php?f=6&t=17526&p=114069</a>

;;; Wrapper for growlnotify
(defun growl-chat (title message &optional sticky)
(interactive "sTitle:
sGrowl: ")
(shell-command
(format "/usr/local/bin/growlnotify %s -m '%s' --appIcon 'Aquamacs Emacs' %s" title message (if sticky "--sticky" ""))))

;;; Sticky notifications
(defun growl-chat-sticky (title message)
(interactive "sTitle:
sGrowl: ")
(growl-chat title message t))

;;; Growl nicknames and highlight words when they are mentioned
;;;; Nickname notifications are sticky
(add-hook 'erc-text-matched-hook
(lambda (match-type nickuserhost message)
(when (and
(boundp 'nick)
(not (string= nick "ChanServ"))
(not (string= nick "services.")))
(cond
((eq match-type 'current-nick)
(growl-chat-sticky (format "%s said %s" nick (erc-current-nick)) message))
((eq match-type 'keyword)
(growl-chat (format "%s mentioned a Keyword" nick) message))))))

source

Write to browser’s error console

throw new Error("Error message not found!");

source

CSS

#loading-message{
position: fixed;
z-index: 100;
top: 10px;
left: 0;
width: 100%;
font: bold 1.8em "Lucida Grande", Helvetica, Arial, sans-serif;
text-align: center;
background-color: #000;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
padding: 3px 0;
/*filter:alpha(opacity=70);
opacity: 0.7;
-moz-opacity:0.7;*/
}

#loading-message #loading-image{
vertical-align: middle;
margin-bottom: 4px;
}

#loading-message #loading-text{
color: #fff;
margin: 0;
/*filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;*/
}

source

LoadingMessage for AJAX requests

// ## LoadingMessage
// ## Version: 0.6
// ## Author: Tim Isenheim - <a href="http://blog.freshlabs.de" >http://blog.freshlabs.de</a>

var LoadingMessage = {
imageURL : 'ajax-loader.gif',
waitImg : null,
containerId : "loading-message",
loadTextId : "loading-text",
waitImgId : "loading-image",
waitImgWidth : 16,
waitImgHeight : 16,

init : function(){
this.waitImg = document.createElement('img');
this.waitImg.setAttribute('src', this.imageURL);
this.waitImg.setAttribute('height', this.waitImgHeight);
this.waitImg.setAttribute('width', this.waitImgWidth);
this.waitImg.setAttribute('alt','loading...');
this.waitImg.id = this.waitImgId;
this.waitImg.style.border = '0';
this.waitImg.style.backgroundColor = 'transparent';
this.waitImg.style.margin = '0';
this.waitImg.style.padding = '0';
},

append : function(where){
var parent = $(where);
var loadbox;
if(!$(this.containerId)){
loadbox = document.createElement('div');
var loadtext = document.createElement('div')
loadbox.id = this.containerId;
loadtext.id = this.loadTextId;
txt = document.createTextNode(" loading");
loadtext.appendChild(this.waitImg);
loadtext.appendChild(txt);
loadbox.appendChild(loadtext);
}
else loadbox = $(this.containerId);
loadbox.style.display = "none";
new Effect.Appear(loadbox, { to: 0.7, queue: 'end' });
parent.appendChild(loadbox);
},

remove : function(){
new Effect.Fade(this.containerId, {duration: 0.25, queue: 'end' });
}

} // ### .LoadingMessage


// Attaching the init function to the window.onload event
Event.observe(window,'load', function(){
LoadingMessage.init();
});

source