Adding Adverts

Those of you that know me will know that I like to do a bit of blogging.

Having no income other than benefits means that even small costs such as my annual domain fees make me wince.  Every penny possible has to be saved.  But I really don’t want to stop any of my blogs – in fact I have started more up since I lost my job!

I used to do all my blogging on Blogger, prior to learning coding.  No particular reason other than it was what I first heard of.

New blogs I set up with WordPress, as it gives me pretty much infinite possibilities in being able to expand with my coding skills.  A few I still do on Facebook only – such as my Political Betting page.  Said page will be moved onto WordPress in the coming month or two, with a newly developed theme from myself.  Only just passed the thought stage – nowhere near pencil and paper stage.

The reason I set that particular page up originally was to see if I could make any money from gambling commission – all the major bookmakers offer affiliate accounts.  With 40 page likes and an average reach of around 10, I am hardly going to be buying a private jet any time soon.  Not even an airfix model.  So far I have a grand total of £20.43 and $6.05 commission.

So my bright idea this week was to add adverts to my 6 WordPress blogs.

I am sure I could have done this simply by using a plug-in, but I decided instead to use my WordPress knowledge.

Firstly I created a child theme for each blog, with a new stylesheet and a new functions file.  I knew how to make a child theme, or at least the theory of it, but had never done so.  This is now quite firmly planted into my knowledge bank.

I enqueued the stylesheet in the functions file – all straight forward.

add_action( ‘wp_enqueue_scripts’, ‘enqueue_parent_styles’ );

function enqueue_parent_styles() {
wp_enqueue_style( ‘gridster-lite’, get_template_directory_uri().’/style.css’ );
}

Then I had to create and register my custom post-types, following this with an initiation action.

Something that became clear in the planning stages after looking at how the adverts themselves were encoded, was that I would need two custom post-types – one main advert, and one mobile-sized advert.

function my_custom_posttypes() {

$labels = array(
‘name’ => ‘Adverts’,
‘singular_name’ => ‘Advert’,
‘menu_name’ => ‘Adverts’,
‘name_admin_bar’ => ‘Advert’,
‘add_new’ => ‘Add New’,
‘add_new_item’ => ‘Add New Advert’,
‘new_item’ => ‘New Advert’,
‘edit_item’ => ‘Edit Advert’,
‘view_item’ => ‘View Advert’,
‘all_items’ => ‘All Adverts’,
‘search_items’ => ‘Search Adverts’,
‘parent_item_colon’ => ‘Parent Adverts:’,
‘not_found’ => ‘No advert sites found.’,
‘not_found_in_trash’ => ‘No advert sites found in Trash.’,
);

$args = array(
‘labels’ => $labels,
‘public’ => true,
‘publicly_queryable’ => true,
‘show_ui’ => true,
‘show_in_menu’ => true,
‘menu_icon’ => ‘dashicons-id-alt’,
‘query_var’ => true,
‘rewrite’ => array( ‘slug’ => ‘adverts’ ),
‘capability_type’ => ‘post’,
‘has_archive’ => true,
‘hierarchical’ => false,
‘menu_position’ => 5,
‘supports’ => array( ‘title’, ‘editor’, ‘thumbnail’ ),
);
register_post_type(‘adverts’, $args);

$labels = array(
‘name’ => ‘Adverts Mobile’,
‘singular_name’ => ‘Advert Mobile’,
‘menu_name’ => ‘Adverts Mobile’,
‘name_admin_bar’ => ‘Advert Mobile’,
‘add_new’ => ‘Add New’,
‘add_new_item’ => ‘Add New Advert Mobile’,
‘new_item’ => ‘New Advert Mobile’,
‘edit_item’ => ‘Edit Advert Mobile’,
‘view_item’ => ‘View Advert Mobile’,
‘all_items’ => ‘All Adverts Mobile’,
‘search_items’ => ‘Search Adverts Mobile’,
‘parent_item_colon’ => ‘Parent Adverts Mobile:’,
‘not_found’ => ‘No advert mobile sites found.’,
‘not_found_in_trash’ => ‘No advert mobile sites found in Trash.’,
);

$args = array(
‘labels’ => $labels,
‘public’ => true,
‘publicly_queryable’ => true,
‘show_ui’ => true,
‘show_in_menu’ => true,
‘menu_icon’ => ‘dashicons-id-alt’,
‘query_var’ => true,
‘rewrite’ => array( ‘slug’ => ‘adverts-mobile’ ),
‘capability_type’ => ‘post’,
‘has_archive’ => true,
‘hierarchical’ => false,
‘menu_position’ => 5,
‘supports’ => array( ‘title’, ‘editor’, ‘thumbnail’ ),
);
register_post_type(‘adverts-mobile’, $args);

}

