Lin's Blog
|
  • Zh-Tw
  • Ja
  • Posts
  • Categories
  • About

Using Command to Display Notification on macOS

macOS has a handy Notification Center. You can write a program to send messages to it, and they’ll appear on screen just like on iOS. But if all you want to do is send a message, you can do it with a single command in Terminal! You don’t need to learn Objective-C or Swift to use macOS’s notification feature. For example, while you wait for tests to run, you might want to make good use of the time by reading some documentation. In that case, you can use Notification to tell you when the tests have finished. You don’t have to worry about getting so absorbed in your reading that you forget the tests are still running, and when they finish, you’ll get a notification right away, so not a moment is wasted! Of course, tests aren’t the only use. Because this Notification works as a command, any program run in Terminal can do the same thing! ...

Hardware
#MacOS
January 19, 2017 · 2 min

Rails Capybara Feature Testing: A Diary of Pitfalls

If I had to describe today in one line, it would be “I learned Capybara for the first time and immediately stepped on a landmine.” I spent a full six hours (or more) writing two simple tests, and ran into all sorts of funny landmines along the way. If I didn’t write a post about this disastrous day, I’d be too angry to sleep tonight. To be clear up front: this is my first time writing tests, so some of my understanding may be wrong or out of date. Please leave a comment and I’ll fix it right away. This isn’t a technical article. It’s a rant (angry!). ...

Programming
#Rails #Testing
January 16, 2017 · 3 min

WTF Elastic X-Pack License - How to uninstall X-Pack

If you found this article through a search engine, you probably feel the same resentment toward X-Pack that I do. At first I thought X-Pack was a free, handy plugin, so I installed it on both Elasticsearch and Kibana. Then 30 days later a message appeared saying the license had expired and I needed to “renew the license key,” otherwise I couldn’t log into Kibana. Up to that point I still assumed I just needed to register an account to get a new license key. But after browsing the official site for a long time, I couldn’t find any text about licensing, pricing, or purchasing (later I found out it does exist — in tiny print… do you people even want to make money?). In the end I only found the pricing page through a Google search. ...

SRE
#Elasticsearch #Kibana
January 16, 2017 · 3 min

JavaScript String Replace All

In JavaScript, String.replace may behave differently than you expect. When you want to replace a string, you’ll find that replace only replaces the first occurrence. For example, “AAA”.replace(“A”, “B”) gives “BAA”, not the “BBB” you might expect. This is because the first argument of JS replace is actually a regular expression, not a string. If you pass in a string, only the first match is replaced, which leads to results you didn’t expect. ...

Programming
#JavaScript
January 16, 2017 · 1 min

Setting Up User Authentication for Elasticsearch and Kibana

After you install Elasticsearch and Kibana, you will quickly run into a serious problem: “Wait, where are the username and password?” That’s right, Elasticsearch and Kibana don’t come with the usual user management module. You can only restrict access by binding them to an internal IP or port. But if you’re like my company and don’t have a fixed IP, or you want to set up several accounts, keep reading. This post shares how to set up basic user authentication for Elasticsearch and Kibana using HTTP Auth. ...

SRE
#Elasticsearch #Kibana
January 15, 2017 · 4 min

Zhangmen Craft Beer - An Awesome Beer Bar Perfect for a Drink After Work

Today I want to share a craft beer bar near Yongkang Street, by Dongmen MRT Station. Yes, you read that right — today we’re not talking about code, we’re talking about bars! I’m sure you’ll gradually get used to all sorts of odd topics showing up on this blog. The place I’m introducing today, Zhangmen Craft Beer, is a great spot for a few friends to have a drink after work. The fact that I still have the energy to write a post after drinking today should tell you how suitable it is for office workers on a weekday — and this was the first time I ever took the MRT home after drinking! Alright, enough rambling. I’ve been to Zhangmen twice, and it’s been great every time. The beer is delicious, there are more than a dozen options to choose from, and they’re all brewed in-house!! The space is comfortable and great for bringing friends to chat, but there aren’t many seats and you can’t make a reservation. I’d suggest calling half an hour before you come and asking the owner to hold a seat for you (though there’s no guarantee you’ll get one). ...

Life
#Taipei #Craft Beer
January 15, 2017 · 4 min

JavaScript: Manipulating Browser History, Changing URLs, and the Back Button Event (Essential for SPAs)

Nowadays JavaScript is everywhere. Using JS to manipulate web pages, for things like Ajax, page switching, and pop-up windows, is more and more common. There are even JS frameworks such as React JS and Vue JS that help you develop Single Page Applications (SPAs). When you manipulate a web page with JS, the thing you fear most is URL changes and history. For example, if you switch pages with jQuery, the URL doesn’t change, because it’s a JS operation. And when the user clicks the browser’s Back button in the top left corner, they go straight to another page, because JS operations aren’t recorded in the history (in fact, they can’t be). To solve this series of problems, you can use history.pushState, history.replaceState, and the onpopstate event provided by HTML5. ...

Programming
#JavaScript #HTML
January 14, 2017 · 6 min

Never Delete Items from a List Inside a Loop

“The foolish mistake I never get tired of stepping on, no matter how many times.” I always thought that once you make a mistake, you will remember it for good. But today I lost three hours to a bug at work. I could not figure out where the problem was. Finally, I carefully reread the code and realized… it was the same problem again. In one sentence: “Never delete any array element inside a loop.” ...

Programming
#Python
January 12, 2017 · 2 min

A Simple Approach to Scheduling Bulk Newsletter Sends and Handling Yahoo Deferrals

When you send a large newsletter, have you ever thought about how to send it? Say you have 10,000 addresses. Would you send them all at once, or spread them out over different times? Most people send them all at once, and that’s usually fine. If your sender reputation is good and you do this regularly, sending bulk email is normal for email providers, and the messages almost always land in the inbox. But there’s one troublemaker: Yahoo. For some reason, if you send too many emails in a short period, they get deferred (temporarily rejected). You can retry, and after a few tries they usually go through. The most I’ve seen is one that only got through after being resent 100 times. Looking at the Yahoo situation, it seems that no matter how good your reputation is, you run into deferrals when you send at high frequency in a short time, regardless of content. Here I tried several approaches to solve the problem. ...

Blog
#Newsletters
January 12, 2017 · 4 min

Implementing a Round-Up-to-Whole-Number Feature: Ideas and Methods

Recently I came across a “round up” feature on Zeczec. For example, if a checkout total is NT$1359, pressing the round-up button changes it to NT$1400. It’s a fun feature, but when I actually tried to implement it, I found that rounding up isn’t easy. There are many non-technical concerns. Here I’ll record the problems I ran into while implementing it, the process I went through, and the final solution! ...

Programming
#JavaScript
January 11, 2017 · 5 min
« Prev  Next 

Categories

All Programming AI SRE Life Hardware Software Blog Travel Web Apps Games Security
© 2026 Lin's Blog · Powered by Hugo & PaperMod