Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="utf-8"?>
<lfm status="ok">
<results for="rage" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
<opensearch:Query role="request" searchTerms="rage" startPage="1" />
<opensearch:totalResults>13989</opensearch:totalResults>
<opensearch:startIndex>0</opensearch:startIndex>
<opensearch:itemsPerPage>20</opensearch:itemsPerPage>
<trackmatches>
<track>
<name>Bombtrack</name>
var Hoverer = {
current: null,
delay: 0.5,
timer: null,
handler: function(event) {
var element = event.findElement('div.nav_menu');
if (!element)
return Hoverer.leave();
if (element == Hoverer.current)
function getScrollbarWidth() {
if (this.scrollbarWidth) {
return this.scrollbarWidth;
}
var inner = document.createElement('p');
inner.style.width = '100%';
inner.style.height = '200px';
var outer = document.createElement('div');
outer.style.position = 'absolute';
namespace :js do
desc "Pack javascript src for production environment"
task :pack => :environment do
# Files to pack
Dir.glob(File.join("public", "javascripts", "**", "*.js")).each do |filename|
puts "packing #{filename}..."
FileUtils.cp(filename, "#{filename}.orig")
js = ""
File.open(filename, "r") { |f| js = f.read }
File.open(filename, "w") { |f| f.write(Packr.pack(js, :shrink_vars => true, :private => true)) }
.texpand {
margin: 0;
padding: 3px;
width: 298px;
height: 29px;
border: 1px solid rgb(189, 199, 216);
font-size: 12px;
color: rgb(119, 119, 119);
}
@fermion
fermion / gist:134480
Created June 23, 2009 11:05
usage example of smugmugr for a Rails 2.3.2 app
# /config/environment.rb
config.gem "fermion-smugmugr",
:lib => 'smugmugr',
:source => 'http://gems.github.com',
:version => "=0.2.0"
# /config/initializers/smugmugr.rb
SMUG_CONFIG = {
Many times, when creating a site, I need hidden elements on a page that I must later make visible. Of course it would be great if one could simply hide them via CSS, and later [easily] show them via javascript. However this is not the case, javascript has some difficulties overriding styles set in a stylesheet. So, I've found the best way to accomplish this is to use a combo of CSS and javascript in a two-step process:
1. Hide the elements via CSS class – so they are hidden when the user first sees the page
2. Hide the elements via javascript and remove the corresponding CSS class, after the DOM has loaded.
The second step has the potential to be quite expensive on the DOM, but feel that it's an acceptable trade-off because they elements in question are already hidden. This way they are ready to be manipulated, one doesn't need to worry about fiddling with CSS classes or styles.
## Stylesheet
.hidden {
display: none;
this.slider.trackLength = Math.max(this.slider.maximumOffset(), this.slider.track.getHeight()) - this.slider.minimumOffset();
document.observeSelect = function(){
$$('select.get').each(function(element){
if(!element.observingChange){
element.observe('change', function(event){
var e = event.element();
if(e.isActive()){
e.indicate();
document.ajaxRequest(e, e.readAttribute('src'), 'get', event, e.serialize());
}
});
namespace :db do
task :pull do
run "cd #{current_release} && RAILS_ENV=#{rails_env} rake db:data:dump"
download "#{current_release}/db/data.yml", "db/data.yml"
`rake db:reset db:data:load`
end
end