add_action(‘init’, ‘my_custom_posttypes’);

A simple media query ensured that only the mobile one would show at screen widths of less than 1200 pixels, only the desktop advert would show on screen widths of 1200px or more.

@media screen and (min-width:1200px) {
.advert.advert-mobile {
display: none;
}

}

@media screen and (max-width:1199px) {
.advert-main {
display: none;
}
}

The painful part was going through all the affiliate accounts and trying to find appropriate adverts to use – problems abound whether that be one company only having Italian adverts when I searched for English, other companies not having filtering options so I’d have to trawl through to find ones with the right size.  And some god-awful adverts too.  Not to mention spending a good 30 minutes or so trying to work out why they weren’t showing on my website – that’ll be Adblock then.

I think they look quite smart.

saqwer

The final part was having to fit them into the particular pages.  Mostly a straight forward case of finding the section after the navigation and before the have_posts loop starts, in the single, page and index pages.

It consisted of two while loops – one for the desktop advert and the other for the mobile advert custom post type, showing just 1 post (advert) per page, and an orderby type of ‘rand’ so that a different one would be shown each time.  I left a couple of divs in there with different classes in case I want to expand or slightly amend the styling at a later date – though now I think about it I wish I have written it as an include, that would have been more sensible.  Job for tomorrow, then.

<?php

$args = array(
‘post_type’ => ‘adverts’,
‘posts_per_page’ => 1,
‘orderby’ => ‘rand’
);

$adverts = new WP_Query( $args );

while ( $adverts->have_posts() ) : $adverts->the_post();?>

<div class=”advert advert-main”>

<div class=”flex-site-title”><?php the_content() ?></div>

</div>

<?php endwhile;

$args = array(
‘post_type’ => ‘adverts-mobile’,
‘posts_per_page’ => 1,
‘orderby’ => ‘rand’
);

$advertsmobile = new WP_Query( $args );

while ( $advertsmobile->have_posts() ) : $advertsmobile->the_post();?>

<div class=”advert advert-mobile”>

<div class=”flex-site-title”><?php the_content() ?></div>

</div>

<?php endwhile;?>

I am going to look into some more interesting affiliate accounts than just gambling ones.  Perhaps clothing, or music – especially for my music-related blogs.  Then again hardly anyone will see them as they use adblockers like me!

It was a good little task to get myself back into the swing of things after my interview disappointment this week and tomorrow I can get back on with some real coding.

Interview Outcomes

I had a flurry of excitement last week with phone interviews, e-mails, applications etc eventually leading to two interviews.

The second interview was for a job that I didn’t remember applying for, wasn’t on my spreadsheet and replied to my unprofessional personal e-mail address (jamesthemonkeh) for which I rarely use.  Apparently my CV was “…selected, from hundreds submitted, to go through to the next phase”.  Hundreds?  My arse.  But I went along with it anyway, had a good telephone interview and a proper interview two days later.

I never received the e-mail confirmation about the interview, but I still turned up, albeit at the wrong entrance, and with plasters falling off my hand having cut my hand open in three places the night before doing the washing up…two hours of bleeding…not pleasant especially when I needed a good night’s sleep.

There was a good connection between myself and the three that I met though the interview itself was only 45 minutes long, and that included a 15 minute test.  They clearly had decided in advance and were going through the motions, though my ego concluded that meant I was in a good position to be offered the role.  I glossed over the suspicion that something wasn’t quite right because I wanted a job.  I want to progress.  I want to contribute.

Thinking back, I stumbled when they asked me to explain why I thought I had intermediate JavaScript knowledge.  I bluffed my way through.  And then there was a question asking why I would describe myself as “creative” – something I have put on my CV header.  Why on earth have I described myself as “creative”?  That was what I immediately thought and had to bluff my way again.  Other questions I answered well and received positive responses.

