CustomLog "|/usr/sbin/rotatelogs /opt/www/awesome-project/log/access.%Y-%m-%d.log 86400" combined Adding that to your site's vhost will create log files that include the current date in their name, like...
...access.2011-04-20.log, without any need to restart the web server every night (like logrotate does). The last argument above is the rotation time in seconds -- here being...
...above should fix it for that one command. If you want to persist that setting, say the following. export LESSCHARSET=UTF-8 Put it into your ~/.bashrc and reopen all...
...terminals (or source ~/.bashrc in open terminals). Note that if you are having trouble with filenames, you should try changing git's core.precomposeunicode config setting...
Pie sometimes does not properly redraw elements upon changes. This often happens when the change comes from somewhere further up the DOM. Consider something like: Active element Inactive element
li .content { -webkit-box-shadow: #666 0px 2px 3px; -moz-box-shadow: #666 0px 2px 3px; box-shadow: #666 0px 2px 3px; behavior: url(/PIE.htc); background: white; } li.active .content...
Using the dialog command you can launch ASCII-art dialogs from your shell scripts. Check out man dialog for a list of supported dialog types. Aside from simple text boxes...
...or choice dialogs, it supports more advanced interactions like file pickers or progress bars. Example: Yes/no choice dialog --yesno "Erase the world?" 0 0 Example: Menu with multiple options
You may know the double asterisk operator from Ruby snippets like Dir['spec/**/*_spec.rb'] where it expands to an arbitrary number of directories. However, it is disabled by default on...
...most systems. Here is how to enable it. If you check your globstar shell option, it is probably disabled: $ shopt globstar globstar off In that case, ** behaves just like * and...
There are 3 built-in file descriptors: stdin, stdout and stderr (std=standard). (You can define your own, see the linked article.) Basic 0/1/2 references stdin/stdout/stderr >/2> redirects stdout/stderr, where...
&1/&2 references stdout/stderr &> redirects stdout and stderr = everything (caution: see below) Caution: &> is functional as of Bash 4. This seems to result in a slightly...
Browsers make this very hard. Even when you explicitely set the selection inside the textarea (e. g. using jquery-fieldselection) the browser will not scroll the textarea to this selection...
...What you can do instead is abuse browsers' behavior that they scroll to the end of a textarea when it gets focus. So we set the textarea's value to...
On 32bit systems, the maximum representable Time is 2038-01-19 03:14:07 in UTC or 2038-01-19 04:14:07 in CET. If you try to instantiate...
...that has a DATETIME value which Time cannot represent. Note that there are some subtle differences between the APIs of Time and DateTime. Also DateTime is implemented in Ruby, while...
...This not only disables the memoization, but will also return wrong results! The best solution is to use the Memoizer gem instead...
You know that Devise offers RSpec test helpers for controller specs. However, in request specs, they will not work. Here is a solution for request specs, adapted from the Devise...
...wiki. We will simply use Warden's test helpers -- you probably already load them for your Cucumber tests. First, we define sign_in and sign_out methods. These will behave...
Cucumber_rails' old-school web-steps have been deprecated for a while, urging developers to write high-level step definitions that directly use Capybara or Webrat. We think that's...
...a bit drastic. More high-level steps are good, but ticking the odd check box with a general step is not always bad. So we took the old web steps...
...and :ignore_if => lambda {...
...}. These options should be helpful in ensuring every notifications means something actionable (instead of a long log of failures that just scrolls by).
...default. Ideally, cool URLs never change and always respond with a helpful redirect or similar. Ignore Errors like this: # config/initializers/exception_notification.rb ExceptionNotification.configure do |config| # ... config.ignored_exceptions += %w[OneException AnotherError] end
...mess around with arcane incantations inside xorg.conf, you can use the graphical arandr tool: sudo apt-get install arandr arandr If all your monitors are stacked in the same space...
...the space is not wide enough and you can't really move them, you need to switch to a proprietary driver. If it works with the open source driver for...
...LICENSE BEGIN ===== 00000yIeXfhGSbt"yULWQR9n 00000yIeXfhGSbt""yULWQR9n olysFAv105bHmKOiqbxRX"Yr olysFAv105bHmKOiqbxRX""Yr ===== LICENSE END ===== ===== LICENSE END =====" See how the copied license is wrapped in quotes and has its inner quotes doubled.
You're using exception_notification and want to send exception mails within a model. Here's how. The ExceptionNotifier class has a method notify_exception for that. Simply pass an...
ExceptionNotifier.notify_exception Exception.new("testfoo") => #<Mail::Message:77493640, Multipart: false, Headers: <Date: Mon, 24 Sep 2012 13:37:00 +0200>, <From: foo@example.com>, <To: ["fail@failtrain.com", "fail@failbus.org"]>, <Message-ID: <5060543b3759_212311986a0305e8@ip-10-234-82-125.mail>>, <Subject: [you...
...know the exact hits on your website (or whatever logfile you want) for a specific date without duplicates, here's how. "Unique" means you don't want to count hits...
...to an URL originating from the same IP twice. You can use the attached script to do so: # ./log_parser.rb 2011-10-04 27 hits on /rss.xml 36 hits on /stylesheets/fonts/slkscr-webfont.woff...
This collection of Sass mixins enables cross-browser styling (including IE with CSS3PIE) with less lines of code. This enables PIE for IE up to version 8 only (the first...
...part is not possible in Haml, so use ERB): <%= stylesheet_link_tag 'screen', :media => 'screen' %> These would be your two screen Sasses: # screen_with_pie.sass =pie behavior: url(/stylesheets/lib/PIE.htc) position: relative
You can configure a Ubuntu system as a gateway in order to share it's internet connection (maybe via WLAN or tethering) with other computers on the network.
...Enable ip traffic forwarding: Open /etc/sysctl.conf Uncomment the line net.ipv4.ip_forward=1 Reload using sudo sysctl -p /etc/sysctl.conf Reconfigure ip_tables to allow NAT: Download the attached file Replace online...
...describes a hack that lets you trace those messages in your code. Let's say you want to get rid of a console message "foobar". Copy the Undebug class below...
...that message. The console output should look like this: Message tracing is active and slowing down the application! Disable me in /home/henning/projects/notes/config/initializers/undebug.rb:34. foobar Printed 'foobar' at /home/henning/projects/notes/features/step_definitions/web_steps.rb:280:in...
Ruby 2.3.0 has been around since end of 2015. It brings some pretty nice new features! Make sure to read the linked post with its many examples! Hash#fetch_values...
...Similar to Hash#fetch, but for multiple values. Raises KeyError when a key is missing. attrs = User.last.attributes attrs.fetch_values :name, :email Hash#to_proc Turns a Hash into a Proc...
The basic idea is pretty simple: an element's height is accessible via the offsetHeight property, its drawn height via scrollHeight -- if they are not the same, the browser shows...
var hasScrollbars = element.scrollHeight != element.offsetHeight; So, in order to say something like... Then the element "#dialog_content" should not have scrollbars ... you can use this step (only for Selenium scenarios...
A snippet of the carrierwave documentation You might come to a situation where you want to retroactively change a version or add a new one. You can use the recreate...
...base file. This uses a naive approach which will re-upload and process the specified version or all versions, if none is passed as an argument. Call recreate_versions! on...
...the remote branch to check out, but when using more than one remote, it seems like it no longer can do that. Even if the branch is the same on...
...both remotes, you need to specify the branch to check out from explicitly, like that: $ git checkout -b my-branch origin/my-branch Branch my-branch set up to track remote branch...
Using OpenSSL it's very easy to seriously encrypt files. Use the script below. Input / Output are self explanatory. Put a long passphrase into PASSWORD_FILENAME. It is the key...
...m 60 > /tmp/openssl_encryption_password Remember to at least delete the input file afterwards. Better use shred to wipe files on Linux as used in the script below. #!/bin/sh PASSWORD_FILENAME=/opt/backup/openssl_encryption_password...