Tag: Github

  • New site, who dis

    New site, who dis

    I haven’t developed a new WordPress theme for this website (that I really loved) in a long time. So naturally, it was time to re-examine my personal tech stack. If you personally know me, you know I’m a WordPress advocate. Big fan of ol trusty.

    There’s a few problems with WordPress I’ve been hung up on for a while now. It can be a bit slow (sometimes). Media managing can be painful on the front-end. Deployment processes are… all over the place. Historically, I’ve been a huge fan of Trellis from Roots. While we’re at it, I was a big fan of Bedrock too. Finally, I work with React and JavaScript all day long — why can’y my personal website run on a modern tech stack too?

    Well, I came across this post from Chris Coyier, and I was pretty much sold on the JAMStack concept immediately. At work, and at other organizations like Twitter, server-rendered pages are stupid fastest. Heck, they’re typically standard these days for most web apps. Enter the Gatsby + WordPress stack. Why abandon years of publishing paradigms when you can keep them?

    There’s no shortage of tutorials on the Gatsby + WordPress setup. Initially I played around with some starter projects, like this one. I personally started (and later forked) with egghead.io’s starter. It’s pretty spectacular out-of-the-box, and if you enjoy love @emotion theming or styled-components, I think you’ll dig too. But, really Gatsby itself has a lot to love. For example, Gatsby has drop-in support for server-rendering. Super cool stuff. I really enjoyed Juliano Rafael’s (@frontendwizard) notes on this subject:

    Progressive image loading? Inlining of critical CSS? Painless PWA configuration? You name it, Gatsby got you. It is really impressive. Don’t believe me? I encourage you to try it out.

    The solution for images is so good, that is constantly referred as a strong point of Gatsby, even thought it actually is a plugin. All you gotta do is add a couple of plugins into your Gatsby config file and you’re good to go. Your images will be available on the GraphQL API at build time and the image component will handle all the resize, picking the best file format and everything else. You even get a blur up effect to improve the user experience for free.

    That’s just the tip of the iceberg. Seriously. These web apps freakin purr. I’m overdue for writing a full tutorial on this subject, so stay tuned. But, for now I want to share a high-level overview of the technical lift I undertook for my site migration.

    My order of operations (yours might be slightly different):

    Now that we have our API-site prepped for deploy-hooks, exposed the frontpage and menus endpoints — we’re ready to consume the API with our server-rendered React app powered by Gatsby. Here’s a sample of my gatsby-config.js file:

    ...
    resolve: `gatsby-source-wordpress`,
    options: {
      // Your API WordPress source goes here.
      baseUrl: `example-api.https://stephen.nyc`,
      protocol: `https`,
      // Fetches posts, tags, categories, etc from the baseUrl.
      includedRoutes: [
        '**/menus',
        '**/categories',
        '**/frontpage',
        '**/media',
        '**/pages',
        '**/posts',
        '**/tags',
        '**/users'
      ],
      useACF: false,
    },
    ...

    I absolutely love this setup.

    All of the un-fun configuration stuff is already handled by the WordPress/WP REST API side, and all of the actually fun conventional interface building is done on the… well, the interface side. A complete separation of church and state, if you will. It’s a thing of beauty. Absolute zen.

  • How to Rename a Branch Locally and Remote in Git

    This took some googling, so I thought I would document my findings here.

    Locally

    If you’re already on the branch you’d like to rename, just run:

    git branch -m new-name

    If you’re on say master, and you have a branch you want to rename now but no checkout, run:

    git branch -m old-name new-name

    Now that you’ve taken care of your local branch, there’s the unfinished business of mending your remote branch with renaming.

    Remote

    If you use Github or Gitlab (or whatever) you’re going to want to remove the old-name branch and push the new-name branch:

    git push origin :old-name new-name

    And finally, push to reset the upstream branch so your local and remote branches are up-to-date:

    git push origin -u new-name
  • How to Move Existing, Uncommitted Work to a New Branch in Git

    So here’s a new one for ya.

    I was working on a branch all day, closed the laptop, went home and fell asleep. Nothing out of the ordinary. The next day, I awoke, and upon returning to work, immediately began working on a new problem.

    The issue arose when I discovered to my horror that I was still on the same branch from yesterday! *Gasp*

    Lest we forget, we have Git at our disposal — so I take a breath and dive in:

    git status

    This will probably return a list of changes not staged like this:

    On branch fix-from-yesterday
    Your branch is up to date with 'origin/fix-from-yesterday-'.

    Changes not staged for commit:
    (use "git add …" to update what will be committed)
    (use "git checkout -- …" to discard changes in working directory)
    modified: project/api-v4.php
    modified: web/assets/js/some-project/package.json
    ...

    Now that we have a pulse on things, we can do this:

    git checkout -b new-branch-of-changes-for-today

    This will leave your current branch as is, create and checkout a new branch and keep all your changes. You can then make a commit with:

    git add <the files you want commit>

    and finally, commit to your new branch with ol trusty:

    git commit -m "Make sure your description is short and sweet"

    And there you have it! According to the git-checkout documentation, -b and -B are interchangeable. Here’s the rub:

    Specifying -b causes a new branch to be created as if git-branch[1] were called and then checked out. In this case you can use the --track or --no-track options, which will be passed to git branch. As a convenience, --track without -b implies branch creation; see the description of --trackbelow.


    If -B is given, <new_branch> is created if it doesn’t exist; otherwise, it is reset. This is the transactional equivalent of

  • David Letterman’s Paper Monuments

    David Letterman’s Paper Monuments

    For the uninitiated, from 1982 to 2015 David Letterman played host to the Late Night with David Letterman. That’s 32 years. A long commitment to say the least. Most productions like these take the summers off, but apart from a short summer reprieve — running a continuous late-night series like Letterman took some real work. Taking stock of your labors can take many forms:

    For artists, it’s their sketchbooks.

    Writers, it’s their notebooks.

    Readers, it’s their libraries.

    For others, their Retweets? Their Github contributions?

    For Letterman, it was his paper cups.

    These paper monuments keep us going I suppose. Ephemeral things — a growing glory like that ivy plant in your apartment. Something to ponder.

  • Thoughts on Microsoft Acquiring Github

    Thoughts on Microsoft Acquiring Github

    So, this just happened. It’s official. Microsoft will acquire GitHub for $7.5 billion in Microsoft stock. Quite the price tag.

    I’ve used Github for years. I’m sure many of you have too. It’s really a remarkable place. Millions of users, all humming at their own pace, piecing code together. Hundreds of millions of unique repositories of codebases, open-source projects, communities, and amazing software.

    I’m a little concerned and sidewinded by the sheer magnitude of this story. Github has largely been hailed as the neutral library of the world’s code. Communities and enemies alike have been forged in fiery maelstroms of pull requests and pithy “+1” comments on issues. But, for the most part, Github has been a great product. Apart from the occasional server downtime or DDoS attack from China, it’s been great. And personally, the community has largely been life-changing for me. If it weren’t for the community, I probably wouldn’t be where am now.

    I can say with certainty, I’m a better developer because of Github.

    It’s important to note that Github has been the center of decentralized projects such as Bitcoin Core, or IPFS. Which may be problematic for many organizations realizing that their codebase is hosted online by none other than Microsoft now. I’m sure the irony is not lost on them either. The Hacker News discussion is pretty temperate so far. Very few are conflicted, and even fewer hate it. But, going forward, I believe Github will have an uphill battle regarding trust.

    So, what are we to make of the new proprietor? Will Microsoft make sweeping changes to how the product operates? How will repos change? Will repos become a signal for Microsoft to source talent on LinkedIn? I’m so curious to understand Satya Nadella’s motive for acquisition. Microsoft is so huge, and we’ve all seen the negative side of acquisitions before. You know, like LinkedIn.

    https://twitter.com/darylginn/status/1002879517751414784

    Ugh. Damnit. That’s the stuff of nightmares right there.

    From The Verge:

    Microsoft is the top contributor to the site, and has more than 1,000 employees actively pushing code to repositories on GitHub. Microsoft even hosts its own original Windows File Manager source code on GitHub. The service was last valued at $2 billion back in 2015, but it’s not clear exactly how much Microsoft has paid to acquire GitHub.

    So that makes sense. I had no idea Microsoft was such a huge contributor. At any rate, Microsoft has never been great at shipping their own creations. Hell, Microsoft never even developed DOS. They bought it. From that perspective, I’m less worried than say if Google or Facebook had acquired Github.

    What feels like eons ago in 2014 when Nadella joined Microsoft, John Gruber wrote:

    Satya Nadella needs to find Microsoft’s new “a computer on every desk and in every home running Microsoft software”. Here’s my stab at it: Microsoft services, sending data to and from every networked device in the world. The next ubiquity isn’t running on every device, it’s talking to every device.

    I thought this was noteworthy to dig up from the Daring Fireball archive. Namely because of the (very) timely news that Microsoft is now more valuable than Google. Sure, market cap fluctuates — regardless, Nadella is penning Microsoft’s new message, and it’s in permanent marker. It’s true that Microsoft in recent years has taken a backseat in services, but only because they’ve gobbled up the best talent in the world. Microsoft is and will continue to, play the long-game. This was a bold and genius move.

    I’m apprehensively optimistic about this. Like I said, trust is an uphill battle. Don’t disappoint us Microsoft.

    Further Reading: