US continental shipping and Magento

A lot of websites in the US offer free ground shipping nowadays. However, most restrict to US continental. State-wise, this means all states except for Alaska an Hawaii. However, the US has a lot of protectorates that do not qualify as continental: American Samoa, all the “Armed Forces”, Micronesia, Guam, Marshall Islands, Mariana Islands, Palau, Puerto Rico, Virgin Islands.

That’s one way to look at it. The other is looking at the zip codes that are not qualified for free shipping. It looks like the continental USA is:

  • between 00900 and 96200 OR
  • between 97000 and 99500

Putting all this together as a set of conditions for a Magento shopping cart rule:

Screen Shot 2018-05-11 at 12.02.13

If you’re using Magento 1, here is the string you can paste in the salesrule table, conditions_serialized field:

 

a:7:{s:4:"type";s:32:"salesrule/rule_condition_combine";s:9:"attribute";N;s:8:"operator";N;s:5:"value";s:1:"1";s:18:"is_value_processed";N;s:10:"aggregator";s:3:"all";s:10:"conditions";a:18:{i:0;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:10:"country_id";s:8:"operator";s:2:"==";s:5:"value";s:2:"US";s:18:"is_value_processed";b:0;}i:1;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"region_id";s:8:"operator";s:2:"!=";s:5:"value";s:1:"2";s:18:"is_value_processed";b:0;}i:2;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"region_id";s:8:"operator";s:2:"!=";s:5:"value";s:2:"21";s:18:"is_value_processed";b:0;}i:3;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"region_id";s:8:"operator";s:2:"!=";s:5:"value";s:1:"3";s:18:"is_value_processed";b:0;}i:4;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"region_id";s:8:"operator";s:2:"!=";s:5:"value";s:1:"6";s:18:"is_value_processed";b:0;}i:5;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"region_id";s:8:"operator";s:2:"!=";s:5:"value";s:1:"7";s:18:"is_value_processed";b:0;}i:6;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"region_id";s:8:"operator";s:2:"!=";s:5:"value";s:1:"8";s:18:"is_value_processed";b:0;}i:7;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"region_id";s:8:"operator";s:2:"!=";s:5:"value";s:1:"9";s:18:"is_value_processed";b:0;}i:8;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"region_id";s:8:"operator";s:2:"!=";s:5:"value";s:2:"10";s:18:"is_value_processed";b:0;}i:9;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"region_id";s:8:"operator";s:2:"!=";s:5:"value";s:2:"11";s:18:"is_value_processed";b:0;}i:10;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"region_id";s:8:"operator";s:2:"!=";s:5:"value";s:2:"17";s:18:"is_value_processed";b:0;}i:11;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"region_id";s:8:"operator";s:2:"!=";s:5:"value";s:2:"20";s:18:"is_value_processed";b:0;}i:12;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"region_id";s:8:"operator";s:2:"!=";s:5:"value";s:2:"30";s:18:"is_value_processed";b:0;}i:13;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"region_id";s:8:"operator";s:2:"!=";s:5:"value";s:2:"46";s:18:"is_value_processed";b:0;}i:14;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"region_id";s:8:"operator";s:2:"!=";s:5:"value";s:2:"50";s:18:"is_value_processed";b:0;}i:15;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"region_id";s:8:"operator";s:2:"!=";s:5:"value";s:2:"52";s:18:"is_value_processed";b:0;}i:16;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"region_id";s:8:"operator";s:2:"!=";s:5:"value";s:2:"60";s:18:"is_value_processed";b:0;}i:17;a:7:{s:4:"type";s:32:"salesrule/rule_condition_combine";s:9:"attribute";N;s:8:"operator";N;s:5:"value";s:1:"1";s:18:"is_value_processed";N;s:10:"aggregator";s:3:"any";s:10:"conditions";a:2:{i:0;a:7:{s:4:"type";s:32:"salesrule/rule_condition_combine";s:9:"attribute";N;s:8:"operator";N;s:5:"value";s:1:"1";s:18:"is_value_processed";N;s:10:"aggregator";s:3:"all";s:10:"conditions";a:2:{i:0;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:8:"postcode";s:8:"operator";s:1:">";s:5:"value";s:5:"00900";s:18:"is_value_processed";b:0;}i:1;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:8:"postcode";s:8:"operator";s:1:"<";s:5:"value";s:5:"96200";s:18:"is_value_processed";b:0;}}}i:1;a:7:{s:4:"type";s:32:"salesrule/rule_condition_combine";s:9:"attribute";N;s:8:"operator";N;s:5:"value";s:1:"1";s:18:"is_value_processed";N;s:10:"aggregator";s:3:"all";s:10:"conditions";a:2:{i:0;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:8:"postcode";s:8:"operator";s:2:">=";s:5:"value";s:5:"97000";s:18:"is_value_processed";b:0;}i:1;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:8:"postcode";s:8:"operator";s:1:"<";s:5:"value";s:5:"99500";s:18:"is_value_processed";b:0;}}}}}}}

 