The first interview was for the job at a green energy company.  I had a good feeling about it from the off, spent a good 5-6 hours on the coding challenge (I will probably upload it to my portfolio, once I change company details) and had a good interview.  Admittedly I turned up 30 minutes early to the interview but I thought that I had performed well and was in with a chance.  It was clear that he was probably interviewing around 10-12 people and had even more applications.

There was lots of good feedback about my coding challenge, in fact he said it was the closest to the design spec out of all of them.  Though there were a few buts.

I came away thinking there was a chance I would get offered both.  The problem in my head was what would I do if I got offered the one I was less keen on before the one I was really keen on?  I don’t like to mess people around, even though I know companies normally won’t hesitate to do the same to me.  I have decency standards.

Neither job was offered to me.

The one that sounded a bit odd, simply said “Thank you for taking the time to come in to **our company**. It was great to meet with you.  Unfortunately, we will not be taking your application further.”.

I asked for further feedback on what I could do to improve but they did not even have the courtesy to refuse to do so.  My ego took a battering as I thought I was a shoe-in, but in time I suspect I will be pleased not to have ended up there.  Something really was not right about it.

The second one I did get constructive feedback.  During the interview, I received specific advice on my code which will be beneficial – a couple of new ways of looking at what I do.  He also advised me to learn Sass, Grunt and Gulp before learning React.

Further to that, the feedback was “I’m really sorry to say that we won’t be inviting you to a second interview this time. It was incredibly close, and you had a really strong interview, it just came down to others having slightly more experience with JavaScript and having a bit of a firmer grasp on Front-end technologies like responsive design and pre-processing.

I really respect your passion and the level you’ve achieved through self-teaching, and I believe that with a little more time learning you will become a web developer.”.

Which is like your football club reaching the semi-final of the FA Cup.  A pretty damn good achievement but there is no reward except for the experience and a bit of kudos.

That I came assumedly 3rd or 4th out of roughly 10-12 interviewees doesn’t feel particularly great now, especially being quite drunk, and after receiving some unrelated pretty damn shit news today too.  It’s been a bad week and a very, very bad day.

I think the main lesson is to keep my ego in check.  Manage my expectations better.

Needless to say, I have not done anything constructive for the last two days and will not do anything tomorrow as I am going to have a fair-sized hangover.

I do have a coding challenge for another role, but it is in PHP which I don’t know so well so probably pointless in trying but I shall hopefully get over my disappointment in time for the deadline.  No harm in trying even though I doubt I’ll get an interview.

Down but not out.

January Is JavaScript Month

Yeah I know, it’s the 9th January already.  I’ve been busy.  First there was New Year’s Eve, then there was a hangover, it was a bad hangover, a long hangover, followed by a cold.  Excuses, excuses.

Actually I have been busy.  Most of last week was spent on telephone interviews, actual interviews, travelling (including the waste of time that my weekly job centre visit is “have you thought about doing any courses for your IT”…yeah thanks for the jobseeking advice) and the required preparation.

There might be another post assessing my interviews – there is certainly a half-decent chance that I will be offered one of the roles that I went for.  For now, I want to set out my plan for January.

I am just finishing the final PHP course that I set myself for December.  It will be finished by time I finish this post.

It really was a step forwards from the “essential” course that I did, introducing classes and Object Orientated Programming (OOP) – though I already understood the structure and idea around OOP from my JavaScript learning.

Whilst it makes sense in my head, using it will be another matter altogether, but I do have one PHP-related project that I would like to try out at some point, and one or two small ideas to use elsewhere.  Learning is one thing, and I do go through and code everything in the video, testing and debugging along the way.  But I know that I will only really start to master it once I have a project or two on the go.

I might still need some advice on how to structure my SQL tables – though I have a very good friend who is very good at PHP that is nagging me to do a PHP project so I know where to go for advice. Hopefully it has given me enough of a grounding in PHP to be able to get my payment system working for my weather forecasting page.  Another one “on the list”.

I Need A Weather Forecast

Further to that I have not been able to get SMTP mailing to work through phpmailer.  I’ve given up for now in trying to figure it out.  But I will figure it out – I always do eventually.

When it comes to PHP, I guess the next step on my learning path is to try to work out MVC architecture.

But PHP is taking a break as for the rest of January I am going to be concentrating on improving my JavaScript abilities.

The first part of my main plan is to complete the JavaScript 30 course, which is a collection of 30 tutorials to create real-world applications in JavaScript – things like making a clock, text shadow mouse move effects and a whack-a-mole game.  I am going to expand at least a couple of them – especially the whack-a-mole game for which I have quite a few ideas for.

