Skip to content

Instantly share code, notes, and snippets.

.Tooltip {
background: transparent url(/images/dark-pointer.png) no-repeat scroll 10px bottom;
font-size: 10px;
line-height: 12px;
margin-left: -5px;
padding: 0 5px;
position: absolute;
z-index: 100;
left: 0;
}
@felixhageloh
felixhageloh / gist:1080035
Created July 13, 2011 10:13
rails tooltips 1
<% with_tooltip "I am a tooltip!" do %>
some html or plain text here ...
<% end -%>
<% with_tooltip "I am a tooltip" do %>
The tooltip will appear for this entire section, but only when hovered over
<span class="TooltipTrigger">this element</span>
<% end -%>
<% with_tooltip "Click to see me!", :event => :click do %>
some html or plain text here ...
<% end -%>
@felixhageloh
felixhageloh / tooltip_helper.rb
Created July 13, 2011 10:28
Rails tooltip application helper code
def with_tooltip(tool_tip_text, options={}, &block)
content = capture(&block)
opts = tag_options(options[:html]);
uid = "tooltipjs_#{get_uid}"
js = %{
var parent = $('#{uid}').up();
var trigger = parent.getElementsByClassName('TooltipTrigger')[0] || parent;
var tooltip = parent.getElementsByClassName('Tooltip')[0];
function showTooltip(tooltip) {
tooltip = $(tooltip);
tooltip.setStyle({zIndex: -1});
tooltip.show();
tooltip.setStyle({top: "-"+(tooltip.offsetHeight)+"px"});
tooltip.setStyle({zIndex: 100});
}
@felixhageloh
felixhageloh / loadchart.coffee
Last active December 4, 2015 01:16
loadchard.widget
colors =
low : "rgb(60, 160, 189)"
normal : "rgb(88, 189, 60)"
high : "rgb(243, 255, 134)"
higher : "rgb(255, 168, 80)"
highest: "rgb(255, 71, 71)"
settings:
background: true
color : true
@felixhageloh
felixhageloh / gist:34645a899a0f22f583bb
Created July 11, 2014 09:12
Pure js widget for Übersicht
command: "echo Hello World!",
refreshFrequency: 5000,
render: function (output) {
return "<div><h1>" + output + "</h1></div>";
},
style: " \n\
top: 20px \n\
@felixhageloh
felixhageloh / cpu-bar-widget.coffee
Created January 28, 2016 16:55
A quick and dirty implementation of an Übersicht cpu bar widget I made for a talk
command: "top -R -l2 | grep 'CPU usage' | tail -n1 | awk '{ print $3+$5 }'"
refreshFrequency: 1000
style: """
top: 50%
left: 80%
width: 208px
margin: 0 0 0 -104px
text-align: left
@felixhageloh
felixhageloh / top-cpu.jsx
Created May 25, 2016 07:21
Example widget using the new JS + virtual DOM syntax
export const refreshFrequency = 1000;
export const command = `ps axro \"%cpu,ucomm,pid\" \
| sed -e 's/^[ \\t]*//g' -e 's/\\([0-9][0-9]*\\.[0-9][0-9]*\\)\\ /\\1\\%\\,/g' -e 's/\\ \\ *\\([0-9][0-9]*$\\)/\\,\\1/g' -e's/\\ \\ */\\_/g' \
| awk 'FNR>1' \
| head -n 3 \
| awk -F',' '{ printf \"%s,%s,%d\\n\", $1, $2, $3}' \
| sed -e 's/\\_/\\ /g'`;
const style = {