I’m guessing all this changes and may not even be 100% accurate, but it’s the best I could find as far as “free continental shipping” goes.

State of remote working in 2018

I am working remotely for more than 5 years now and I hope I will continue doing so. My personal opinion is that remote work opportunities are stronger than ever. I compiled together a list of sources which I believe can land you remote gigs.

But first, a few assumptions…

  • The below refer to remote work opportunities for developers. I am not aware of the market for other specialisations.
  • I am assuming you are a senior developer and have skills that are somewhat in demand.
  • I considered sources that can get you to at least $50k a year, i.e. a decent living in most countries. But usually under $100k. It’s pretty hard to go over this if you are working remotely.

Upwork

https://www.upwork.com/ is probably the largest freelancer market in the world. It’s a jungle. 95% of the clients have unrealistic expectations. If you post a project, you get hundreds of applicants in minutes, most of them being fake profiles, accepting any conditions you ask for just so you award them the job.

However, if you manage to get over all the noise, you can land some well paid and interesting jobs. On top of that, anyone can join Upwork. Activate your account, put up a good looking profile and you’re good to go.

Here are a few tips to be efficient on Upwork

  • Do not bother with general job applications, search for the specific combination of skills that you have (i.e. Magento + WordPress + SEO). Once in a while, a client will need exactly that, you will be an awesome fit. Any Upwork search can be saved as a RSS feed, do so and wait for the jobs to come to you.
  • To get reputation, snipe for “Urgent” jobs, i.e. set your RSS feeds to “Urgent Magento”. There are a few number of users that break their sites and will take on the first developer that applies to the job. This assumes you are available to work right away. And most of the time, it implies only a few hours of work. Definitely not worth the money, but can help build up reputation quickly.

Even with a good reputation, you will still spend a lot of unbillable time searching for jobs. I’d advice to leave Upwork as the last resort to get work, but consider it nevertheless.

TopTal

https://www.toptal.com/ is a nice surprise. Similar to Upwork, they are a project/job market. However, they are curated. First, you have to go through a pretty hard interview process to get admitted. Then, they do the same with the clients. You will not find any “I need a website built for $100” requests on TopTal.

Then, TopTal only works hourly. Not sure about you, but I suck at estimates. 9 cases out of 10 I lose money in a fixed bid, so being able to work on hourly engagements is the best for me.

The best thing about them is that they have recruiters. Most of the time, a recruiter will ping you about a job that was posted and fits your skills. While you can definitely apply to jobs yourself, you can also sit tight and wait for the recruiters to find good matches for you.

They also try to build a community, there are a lot of events, both online and offline that can really help you grow professionally.

Crossover

https://www.crossover.com/ only does full-time jobs, so it is a bit different from the above. They also have pretty hard interview process. As a twist, they organise “hiring tournaments” in which you go, spend the day working on some challenges and can go home with a job.

They exaggerate a bit in that when they say a job is paid 200k per year, they actually mean you get the amount if you log 8h/day, which would mean at least 10-11 hours spent in office. And that you never take a vacation. So a job with them is probably paid 30% less than advertised, but that’s still a pretty sweet deal!

