<?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 Phillip Hartin on Medium]]></title>
        <description><![CDATA[Stories by Phillip Hartin on Medium]]></description>
        <link>https://medium.com/@philliphartin?source=rss-421dee149bd6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*gyKAtVEo8tFr0s9g.jpg</url>
            <title>Stories by Phillip Hartin on Medium</title>
            <link>https://medium.com/@philliphartin?source=rss-421dee149bd6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 17:38:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@philliphartin/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[How to implement long press gestures in Ionic 4]]></title>
            <link>https://medium.com/madewithply/ionic-4-long-press-gestures-96cf1e44098b?source=rss-421dee149bd6------2</link>
            <guid isPermaLink="false">https://medium.com/p/96cf1e44098b</guid>
            <category><![CDATA[ionic]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[ux]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Phillip Hartin]]></dc:creator>
            <pubDate>Tue, 09 Oct 2018 23:58:13 GMT</pubDate>
            <atom:updated>2018-10-15T21:54:59.953Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently we had an app project in which a <em>long-press</em> was the perfect UX interaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OhLu6duLX4AE3i5Zh0d12w.png" /></figure><p>As it turns out, it’s not as straightforward to implement in Ionic 4 as it is natively. But then everything else is, and so we ploughed on.</p><p>The event that we want to leverage here is very similar to the standard <strong><em>(click) </em></strong>event binding provided by angular, but for a long press, there are 2 actions we want to hook into, <strong><em>(</em></strong><a href="http://hammerjs.github.io/recognizer-press/"><strong><em>press</em></strong></a><strong><em>) </em></strong>and<strong><em> (</em></strong><a href="http://hammerjs.github.io/recognizer-press/"><strong><em>pressup</em></strong></a><strong><em>)</em></strong>. You can try adding these events straightaway, but you will notice the following issue:The “press” event cannot be bound because Hammer.JS is not loaded and no custom loader has been specified.</p><h3>Setup</h3><p>As they say, nothing worth having comes easily, so we’ve got a little bit of configuration to do before we get to play with events.</p><h4>Install HammerJs</h4><p>So we want to make <a href="https://hammerjs.github.io/">HammerJS</a> available across the entire project by adding it via npm: npm install hammerjs — save</p><p>Next, we add it to our codebase by importing it directly within src/main.ts :</p><pre><strong>import </strong>{ enableProdMode } <strong>from </strong>&#39;@angular/core&#39;;<br><strong>import </strong>{ platformBrowserDynamic } <strong>from </strong>&#39;@angular/platform-browser-dynamic&#39;;<br><br><strong>import </strong>{ AppModule } <strong>from </strong>&#39;./app/app.module&#39;;<br><strong>import </strong>{ environment } <strong>from </strong>&#39;./environments/environment&#39;;<br><br><strong><em>import </em></strong><em>&quot;hammerjs&quot;; // HAMMER TIME</em><br><br><strong>if </strong>(environment.production) {<br>  enableProdMode();<br>}<br><br>platformBrowserDynamic().bootstrapModule(AppModule)<br>  .catch(err =&gt; console.log(err));</pre><h4>Setup a Hammer Gesture Config</h4><p>Now we should be able to access Hammer directives inside our app, but with Ionic 4 being in beta, we ran into some issues at this point and found the resolution was to create our own HammerGestureConfig by extending it, so for your convenience, I’ve added how we did that below:</p><pre><strong>import </strong>{ Injectable } <strong>from </strong>&quot;@angular/core&quot;;<br><strong>import </strong>{ HammerGestureConfig } <strong>from </strong>&quot;@angular/platform-browser&quot;;<br><br><em>/**<br> * </em><strong><em>@hidden<br> </em></strong><em>* This class overrides the default Angular gesture config.<br> */<br></em>@Injectable()<br><strong>export class </strong>IonicGestureConfig <strong>extends </strong>HammerGestureConfig {<br>  buildHammer(element: HTMLElement) {<br>    <strong>const </strong>mc = <strong>new </strong>(&lt;<strong>any</strong>&gt;window).Hammer(element);<br><br>    <strong>for </strong>(<strong>const </strong>eventName <strong>in this</strong>.overrides) {<br>      <strong>if </strong>(eventName) {<br>        mc.get(eventName).set(<strong>this</strong>.overrides[eventName]);<br>      }<br>    }<br><br>    <strong>return </strong>mc;<br>  }<br>}</pre><h4>Add to App Providers</h4><p>With HammerJS added and a custom HammerGestureConfig defined, we want to add it to our Angular providers in app.module.ts.</p><pre>@NgModule({<br>    declarations: [AppComponent],<br>    entryComponents: [],<br>    imports: [BrowserModule, IonicModule.<em>forRoot</em>(), AppRoutingModule],<br>    providers: [<br>        StatusBar,<br>        SplashScreen,<br>        {provide: RouteReuseStrategy, useClass: IonicRouteStrategy},<br>        <strong>{<br>            provide: HAMMER_GESTURE_CONFIG,<br>            useClass: IonicGestureConfig<br>        },</strong><br>    ],<br>    bootstrap: [AppComponent]<br>})</pre><h3>The Good part</h3><p>Now that the setup is out of the way, we can now get playing with the events.</p><p>For the sake of this demo, I’m going to use an ion-button, but you can use whatever HTML element you want.</p><h4>Add Event Bindings</h4><p>So go ahead and add a (<a href="http://hammerjs.github.io/recognizer-press/"><strong><em>press</em></strong></a>) and (<a href="http://hammerjs.github.io/recognizer-press/"><strong><em>pressup</em></strong></a>) event binding onto your element and point them to a respective function on your controller:</p><pre><strong>&lt;--Template Segment--&gt;</strong><br>&lt;ion-button (press)=&quot;onPress($event)&quot; (pressup)=&quot;onPressUp($event)&quot;&gt;Press Me&lt;/ion-button&gt;<br></pre><pre><strong>// Controller Functions<br></strong>onPress($event) {<br>    console.log(&quot;onPress&quot;, $event);<br>}<br><br>onPressUp($event) {<br>    console.log(&quot;onPressUp&quot;, $event);<br>}</pre><p>If you’ve set it all up correctly, you will see the events firing in your console. The onPress will fire after about 1 second of a long press, and upon releasing the onPressUp event will then fire.</p><h4>What next?</h4><p>Well, given that this UX interaction could be used for a gazillion different things, I’m not going to preempt why YOU need it, however, a good use case for this demo (I think) would be to create a progress counter whilst the button is being held down.</p><h3>Demo: Long Press to Increment a Counter</h3><p>First up, I’ve added the<a href="https://github.com/pjhartin/ionic4-long-press-demo"> source code for this demo on Github</a>, so feel free to use it as a reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*DeLwNK24FRCfXklrrz06ww.gif" /><figcaption>Press it, press it good.</figcaption></figure><h4>Don’t forget: Event Bindings only fire once!</h4><p>It may feel counterintuitive, but despite holding the button, the actual press event is only fired once, and so if we wish for the counter to continually increment until the button is released we have to find a way to recall the incrementing function. In this demo, I will use a simple setTimeout function to do this.</p><h4>Managing the Timeout Interval</h4><pre><strong>import </strong>{Component} <strong>from </strong>&#39;@angular/core&#39;;<br><br>@Component({<br>    selector: &#39;app-home&#39;,<br>    templateUrl: &#39;home.page.html&#39;,<br>    styleUrls: [&#39;home.page.scss&#39;],<br>})<br><strong>export class </strong>HomePage {<br><br>    <strong>public </strong>progress: <strong>number </strong>= 0;<br><br>    // Interval function<br>    <strong>protected </strong>interval: <strong>any</strong>;<br><br>    onPress($event) {<br>        console.log(&quot;onPress&quot;, $event);<br>        <strong>this</strong>.startInterval();<br>    }<br><br>    onPressUp($event) {<br>        console.log(&quot;onPressUp&quot;, $event);<br>        <strong>this</strong>.stopInterval();<br>    }<br><br>    startInterval() {<br>        <strong>const </strong>self = <strong>this</strong>;<br>        <strong>this</strong>.interval = setInterval(<strong>function </strong>() {<br>            self.progress = self.progress + 1;<br>        }, 50);<br>    }<br><br>    stopInterval() {<br>        clearInterval(<strong>this</strong>.interval);<br>    }<br><br>}</pre><p>So I’ll try and break down exactly what is happening here. When the<strong> (press) </strong>event binding is observed in the markup, the<strong><em> onPress($event)</em></strong> method runs. This method calls the startInterval function, which creates an interval function that is set to re-run every 50 milliseconds, and binds the function to a local variable so that it can be cleared (stopped) at a later time. Notice the redeclaration of this as another local variable self. <a href="https://quirksmode.org/js/this.html">Don’t forget the importance of the </a><a href="https://quirksmode.org/js/this.html">this keyword</a> in javascript and how it’s context can change!</p><p>So, now that the interval is up and running, you will see that the progress variable is incrementing by 1 every 50 milliseconds. Now when the user lifts their finger off the button, the<strong><em> (pressup)</em></strong> event binding is fired, which in our example clears the interval that was created by the initial press event, and so the counter stops incrementing… magic!</p><h4>Reuse and Scalability</h4><p>One thing you might note is that if you wanted to have multiple buttons on the page, there would be an awful lot of code duplication. The smart thing to do in this case is to move all of that press logic into its own component and have it self-contained and reusable. But that’s for another day!</p><h3>Source Code</h3><p>Don’t forget, the source code for this demo is available at <a href="https://github.com/pjhartin/ionic4-long-press-demo">https://github.com/pjhartin/ionic4-long-press-demo</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96cf1e44098b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/madewithply/ionic-4-long-press-gestures-96cf1e44098b">How to implement long press gestures in Ionic 4</a> was originally published in <a href="https://medium.com/madewithply">madewithply</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hackintosh on AMD: Virtualisation is the Achilles heel]]></title>
            <link>https://medium.com/@philliphartin/hackintosh-on-amd-virtualisation-is-the-achilles-heel-2648f2e92ec2?source=rss-421dee149bd6------2</link>
            <guid isPermaLink="false">https://medium.com/p/2648f2e92ec2</guid>
            <category><![CDATA[hackintosh]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[hardware]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Phillip Hartin]]></dc:creator>
            <pubDate>Mon, 16 Oct 2017 21:52:01 GMT</pubDate>
            <atom:updated>2017-10-18T10:24:08.693Z</atom:updated>
            <content:encoded><![CDATA[<p>What started out as a little light reading on a rainy Saturday quickly spiraled into a weekend consumed with the elusive goal of getting macOS to boot on AMD hardware. You see, around 6 months ago, AMD launched their Ryzen lineup of CPUs and introduced the R1700. It didn’t take long before the internet got talking about how great these CPUs were for development heavy workstations and I started listening. I’d been using a Macbook Pro for &gt; 4 years at this point and managed to hold off on getting a desktop, but I could wait no longer. The hype was too real.</p><iframe src="https://cdn.embedly.com/widgets/media.html?type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=instagram&amp;url=https%3A//www.instagram.com/p/BUxs5UnBQLC/&amp;image=https%3A//i.embed.ly/1/image%3Furl%3Dhttps%253A%252F%252Fscontent-iad3-1.cdninstagram.com%252Ft51.2885-15%252Fs640x640%252Fe15%252F18723644_311652319270125_1084996665540083712_n.jpg%26key%3Da19fcc184b9711e1b4764040d3dc5c07" width="640" height="640" frameborder="0" scrolling="no"><a href="https://medium.com/media/0468d3229237b85a407bc8bf4993c880/href">https://medium.com/media/0468d3229237b85a407bc8bf4993c880/href</a></iframe><p>The build was bitter sweet; The resulting machine was glorious, powerful and beautiful to look at, but I had to say goodbye to macOS. I gave Win10 a go, but that lasted about 6 hours before I feared I’d need a lobotomy. I welcomed Ubuntu, tried every flavour and settled on gnome.</p><h3>Phillip Hartin on Twitter</h3><p>Finally made the switch and loving it. Gave #windows 10 a go as a dev env, lasted ~6hrs. Loving #ubuntu, don&#39;t even miss #osx. #programming</p><p>Happy as I was for 6 months, a video about macOS running on ryzen appeared in my youtube feed, and my eyes started to wander.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FIAut2VGpDvo%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DIAut2VGpDvo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FIAut2VGpDvo%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2238f4bc2b03c12eac74f3d5e4ed6c27/href">https://medium.com/media/2238f4bc2b03c12eac74f3d5e4ed6c27/href</a></iframe><p>Working for a creative agency, our hardware and software choices are Apple-centric, and rightly so, everything just works. Acting like a proud but disallusioned parent, I excused the obvious and frequent shortcomings of my awkward boxy ubuntu tower when interacting with my colleagues streamlined aluminum slabs. I ran into lots of little issues that I didn&#39;t predict, like being unable to run Sketch.app, 1password, or reliably perform screencasts. These little things add up over time, and when I seen that a <a href="http://amd-osx.com/">community had formed around running macOS on AMD</a>, I was intrigued.</p><p>After hours of pre-reading I decided to bite the bullet. With data backed up, USB sticks made bootable and SSDs wiped, I got stuck in. Fast forward 24 hours and I had finally booted macOS successfully on AMD hardware. It came with a sense of achievement, but to be honest, to get to this point was relatively pain free thanks to these superb <a href="https://forum.amd-osx.com/viewtopic.php?f=24&amp;t=2707&amp;p=29772#p29772">beginner guides</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aGtUQ3ESjF66dVo1UEhhFg.png" /></figure><p>What was painful, however, was the realisation upon downloading, installing and configuring all my apps and dev toolkits, that virtualisation was not working.</p><blockquote>Virtualisation is the thing that allows your computer to simulate running other hardware devices, storage devices and operating systems. This allows a programmer to develop and test their code across a variety of platforms, despite not having physical access to these systems. For a programmer working across multiple environments, virtualisation is as important as the computer itself.</blockquote><p>Initially I thought it’d be an easy fix, I’d just have to enable virtualisation support in the BIOS. Turns out it was already on. Maybe it’s one of those flags in the boot loader? After some digging, seems we were supposed to remove dart=0 from the bootloader arguments. Ok, did that. Nope. Still not working. And so, the journey down the rabbit hole began. Stopping only to rub my eyes, I buried my head in the disjointed world of hackintosh developers. Scattered across various community forums, GitHub repos, source forge discussions, discord and IRC chats, are nuggets of golden hacker knowledge burried amongst mounds of newbie confusion. The trick is to not open too many tabs at once.</p><p>After learning the lingo, I managed to persuade some gentlemen on Discord to provide me with terminal outputs from their builds, and they confirmed my darkest fear. The current Sierra 10.12.6 kernels (by Bronya) do NOT support AMD virtualisation…yet. Virtualisation does seem to work on Intel CPUs, but I didn’t find a single soul with VMX available or kern.hv_support on their AMD builds.</p><p>So there you have it. Sadly Hackintoshs running on AMD CPUs are not ready for developers just yet. I have no doubt I’ll revisit this space in a few weeks and hopefully things will have progressed, but for now it’s back to Ubuntu.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2648f2e92ec2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>