Posts

Showing posts with the label code

D3.js Favorites

(This was written and first published elsewhere in June 2020) A few years ago I got really into d3.js while working on some front end-heavy projects, and still love to see the awesome work shared by its community. (Observable notebooks are 😻)

Read-once objects

(This was written and first published elsewhere in June 2020) This concept comes from a book I really enjoyed reading last year, Secure by Design . The authors suggest using a "read-once object" to represent sensitive values to avoid unintentional use or data leakage.

A New Serverless Look

(Update 3/20/2024: If it ain't broke, do the classic developer thing and rebuild it! I've taken the site described below offline, and moved its posts here.) Until recently, I had no reason to build anything elaborate with a serverless architecture. Yet it's everywhere now! There's  Amplify , Netflify , JAM , SAM , lambdas , workers and more to learn about.

Changing PDF Metadata with Python

While updating a pdf recently, I noticed some metadata I wanted to change and a few annotations that were hidden from view but still in the file. However, the "Get Info" pane in Preview on OS X doesn't provide a metadata editor, nor does its Export function, so it seemed like a good opportunity to learn a bit more about the PDF standard and Python packages for getting the job done. Adobe Acrobat or other GUI's would've been much faster, but I'll likely need to do this programmatically again at some point like those of you who might've found this post by looking on your favorite privacy-preserving search engine for "change pdf metadata in python". So here we go. Before starting, I hopped into a new folder and created a git repository with a first commit of my original pdf in case anything went wrong. Then I ran conda create --name pdf --python=3.8.1 and conda activate pdf to set up an Anaconda virtual Environment named pdf to keep my work is...

September in (and out of) iOS

This month my intention was to continue the Udacity Nanodegree program. I think the learn-by-doing approach it takes is great, and usually works well for me. However, in a fit of frustration -- wrestling with NSRegularExpression for something that would be trivial in many other languages and forgetting about the .rangeOfString method -- I began to reflect on the overall experience and my approach to learning at this point. What were really my goals in becoming a better iOS programmer? I'm familiar with enough of the APIs and resources for learning, can wade through the docs if necessary, have built some toy apps, etc. So why the urgency to add more to the never-ending list of things to keep up with (in code, business and law)? What other stuff would get put on the backburner for a while?  Well, part of the problem is that the other stuff is never really on the backburner. I spend my days in Ruby and the browser, and absolutely love it, and my subway rides reading articles and ...

August in iOS

Last year I began working with iOS right around the time Swift came out. While I'm glad to have some familiarity with Objective C, Swift is much more comfortable (coming from working mostly in Ruby and Javascript). I soon dove in! While this blog's been silent in 2015 so far, I've got tons of draft posts sitting around that need to see the light of day. One new commitment I've made is to start posting a monthly rundown of tips, tricks and adventures as I get back into iOS development, similar to the TMIL (This Month I Learned) series I posted in 2014. Zooming back to last year when I wanted to start learning another programming ecosystem beyond the web world I know and love, here are a few of the resources that helped me get started (and very much continue to help) with the world of iOS: The Swift Programming Language  ( iBooks )  http://www.raywenderlich.com/ https://www.objc.io/   WWDC videos ( 2015 , 2014 ) Introducing iOS 8 CS 193P Zooming forward to ...

NovEmber #TMIL

Over the summer, I decided it was time to learn a client-side Javascript framework. I chose to start with Ember , mostly because it felt more like Rails and I kept hearing about the combination of an Ember app with a Rails backend. While I usually jump right in and try to build something, I had enough other coding   side projects going on at the time (and it was summer!), so I joined the Ember Weekly mailing list, attended a few of the NYC meetups and kept a loose eye on things... which have been moving along quickly ! By November, it was time for another look.

October #TMIL - Browser Extensions

From the Unfinished Business department: At the Books in Browsers Conference hackathon in October, I worked with a few others to port the Readium Chrome extension , an in-browser epub reader, to Firefox. The core team had already been working on a branch which we didn't notice before diving in. Oops. However, it seems like they ran into the same issue that prevented us from going all the way: working with the user's filesystem from the extension.

September #TMIL - Back to Drupal