While I never worked with them directly, I heard from first-hand acquaintances that you get hired in a few weeks after passing the interview.

X-Team

https://x-team.com/ – similar to Crossover, they only offer full time jobs. You sign up with them and get to work as an addition to an existing dev team. Their interview is easier, in that you can showcase existing code instead of writing something new. If you get accepted, you tell them your rate, skills and desired start date and they will find something for you.

I never worked for them since I am not looking into a full-time job, but they contacted me a few times with opportunities so they look like an active community.

Stack Overflow

This is pretty simple – https://stackoverflow.com/jobs/remote-developer-jobs . Watch this list, apply to jobs that fit your skills.

LinkedIn

LinkedIn is usually fit for full-time in-office jobs. However, there are a few tricks here…

  • Add the word “freelancer” to your profile.
  • Make sure your profile emphasises your technical skills. Things like “I helped the company grow 10 times bigger” are good for corporations/non-dev roles.
  • Be prepared to get a lot of offers that are not remote. Responding with “Thanks, but I am not interested in an office job” is not too hard.
  • Wait. At some point you may get a remote opportunity. Personally I got a few clients form LinkedIn.

Direct

Know the companies that work remotely. GitHub, Automatic, Mozilla are just a few names that hire remotely. Get to know the ones that match your skill set. Watch their job listings. Get hired.

ROM Hacking – Battletoads

One of my preferred games as a kid was the NES version of Battletoads.  NES games are hard, but Battletoads was almost impossible. I remember I got pretty good at it, managed to get to level 10 or so. I thought I’d give it another chance, but this time over, I did not manage to get over level three. Since I barely have the time or the will to replay a game hundreds of times, I decided to get into ROM hacking, see if I can make my own cheats and finish the game.

While there are many emulators out there, it seems that the best tool if you are into ROM hacking/modding is http://www.fceux.com/ . The nice twist is that the emulator can load Lua scripts that allow you to manipulate the game. You launch Fceux (via wine if not a Windows user), load the ROM and load your scripts. My “IDE” for the day looks like this:

Our dev env....png

Now, for the “Hello World” script:

while true do
 emu.message('Hello World!') 
 emu.frameadvance() 
end

The principle is pretty simple. The script is a while loop. You add your code, then call emu.frameadvance() to pass control to the emulator and render the next frame. The code above simply displays “Hello World” on the screen all the time:

hello-world

Let’s do something interesting. ROM hacking is about finding where in the memory a value is stored (i.e. number of lifes)  and changing it. Here is someone hacking Mario:

8nnzb_feir-jw_drgzdj_ir9vntk4rrpdjjzlbidrx2lmw1bng-ktcw_kedilyqmrdfdfptswbddyefak8whnfa8xdgwzcsgymvs8rgszi7cg6n_anvcp0j6mjznjpzgv1cy4m

This guy makes it look easy. The truth is that you can spend countless hours trying to look for a certain value. In the end, you have a memory address that you can change. For Battletoads, I got a bit lucky as someone already found some useful addresses – http://www.thealmightyguru.com/Games/Hacking/Wiki/index.php?title=Battletoads

So, to add infinite lives, it looks like I need to put in 05 in the 0011 address. My Lua cheat can simply be:

memory.writebyte(0x0011, 0x05)

That might work for a normal game, but Battletoads is incredibly hard. Having infinite lives is not enough. In most levels, when you die you restart from a checkpoint, having to redo part of the level, which can be very frustrating.

Another cheat caught my eye – invulnerability. Since I cannot be killed, I don’t have to restart from a checkpoint. Our lua script can now become:

-- infinte lives
memory.writebyte(0x0011, 0x05)
-- invulnerability
memory.writebyte(0x0574, 0x7E)

My joy was very short lived. About half way through level 1, I met one enemy that won’t attack me:

wont-go down

The flying monster won’t come down and is to high up to be hit, so I cannot progress further. I guess somewhere in the game logic this enemy does not attack you until it can see you. And since I am invulnerable, it cannot see me. What I need at this point is a way to enable/disable the invisibility/invulnerability. Pressing the “select” button would do, as I don’t use it for anything. Ended up with this hackish script:

