tomo's blog

Vim is grep, and more vim search tips

Something I learned the other day blew my mind even after years of using VI/vim. Because I'd also been using grep for years.

The name 'grep' comes from the vi command g/re/p

g in ex-mode of vi means 'global', so any :g command will apply to all the text in the current buffer.

p after 're' means print.

're' in g/re/p actually just means a regular expression should go there (a vim regular expression, which is different fromregex in PHP or even a re string in grep - this is where vim magic modes...

How to save battery life on MacBooks

Here are some tips I use to optimize battery life on my MacBook Pro. Being aware of energy hogging apps (all browsers) and pausing them can extend your battery life to what Apple advertises.

  1. Open Activity Monitor and switch to the Energy pane. This will tell you who the big offenders are. Chrome is a notorious energy hog, but Safari would be #1 too if you're using it to do a lot of browsing. If there's anything else in there which isn't obvious (like video players, bitcoin miners ;) then you may want to shut them down while you're on battery power. You can also get a summary
  2. ...

Stack traces, backtraces, call stacks explained in JavaScript, Python, PHP

People are rarely happy to see a stack trace. A stack trace often appears when software encounters an exception, an unexpected error which can't be handled gracefully and therefore most stop execution of the program. What the stack trace shows is what was happening in the moments leading up to the bug. The stack is called a stack because each item (each function call) is stacked on top of the previous one in a special part of computer memory called the stack. Most computers and programming languages work with a stack. In programs written in programming languages without side effects, a...

FTP vs SFTP vs FTPS vs SCP/SSH

FTP is the historically standard protocol for copying files from one computer to another over a network connection (TCP/IP, so any host on today's Internet, but it wasn't always the case). Many people including many developers learned how to use an FTP client on Windows in order to connect to a server and upload and download files.

Stop using FTP!

FTP is not secure for the same reason that HTTP is not secure and why there's a movement (Let's Encrypt) to move every website to use TLS, i.e. HTTPS instead of HTTP. The reason HTTP and FTP are not safe is that they are not...

Tricks to get the full path and filename of a file in Finder

Since I do a lot of work in Terminal and find it quicker to process files on the command line for some things so I need to get the path to a file for passing as an argument to Unix commands. It's not obvious at all how to do this from Finder. You can have Finder show the path but there's no way to copy it! Right-clicking only shows the parent directories in order to quickly navigate but not to copy (unlike Windows Explorer where you can access the path like a browser URL).

If you right click a file and select 'Get Info' you will see in the 'Where' section the parent folders are...

Using ExFAT on Mac OSX

ExFAT is an updated version of FAT (Microsoft DOS's original File Allocation Table) meant for use across platforms (not only PCs) and on external drives. Don't confuse exFAT with EXtFS. ExFAT is still a Microsoft product, meaning companies (hardware companies, like memory card manufacturers, who want to use exFAT on their disks/drives) need to pay a licensing fee to Microsoft. It is not open source. ExFAT is the file system I recommend for external USB disks.

Fortunately...

Free mailing list service: MailChimp + MPZmail + MailerLite (Freshmail + Campayn) and an unlimited bonus

How can your organization get free email list management service totaling 6000 managed addresses?

MailChimp is the leader in the full-featured managed mailing list services, helping customers get users signed up to a mailing list, then letting owners manage lists and campaigns, including editing email campgaign templates in the browser. They also let you subscribe up to 2000 members for free, This is a great way for non-profit organizations to get started. But they aren't the only company around for sending emails and their pricing when you pass 2000 subscribers, even if you are...

Drupal SEO in 2016: URLs

SEO is a moving target. For blackhat SEOs, it's a constant back and forth cat-and-mouse game between them and Google. And the potential penalties by Google against sites employing blackhat tactics should be enough to encourage you as a site owner to focus your efforts on whitehat SEO. Drupal has a lot of tools which can help site builders format their content to be easily understood and categorized by search engines. And one of those factors which Google uses is the page's URL.

So it's important to pay attention to a few things related to URLs in your Drupal config.

  1. ...

How to Use Drupal 7 Views to Count Content

Here's how to quickly use Views UI to count content in your Drupal database. You can then display the counts as Blocks or even pages or just use them internally as site admin. The only prerequisite is to have Views and VIews UI enabled.

  1. Create a new view of content (aka nodes). Leave out sorting! (Sorting/ordering won't be visible in the count anyways but can prevent counting from working.)
  2. Under Advanced settings, enable Use aggregation to Yes.
  3. Under FIELDS, only use one main field, such as a title or nid. There should
  4. ...

Scala vs Javascript (ES6, TypeScript, Node.js)

Now with Scala.js allowing isomorphic Scala code to run on both browser and server. Scala contends with JavaScript in the web domain. But assuming we are talking about web, how do the two languages compare?

First, JavaScript comes in a few flavors. There's ES5 which is currently running in all browsers. There's Node.js, which is the same Google V8 JavaScript engine but running outside the browser and thus without browser/web apis included, but which can run ES6 (EcmaScript 6). And then there are the many languages that compile or transpile down to plain old ES5 JavaScript,...