Last fall, I finally got around to moving joemerante.com, a Drupal site, to a new host. It was getting a little ridiculous that I had no way to ssh into the hosted space and couldn't simply git push origin master or similar to deploy (no need for anything fancy given the traffic and simplicity of the site - see my previous workaround here ). Why didn't I just quickly redo the site in Sinatra or Rails? Mostly because it works fine as-is, I like Drupal (the nostalgia factor of being the first web framework I learned well, also it's a great CMS and community) and jumping around between different environments keeps you sharp. This post rolls through a few things I came across while moving the site, maybe it'll help someone out there.

August #TMIL - Getting Started with iOS

By August I wanted to get out of the browser and learn something entirely different! Although my journey began in anticipation of iOS 8's September release and the introduction of Swift in June, after reading tons of comments and discussions about whether to learn Swift, I decided to stick with iOS 7 and Objective-C at first to gain a better understanding of the entire iOS ecosystem.

July #TMIL - Some command line favorites

Getting close to the end of the year.. will I make all twelve TMIL posts? Let's see how far we can get as things might start to take on a "best of 2014" flavor. Here are some command line favorites I've noted and usually forget, mostly around searching: List the first ten items in a directory ls | head -10 Show only the human-readable sizes of all xml files in a directory ls -lSah *.xml | awk '{print$5}' Sum the sizes of all zip files in a directory (notice there's no -h flag to ls, this way you sum only bytes, then later convert to kilobytes then to megabytes) ls -lSa *.zip | awk '{ total += $5}; END {print total/1024/1024 "Megabytes"}'

May #TMIL - A Touch of eval()

In a Rails app, I've got a Plan that belongs to a Subscription. The Plan has a duration, and the Subscription has an expiration. The expiration gets set in an after_create callback using the current time (DateTime.now) plus the Plan's duration. Then, there's an expired? method on the Subscription which checks if self.expiration < DateTime.now . Pretty straightforward, right? (code snippet below)

April #TMIL - RSpec

As expected, this series of posts has drifted off schedule. At least the drafts have been on time! Below is a list of RSpec tips, preferences and best practices I've been accumulating over the last year, finally realizing that's it much more art than science.

March #TMIL - Ruby class macros

My how the time flies. Still, I'd rather be late than abandon my New Year's resolution early! Here are some notes that have been sitting in this draft for the last two months. Two quick tips PC Keyboard Hack is a must-have extension for me. I find it's much nicer on your hands to avoid using the Return key on the right side of the keyboard. (You can make some remappings in the Keyboard->Modifier Keys panel in the OS X system preferences; however, Return is not an available choice for remapping Caps Lock.)  Enable control-R backsearch in irb by adding this code to your ~/.editrc file : bind "^R" em-inc-search-prev Source Class macros in Ruby

Add a Keyboard Shortcut to Toggle WiFi On and Off

Clicking the WiFi icon in OS X on and off when you're trying to troubleshoot Internet connectivity or AirPort issues can be annoying and disruptive to your workflow. Here's how to add a global keyboard shortcut to do it: Copy the script from  here  and paste it into a new document in the AppleScript Editor. Save it as ToggleWifi (or whatever you want). Save it with Application as the file format. Since there's no built in way to create a keyboard shortcut to launch an application in the Keyboard system preferences panel, first create a Service in Automator. This post  shows screenshots of the steps to create the Service. Open Automator, go to File->New and choose Service from the options that appear. Set "Service receives selected" to 'no input' and leave "in" set to 'any application'. Then search for the Launch Application action in the Actions menu on the left, and drag it to the open area that says "Drag actions or files h...

February #TMIL - vim

Although it's already halfway through March, I'm not quite ready to give up on my resolution to collect a few of the things I've been learning each month as an opportunity to review the material. Don't worry, it's all a healthy exercise in non-competitive professional development. I haven't gone crazy but the risks of losing balance described here are very real, especially when you enjoy what you're doing. OK, on to the good stuff. Vim I've been meaning to learn more than the basics of Vim for years and finally dug in last month.

January #TMIL

Here's to keeping up with one New Year's resolution! Documenting and collecting resources has always helped me learn, not only for the occasional refresher but also a reminder of the progress I'm making (or not). For some of us, giving oneself a pat on the back every now and then isn't as forthcoming as it should be. Amidst the countless blog posts, tutorials, books, projects and rabbit holes, I'd like to begin collecting them a bit better. Just kidding, I'm kind of an information pack rat as anyone who's seen the multiple browsers on my computer, each with multiple windows containing dozens of tab, can attest. I'd like to start sharing more as a way to help others and help keep myself organized and focused. With that, here's the first This Month I Learned.

Book Review of POODR: It Helped the Pieces Fit Together

After an extended blogging hiatus, time to take some baby steps back in by reposting my book review on Goodreads for " Practical Object-Oriented Design in Ruby ," aka the POODR book. This book helped tie together my understanding of OOP best practices in Ruby and has produced immediate benefits in the quality of code I'm writing. It contains great examples of refactoring code, along with checklists, red flags and questions to ask yourself throughout the design process.  The author does a great job of following the development and improvement of a sample app throughout the book (an app for a bike shop). The continuous narrative helps you see how the pieces fit together, though a few examples from other domains would have been helpful in some places. At the same time, that's really an exercise for the reader.  I found Chapter 4's discussion of creating a public interface particularly helpful in determining the proper responsibilities of objects by "Ask...

Drupal Workflow with Drush, Git and git-ftp

As I prepare to upgrade some sites to Drupal 7, it seemed like a good time to document my workflow. I'd used  Drush  for local development on Drupal 6 sites and it eliminated the time spent manually downloading modules and updates. In Drupal 7, module updating isn't nearly as painful - in fact, it's built right into the admin pages (though you'll probably want to do this on a local or staging server first, just in case). A few sites I'm working on are hosted with a cPanel-based host that doesn't allow ssh access, so I can't just set up a git remote and push to the production server. Moving them to another host also isn't the best option right now.  Git-ftp to the rescue. tl:dr  Set up your site and Drush locally, commit changes to git, test then use git-ftp to push them to the production server Here's how I set up things up: Set up your site locally. For OS X, I go with MAMP .  Install Drush  and git-ftp on your machine. Initialize a git re...

Learning Patterns

I've always spent a lot of time thinking about how I learn. Topics like how long it takes to fully grasp something, whether it's something I need to passively take in or actively work with to understand, structuring unstructured time for analysis, etc. Most of this developed during my years obsessively practicing the guitar and much of it still holds true. Maybe it's more superstition than science at this point but it seems to be working! For example, before diving into writing, research or coding (or before the coffee kicks in in the morning), I'm pretty particular about warming up my brain. I'll look over my calendar or to do list(s), then play a quick game of Sudoku and read a longer form newspaper article while the to do items simmer. If I need to learn a new topic, the progression and type of analysis is essential - usually starting with an encyclopedia, reading a few articles by different authors on the same sub-topic to gain perspective, browsing academic syl...