--infinte lifes. Can be called once at the start
memory.writebyte(0x0011, 0x05)

invisibility_enabled = false
while true do
  jp = joypad.read(1)
  if(jp.select) then
    invisibility_enabled = not invisibility_enabled
  end

  if invisibility_enabled then
    memory.writebyte(0x0574, 0x7F)
  else
    memory.writebyte(0x0574, 0x00) 
  end

  emu.message(tostring(invisibility_enabled))
  emu.frameadvance() 

end

Roughly, for each game cycle I am checking whether the select button was pressed. If so, I toggle the invisibility. I also display it on the screen (as true/false) so I keep track of the status.

This got me over level 1 easily. However, I realised that being invincible breaks the game easily. You can fall over the edges of the level or end up in places you cannot get out of. I guess that’s the reward for cheating. You can of course restart the game, but playing again through a number of levels does not sound fun. Luckly, it looks like there is a cheat to start from a specific level. You just add the level number at the 8320 memory location. However, this one needs to be timed to happen somewhere between pressing start on the main screen and starting level 1. While I guess there is a way to do it in the Lua script, I discovered a quick solution via Game Genie. Game Genie was an interesting device, better explained here . Roughly, this device would stay between your NES console and the ROM cartridge, sniff on all communication, look for specific memory address and change the values on the fly, allowing you to do short modifications, like infinite lives.

Fceux also “emulates” Game Genie, allowing you to generate codes. At Debugger > Game Genie Decoder/Encoder, you can transform an address/value/cmp into a genie code. Still from http://www.thealmightyguru.com/Games/Hacking/Wiki/index.php?title=Battletoads , I was able to generate a genie code that would allow me to start from any level. It is a bit manual, i.e. I have to regen the code if I want a different level, but it works fine. Overall, the game genie is a lot simpler to use than the Lua scripts, but also a lot more limited.

With all this in place, I was able to have infinite lives, toggle invisibility and start the game from any level. However, even with all this in place, the game was still very hard. While some levels, like the cave or the hole were extremely easy, there were others, like the snake pit, where you had the same hardcore NES experience. Using the invisibility was impossible since every wrong turn would send you in an unplayable state. Not using it would result in restarting the game tens or hundreds of times from the same checkpoint. In the end, I decided to watch a YouTube speed run and concentrate on easier games.

Thoughts on the Magento 2 Certified Professional exam

On March 1st 2018, the new Magento 2 Certified Professional Developer exam became available. Wanting to keep the tradition of getting my certifications early, I have attempted and passed the exam.

The exam experience is nice and easy as usual. You buy a voucher from https://u.magento.com/magento-2-certified-professional-developer#.WrtdjdNuZsY , then you can schedule an exam at a certified center. The exam has 60 multiple choice questions, a 90 minutes time limit and you get your results on the spot. It’s also possible to take the exam online, did not try it myself but Andreas did a nice write-up on this.

The exam is aimed at developers with about 1.5 years of experience with Magento 2. My opinion is that in order to pass you need to:

  • Have at least one full year of experience writing Magento 2 code.
  • Had the occasion to customize most of the Magento 2 areas, with a focus on backend
  • Are aware of the Magento best practices and apply them through your projects

Compared to the Magento 1 exam, this time a lot more value is put on proposing the correct architecture for a change. A fair number of questions is about doing things “the right way”. Sometimes solutions that work but are not correct are presented and you are expected to choose the ones that respect the best practices.

You can get away with very little CSS and JS knowledge (I guess a fronted developer certification will be coming out soon), but you are expected to know how to setup a theme, how to override templates or how to configure the ui components.

Besides the official guides, I encourage you reading the study guide and attempting the test exam from Swift Otter. The test exam is realistic, although I think it is a bit easier than the real thing. Personally I would have not passed without their guide. Other than that, having one year of hands-on Magento 2 experience is the only way to pass, no courses/magic formula to make up for it.

Overall, I consider this the best Magento 2 exam to date. More than ever, answering the questions correctly proves that you have experience with the platform and can deliver elegant solutions.