Category: Programming

I’ve been doing web development for ages and still do not really “know” regex. I think there are many in this camp, so I wanted to show you how I handle situations when I need to do something with regex.

I spent about 3 hours this morning trying to figure out what happened to my Shopify App. It is June 1st, 2016, which is sugnificant because now that I know what happened, apparently Shopify has changed how they want you to authenticate your App. They have dropped the SIGNATURE parameter and want you to authenticate using a hashed HMAC.

This is something that has been on my “unsure” list for a long time. Partly because I haven’t really done my research on it and because, well, I just don’t require this very often. Finally, today I had a situation come up when I needed to ensure that the notes I am adding into the database are broken up with a line break between each note.

I know that there are these “\n” and “\r” or something like that but any time I’ve tried using them in the past it never worked consistently.

I am a web designer so naturally I do not follow standard website layouts… I love the Monarch social sharing plugin for WordPress, but I needed a way to add the inline sharing buttons to a custom sidebar that I’ve made. I searched high and low to find a way to do this using their settings but there is just no way to do it.

They have a shortcode for adding the Follow buttons anywhere you want but not the sharing buttons. I went ahead and added this capability by adding a few lines of code to their plugin. Here is how you do it.

1. Find the function named “display_inline” in monarch.php file and right after this function closes, add this function:

This is a quick tutorial or a note on how to make your tabs content display instantly on-click, rather than have to reload the page and send them to a new page. This is really simple and not formatted but illustrates the concept, plus I just wrote it up for one of my friends so it’s perfect to post here for everyone else.

Now take a look at it, you have the navigation at the top, notice the href is using JavaScript to void out the redirect and instead initiating a JavaScript function using the onclick parameter. Each link is passing it’s div id value to the function so it knows which DIV to display.

Second, we have the divs that are holding the content for each of the tabs. Only the main div is set to be visible using style=”display:block;”, the others are set to none, so they are hidden until their tab is clicked.

Thirdly, the JavaScript function. It listens for a call with a value and as soon as it receives that value, it hides all the divs and then only displays the one that has the value that was passed to it.

That’s is. This is a basic concept of a JavaScript instant tabs content displaying… or whatever you would call this.

Do you have a better, or a different way of doing this? I’d love to see it. Please add it in the comments.

These are some handy queries you will need when building Facebook Apps. As I work on Facebook stuff building out FanPageEngine tool and building various Facebook Apps, I spend hours figuring this stuff out so I don’t want it to vanish after I use it. Bookmark this page. I will be adding more and more to it as I find new nuggets of useful code.

Once you have the place holder image, now we just need to code it in. First I will tell you how I do it and then I will show you. Maybe it’ll be easier to grasp this way.

First I create two DIVs, one will hold the placeholder image and the other will be where the video will go. I do not directly paste the video embed code into this second DIV but instead I have javaScript insert it in there when someone clicks the image. The reason is because we want the video to be set to autoplay but if we stick it in the DIV when the page loads, it will start playing right away in some browsers. So we leave that second DIV empty until someone clicks the placeholder image.

The image DIV has a onclick function call that will engage the function that swaps everything. It will first hide the placeholder image DIV and then insert the video embed code into the video VID and then will make this DIV visible.

I just wanted to make some notes on this new project for mine while I work on it. I am trying to build an iPhone App for my bookkeeping website Cakeio.com. This would be my first iPhone app, so some stuff may take a while to figure out. So far I got the login part working. The app connects to a PHP file on the server and checks the username and password.

The PHP/MySQL

So to start, I created a php script on my server that checks the login info and responds with a Yes or a No.

Then in the Xcode I created a new View-Based Application project. Before I did anything I loaded up some extra files into the Classes directory. The ones we need is the ASIHTTPRequest and SBJson files. First lets take a look at the ASIHTTPRequest.

Header Search Paths

I had an issue with Xcode trying to include a libxml source by that name but on my Mac I have it named libxml2 so it could not find it. To fix that I went to Xcode at the top tool bar and clicked Preferences. There click the Source Tree tab and add a new setting by clicking the + button at bottom left. There add this:

Setting Name: HEADER_SEARCH_PATHS
Path: /usr/include/libxml2

This might not be the same for you, so use your Terminal and cd over to /usr/include and see if you have a libxml or libxml2… maybe even some other one, so set it to whatever you have there.

ViewController.h

Ok, here is the fun part, here is what I did in the ViewController.h file:

ViewController.xib

In the ViewController.xib file I added 2 text fields and a button, then Ctr+Dragged From File’s Owner box to each text box and assigned each the appropriate textfield variable. Then I Ctr+Dragged from the Button to the File’s Owner box and assigned the btnClicked event to it.

That’s that, save and Command+R it to see if it worked. I also open up the Debugger window by doing Command+Shift+R.

It’s never been done before, no geek has gone this far as to plank within the source code. Beat that my geekstas! After seeing David plank in his video I was curious what that was all about. I mean I’ve heard of planking before but never really cared enough to find out more about it as it looked, frankly, pretty stupid.

After Googling it I find out that this “game” has been in effect since 1997, it has simple rules, lay face down, hands and feet straight, in the most unusual place. This thing’s been moving across the globe and it just now has reached me. Although, if I have not came up with this awesome place to plank, I would have probably just let this thing pass right by but this genius idea has stricken me and so there you go.

There should probably be a t-shirt out there somewhere that says “I’ve planked” or some kind of award like that. lol.

If you’ve read the previous post I did, Tutorial on how to add HTML to facebook, you probably know now how to get your custom HTML into a facebook page. Once you do, you might see a slight problem, your page may be miss-aligned and may have scroll bars. This happens if your images or DIVs are bigger than 520 pixels wide. Sometimes your elements would be 520 pixels wide and it would still have scroll bars and look all messed up, this might also be because you may have a border on the outer DIV or an image. If you’ve checked everything and it is all within the 520 pixel width but the scroll bars are not going away, you may be in the category of pages which just do not play well with the iFrame and to remedy this I”ve been using some CSS and JavaScript to move things into place and get rid of the scroll bars.

UPDATE: Also try doing it this way, I am told things have changed since I wrote this post.

Now this is still not a guarantee that it’ll be perfect, there are a few bugs with auto-size function on facebook, so here is another piece of code to replace the first Facebook auto-size JavaScript code, it is an older and my own hacking of the code but it works on some of my pages.

And then add this at the very bottom before the closing BODY tag replacing the previous code:

<script language="javaScript">
sizeChangeCallback();
</script>

The problem with getting this auto size thing to work has been going on over a year now and Facebook has still yet to fix this issue once and for all… There are so many fixes out on the web but none of them work every time. You just about have to try different things until you find the one that works for you. In fact, I am working on a page right now that I can not, for the life of me, get to resize. I’ve tried all the hacks and nothing fixes it permanently. It’ll work one time and then you refresh and it puts the scroll bars back in.

Another thing that may work is resizing everything to 518px in width and sometimes even to 510px to get it to work.

Also you can specify a static length for the page to do away with the scroll bars but then you have to know how tall your page will be. Dynamic content will not work with this if it changes the height of the page.