I test my wordpress plugins with: wp-env run tests-cli vendor/bin/phpunit and I put this in a bin/test.sh script. If I add a .git/hooks/pre-push script: #!/bin/bash ./bin/test.sh and git push , I see this error: the input device is not a TTY ✖ Command failed with exit code 1 Command failed with exit code 1 error: failed to push some refs Docker checks whether stdin is a TTY before executing. I…
The goal: a static Nim binary that can make http requests using ssl with no dependencies or runtime configuration. This is useful for creating single-file deployables or running in minimal container environments like scratch . Static Binary Hello World nimble init and select "binary". nimble run will print "Hello, World!" To isolate the environment, build this in a docker image: FROM…
Context Hello World Logging the Visible Map Region Plotting a Polyline Using Core Data Filtering results with NSPredicate Context I had an idea for an iOS app that would display my location history in a visually interesting way and ran into this problem: How do I change the @FetchRequest 's predicate when someone pans or zooms the map? I was able to setup the location tracking, storing coordinates…
I recently had a need to create a jwt with a valid signature in a browser without using a library. Creating a JWT The header and the payload const header = { "typ" : "JWT" , "alg" : "ES256" } const payload = { "iss" : "joe" , "exp" : 1300819380 , "http://example.com/is_root" : true } are base 64 encoded const base64UrlEncode = ( object ) => { return btoa ( JSON . stringify ( object ) ) } to…
I've been working my way through Robert Nystrom's Crafting Interpreters and had to learn some Java in order to run the Scanner class implemented in Chapter 4. The last time I wrote Java was right before I withdrew from my first CS 101 course, so I had to put some time into mastering the basics. This post documents a handful of the things I had to learn to start scanning tokens in Lox! Here's a…
See what I did there? I recently encountered a project that used require for including external modules, and when upgrading the dependency's major version, I was met with this error: Error [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/beeper/index.js from .../index.js not supported. Instead change the require of index.js in .../index.js to a dynamic import() which is available in all…
Demo Background and motivation How it works Generate a session secret Poll for the SSH connection SSH in with the session secret Map the session secret to the user's public key Redirect to an authenticated page Next steps Other projects worth checking out Demo Visit https://auths.sh/ and follow the command line instructions, or browse the source code , specifically: ssh.go - the SSH server http.go…
I was recently working on a SOAP client user interface and needed the ability to nest inputs to an arbitrary depth and edit the data inline. Demo Given an object of unknown depth: { "age" : 33 , "name" : { "first" : "Jesse" , "last" : "Shawl" } , "interest" : { "javascript" : { "for" : "sure" } } } Display a form that visually matches the data structure and allows users to edit the data. See the…
I recently had a need for an <input type='range'> with start and end buttons, so I built one: See the Pen Dual Range Input Hello World by Jesse Shawl ( @jshawl ) on CodePen . View on GitHub View on npm I made a few API and design decisions that I wanted to think through here for the next npm package I might build. Design Decisions Functional UI From the Start It is important to me that a…
We all have to start somewhere, right? This is my new side hustle: https://www.telephony.cc I'm feeling super optimistic about starting something new, and am placing bets on the things that are important to me. I can't remember the last time I called a business let alone answered a phone call. I almost always prefer sms so that I have time to think about my response and/or have a papertrail for…
When publishing on npm, how do you know that what you intend to publish is what ends up getting published? Worst case scenario a bad build config publishes secrets like a .env file. Given the following project: $ tree -a . ├── .env └── package.json 0 directories, 2 files and those files' contents: $ cat package.json { "name": "bad-npm", "version": "1.0.0" } $ cat .env SUPER_SECRET=true…
In this post, I'll walk through my process of creating a recursive Vue.js component, that is, a component which can render itself. Demo Completed Code Wait, What? Why?! I recently had a need for building a custom file-browser, which allowed users to click through any number of folders and files stored on their Dropbox account. A directory listing is a classic example of recursion. Imagine the…
If you are using Rails' form helper collection_check_boxes , it's not entirely obvious how you might go about customizing the label's html. The "Normal Way" ...or what frequently shows up in the documentation . Say we have the following Ruby classes: class Post < ActiveRecord :: Base has_and_belongs_to_many :authors end class Author < ActiveRecord :: Base has_and_belongs_to_many :posts def…
I recently made a few upgrades to updog.co which have decreased the Time To First Byte dramatically. Before: After: Wait, What?! How?! Updog uses memcached as its cache store, and requests to the Dropbox API were cached for 5 seconds to avoid exceeding Dropbox's API rate limits. Here's some pseudo-ruby code: Rails . cache . fetch ( the_content , expires_in : 5. seconds ) do # If nothing found in…
View demo | View code I recently built an application - https://stopgap.store/ which is a simple way to get up and running with an API with almost zero configuration. In an effort to demo its capabilities, I thought I'd explore working with the fetch API as well. Fetch is an experimental technology! TOC {:toc} Initial Setup We're gonna do this thing entirely in a single html file: <! doctype html…
"Dependency injection" is a somewhat scary term to explain loading modules and making sure memory footprint is minimal. I've been thinking a lot about Angular's $injector and how I might build a dependency injector from scratch. A thing that creates things À la angular, I wanted an injector as the global namespace, a module method that allows me to both read and create modules. Let's start with…
I just finished The Art of Unix Programming and I highly recommend it. I ended up reading the book cover to cover but it's written in such a way that you can skip around if you like. Despite being last updated over 12 years ago, the book is surprisingly relevant today and I wanted to document some of my favorite parts: Configuration Over the years I've noticed patterns in both configuration files…
Hoisting is often convenient in JavaScript. It allows us to call functions before they’re defined: sayHi ( ) function sayHi ( ) { console . log ( 'oh hey' ) } If you define a function inside of a conditional, you run the risk of having a function being overwritten via hoisting: if ( true ) { function truthy ( ) { document . write ( "true is true!" ) } } else { function truthy ( ) { document .…
I recently built an application - restful.link in order to inspect the data that was sent as a webhook, like information about about any new pull request on GitHub. I had to keep manually opening pull requests on github.com anytime I wanted to process the data that was posted. This was time consuming, so I implemented a new feature which allows users to proxy new requests and resend existing…
When recommending any new service like Dropbox or DigitalOcean, I send my referral codes to the potential customer in hopes that they’ll sign up, and my account will be credited accordingly. Instead of having to look up these referral codes for each of these interactions, I’ve created a few nginx aliases to make the links easier to share. In my domain’s nginx configuration file, I’ve added: #…
Unfortunately, undoing a git clean is impossible, as C’s unlink() is called on each of the untracked files (and directories if -d is supplied). I was working on a rails application earlier this week and wanted to implement a third party login authentication system. So I created a feature branch and began working on implementing the OAuth flow. I created a new file to store all of my API keys and…
I recently came across a gem for handling user authentication with sinatra - sinatra simple authentication . This gem was easy to install and use, but the log in and sign up views were hardcoded in Haml. This meant I couldn’t take advantage of Sinatra’s layout.erb global view, and any shared markup (navigation, footer, etc.) would have to be copied and pasted into each of the views, and be written…
I’ve been playing around with mercurial as of late as a way to enhance what I know about git and version control in general. These are my in-progress notes. A lot of things are familiar hg help behaves like git help hg init behaves like git init . hg status behaves like git status . but with more cryptic responses: $ touch newfile && hg status #=> ? newfile no output indicates a clean working…
I recently created a landing page for my jshawl.github.io domain and wanted to get all of my public repos from the github api. At first, I considered writing a little ruby script, triggered by cron job that would fetch all of my repos and save the output as a JSON file. This would allow me to reuse an existing codepen to display and filter all of my repos. Instead, I thought I’d just use…
Submitting pull requests with few files changed and a clean history means cleaning up your commits. One common solution is to do an interactive rebase and squash commits to rewrite history. While on a feature branch, I would git rebase -i master , which requires me to remember a few things: Have I pushed this branch to a shared remote? What changed in each commit? I often forget the answer to both…
I was working on a rails application that responded with the following JSON: [ { "id" : 14 , "title" : "post title" , "description" : "my awesome description" , "user_id" : 1 , "created_at" : "2014-10-29T02:50:01.707Z" , "updated_at" : "2014-10-29T02:51:38.481Z" } ] Even though I have access to the user_id attribute of this post, I wanted to be able to show the user name or email without having to…
I've recently removed the /finds-links url from my site, which was a jQuery plugin powered by pocket. This project, "The Q" has come back to life as a rails application that lets users expose links saved in their Pocket account. Check it out at http://the--q.herokuapp.com/ . I might bring back the /finds-links page by collecting JSON from The Q . I wanted to share / document my workflow for…
Last night, Ramsay Lanier and I competed in DC's first devbattle. Our challenge was to build a basic crud app with users, posts, and comments. The winner Was Jesse Shawl! I completed the challenge in a mere 19 minutes. View the solution Check out more of the action from Twitter: devbattle-01
Today I learned how to listen to <select> change events, and store the selected option in plain-jane javascript: See the Pen phLAj by Jesse Shawl ( @jshawl ) on CodePen . I had never heard of the selectedIndex method, so I checked out the documentation on the mozilla developer network . I'm not sure this is super useful outside the context of dropdown menus, but it's a heck of a lot easier than…
Today I learned how to self-host gh-pages-esque project pages in an easy way using an nginx alias. I have my main domain: http://jshawl.com/ which lives in /var/www/jshawl.com/ I wanted to be able to cd into that directory, clone any new repos, and if there is a gh-pages branch, serve it with the url as http://jshawl.com/project-name/ . Normally, this URL structure doesn't play nicely with jekyll…
Jekyll 2.1.0 was recently released, and my name is listed under the contributors! http://jekyllrb.com/news/2014/06/28/jekyll-turns-21-i-mean-2-1-0/ It was only a small css change , but it's the thought that counts, right?!
Linode has recently expanded their hosting offering to include a $10 a month plan. The stats look good, and I almost binge-bought a new virtual private server, to return to my linode roots. I used to be a linode user and evangelist until Digital Ocean popped up seemingly out of nowhere with their solid state drive and cheaper hosting options. I decided to dig in deeper and compare the two $10…
Earlier this week, I began working on my first npm package. I've published it, but only to understand how packages are distributed via npmjs.org . I built a simple little command line tool to upload files to my server and print out the url to the resource in the console. Since I wanted to use this command without specifying a path to the executable, I knew I had to install it globally. Normally I…
Sometimes, I will receive a pull request to one of my repositories that has commits that affect several files. I want to merge the changes to one or two of those files across several commits, but ignore the changes to the other files. Getting the latest changes. First, create a new branch and pull in the commits submitted in the pull request: $ git checkout -b pull-request-23 $ git pull…
I recently watched a talk by Tim Berglund on advanced git - http://vimeo.com/49444883 wherein he demos some git plumbing commands with a git log that keeps refreshing. It looks like this: This is incredibly useful for visualizing what's happening to your repository as you switch between and modify branches. The code below has been reproduced from his original gist #!/bin/bash while : do clear git…
Did you know?! You can see github-style commit stats from the command line. $ git shortlog -sn | head -5 This will summarize the output of git log, sorted by number of commits per author, with only the author's name and total commits. ~/jekyll-source git:(master) git shortlog -ns | head -10 1654 Parker Moore 409 Tom Preston-Werner 395 Matt Rogers 145 maul.esel 96 Anatol Broder 85 Nick Quaranto 56…
Sometimes I binge code for like 3+ hours and work on several unrelated things. Since I'm so in the zone, I often forget to commit regularly, and am left with a bunch of changes not yet staged for commit when I take a break: ffffffaaaacccckkkkkk!!!!!!! First, I stage the changes: $ git add . And then create a new branch and prefix the branch name with wip $ git checkout -b wip/clean-me This…
The standard git log is pretty useless: It tells me nothing about my current branch and/or how it differs from its upstream counterpart. I personally use: $ git log --all --decorate --graph --pretty=format:"%C(yellow)%h%Creset %C(auto)%d%Creset %Cblue%ar%Creset %Cred%an%Creset %n%w(72,1,2)%s" It shows all of my current local and remote branches, commit times in "time-ago" formats, author names,…
Have you seen this before when running git push with no remote or branch name specified? $ git push warning: push.default is unset; its implicit value is changing in Git 2.0 from 'matching' to 'simple'. To squelch this message and maintain the current behavior after the default changes, use: git config --global push.default matching To squelch this message and adopt the new behavior now, use: git…
A note about browser support: There's some pretty crazy stuff going on in this post. The support for pseudo classes and elements is quite good, and you can start using them in production now. The code examples in this post show properties without vendor prefixes for readability purposes. If you're not using Compass or Autoprefixer to deal with vendor prefixes, you can always reference Can I Use to…
I've come to appreciate that scary git command - git rebase . I've found two incredible uses for it: Updating feature branches with progress made on master. Avoids those nasty merge commits. Cleaning up feature branches before merging with master There's no need to keep 'fix typo' commits in our git history. Updating feature branches Say you've branched from master to work on a new topic. Since…
In May of 2012, Chris updated a previous post about dynamic page replacing content . This article is an update to that update, which uses the HTML5 history API for a better user experience. Here's a quick recap of the best practices: Works fine with JavaScript disabled. It is possible to "deep link" to specific content. The browsers back button and forward button work as expected. The problem with…