Safari doesn’t load/show a base64 encoded image.
Posted by Randy in Programming, Web Development on March 17, 2015
Normally when I run into a road block while coding, I can find the solution rather quickly via Google. Most of the time that solution is at stackoverflow. It’s pretty easy to overcome most things this way. However, there are some times when you just run into a problem that few people have talked about online understanding paystubs. That becomes rather frustrating. It reminds me of the days before the internet, or at least before Google, when finding information was much more difficult. We take that for granted a lot these days.
Hopefully this post will find it’s way to the top of Google search results for some of the keywords I used in my searches. One example is the following error I was seeing when I inspected the element in Safari.
Failed to load resource: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -10.)
You see I had a chevron icon added to a custom select box in a web site I’m working on. The chevron icon showed up in every browser except for Safari. Safari just complained that it couldn’t load the image. Here’s the exact CSS I used for the image:
{ background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAA3NCSVQICAjb4U/gAAAACXBIWXMAAAI3AAACNwH3BkTCAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAB5QTFRF////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhow4rQAAAAp0Uk5TABUcLTJHSLju+FWeOqcAAAA8SURBVAhbY2AgBiiCCCEgrnBgYGBpBzIiWxgYPKYCGWwzHFg6E0DymS0e08Cq2WZABIBC06AGMBswEAcAs7AJgLl9xCcAAAAASUVORK5CYII8f334b553cdd5aeff8fb47bae1fe9ead') no-repeat 95% 55%; } |
It worked fine in every browser (including IE mind you) except for Safari.
I’ll cut to the chase. Base64 requires the number of characters in the encoded string to be divisible by 3. If you count all the characters starting with “iVBORw0KG…” all the way to “e1fe9ead”, you’ll see that the base64 string is 371 characters long. I remember that I got this chevron and the base64 encoded css directly from a website which automatically encoded the image for me. 371 isn’t divisible by 3 evenly. However, 372 is. The solution to this problem is to pad your string at the end. I added an equal sign (=) to the end of the string, making it 372 characters long total. Now Safari likes it. Hope that helps. If you are having this same issue, you’ll either need to add one or two equal signs, whichever amount makes the total character count divisible by 3.
The Do’s and Don’ts of Tutorial Youtube Videos
Youtube allows anyone to broadcast themselves. While it’s an awesome movie maker online, there are a few things that everyone should know before recording and uploading a video to Youtube. I watch many tutorials and such on Youtube so many of the things in this list pertain to those types of videos. So, let’s get started with my rules of Youtube!
1.) Introductions
Don’t start your tutorials with “What is up guys?”
This is especially true if you are extremely nerdy sounding. I don’t have anything against nerds. I’m one myself. I do have a problem with people trying to sound cool.
Do try to be professional.
If you are making tutorial videos, try to present yourself as professional as possible. We aren’t watching your video because we want you as a friend. We don’t want to go hang out and drink a few beers. We do want to learn something. I understand that you are making the video voluntarily and mostly for free (unless you get tons of views and great ad revenue.
2.) Recording from a phone
Don’t hold your phone vertically.
This causes your video to look horrible on youtube. Refer to this link for more information on Vertical Video Syndrome.
Do hold your phone horizontally.
ALWAYS record your videos this way. There’s is never a proper time to record a video vertically with your phone. It doesn’t look good anywhere.
3.) Preparation
Don’t make a tutorial without first trying what you are supposed to be teaching.
I can’t tell you how much time I’ve wasted watching coding tutorials where the guy would have a bug that he couldn’t fix within a few moments, or he may be teaching something and winging it. In fact, most of the tutorial videos I’ve watched on Youtube are from people who are totally trying to teach something off-the-cuff.
Do edit your videos for brevity and details.
Even if you make a typo, you should edit out your search for the cause of your issue. Cut that time out and just show where the bug was located and what you did to fix it. Edit out long pauses and interruptions. Edit out your frustrated remarks when something doesn’t work how you expected. Have a cheat sheet beside you details the steps you are presenting. Make sure you have went through the presentation before hand and have a working copy of all the code you plan to present. Keep your videos short. Make your videos address specific points. Record your videos, keeping the recorded time below 15 minutes, and then attempt to edit out 5 minutes worth of “ums” and other pauses, interruptions, and mishaps. You’ll get a less-than-10-minute video nearly every time. A ten minute video is easier for your viewers. They can take in the information better with shorter, to-the-point videos.
4.) Communication
Don’t use Notepad or other on screen text in tutorials.
There are two reasons I say this. First, if I wanted to read, I’d just go look for a written tutorial on the subject. Secondly, if your video isn’t HD, it’s nearly impossible to read the text, unless you are using 48 point font.
Do use a high quality microphone
There are some great USB condenser mics on the market for less than $50. One of these, along with a pop filter, will be extremely beneficial. Headsets tend to pick up your breathing, and your breaths sound like waves crashing into the shore. It takes a lot of intricate editing to remove all of these breaths. Get a good mic and you can avoid most of this work.
5.) Self-criticizing
Don’t spend half the video apologizing for your mistakes or making excuses for the poor quality of you video.
“I’m sorry. I can’t believe I did that. How stupid of me. I’m half asleep. I have to work all day tomorrow. I hope to have another video out by tomorrow. Whoops I’m sorry for the delay. I’ve been busy.” These are not adding to the quality of your tutorial.
Do remove your mistake and talk briefly about some of the related pitfalls which others may experience.
Again, edit those mistakes out. They don’t add to your video. They subtract from it. They use up valuable time you could spend teaching. If you run into a problem with your code or whatever you are trying to teach, just edit it out and explain that it happened and you removed it. Then touch on some of the problems others may have. It’s pretty simple
6.) Knowledge of the material
Don’t teach something that you barely grasp yourself.
I’ve seen Java tutorial videos from people who didn’t fully understand the definition of class and object. It’s also common that they don’t know what the keywords static and final actually do. If you don’t have a clear understanding of object-oriented programming, don’t attempt to explain it. You’ll only confuse your viewers even further.
Do make sure that you know your stuff!
If at any point in your video you say something along the lines of, “It’s pretty complicated, but basically it’s…” If you can’t explain something in simple terms, you probably shouldn’t even mention it, because you honestly don’t understand it yourself. At least look up definitions for the words you are using.
7.) Ending the video
Don’t spend the last five minutes of the video saying bye to your viewers.
This one is very important. Going on and on about when your next video is going to come out or asking everyone to like your video and leave comments are just a few things that drive me nuts at the end of videos.
Do give a 10 second or less closing.
Tell everyone thanks for viewing, and quickly tell them what the next video will cover. You may even squeeze in something about what was learned in the current video. Either way, keep it short, sweet, and to the point. Don’t ramble. It’s very unprofessional.
8.) Low resolution and zooming
Don’t record a 1080p display and keep it zoomed to the full screen size the entire time.
This is especially true with coding tutorials. If I’m required to play back the video at 1080p just to make out the text you are typing, then I’m going to pass up you video.
Do use recording software that allows you to zoom in and out during the editing process.
Zoom in and out based on what the viewer needs to see. If you are typing something, make sure the editor is zoomed in so your viewers can see the text. If the viewer ever needs to see the full screen, then that is the time to show it to them. Any other time, zoom and pan.
9.) Swearing
Don’t use swear words.
Cussing adds nothing to the video. It only removes some of your credibility.
Do remove and try to refrain from cussing.
Tutorial videos should focus on learning/teaching a skill. Being profession adds credibility to your video. Cussing is one of the most unprofessional things you can do in a video. I’m not someone who’s against cussing. I just think that it’s better to edit out any swear words to keep everything professional.
Starting a Diet
I’ve decided to start trying to lose weight. I’m around 240lbs which is very overweight for someone 5’9″. I’ve set a few goals for myself and today I started on my trip toward those goals. I’m going to detail my journey on my personal website, but I’m going to have to build that site first. So I’m going to post my first few entries here. I’ll link to the other site once I have it up in a few days.
My ultimate goal is to get below 160lbs. That’s quite a trip from 240. So my first goal is to get below 200lbs. I’ve set that goal for 3 months. I may be able to get there faster, but that’s my conservative time frame. To reach this first goal, I’m cutting my calorie intake down to 1200 per day. I estimate that my current calorie intake is around 3000 calories per day. At that rate, I have stayed at 240 for around two years. So it’s safe to say that my body currently burns around 3000 calories per day.
It won’t stay at 3000 calories per day because as I lose weight my body will stop burning so many calories, unless I increase my daily activity. Since I’m lazy and overweight, exercise isn’t something I’ll focus on at first. I have to drop my weight through diet so that I’ll feel more comfortable exercising and increasing my general daily activities.
Looking at my current diet, I can find quick ways to reduce my calorie intake. One thing that instantly comes to mind is to remove my soda intake and replace it with water. The problem with that is that water gives me intense heartburn for some reason. I think this is mainly do to my current diet, and I’ll be compensating for this at first using heartburn medication. I’ll also be drinking milk or juice a couple times per day. When counting calories, it’s important to remember your drink calorie intake as well. A glass of whole milk is around 140 calories. Even skim milk is over 100 calories per glass. A glass of orange juice is around 110.
Which leads me to my 1200 calories per day. These calories have to be spaced out in such a way to keep me from getting hungry. I also have to incorporate low-calorie filling foods. So my plan thus far is to eat 6 meals per day each at an average of 200 calories. So when I drink orange juice or milk, I’m only left with 100 calories for the actual food. I’m using oatmeal to help with this. Oatmeal is around 10 calories per table spoon. In meals where I will be drinking milk or juice, I will be eating 4 tablespoons of oatmeal with a small pinch of sugar or honey…a very small pinch. This will give me at most 50 calories for the food and 110 calories for the drink. I’m eating once every three hours starting with when I wake up.
For example my schedule for today is (I woke up at 2am):
2am: Milk(110 cal) + Oatmeal (no sugar, 3 tablespoons – 30 cal) = 140 calories
I missed my 5am schedule because I was grocery shopping for low calorie foods, but I ate and changed my schedule when I got back home.
6:20am: Tuna (70 cal), Mayo(one teaspoon for flavor in tuna – 45 cal), saltines(60 cal) = 175 calories
So far, I’m at 315 calories for the day. I have four more meals scheduled:
8:00am: Orange juice(110 cal), Blueberries(1/2 cup – 40 cal), Oatmeal (with dash of sugar – 50 cal) = 200 calories
9:00am: Gelatin Snack = 39 calories
11:00am: Low calorie frozen dinner = 220 calories
1pm: Milk (110 cal), Soup (chicken noodle homestyle = 88 cal) = 198 calories
3pm: Gelatin Snack(39 cal), Tuna (70 cal), Mayo (45 cal), saltines (60 cal) = 214 calories
That will be my final meal of the day, and it will bring my total calories for the day to 1186. I hope that I can make the stretch between 3 and 6pm without getting hungry. I’m going to try to go to sleep around 6pm. I may move the gelatin snack from 3pm to 5pm. That may help. For now, I’m off to get my OJ and oatmeal going. After I eat, I’ll be working on my calorie counting site. I’ll make another post about it in a bit.
My first Electronic Composition
I’ve been getting into chiptunes and other electronic music lately. So, I thought I’d try my hand at some electronic music. Check out my Warm Up Song.
Force user to login method in Codeigniter without checking Session in every method.
Posted by Randy in PHP, Programming on July 20, 2013
If you need to secure every method of a Codeigniter controller, you can do it with one line instead of checking the session in every method before doing anything else. In the constructor of the controller simply check that $this->router->fetch_method is not equal to your login method and that a user isn’t logged in. If you meet both of these criteria, redirect to the login method.
Emerson Portable Ice Maker Doesn’t Work – Possible fix!
We bought an Emerson Ice maker about two years ago because the built-in ice maker in our freezer stopped working, and I’m a huge consumer of ice. So, I wanted a dedicated ice maker. It worked well for a few months. Then it decided that it didn’t want to make ice. I should have sent it back but I decided to tear it apart and try to fix it. I wasn’t able to really get anywhere with it. So, I put it back together and plugged it back up and miraculously enough it started working again. If you ever find yourself dealing with appliance mishaps, a good sense of humor can be a remedy. Consider exploring gag gifts for some lighthearted moments amidst technical challenges.
Since then, I discovered why it was failing to make ice. I post this because there may be someone else out there with the same problem from their Emerson Ice Maker.
The problem I have stems from the 120mm exhaust fan used in this device. I’m no expert on refrigeration, but I think this fan has to be running in order for the thing to make ice correct. It puts out a lot of heat. With my very basic knowledge of thermal dynamics, I’m assuming that this is how the ice is made. It removes the heat, thus reducing temperature and creating ice.
This fan is the exact fan used in a lot of computers. So if it isn’t running, you may need to replace it. However, I took a shortcut that seems to have worked, a little trick I’ve learned from working on computers. You can give it a try if you want. It’s pretty simple.
The fan has a sticker in the center. This should have some sort of logo on it, but it also has a second purpose. It holds a little rubber cap in place. Under that cap are the bearings for the fan. If you oil the bearings and replace this sticker, the fan may start to work again. You can get to the fan by removing the cover. I won’t go into details here how to do that, because I don’t have enough time to write the detailed instructions. It’s pretty easy to do. In my case the fan grill was almost broken completely out. So, I just finished it off for easy access to the fan.
“What can you use to oil the bearings”, you may ask. I used baby oil, because it’s basically mineral oil with a little fragrance. You can use mineral oil and there are some actual products that are made for greasing fan bearings. There are a ton of videos on Youtube on how to do this to a regular computer fan.
I hope this helps. If it does, leave a comment! I like to hear when I help.