Dropbox Uploader (Stuff I love!)
August 27, 2010 on 1:14 pm | In Category-less | No CommentsSo, lifehacker had a blog post about a dropbox uploader and I really really wanted to get it working. It took me awhile, but I finally got it working how I wanted.
Check out the final product: http://nathan.bethandnathan.com/dropbox/
However, I had some problems getting it going. Here is everything I had to do to make it work…
Day 1:
I first downloaded the code from ampercent but after manually entering in my email address and password I was getting weird errors because I’m on windows hosting on not unix hosting. So the first thing I did was change the $tmpDir variable to be an absolute path to a directory that I wanted to store the files:
$tmpDir = 'D:\path\to\my\domain\myUploadFolder7837839';
That fixed my $tmpDir problems but I had another problem…
I was now getting cURL errors because the cURL php extension wasn’t installed. Unfortunately, I couldn’t fix the cURL errors on my own so I had to submit a ticket with my hosting provider to have them install the cURL extension for PHP.
Day 2:
After my hosting provider installed the cURL extension, I tried again. Unfortunately, I was now getting SSL Cert errors:
Error: Cannot execute request: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
This was frustrating… Luckily it seemed that Google had a solution for me on the original coder’s blog. I simply needed to download the needed certificate and point the Dropbox uploaded to it before the upload method:
$uploader->setCaCertificateFile('path/to/the/certificate.cer'); //<--this is the new line you have to add)
$uploader->upload($tmpFile, $_POST['dest']);
I was really excited until I got another error:
Error: Cannot execute request: error setting certificate verify locations: CAfile: D:\path\to\my\cert.cer CApath: none
Wow! I was really struggling here. After a lot of struggling and searching, it turned out to be a combination of issues.
- Issue #1: one of the directories in the path to my cert file started with an ‘n’ (‘nathan.bethandnathan.com’)
- Issue #2: the original code to fix the cert issue from coder’s site has double quotes around the path to the cert file
- Issue #3: PHP handles double quotes around strings differently than it does single quotes.
Why does this matter? Well, \n in PHP means “New Line”. So when the path to my directory was being interpreted by the PHP interpreter it never found the cert file because there was a \n right in the middle of my path (‘\nathan.bethandnathan.com’ starts with \n, so the interpreter thought my path had a “new line” in it, which doesn’t make sense and so it blew up).
How did I fix this? change the double quotes surrounding my path to be single quotes. (I already fixed this in the code above).
So, I fixed the path, things are looking good, right? Wrong. I had the same error again:
Error: Cannot execute request: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Argh! What is the issue here? After more Googling I couldn’t find anything so I changed my search terms to “cURL PHP SSL” and I found this page which explains how to use cURL in PHP to access HTTPS sites. After reading about it I realized I had two options:
- Ignore SSL
- Get it working the right way
I opted for option 2 because it was simple:
- Go to the site where you are trying to connect to via SSL
- Download the cert (click the lock icon, view the cert, export it, save as X.509 Certificate (PEM) with a .cer extension
- Upload the .cer file to your hosting provider
I did all of that, changed my path to my cert file in my uploader code… and… IT WORKED!
WAHOO!
I was way excited. I uploaded a few files and it works great. However, instead of being done I decided to get the “pretty” version of the uploader from Addictive Tips. Neat, right? But wait a minute, what about password protection?
Well have no fear! Ampercent updated their post to include password protection! So, I downloaded their password version and integrated it with the pretty version.
Well hold on here, would it be possible to easily share my code with others? Why of course! I decided to clean up my integrated version and I put a configuration at the top of the index.php. I also removed the dropbox destination out of the HTML form so people can’t see it.
You can download my final version as a zip file here. Just update the top configuration section with your own settings and you should be good to go!
Woot!
UPDATE #1:
I just found someone that uses the API instead of page scraping, so I’m going to update my code accordingly and put a new download… I’ll let you know when that happens.
Also, my hosting provider is limiting me to only 2M files… bummer.
UPDATE #2:
I added my modifications to the other OAuth code and updated my zip file.
Thanks!
The Over 30 Crowd
June 22, 2010 on 2:25 pm | In Category-less | 1 CommentI saw this today about The Over 30 Crowd and how easy it is for kids these days. Although I don’t necessarily agree, it is a funny read (warning, minor swearing).
Open in Explorer View Running Slow in SharePoint?
June 15, 2010 on 8:45 am | In Category-less | No CommentsI used to have a wiki to store knowledge, now I don’t really have anything (maybe I should put my wiki online again)…
Anyhow, I found this little gem today regarding webdav slowness.
Essentially, SharePoint uses WebDav connections when you click “Open in Windows Explorer”. If you happen to be running IE 8, you are going to want to turn off “Automatically Detect Settings” (Internet Options > Connections Tab > LAN Settings > Uncheck “Automatically Detect Settings”).
The speed of your connection should go from a 1994 1,200 baud modem to a 2008 DSL connection. Wahoo!
Why does Apple do so well when it comes to technology?
June 10, 2010 on 4:00 pm | In Category-less | No CommentsHere’s why:
Can anyone say “painful”? I can’t believe that there are 9 steps to just start using office web apps… I know there isn’t an Apple alternative, but there are Google Docs. Let me show you how to log in to Google Docs:
- Log in to http://docs.google.com
- Done.
Glass Coverage on your auto insurance
May 10, 2010 on 5:06 pm | In Category-less | No CommentsSo, I just got an insurance quote today to see how much it would cost to get glass coverage on my auto insurance.
$35/year for glass coverage
Well, that seems reasonable, except that my comprehensive deductible is already set at $100 and my insurance will cover a windshield replacement as a comprehensive claim that doesn’t count against me.
$100/claim
So, at $35/year extra OR keeping my coverage @ $100/claim, I would need to replace my windshield more often than every 2.85 years to make the glass coverage worth it. ($100/$35)
So, am I going to need a windshield replacement more often than every 2.85 years?
If I had only one car, I might say, “no”.
If I lived in a different state (one with less rocks
), I might say “no”.
But, I have two cars, and we live in a state with lots of rocks and dirt. Besides, I walked around the block the other day and it seems that nearly half of the cars parked on the street had cracks in their windshield.
I suppose that given the reasons above, I’m leaning towards the side of getting the glass coverage. Why? Because I have 2 cars and potentially having to wait 5.7 years (2.85 years x 2 cars) between windshield replacement for each car . We’ll see…
Photocopy machines have hard drives, too
May 2, 2010 on 9:15 pm | In Category-less | No Commentshttp://www.thestar.com/news/gta/article/781567–high-tech-copy-machines-a-gold-mine-for-data-thieves
Looks like you should be mindful of what you are photocopying and where.
8 Bits O’ Fun
December 11, 2009 on 4:48 pm | In Category-less | No CommentsListen to “Gloria” (flash required). The others are okay but that one seemed the best to me.
Please stop spending so much
August 7, 2009 on 12:50 pm | In Category-less | No CommentsI know some people think Glenn Beck is out there, but I do think he brings up some good points:
(link)
Specifically, our government is spending too much. We can’t afford a full re-write of Healthcare or offer a government option that competes with private insurance. We can afford some reform to make healthcare more accessible but not a full rewrite.
Why? Well, here’s what I’m thinking: if the government creates a government sponsored option, they will be competing with current healthcare providers. We know the government option is going to cost less. So, what will your employer do when faced with the choice every year: continue to offer the more expensive plan (private insurance) or switch all their employees to the lower-cost government one?
If your employer sticks with their private plan, great, right? Well, what about the employer down the street? What about a large corporation? What if ExxonMobil switches? Or GE? Or Wal-Mart? If other companies switch but yours doesn’t, private insurance costs are going to go up.
Now fast forward another year or two. The cost differential between government insruance and private insurance continues to widen. How long do you think it will be before we have a single payer system (government run healthcare)? How much is that single payer system going to cost? Who pays for government programs? How good do you think the coverage of the single payer system will be in comparison to how it is now? [1]
We already how Obama feels about single payer: (I’m not sure why this is “SHOCKING”, here’s a WSJ Article where he talks about it)
(link)
—
So, I want the government to stop spending so much money. I DO think that healthcare can be better and we can make simple changes to help things along (make it so there is a reward cap on malpractice cases so malpractice insurance doesn’t cost so much, do other simple things that people smarter would come up with but still don’t cost $1 trillion).
I DON’T think we should spend $1+ trillion to fundamentally change how the whole system will work. I don’t even think we should spend $1+ trillion. Let’s come up with something better.
—
[1] I know other countries have government sponsored healthcare. Do you want that type of healthcare? What about scarcity: when we have to choose who gets a surgery because there are too many people and not enough doctors? Who gets to have the surgery? Are specialists going to want to spend 15+ years of their life becoming the absolute expert in their specialty and do it to get paid less money?
Let’s make small changes, let’s make things better through evolution, not revolution.
15 Reasons Why I Love My Wife.
February 20, 2008 on 6:56 pm | In Category-less | 1 Comment- She is kind
- She is my best friend
- She is cute
- She loves our kids
- She loves the gospel
- She reads the scriptures
- She prays
- She makes excellent food
- She wakes up with our youngest son in the night to feed him
- She listens to me
- She means it when she tells me she loves me
- She smiles
- She knows what database normalization is
- She is computer savvy
- She loves me
Why Linux is still a pain
December 12, 2007 on 5:31 pm | In Category-less | 1 CommentSo, I’m trying to install OpenVPN on Debian, right?
apt-get install openvpn
Well, it looks like it installs, but upon further inspection, it seems that it didn’t install the TAP/TUN adapter:
ifconfig -a
Argh!
So, I thought I’d download it and compile it from source:
wget http://openvpn.net/release/openvpn-2.0.9.tar.gz
tar -xzvf openvpn-2.0.9.tar.gz
cd openvpn-2.0.9.tar.gz
./configure
But that gives a painful error:
checking for ifconfig... /sbin/ifconfig
checking for ip... /sbin/ip
checking for route... /sbin/route
checking build system type... i686-pc-linuxlibc1
checking host system type... i686-pc-linuxlibc1
checking target system type... i686-pc-linuxlibc1
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... configure: error: C compiler cannot create executables
See `config.log' for more details.
Hmmm, upon inspection of config.log, I see:
/usr/bin/ld: crt1.o: No such file: No such file or directory
A google search of the above text reveals this, with a solution:
apt-get install libc6-dev
Problem solved. I’m starting to remember why I stopped using linux
Update, problem not solved. It turns out I needed the LZO compression:
wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.02.tar.gz
But that needs the g++ compiler:
apt-get install g++
When does it stop?!?
Update: it doesn’t stop:
configure: error: OpenSSL Crypto headers not found.
Google reveals:
apt-get install libssl-dev
Wow, all of that just for ./configure. Hopefully make exits okay…
Update: this is like the post that never dies. LOL.
So, I was able to figure out that the TAP/TUN adapter installed:
limybox:~# lsmod | grep tun
tun 10336 0
I’m not sure if it was my doing (I did run a few commands that openVPN requested I run):
(1) make device node: mknod /dev/net/tun c 10 200
(2a) add to /etc/modules.conf: alias char-major-10-200 tun
(2b) load driver: modprobe tun
(3) enable routing: echo 1 > /proc/sys/net/ipv4/ip_forward
Note that either of steps (2a) or (2b) is sufficient. While (2a)
only needs to be done once per install, (2b) needs to be done once
per reboot.
Anywho, it turns out that with a windows client, the VPN server can push gateway and IP information to the client and windows will change the route table (route print). But with Linux as a client, it ignores the messages from the VPN server, SO, you have to set the route stuff yourself either on startup of openvpn (–ifconfig 192.168.1.160 255.255.255.0), or put that in a config file, or try a script (see http://openvpn.net/howto.html#dhcp).
For those that care, here is my client side config:
remote my.ipaddress.com
port 21
dev tap
ifconfig 192.168.1.160 255.255.255.0
secret static.key
proto tcp-client
comp-lzo
route-gateway 192.168.1.1
redirect-gateway
Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^
