Whoa just saw this awesome bit of code in Tire a Ruby gem for Elasticsearch:
@total = response['hits']['total'].to_i rescue nil
For so long I have been checking Ruby Hash’s like that with a nil? or exists? check after everyone.
Never again!
Whoa just saw this awesome bit of code in Tire a Ruby gem for Elasticsearch:
@total = response['hits']['total'].to_i rescue nil
For so long I have been checking Ruby Hash’s like that with a nil? or exists? check after everyone.
Never again!
There is so much old data out there about debugging in Ruby that I wanted to post a quick reminder here so I could remember the current way to do it.
So here goes… debugging in Ruby 1.9 on Rails:
In the Gemfile…
gem 'debugger', group: [:development, :test]
Then from anywhere in your code:
debugger
One quick tip as well, type in irb from the debug console to get to a Rails console. Niiice!
Found the answer on Stack Overflow.
From the terminal, after downloading Mountain Lion from the App store:
hdiutil makehybrid -iso -hfs /Applications/Install\ OS\ X\ Mountain\ Lion.app/Contents/SharedSupport/InstallESD.dmg -o OSX-10.8.iso
Here is a quick way to create a self-signed SSL certificate with openssl and output the key/cert into PKCS#12 format. I’ve found that I’ve had to do this several times at work to get a certificate ready for a Windows machine. I got tired of looking up the procedure each time, so here goes…
# create the private key
openssl genrsa -out server.key 2048
# create a new csr
openssl req -new -key server.key -out server.csr
# sign the csr into a PEM cert file
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
# convert the PEM cert and key into a PKCS#12 file
openssl pkcs12 -export -out server.pfx -inkey server.key -in server.crt
After coming back from vacation my Mitsubishi LaserVue L65-A90 TV would not start. It had a solid red LED status indicator and would not turn on.
After talking to a local technician he gave me the following steps to try:
On the TV press and hold the Menu and Input buttons for 5 seconds.
This will trigger the system to report an error code using the power LED light. It blinked once, then paused, then blinked 9 times, indicating error code 19.
He said this error code indicated that the “receiver was locked”.
He then had me do the following to unlock and restart it:
Hold Menu and Channel Up for 5 seconds. Status light turns to green for 3 seconds. Then, hold Menu and Channel Down for 5 seconds.
Seemed a lot like resetting the CMOS on a computer to me.
After that the TV is working perfectly fine! Although, he said it may not work in all cases.
Big thank you to Ultimate Audio Video in Laguna Hills, CA! They helped me fix my TV over the phone for free!
Here is a quick script that will convert all js file line endings in a folder from either Windows or Unix into Unix line endings:
find . -type f -name '*.js' -print0 | xargs -0 perl -pi -e 's/(\n|\r\n?)/\n/'
And here is the same script to convert them into Windows line endings:
find . -type f -name '*.js' -print0 | xargs -0 perl -pi -e 's/(\n|\r\n?)/\r\n/'
For the last couple days I’ve had a problem with VMWare Workstation v.7.1.4 build-385536 where my left mouse click suddenly stopped working in my Windows 2008 guest VM.
I finally found the problem!
When dragging and dropping text inside the guest VM I was dragging outside the VMWare container. This is what caused the problem.
To fix it so that never happens again I’ve disabled the ability to Drag & Drop from the guest. You can set this in your virtual machine settings, under Options > “Guest Isolation”.
I often will search Google for a keyword that I know will return the result I want in the first spot. Until now I was using Chrome to search for the keyword and then clicking on the link to go to the page.
There must be a better way!
There is!
Setup a custom search engine in Chrome like this:
Bam!
Now you can do an I’m Feeling Lucky search just by hitting the exclamation point, a space, and then the keyword. Like this:
! ruby arrays
I’ve found that in Windows 7 sometimes I will randomly be unable to drag and drop files from the explorer shell.
If you ever have that problem try this to fix it:
This worked great for me. Your results may vary!
By the way: Thanks Microsoft for yet another reason to use a Mac instead of a PC.
Source: superuser.com
I have been using Remote Desktop Connection on my Mac to connect to my new Windows 7 PC for the last couple weeks. Ever run into a problem where your RDP connection stops sharing copy and paste with your Mac?
It was driving me nuts, but thanks to this website I was able to finally find the answer:
Update: After the break is a script that will automatically kill and restart rdpclip.exe.
Read the rest of this entry »