<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rich Barrett on Medium]]></title>
        <description><![CDATA[Stories by Rich Barrett on Medium]]></description>
        <link>https://medium.com/@richb_?source=rss-918f54808135------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*05ATS_BDBVXf5OgnsggN9A.jpeg</url>
            <title>Stories by Rich Barrett on Medium</title>
            <link>https://medium.com/@richb_?source=rss-918f54808135------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 00:57:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@richb_/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Dahua XVR CCTV Troubleshooting]]></title>
            <link>https://medium.com/@richb_/dahua-xvr-cctv-troubleshooting-5a0b37b20894?source=rss-918f54808135------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a0b37b20894</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[cctv]]></category>
            <category><![CDATA[security-camera-system]]></category>
            <category><![CDATA[security-camera]]></category>
            <dc:creator><![CDATA[Rich Barrett]]></dc:creator>
            <pubDate>Thu, 04 Jul 2024 12:00:25 GMT</pubDate>
            <atom:updated>2024-07-04T12:00:25.902Z</atom:updated>
            <content:encoded><![CDATA[<p>We recently had an issue with our CCTV at home, I ended up fixing it but not without a bit of guesswork given the lack of information available online. So thought I’d publish my findings here so it might help anyone else suffering a similar problem.</p><p>We have a Dahua XVR system (DHI-XVR5108HS-S2) with a 2TB disk in it, and cameras connected via both BNC Coaxial cables <em>and</em> via Ethernet across the network. It’s about 5 years old and besides the software being ancient it does what it’s meant to do reliably.</p><p>Last week the CCTV dropped offline accompanied by an audible ‘beeping’ from the XVR box.</p><p>After I managed to retrieve the box from its hiding place, I plugged it into a monitor to see what was going on. It was stuck in an endless reboot cycle where it would come online for a few seconds, flash an error for a second, then immediately reboot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*7QZnAlfrAL7peBinG1ouxw.jpeg" /></figure><p>This pattern of behaviour is different to what I read other people having experienced when I was Googling and scouring online forums for clues.</p><p>Based on the momentary error, I figured it might be a failed hard drive. So took the box apart and disconnected the SATA cables from the 3.5&quot; Seagate disk inside. Now, it booted fine and would stay alive, albeit disconnected from everything because I took all the cables out.</p><p>Ideally I would have liked connected the old hard disk to my computer to see whether or not I could read it with a different device. But I don’t have a suitable Caddy for the 3.5&quot; SATA drive (because it needs a power supply), so took a chance and ordered a brand new 2TB Seagate SkyHawk 3.5&quot; SATA drive from Amazon (£67).</p><p>When it turned up, I replaced the disk, and voila — everything worked again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yeO_ao2Ns2zM17JtvCZiSA.jpeg" /><figcaption>The original disk</figcaption></figure><p>In hindsight I suppose it makes sense. It’s a mechanical hard drive that is constantly writing and has been every minute of every hour for the past six years. You have to consider it as a wear and tear item I suppose.</p><p>On a positive note, it was a simple replacement and I didn’t even need to do any kind of formatting — it worked straight out of the box. So if you’re also having a similar issue with your Dahua XVR, DVR or NVR, this could very well be a likely cause.</p><p>One thing I have noted about CCTV — the software and interfaces are absolutely ancient. There aren’t any firmware updates available and using it is like going back in time 20 years. I know there are systems like Ring, Nest etc, but those are a different offering in my eyes because they come with a monthly subscription and are more ‘consumer’ focussed. It definitely feels like there’s room in the market for a better solution for ‘traditional’ CCTV.</p><p><em>Originally published at </em><a href="https://ribpx.notion.site/Dahua-XVR-CCTV-Troubleshooting-9475a88cb3d2407dac2ef82168158785"><em>https://ribpx.notion.site</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a0b37b20894" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple logging with PHP and Slack]]></title>
            <link>https://medium.com/@richb_/simple-logging-with-php-and-slack-e5e997679c0e?source=rss-918f54808135------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5e997679c0e</guid>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Rich Barrett]]></dc:creator>
            <pubDate>Tue, 08 Sep 2020 20:59:12 GMT</pubDate>
            <atom:updated>2020-09-08T21:06:34.686Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve not been living under a rock in recent years then you’ll probably have heard of Slack, a great tool for collaboration between distributed teams.</p><p>It comes with lots of useful features, some of which make it a great solution for logging events from your PHP applications. Out of the box, Slack has:</p><ul><li><strong>Channels:</strong> so you can easily separate log messages for different projects.</li><li><strong>Mentions:</strong> so you can get push notifications to your computer or mobile device if something requires your attention.</li><li>A powerful <strong>search</strong> feature to help you search for log messages.</li></ul><h3>Step 1: Install a composer package to help do the interaction with Slack.</h3><pre>composer require maknz/slack</pre><h3>Step 2: Create an Incoming Webhook in Slack so we can post messages to it.</h3><p>You can configure the “Incoming webhooks” app in Slack, follow steps 1–3 in the “Getting Started” section here:</p><p><a href="https://api.slack.com/messaging/webhooks#getting_started">Sending messages using Incoming Webhooks</a></p><p>The end result should be a URL (that you need to keep secret) that will look something like this:</p><pre>https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX</pre><p>Good practice would suggest you should store this URL somewhere safe, like as an environment file, rather than hard code it or keep it in Version Control.</p><h3>Step 3: Send some log messages to Slack!</h3><p>The most basic implementation looks like this:</p><pre>// Replace this with your Incoming Webhook URL<br>$webhook_url = &#39;https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX&#39;;</pre><pre>$client = new Maknz\Slack\Client($webhook_url, $settings);<br>$client-&gt;send(&#39;Hello world&#39;);</pre><h3>Optional: More sophisticated messages.</h3><p>In most instances I use a simple function like the example below.</p><p>It allows you to use mentions and I configure the channel to send me a push notification on my phone if my name is mentioned in the channel. I can then be alerted to any urgent issues, even if I’m away from the computer.</p><pre>function log_to_slack($config, $message) {<br>    <br>  $settings[&#39;username&#39;] = $config[&#39;username&#39;];<br>  $settings[&#39;link_names&#39;] = true;<br>  $client = new Maknz\Slack\Client($config[&#39;webhook_url&#39;], $settings);<br>  $client-&gt;send($message);<br>  <br>}</pre><pre>$config[&#39;username&#39;] = &#39;My App&#39;;<br>$config[&#39;webhook_url&#39;] = &#39;https://my.webhook.url.com&#39;;</pre><pre>log_to_slack($config, &#39;@rich hello world&#39;);</pre><h4><strong>You can download my example code here:</strong></h4><p><a href="http://richbarrett.co.uk/medium/log_to_slack.zip">https://richbarrett.co.uk/medium/log_to_slack.zip</a></p><h4>More examples:</h4><p>You can do lots more with this package, such as post links and embed images among other media. See the examples here: <a href="https://github.com/maknz/slack">https://github.com/maknz/slack</a></p><h4>Extra reading:</h4><p>Take a look at PHP’s <a href="https://www.php.net/register_shutdown_function"><em>register_shutdown_function</em></a><em> </em>to see how you can incorporate the above to log uncaught exceptions and other PHP level errors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5e997679c0e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How much does it really cost to own an Aston Martin? A buyers guide.]]></title>
            <link>https://medium.com/@richb_/owning-an-aston-martin-vantage-answers-to-the-questions-you-really-want-to-know-99b503fdfdce?source=rss-918f54808135------2</link>
            <guid isPermaLink="false">https://medium.com/p/99b503fdfdce</guid>
            <category><![CDATA[aston-martin]]></category>
            <category><![CDATA[cars]]></category>
            <category><![CDATA[money]]></category>
            <dc:creator><![CDATA[Rich Barrett]]></dc:creator>
            <pubDate>Tue, 10 Dec 2019 23:35:55 GMT</pubDate>
            <atom:updated>2019-12-10T23:38:53.065Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4S8kUIdEe0TJuHS7BleqUw.jpeg" /><figcaption>Best of British</figcaption></figure><p>Since I was a little kid, I always loved cars. In particular, Aston Martins.</p><p>I’m not sure whether it’s the brand, understated styling, or maybe the Bond connection, but I promised myself one that someday I would buy one.</p><p>As it worked out, through a lot of hard work and a little luck, the opportunity came sooner than I thought. So in December 2011, I bought a 2007 Aston Martin V8 Vantage Roadster. Over the next 5 years I did more than 40,000 miles in the car and got to know it pretty much inside out.</p><p>Eventually I made the decision to sell the car — changes in my life and other commitments meant it was spending more time in the garage than out, so I decided it was time for someone else to enjoy it.</p><p>Reflecting on my time with the car, I thought I would shed light on some of the questions and uncertainties I had before I bought one, so that others might benefit from my experience.</p><h3>How much does it really cost to own?</h3><p>This is of course the big question. Here’s how it breaks down:</p><p><strong>Depreciation: </strong>Buying the car at the right age is key to keeping this under control. To illustrate the point, the previous owner of my car lost more than £60k in the first 4 years and 19,000 miles. I lost £8k in the next 5 years and 40,000 miles (~£1,600/yr).</p><p><strong>Servicing:</strong> Annual servicing costs are approximately £600 at a specialist, or £900 at a dealer. (~£750/year).</p><p><strong>Consumables: </strong>Tyres are roughly £200 each and last 10k miles. Brake disks are £260/axle and last approx 20k miles. Brake pads are £260/axle and last 15–20k miles. (~£1060/year assuming ~10k miles/year).</p><p><strong>Other Maintenance:</strong> Parts for this car are not cheap. During the 5 years, I ended up buying: A clutch (lasts up to ~50k miles) @ £4k. New brake caliper @ £450. A new rear lamp @ £350. Front lamp repair @ £450. Bubbling paint repair, common on these cars @ £780. Boot button @ £150. Thermostat @ £120. (So it averages out at £1260/year assuming ~ 10k miles/year).</p><p><strong>VED (Road Tax): </strong>It’s the most expensive tax band. £545/year.</p><blockquote>The grand total: £5,215 per year.</blockquote><p>Obviously there are other costs that come with owning any car, insurance — I found it not to be dissimilar from a mid range BMW (Astons don’t tend to get stolen, or be driven by boy racers) and fuel (expect 17mpg on a good day).</p><h3>Do I need a warranty?</h3><p>That all depends on what’s been done already. The V8 is a solid engine and (maintained appropriately) is pretty much bulletproof. However they tend to suffer from a few common issues:</p><p>A timing cover oil leak, roof module failure, sticky first gear (manual cars), dodgy door locks, noisy power steering (additive required). All in all I had £8k (albeit priced at extortionate dealer rates) of work done under warranty in the first year I owned the car, making it very much worthwhile. I negotiated a second year of warranty that I didn’t end up needing, and didn’t renew for the final 3 years (only replacing ~£600 of parts the warranty would have covered in that period anyway).</p><p>The AM warranty costs £1800/year meaning if you’ve got a well looked after car with the common issues sorted, you might be better of putting that money in your piggy bank and taking your chances.</p><h3>Is it worth it?</h3><p>In a word, yes. If you can afford it, it’s not a selfish decision and you’ve always wanted to do it, then do your research, find the right car, then go for it.</p><p><strong>Here are some gratuitous pics if you needed any further convincing…</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ah_xeGa7aA-du73wssVrMQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VmCBtaYIqaWjVFXNT7o2NA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B4OVFyn9N7G6UueNV3YXaw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Vwi8GtTfD-N2JSOuO9Tnw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99b503fdfdce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I ditched Facebook & Instagram and gained more than just time.]]></title>
            <link>https://medium.com/@richb_/i-ditched-facebook-instagram-and-gained-more-than-just-time-b720dc8892d6?source=rss-918f54808135------2</link>
            <guid isPermaLink="false">https://medium.com/p/b720dc8892d6</guid>
            <category><![CDATA[narcissism]]></category>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[influencer-marketing]]></category>
            <category><![CDATA[values]]></category>
            <category><![CDATA[time-management]]></category>
            <dc:creator><![CDATA[Rich Barrett]]></dc:creator>
            <pubDate>Tue, 10 Dec 2019 23:29:04 GMT</pubDate>
            <atom:updated>2019-12-10T23:29:04.975Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Cnin5_oLR3A5E6Rg1X3Yw.jpeg" /></figure><p>3years ago I made the conscious decision to close my Facebook and Instagram accounts.</p><p>At the time my motivation was twofold:</p><ol><li>I wanted to stop wasting valuable time scrolling through inane posts by people I’ve not seen in 15 years.</li><li>I wanted a more private life. It’s a sad reality that some people keep tabs on you from the periphery and in the worst cases, will you to fail. I didn’t want that kind of energy in my life.</li></ol><h3>Going cold turkey</h3><p>At first I thought it was going to be difficult. But to be honest after a couple of days occasionally (absentmindedly) tapping the Facebook or Instagram apps on my phone, only to be greeted by the login screen, I stopped doing it.</p><p>It actually served to highlight how often I checked them before without even thinking about it; reinforcing in my mind the need to change my habits.</p><h3>No looking back</h3><p>So more than 3 years on, am I glad that I quit social media? Absolutely.</p><p>I’ve regained hours every week that were wasted before; I consciously focus my attention on being in the moment rather than taking photos for social media; and I’ve dramatically cut down the number of people who have the inside track on what’s happening in my private life.</p><p>Overall, it feels pretty liberating.</p><h3>But the biggest win was unexpected …</h3><p>A life free from social media made me see my previous online activity and mindset from a new perspective.</p><p>Frankly, my posts were often pretty narcissistic and immature.</p><blockquote>“Too many people spend money they haven’t earned to buy things they don’t want to impress people they don’t like” — Walter Slezak.</blockquote><p>I quote this to people a lot, it’s one of my favourites.</p><p>Whilst I don’t fit exactly into this category, I can relate to the sentiment. Like many, I used social media to showcase the 10% of my life that’s about material things, cool places and experiences. However I mostly omitted the other 90% of my life, such as working 18 hour days, worrying if business wasn’t going well, times when I was bored, or lonely.</p><p>It was simply not an accurate portrayal of my real life. I was contributing to a broader problem I believe exists in society today — social media gives people (especially young people) an unrealistic expectation about what’s “normal”. The net result is many people feel unhappy, dissatisfied or hard-done-by in their own lives.</p><p>Overall I think that ditching social media made me a better person. It served to remind me of my core values and reconsider what is actually important to me.</p><p>The end result is a simpler, more fulfilling life, focussed on quality time and happiness; rather than social acceptance and underlying insecurity.</p><p><strong>I would encourage anybody to consider taking a break from social media. If not for any other reason than to remind yourself of what is really important and interesting to you; not what you think will interest, or impress other people.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b720dc8892d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why not all technical debt is created equal]]></title>
            <link>https://medium.com/@richb_/why-not-all-technical-debt-is-created-equal-253d727302b1?source=rss-918f54808135------2</link>
            <guid isPermaLink="false">https://medium.com/p/253d727302b1</guid>
            <category><![CDATA[management]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <category><![CDATA[technical-debt]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Rich Barrett]]></dc:creator>
            <pubDate>Mon, 04 Jun 2018 18:25:35 GMT</pubDate>
            <atom:updated>2018-06-04T19:18:37.951Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YZnsdY6LHPJY_eK-EMclig.jpeg" /></figure><p>There is a lot of talk in tech circles about “technical debt” … for those unacquainted with the concept, here’s a definition for you:</p><blockquote>Technical debt is a concept in programming that reflects the extra development work that arises when code that is easy to implement in the short run is used instead of applying the best overall solution.</blockquote><p>While it’s generally accepted that technical debt can be used strategically to a business’ advantage, everything I read makes two assumptions that I think are fundamentally flawed:</p><ol><li>The concept that technical debt is black and white: it either is, or is not technical debt, and all technical debt is the same.</li><li>All technical debt must be repaid in the fullness of time.</li></ol><p>Let’s look at these two points individually:</p><h4>What is the interest rate on your technical debt?</h4><p>To be absolutely clear — I am in no way suggesting you should write terrible code with zero consideration of the future implications.</p><p>However, you can still write robust, future proof and performant code even if it’s not the “textbook” solution. It’s about being commercially strategic.</p><p><em>A practical example:</em></p><p>Assuming an MVC architecture, putting SQL queries in view files might be considered the 1000% APR payday loan of technical debt; conversely putting a few inline styles within views is still ‘wrong’ but isn’t the end of the world — it’s the 4% APR option.</p><p>In reality your compromises are probably more complex than this, but the principle is the same — the ‘cost’ of technical debt in the second example is far lower because you’ve limited the scope of the compromise.</p><h4>Fact: a lot of technical debt gets written off.</h4><p>In reality it is highly unlikely that you’ll have to pay back all technical debt.</p><p>A disruptive business needs to be experimenting and evolving constantly. Many of those experiments will fail, leaving only a small proportion of the ‘compromised’ code actually requiring refactoring in the fullness of time.</p><p>If the ‘best solution’ takes 10 days to develop, but you can deliver a functional but ‘affordably’ technically indebted solution in 2 days, then you have time to run 5 experiments in the time it would’ve taken you to write just one ‘perfect solution’.</p><p>The result of this is that you’ll have a much better idea of which ‘experiment’ is going to deliver the most commercial value for your business. In the example above, even if you end up refactoring 4 out of the 5 experiments (not likely) then you’ll still have time in hand.</p><h3>The Disclaimer</h3><p>I’m not saying this is right for every business. If you work for a bank, the government or a corporate, there is likely (a) a ton of change control governance, and (b) a lot of people with ‘job preservation’ comfort zones.</p><p>But if you’re starting something new, have limited funds, or need to move quickly to disrupt and/or gain a competitive advantage, then accepting a level of technical debt in return for being able to experiment quickly could be the difference between success and failure.</p><h3>Don’t just take my word for it</h3><p>I have first hand experience in several businesses of leveraging technical debt to gain a competitive advantage (and paying it back when required), but I’m not alone in promoting this approach to managing development:</p><p>“Move Fast and Break Things” was Facebook’s mantra for years.</p><p>Jeff Bezos of Amazon was quoted saying <em>“Failure and invention are inseparable twins. To invent you have to experiment, and if you know in advance that it’s going to work, it’s not an experiment.”</em></p><p>I have lost count of how many businesses with great ideas I’ve seen either run out of money, or sell their souls to investors to finance their pursuit of the ‘perfect solution’ to a problem that they don’t even fully understand because they’re not in the market yet.</p><p>You’ve got to be in it to win it, and an <em>affordable</em> level of technical debt is a no-win-no-fee deal.</p><h3>My top 3 tips for affordable technical debt:</h3><p>In practical terms, a lot of academically trained developers struggle to see where the line needs to be drawn.</p><p>The key to overcoming this is encouraging and developing the commercial awareness of your engineers . Explain the context of <em>why</em> they’re building a feature, and what it’s commercial value is to the business — ultimately it’s going to to be them that call the compromises so your perspectives need to be aligned.</p><p>Here are my top 3 tips on getting it right:</p><ol><li><strong>Less moving parts:</strong> like anything, more moving parts (more lines of code) means more things to go wrong. Don’t over complicate your code for the point of principle, to cater for an edge case, or an improbable future development. Write clean and concise code.</li><li><strong>Stick to the basics:</strong> don’t repeat yourself, do one thing, single point of truth. Being tidy will not only isolate your compromises, but will make any eventual refactor far easier.</li><li><strong>Pick your battles:</strong> are you developing a critical part of the application, or a value-add feature? Maintain perspective and work smart to identify where you can afford to compromise.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=253d727302b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Startup Advice: Your logo and Intellectual Property / Copyright]]></title>
            <link>https://medium.com/@richb_/startup-advice-your-logo-and-intellectual-property-copyright-107e14a672f2?source=rss-918f54808135------2</link>
            <guid isPermaLink="false">https://medium.com/p/107e14a672f2</guid>
            <category><![CDATA[copyright]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <category><![CDATA[legal]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[logo-design]]></category>
            <dc:creator><![CDATA[Rich Barrett]]></dc:creator>
            <pubDate>Thu, 19 Apr 2018 05:31:01 GMT</pubDate>
            <atom:updated>2018-04-19T05:31:01.856Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve been in business for any significant length of time, it’s easy to forget the things that worry people when they’re first starting out.</p><p>Somebody recently asked me:</p><blockquote>Can I pick your brain on logos for new businesses…. Do you need to register a logo? And how do you avoid copyright issues?</blockquote><p>So I thought I’d publish my reply here so that others might benefit…</p><h3>When it comes to protecting your logo, there are two things to consider</h3><ol><li>The “copyright” (and Intellectual Property).</li><li>A Registered Trademark.</li></ol><h4>A simple overview of Intellectual Property &amp; “Copyright”</h4><p>If you create the logo yourself, the Intellectual Property Rights (IPR) and therefore copyright are yours.</p><p>If someone else creates it for you, then technically the IPR is theirs and so they own the copyright. It’s good practice to get the designer of your logo to sign a simple agreement that includes a picture of the logo and that assigns the IPR to you or your business. This doesn’t need to be anything fancy — despite popular belief, even the most simple of notes clearly written, dated and signed can be legally binding.</p><h4>Registered Trademarks</h4><p>If you so wished, you can apply (usually easiest with the help of a specialist company) to register your logo and/or business name as a Registered Trademark (you have do do this separately for UK, EU and US). If your application is successful you can then use the little ® symbol.</p><h3>Avoiding infringing other people’s IPR</h3><p>In terms of avoiding copyright issues yourself, you might want to make sure your logo (or name) is not infringing anyone else’s trademark by searching the online databases of wherever you’re operating (just Google “trademark search UK” for example, and you’ll find the right website).</p><p>Another easy way to check your name isn’t crossing over too much with anyone else’s is to search Companies House for any other businesses very similarly named (<a href="https://beta.companieshouse.gov.uk/">https://beta.companieshouse.gov.uk/</a>).</p><h3>In Summary</h3><p>In reality, if the logo is unique and you (or a designer) created it as an original piece of work (and correctly assigned the IPR), then you can can be fairly confident that you could prove in the future that it’s your logo and you are the copyright owner. You’re also free to use the © and “TM” designations.</p><p>Registering a Trademark is something you’d generally do once the business is more established, usually because you want either (a) more robust way of protecting your IPR, or (b) you need the brand to become an “asset” of the business with a value for accounting or valuation purposes (eg. if you’re selling up).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=107e14a672f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tuning MySQL: 3 Simple Tweaks]]></title>
            <link>https://medium.com/@richb_/tuning-mysql-3-simple-tweaks-6356768f9b90?source=rss-918f54808135------2</link>
            <guid isPermaLink="false">https://medium.com/p/6356768f9b90</guid>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Rich Barrett]]></dc:creator>
            <pubDate>Thu, 01 Feb 2018 19:31:01 GMT</pubDate>
            <atom:updated>2018-02-01T19:31:01.190Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>If you don’t change the default MySQL configuration, your server is going to perform like a Ferrari that’s stuck in first gear…</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b7M28XbrOc4FF3tJP-vvyg.png" /></figure><p>I don’t claim to be an expert DBA, but I am a strong proponent of the 80/20 principle and when it comes to tuning MySQL, it’s fair to say you can squeeze 80% of the juice by making a few simple adjustments to your configuration. Useful, especially when server resources are getting cheaper all the time.</p><h4>Health warnings:</h4><ol><li>No two databases or applications are the same. This is written with the ‘typical’ website owner in mind, where fast queries, a nice user experience and being able to handle lots of traffic are your priorities.</li><li>Back up your database before you do this!</li></ol><h3>1. Use the InnoDB storage engine</h3><p>If you’re using the MyISAM storage engine, then it’s time to move to InnoDB. There are many reasons why it’s superior, but if performance is what you’re after, it comes down to how each utilises physical memory:</p><ul><li><strong>MyISAM: </strong>Only stores indexes in memory.</li><li><strong>InnoDB: </strong>Stores indexes <em>and</em> data in memory.</li></ul><p><strong>Bottom line:</strong> stuff stored in memory is accessible much faster than stuff stored on the disk.</p><p>Here’s how you convert your tables:</p><pre>ALTER TABLE <em>table_name</em> ENGINE=InnoDB;</pre><p><strong><em>Note:</em></strong><em> You have created all of the appropriate indexes, right? That should always be your first priority for better performance.</em></p><h3>2. Let InnoDB use all that memory</h3><p>You can edit your MySQL configuration in your <em>my.cnf</em> file. The amount of memory that InnoDB is allowed to use on your server is configured with the <strong>innodb_buffer_pool_size</strong> parameter.</p><p>The accepted ‘rule of thumb’ for this (for servers <em>only</em> tasked with running MySQL) is to set this to 80% of your server’s physical memory. You want to maximise the use of the RAM, but leave enough for the OS to run without it needing to utilise the swap.</p><p>So, if your server has 32GB memory, set it to ~ 25GB.</p><pre>innodb_buffer_pool_size = 25600M</pre><p><strong><em>Notes:</em></strong><em> (1) If your server is small and this number comes in less than 1GB, you ought to upgrade to a box with more memory for the rest of this article to be applicable. (2) If you have a huge server, eg. 200gb memory, then use common sense — you don’t need to leave 40gb free memory for the OS.</em></p><h3>3. Let InnoDB multitask</h3><p>For servers where <em>innodb_buffer_pool_size</em> is greater than 1GB, <em>innodb_buffer_pool_instances </em>divides the InnoDB buffer pool into this many instances.</p><p>The benefit to having more than 1 buffer pool is:</p><blockquote>You might encounter bottlenecks from multiple threads trying to access the buffer pool at once. You can enable multiple buffer pools to minimize this contention.</blockquote><p>The official recommendation for the number of buffers is:</p><blockquote>For best efficiency, specify a combination of innodb_buffer_pool_instances and innodb_buffer_pool_size so that each buffer pool instance is at least 1 gigabyte.</blockquote><p>So in our example of a 32GB server with a 25GB <em>innodb_buffer_pool_size,</em> a suitable solution might be 25600M / <strong>24</strong> = 1.06GB</p><pre>innodb_buffer_pool_instances = 24</pre><h3>Don’t forget!</h3><p>After making changes to <em>my.cnf </em>you’ll need to restart MySQL:</p><pre>sudo service mysql restart</pre><p><strong>There are far more scientific ways to optimise these parameters, but using this as a general guide will get you a long way towards a better performing MySQL server.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6356768f9b90" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The easy (and secure) way to migrate MySQL / MariaDB databases]]></title>
            <link>https://medium.com/@richb_/the-easy-and-secure-way-to-migrate-mysql-mariadb-databases-d72b9108bb38?source=rss-918f54808135------2</link>
            <guid isPermaLink="false">https://medium.com/p/d72b9108bb38</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[data-migration]]></category>
            <category><![CDATA[database-administration]]></category>
            <category><![CDATA[mariadb]]></category>
            <category><![CDATA[mysql]]></category>
            <dc:creator><![CDATA[Rich Barrett]]></dc:creator>
            <pubDate>Mon, 11 Dec 2017 22:14:20 GMT</pubDate>
            <atom:updated>2018-01-29T15:23:03.093Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p><em>tl;dr: pipe the output of mysqldump through an ssh tunnel directly into the mysql binary on the destination server.</em></p><p>Migrating databases between servers is not a fun task, but it doesn’t have to be difficult. I’ve broken this down below in some detail for those unacquainted, but the principles here are straightforward.</p><h3>Things worth checking</h3><h4>max_allowed_packet</h4><p>Make sure the max_allowed_packet is the same on both servers (in <em>my.cnf</em>). This ensures the output from mysqldump is within the required size constraints for processing by mysql on the destination server.</p><pre>[mysqld]<br>max_allowed_packet=16M</pre><pre>[mysqldump]<br>max_allowed_packet=16M</pre><h4>SQL_MODE</h4><p>Something that can trip you up is the new more strict mode that is enabled by default in newer versions of MySQL / MariaDB. This can cause your application to fail because:</p><blockquote>“Strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE. A value can be invalid for several reasons. For example, it might have the wrong data type for the column, or it might be out of range.”</blockquote><p>To fix this, on your new server ensure SQL_MODE is set as follows in your <em>my.cnf</em> file:</p><pre>sql_mode = NO_ENGINE_SUBSTITUTION</pre><h3>Setting up a secure connection</h3><p>Your existing server is going to need secure access to the new one. You can use SSH keys to achieve this.</p><p>On your source server:</p><pre>cat ~/.ssh/id_rsa.pub</pre><p>Copy the contents of this public key, then use nano to paste it onto a new line in the authorized_keys file on your destination server.</p><pre>nano ~/.ssh/authorized_keys</pre><p>You’re now able to securely open an SSH connection from the source server to the destination server.</p><h3>Transferring your data</h3><p>You’re all set to go ahead and transfer the data from the source to destination server. This is the command you will use:</p><pre><strong>mysqldump -u srcdbuser -p&#39;srcdbpass&#39; srcdatabase | ssh dstsshuser</strong><a href="/service/mailto:forge@xxx.xxx.xxx"><strong>@xxx.xxx.xxx</strong></a><strong>.xxx mysql -u dstdbuser -p&#39;dstdbpass&#39; dstdatabase</strong></pre><p>You’ll replace these values:</p><ul><li><strong>srcdbuser: </strong>the database user on the source server.</li><li><strong>srcdbpass: </strong>the database passwordon the source server.</li><li><strong>srcdatabase</strong>: the name of the database on the source server.</li><li><strong>dstsshuser</strong>: SSH user on the destination server.</li><li><strong>xxx.xxx.xxx.xxx:</strong> IP Address of the destination server.</li><li><strong>dstdbuser: </strong>the database user on the destination server.</li><li><strong>dstdbpass: </strong>the (new, empty) database user on the destination server.</li><li><strong>dstdatabase</strong>: the name of the database on the destination server.</li></ul><h4>Let’s break this down:</h4><p>This part outputs SQL statements required to rebuild ‘srcdatabase’ database on the source sever:</p><blockquote><strong>mysqldump</strong> -u srcdbuser -p&#39;srcdbpass&#39; <strong>srcdatabase</strong></blockquote><p>The ‘pipe’ pushes the output of mysqldump into the SSH tunnel:</p><blockquote>| ssh dstsshuser<a href="/service/mailto:forge@xxx.xxx.xxx">@xxx.xxx.xxx</a></blockquote><p>MySQL on the <em>destination</em> server receives the data streamed through the SSH tunnel and inserts it directly the new database ‘destdatabase’:</p><blockquote>mysql -u dstdbuser -p&#39;dstdbpass&#39; dstdatabase</blockquote><h3>Summary</h3><p>Moving a database like this streamlines the normal process of dumping to a file, moving the file across, then reimporting. It can save you a lot of time and as I always profess, less moving parts = less to go wrong.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d72b9108bb38" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Easy Two Factor Authentication (2FA) with Google Authenticator & PHP]]></title>
            <link>https://medium.com/@richb_/easy-two-factor-authentication-2fa-with-google-authenticator-php-108388a1ea23?source=rss-918f54808135------2</link>
            <guid isPermaLink="false">https://medium.com/p/108388a1ea23</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[2fa]]></category>
            <category><![CDATA[two-factor-authentication]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Rich Barrett]]></dc:creator>
            <pubDate>Wed, 01 Nov 2017 17:44:12 GMT</pubDate>
            <atom:updated>2022-08-04T10:19:22.349Z</atom:updated>
            <content:encoded><![CDATA[<p>Implementing two factor authentication with PHP is easier than you think and is hugely beneficial for the security of your application.</p><p>In this article I show you how you can quickly implement 2FA with Google Authenticator (but is also compatible with other 2FA apps).</p><h3>What is Two Factor Authentication?</h3><p>2FA is nothing new. In fact it’s already been widely adopted by most major platforms (Facebook, Apple, Google etc) as a means of making account logins more secure.</p><blockquote>Two Factor Authentication, also known as 2FA, two step verification or TFA (as an acronym), is an extra layer of security that is known as “multi factor authentication” that requires not only a password and username but also something that only, and only, that user has on them, i.e. a piece of information only they should know or have immediately to hand — such as a physical token.</blockquote><p>So how does the user get the code?</p><ul><li>Historically this required the user to carry a widget or card reader device (in the case of bank accounts) on their person, to generate a unique code.</li><li>Recently a popular method has been sending the user an SMS with a one time use code.</li></ul><p>However there are other options…</p><h3>How Google Authenticator works</h3><p>Google Authenticator is a free app for your smart phone that generates a new code every 30 seconds. It works like this:</p><ol><li>When enabling 2FA, the application you’re securing generates a QR code that user’s scan with their phone camera to add the profile to their Google Authenticator app.</li><li>Your user’s smart phone then generates a new code every 30 seconds to use for the second part of authentication to the application.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*TMyswLat4xWqrEt8_o7N-Q.png" /></figure><h3>Implementing Google Authenticator on your website using PHP</h3><p>The easiest way to do this is to use an open source composer package to do the tricky stuff for you:</p><p><a href="https://packagist.org/packages/pragmarx/google2fa">https://packagist.org/packages/pragmarx/google2fa</a></p><p>You’ll use the library to:</p><ul><li>Generate a secret key for each user</li><li>Generate the QR code for your user to scan when they enable 2FA.</li><li>Verify that the code entered is valid at login.</li></ul><p><strong>Generating the Secret Key</strong></p><p>Each user needs to have a “secret key” stored against their account (for example, a column in the database table where you store your user account information).</p><p>This key is used to generate the QR code that they scan, then subsequently to verify that the code they enter at login is correct.</p><p>Here’s the PHP that you need:</p><pre>$google2fa = new \PragmaRX\Google2FA\Google2FA();<br>$secret = $google2fa-&gt;generateSecretKey();</pre><pre>// Now store the key in your database</pre><p><em>Note: although the secret key appears to be just a text string, to be compatible with Google Authenticator it has to be a Base32 string. That’s why the most reliable route to generate the key is to use the library because it takes care of all of that for you.</em></p><p><strong>Generating the QR Code</strong></p><p>Using the same library, we can generate the text string that makes up the QR code. Then we can use a public API to generate a QR code image.</p><pre>$google2fa = new \PragmaRX\Google2FA\Google2FA();<br>      <br>$text = $google2fa-&gt;getQRCodeUrl(<br> &#39;example.com&#39;,<br> $username,<br> $secret_key<br>);<br>    <br>$image_url = &#39;<a href="https://chart.googleapis.com/chart?cht=qr&amp;chs=300x300&amp;chl=&#39;.$text">https://chart.googleapis.com/chart?cht=qr&amp;chs=300x300&amp;chl=&#39;.$text</a>;</pre><pre>echo &#39;&lt;img src=&quot;&#39;.$image_url.&#39;&quot; /&gt;&#39;;</pre><p><strong>Verifying entered codes</strong></p><p>When the user logs in, you can then verify the code they’ve entered is valid by using their secret key and the code they entered into your UI.</p><pre>$google2fa = new \PragmaRX\Google2FA\Google2FA();</pre><pre>if ($google2fa-&gt;verifyKey($secret_key, $user_provided_code)) {<br> <br>// Code is valid</pre><pre>} else {</pre><pre> // Code is NOT valid</pre><pre>}</pre><p>While Google Authenticator might not be the most desirable 2FA method for your customers, there’s no reason you can’t implement it for staff or administrators when it’s this easy.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=108388a1ea23" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sending SMS with iTagg and PHP]]></title>
            <link>https://medium.com/@richb_/sending-sms-with-itagg-and-php-35983368ba59?source=rss-918f54808135------2</link>
            <guid isPermaLink="false">https://medium.com/p/35983368ba59</guid>
            <category><![CDATA[itagg]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[sms]]></category>
            <category><![CDATA[sdk]]></category>
            <dc:creator><![CDATA[Rich Barrett]]></dc:creator>
            <pubDate>Tue, 24 Oct 2017 12:16:02 GMT</pubDate>
            <atom:updated>2017-10-24T12:16:02.645Z</atom:updated>
            <content:encoded><![CDATA[<p>If you use composer to manage packages, you may want to use this little SDK to send SMS messages using the iTagg SMS Service (itagg.com).</p><h3>Installation</h3><p>Install using composer from Packagist.</p><p>composer install richbarrett/itagg-sdk-php</p><h3>Usage</h3><p>It’s really straightforward to use:</p><pre>include_once(&#39;vendor/autoload.php&#39;);<br><br>use richbarrett\itagg\send;<br><br>$send = new send(&#39;YOUR_USER&#39;,&#39;YOUR_PASSWORD&#39;);<br>$send-&gt;addTo(&#39;00000000000&#39;);<br>$send-&gt;setBody(&#39;Hello world&#39;);<br>$send-&gt;setFrom(&#39;iTagg SMS&#39;);<br><br>try {<br> <br>  $response = $send-&gt;sendRequest();<br>  die(&#39;Success!&#39;);<br> <br>} catch (\Exception $e) {<br>  <br>  die(&#39;Failed with error: &#39;.$e-&gt;getMessage());<br>  <br>}</pre><p><a href="https://packagist.org/packages/richbarrett/itagg-sdk-php">https://packagist.org/packages/richbarrett/itagg-sdk-php</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35983368ba59" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>