Initiate SSL secured TCP connections to remote services
Establishing a TCP connection to a SSL secured remote service is not possible using telnet
or nc
.
Though, you can use openssl
for that:
openssl s_client -connect www.makandra.com:443
Chart.js - a promising JavaScript charting library with MIT-license
Chart.js seems to be a good alternative to Google's Chart API and other commercial chart drawing libraries.
- good looking charts
- canvas based (means less memory consumptive, but no interactivity out of the box)
- highly configurable
- good API and documentation
- just 4.5 kilobytes
- MIT license
- Browser support: all browsers supporting the canvas element (for IE8 and below, use the polyfill as describes in the [chart.js documentation...
Comparing Rails' flash hashes will not respect their internal lists of used entries
Rails flashes (FlashHash
) track a list of used keys, which is not respected when comparing flash hashes.
This does not concern you under most circumstances.
Basics
When ActionController
picks up a flash object, it will call the #sweep
method once; that method checks the list of used flash entries and deletes those. All other entries are flagged as used. This means they will be deleted on the next request, but are still be available for rendering during the current request.
Fun facts: When redirecting, this does not happen. Also,...
Fix „rvm no such file to load -- openssl“ or "rvm no such file to load -- zlib"
For example if you use rvm and get this message:
ERROR: Loading command: install (LoadError)
no such file to load -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
You've installed your ruby without having all required libraries.
I don't know why there isn't a Warning message if you install a ruby with rvm and didn't have libraries like openssl and zlib.
To fix this you can execute this:
#to show the requirements for your system
rvm requireme...
Tips And Tricks For Print Style Sheets
Smashing Magazine lists some handy tricks for print style sheets, all with CSS:
- Expand External Links For Print
- Print QR Codes For Easy URL References
- Use CSS filters to improve the result of printed graphics (i.e. images with transparent parts)
- Use your DevTools to preview the print styles in your browser
Interactive generator for gradients, borders, noise textures and box shadows
CSSmatic lets you play around with four rather complex CSS stylings and gives you CSS or SASS code to use your result right away.
- Gradients
- Borders
- Noise textures – offers a texture download
- Box shadows
Browser Hacks: CSS Rules to Target Specific Browsers And Versions
The linked site lists a wealth of CSS hacks that let you apply styles to just that one browser. You should be using this mostly for fixing browser issues and not give up on creating solid styles.
About progamming with Multi-Touch, Touch- and Mouse-Events in the webbrowser
Since there are more and more touch-capable devices out there, as a web-developer it becomes more and more important to know how to deal with touch events next to mouse events and how you you can combine both worlds (mouse and touch interaction).
Here's a quick introduction to (multi-)touch browser events and an advanced article that deals with touch and mouse events and how they can be combined.
Ruby 1.9 or Ruby 2.0 do not allow using shortcut blocks for private methods
Consider this class:
class Foo
private
def test
puts "Hello"
end
end
While you can say create a block to call that method (using ampersand and colon) on Ruby 1.8, ...
1.8.7 > Foo.new.tap(&:test)
Hello
=> #<Foo:0x1e253c8>
... you cannot do that on Ruby 1.9 or 2.0:
1.9.3 > Foo.new.tap(&:test)
NoMethodError: private method `test' called for #<Foo:0x00000001e8c258>
^
2.0.0 > Foo.new.tap(&:test)
NoMethodError: private method `test' called for #<Foo:0x000000027bc738...
Different behavior for BigDecimal#floor in Ruby 1.8 and Ruby 1.9
Ruby 1.8 (supplied by Rails' ActiveSupport)
>> BigDecimal.new("0.1").floor.class
=> BigDecimal
Ruby 1.9 (supplied by Ruby 1.9 itself)
>> BigDecimal.new("0.1").floor.class
=> Fixnum
In fact, Float#floor
has changed from Ruby1.8 to Ruby 1.9 which is used by BigDecimal#floor
internally.
Attached initializer backports Ruby 1.9 behavior to Ruby 1.8.
How to copy your „Google Chrome“ or „Chromium“ profile without creating an online account
Google Chrome saves your profile data in ~/.config/google-chrome
.
To transfer the profile to for example a system you have setup freshly do following steps:
- make a copy of
~/.config/google-chrome
- install google-chrome
- restore your backuped profile to
~/.config/google-chrome
- launch google-chrome
(Replace google-chrome by chromium-browser if you use chromium-browser)
How to: Ruby heredoc without interpolation
When you use heredoc, string interpolation is enabled by default:
x = "Universe"
<<-MESSAGE
Hello #{x}
MESSAGE
# => "Hello Universe"
This may be impractical sometimes. To avoid interpolation in heredoc strings, simply enclose your heredoc marker with single quotes:
x = "Universe"
<<-'MESSAGE'
Hello #{x}
MESSAGE
# => "Hello #{x}"
That will make the string behave like a single-quoted string, so sequences like \n
wil...
Ensure reloading of favicons
Sometimes it seems a favicon does not work because your browser displays an old version or (in case of local development) a favicon of another project you worked on recently.
Though, you can force your browser to really reload the favicon using some kind of additional version parameter string like this:
= favicon_link_tag("/favicon.ico?v=2")
Loading dumps via SSH, unpacking and sourcing them, all with a progress bar
Here is a hacky way to load dumps directly from the source server, without fully copying them over and extracting them first.
It may break horribly for you. This is the dark side of the force.
- Install pipe viewer, if you don't have it already:
sudo apt-get install pv
- Know the location of the dump file on the remote server. We'll use
/mnt/dumps/my_project.dump.bz2
in the example below. - Find out the size of the (bzipped) file in by...
Capistrano: Bundler stalls and asks for "Username"
Given you use Capistrano together with bundler to automatically install your gems when deploying.
I recently had the problem that Capistrano stalled like this:
[err :: host.name.tld] Username:
It turned out that I this originated from GitHub. We had a gem in our Gemfile that explicitly pointed to a GitHub URL like that:
gem 'foogem', :git => 'https://github.com/blubb/foogem.git'
The URL was returning a 404 which caused the problems. You have to get another gem or point to a fork on GitHub.
The Startup Toolkit
Good collection of crash-course articles about founding a start up, getting funded, validating ideas, etc.
Test xpath expressions in your browser
Safari & Chrome
Use $x()
in your console:
$x('//span') # selects all span elements
Firefox
There's an add-on.
How to find out your Ubuntu's release codename or version
So you want to know if you are on natty
, precise
, quantal
, or something else? Check /etc/lsb-release
.
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.2 LTS"
Or, use the lsb_release
command:
$ lsb_release -cd
Description: Ubuntu 14.04.1 LTS
Codename: trusty
SFLPhone won't start
You might get the following error:
Unable to initialize.
Make sure the daemon is running.
Error: Process /usr/lib/sflphone/sflphoned exited with status 1
This mean the last process didn't shut down properly and let a PID file lie around. You can delete it with
rm ~/.cache/sflphone/sfl.pid
(If you've shut sflphone down some seconds ago, you just have to wait 10 seconds and don't have to remove the pid file manually)
Firefox 22 to Stop Eating Third-Party Cookies
Mozilla has announced that, starting with Firefox 22, the popular open source web browser will begin blocking third-party cookies by default. That means only websites you actually visit will be allowed to set cookies; advertisers on those sites will no longer be able to easily track you by setting a cookie.
MongoMapper for Rails 2 on Ruby 1.9
MongoMapper is a MongoDB adapter for Ruby. We've forked it so it works for Rails 2.3.x applications running on Ruby 1.9. [1]
makandra/mongomapper
is based on the "official" rails2
branch [2] which contains commits that were added after 0.8.6 was released. Tests are fully passing on our fork for Ruby 1.8.7, REE, and Ruby 1.9.3.
To use it, add this to your Gemfile
:
gem 'mongo_mapper', :git => 'git://github.com/makandra/mongomapper.git', :branch => 'rails2'
...
"Module.const_defined?" behaves differently in Ruby 1.9 and Ruby 1.8
Ruby 1.9 changed the default behavior of Module.const_defined?
from what it was in Ruby 1.8 -- this can be especially painful when external code (read: gems) uses const_defined?
to look something up and gets different results on different Rubies.
Consider this:
module Foo
FOO = 42
end
class Bar
include Foo
end
On Ruby 1.8, Bar
won't have FOO
defined as a constant since that's (even though it's accessible):
1.8.7 > Foo.const_defined? :F...
Extracting the conditions of a named scope in Rails 2.3
See attached link for a way to extract the conditions of a named scope in Rails 2.3.