The second main part is to continue with the Free Code Camp syllabus – I have around 20 algorithm challenges to do, such as Sum All Primes, then 4 advanced projects to do, including making my own calculator and a tic-tac-toe game (I haven’t got the foggiest how to attempt that!  15 minutes later I do have some ideas on how that might work…the AI, of course being the hardest part to tackle).

I doubt I will get all of that done.  In fact, I will not complete it all.  A vague estimate would be that would take 300 hours to do and I don’t need an algorithm to work out that I wouldn’t have enough time before the end of the month to complete this.

Of course, my time available also depends on whether I get offered a job.  I’d like to think that I will employed soon.  Although I am coping ok with the 8am starts.

 

To break it up I might start learning React too.  There is a course on Codecademy which looks like the perfect way to start learning it.  Knowing React is probably the one thing that would really make me stand out as a potential employee.

Christmas Coding Break

I had every intention coming up to Christmas to keep coding right through it.  Travelling back up north, I only had a surface with me – with no desk or anything suitable at my parent’s home to make it comfortable.

Once I got there, I decided to actually have a break.  A few days with no code.  In fact, I tried my hardest not to use my surface at all – bar weather models and some sale shopping, I stayed away.

It did me some good.  I felt a renewed vigour and focus when I sat down at 9am the morning after I got back to London to get cracking on finishing the PHP with MySQL Essential Training course on Lynda.

Some of the course went over the basics that I already knew, which was fine for a reminder and I picked up one or two tips.  Where the most learning was achieved was from the chapters on working with MySQL – I know SQL reasonably well in terms of structuring data requests, SELECT, INPUT, DELETE yadda yadda, but what I had no idea of was how to actually use it, and also how to structure it within PHP.

The course took me through building my own Content Management System, the four basic functions of data storage – CRUD, and login systems, including theories around hashing passwords.

I still have some questions though, especially with regards as how to best structure tables within databases, so I shall be looking to expand my knowledge further.  The next course I’m planning on starting tomorrow morning, at no later than 9am, is PHP with MySQL Beyond the Basics – pretty much the follow-up, by the same author – only 10 and a half hours of video this time, which could easily turn to double once I have re-coded it all myself and convinced myself that I have enough of an understanding to move on.

No later than 9am as I have a new structure.  I was studying much of the day anyway but getting distracted a bit too much.  I have set myself a 9am to 6pm workday, working in chunks of 45 minutes followed with a 15 minute break, until 4pm at which point I’m working in 30 minute chunks followed by a 15 minute break.  I shall also be allowing myself every Sunday off – to recharge and do whatever the heck I want.  Within the bounds of my strict unemployed budget, of course.

Hopefully I won’t be unemployed for too much longer.  I am doing what I can in terms of applying for every role that looks like I am suited for, and that looks at least vaguely interesting.  I’ve had four telephone interviews over the last week – one I know I won’t get, perhaps two, but one has led to an interview this Friday.  A very interesting role and very interesting company (of course I would say that just in case they are reading!).

Importantly, I also have an interview tomorrow for the job that I did the coding challenge for.  I was really happy with what I did, albeit knowing there were one or two areas that I didn’t have the time to put into it, and it seems my interviewer was impressed too.

I’ve had a good feeling about this one right from when I sent the application, for some reason.  Of course, I may be up against more suitable or more experienced candidates – who knows.  My Dad told me not to get my hopes up but balls to that – I have my hopes up.  I may be a realist but I’m generally an optimist too.

And there are other jobs that I have applied for directly (ie not through those blinking job sites…I could do a whole post just on my frustrations with those) that I think I have a good chance of hearing back from.  Lots going on.

I have always believed that I am a very employable junior web developer, more so by the day, and if I don’t do myself justice in the upcoming interviews I shall be disappointed.  If I do well, it is certainly feasible, without wanting to be too arrogant, that I could be offered one of these roles.  The most important goal is to represent my abilities.

Time to get back on with things – having fun breaking a website that I am making.  All for good reason, just a fun little project.  It isn’t shit enough yet but it will be by the end of the week (apologies for the swearing dear future potential employer, I am affably polite to face, I occasionally swear in writing).  Must sort out those link colours on this blog too.

wqewe

Looks awful doesn’t it?  But not quite bad enough yet…