The ONNX Runtime package makes it easy to run TensorFlow models in PHP. This short tutorial will show you how. It’s based on this tutorial from tf2onnx. We’ll use SSD Mobilenet, which can detect multiple objects in an image. First, download the pretrained model from the official TensorFlow Models project and this awesome shot of polar bears. Photo from the U.S. Fish and Wildlife Service Install tf2onnx pip install tf2onnx And convert the model to ONNX python -m tf2onnx.convert --opset 10 ...| Shorts
2023 Update: Check out Polars Ruby as well. NumPy and Pandas are two extremely popular libraries for machine learning in Python. Last post, we...| ankane.org
NumPy is an extremely popular library for machine learning in Python. It provides an efficient way to work with large, multi-dimensional arrays....| ankane.org
Welcome to another installment of deep learning in Ruby. Today, we’ll look at FER+, a deep convolutional neural network for emotion recognition developed at Microsoft. The project is open source, and there’s a pretrained model in the ONNX Model Zoo that we can get running quickly in Ruby. First, download the model and this photo of a park ranger. Photo from Yellowstone National Park We’ll use MiniMagick to prepare the image and the ONNX Runtime gem to run the model. gem "mini_magick" ge...| Shorts
The ONNX Runtime gem makes it easy to run TensorFlow models in Ruby. This short tutorial will show you how. It’s based on this tutorial from...| ankane.org
I’ve created a few Ruby gems over the years, and there are a number of patterns I’ve found myself repeating that I wanted to share. I didn’t invent them, but have long forgotten where I first saw them. They are: Rails Migrations Rails Dependencies Testing Against Multiple Dependency Versions Testing Against Rails Coding Your Gemspec Let’s dig into each of them. In the examples, the gem is called hello. Rails Migrations Create a template in lib/generators/hello/templates/migration.rb.t...| Shorts
This is an update to Securing User Emails in Rails with a number of improvements: Works with Devise’s email changed notifications Works with...| ankane.org
Encrypting sensitive data at the application-level is crucial for data security. Since writing Securing Sensitive Data in Rails, I haven’t been...| ankane.org
Suppose a worst-case scenario happens: an attacker finds a remote code execution vulnerability and creates a reverse shell on one of your web...| ankane.org
Hybrid cryptography allows certain servers to encrypt data without the ability to decrypt it. This can greatly limit damage in the event of a...| ankane.org
It feels like data breaches are showing up every week in the news. If you haven’t taken a second look at how you’re storing sensitive data, now is...| ankane.org
DVC is a version control system for machine learning datasets and models. It allows you to store large files outside of Git while keeping them...| ankane.org
The ONNX Model Zoo has a number of interesting pretrained deep learning models. Thanks to the ONNX Runtime, we can run them in Ruby. Today, we’ll...| ankane.org
Ruby isn’t a common choice for machine learning, but companies running Ruby can get tremendous value from it. I’m happy to announce it’s now...| ankane.org
I’m happy to announce that XGBoost - and its cousin LightGBM from Microsoft - are now available for Ruby! XGBoost and LightGBM are powerful machine...| ankane.org
I’m happy to announce that Lockbox now supports Mongoid. This makes it easy to add application-level encryption to your MongoDB documents. Blind...| ankane.org
Some Ruby features like scrypt and hkdf require OpenSSL 1.1. Here’s how to make it work on Mac: Install rbenv and OpenSSL 1.1 Install Ruby Open an...| ankane.org
bcrypt has been a great choice for safely storing passwords. However, as time has passed, a better alternative has emerged: Argon2. OWASP now...| ankane.org
It's important to understand where personal data is stored in your applications. Personal data that’s not encrypted at the application level is...| ankane.org
Many companies today run infrastructure where machines or containers can be replaced at any time, so you can’t depend on them for permanent...| ankane.org
Slack signs its requests so you can verify they’re authentic. Here’s a method you can use in your Rails controllers for it. :lock:| ankane.org
Here’s how to use Vault for public key infrastructure. Update: Vault now has a great article on this Install the latest version of Vault and jq...| ankane.org
QR decomposition is a stable way to solve linear regression. You can use the extendmatrix gem to do decomposition in pure Ruby. Givens rotations...| ankane.org
Jupyter notebooks are a great alternative to the Rails console for doing exploratory data analysis and building predictive models. Here’s how to...| ankane.org
The upsert gem is great for individual upserts, but for performant bulk upserts, use the activerecord-import gem. Add a unique index on the columns...| ankane.org
With the GDPR just around the corner, here are two useful ways to protect your users’ IP addresses. Both support IPv4 and IPv6, and are included in...| ankane.org
TPC-DS is a database benchmark. Create the database and load the schema Generate data Load the data Generate queries Run queries Bonus: Add Indexes...| ankane.org
TPC-H is a database benchmark. Create the database and load the schema Generate data Load the data Generate queries Run queries Bonus: Add Indexes...| ankane.org
Rollup is a great tool for building libraries. “Webpack for apps, and Rollup for libraries” Run: Add to package.json: Add dist/ to your .gitignore....| ankane.org
Install Vault, as well as JQ for JSON parsing Start the dev server Then open another window. For this demo, we’ll create a new Postgres database....| ankane.org
Simple rules to follow when creating metrics Over time: You must see how metrics change over time. Ideally you can view them by day, week, and...| ankane.org
AWS makes it easy to enable server-side encryption on many of its services, but it also provides ways to do client-side encryption well. Here are a...| ankane.org
How I personally start new apps Create Project Get the latest version of Rails Create a new app Don’t fret too much over the name - you can easily...| ankane.org
When it comes to data, you can mistakenly optimize by trying to choose the “right” technology for the job. Often, the best choice is right in front...| ankane.org
The Safely Pattern is a simple one. It allows you to tag non-critical code by wrapping it in a function. It’s built on top of exception handling...| ankane.org
Note: This article was written for Postgres 9.6 and below. For Postgres 10+, use hash indexes instead. An index on a sufficiently large text column...| ankane.org
navigator.sendBeacon is a neat new API. It allows you to send an asynchronous POST request without delaying the page unload. To prevent Can't...| ankane.org
Presto is a “Distributed SQL Query Engine for Big Data” that gives you the ability to join across data stores! :tada: Server The easiest way to...| ankane.org
A few basic steps to make your Devise setup more secure :lock: Send notifications for important events Like a user changing his or her email or...| ankane.org
R supports global error handling, making it easy to report all errors without individual tryCatch statements. Create a file to source at the start...| ankane.org
A few simple steps to keep you secure. Require 2-factor authentication for important accounts, like Gmail and GitHub. Require hard drives to be...| ankane.org
R and Python are two popular languages for data science. We use both at Instacart. This is a short guide for R. It’s quick and everything is...| ankane.org
You should see verify return:1 for each certificate in the chain. Host header injection Read about it here. Your site is vulnerable if evilsite.com...| ankane.org
Root mean squared error Mean absolute error Mean error Median - get it here| ankane.org
Note: This approach is now built into the dbx package To use a DATABASE_URL with R, do: Postgres MySQL :cake:| ankane.org
Do you know what part of your application is generating that time-consuming database query? There’s a much simpler way than grep. Add comments to...| ankane.org
My simple ~/.irbrc| ankane.org
To open a Rails console, run: Migrations| ankane.org
When interviewing candidates for Instacart’s first site reliability engineer, I volunteered to cover monitoring as one of my topics. I’d start by...| ankane.org
Running Rails 4 with attr_accessible? Upgrade in three safe and easy steps 1 First, log all instances of forbidden attributes. Add to...| ankane.org
Curious to try machine learning in Ruby? Here’s a short cheatsheet for Python coders. Data structure basics Numo: NumPy for Ruby Daru: Pandas for...| ankane.org
Git LFS allows you to version large files while storing them outside of your Git repository. Heroku doesn’t have built-in support for it, so a few...| ankane.org
I’m happy to announce another round of machine learning gems for Ruby. Like in the last round, many use FFI or Rice to interface with high...| ankane.org
In August, I set out to improve the machine learning ecosystem for Ruby and wasn’t sure where it would go. Over the next 5 months, I ended up...| ankane.org
Note: Searchkick Pro is no longer available. Searchkick makes it easy to add intelligent search to Rails applications. It was launched in 2013 back...| ankane.org
A new version of Lockbox was just released with support for types, making it easier to encrypt non-string fields. Previously, you’d need to perform...| ankane.org
Blind indexing is an approach to securely search encrypted data with minimal information leakage. I’m happy to announce that Blind Index 1.0 was...| ankane.org
When you connect to a database, Postgres uses the sslmode parameter to determine the security of the connection. There are many options, so here’s...| ankane.org
Use client-side encryption to encrypt your data before sending it to S3. You can provide an encryption key to use directly or a KMS key for...| ankane.org
Many companies start out with a single web application. As the team and codebase grow, things feel less organized and common tasks like booting the...| ankane.org
Organizations today have more data than ever. Predictive modeling is a powerful way to use this data to solve problems and create better...| ankane.org
Encryption is a common way to protect sensitive data. Generating a secure key is an important part of the process. attr_encrypted, the popular...| ankane.org
There is an updated version of this post. The GDPR goes into effect next Friday. Whether or not you serve European residents, it’s a great reminder...| ankane.org
Securing database traffic inside your network can be a great step for defense in depth. It’s also a necessity for Zero Trust Networks. Both Amazon...| ankane.org
It’s been over 2 years since PgHero 1.0 was released as a performance dashboard for Postgres. Since then, a number of new features have been added....| ankane.org
Your database knows which queries are running. It also has a pretty good idea of which indexes are best for a given query. And since indexes don’t...| ankane.org
Setting up database users for an app can be challenging if you don’t do it often. Good permissions add a layer of security and can minimize the...| ankane.org
Here’s a quick guide to setting up Google OAuth as your app’s exclusive authentication method Add to your Gemfile And run Create a User model In...| ankane.org
Content Security Policy can be an effective way to prevent XSS attacks. If you aren’t familiar, here’s a great intro. To get started with Rails,...| ankane.org
The official guide is a great place to start, but there’s more you can do to make life easier. :tangerine: Based on lessons learned in the early...| ankane.org
:droplet: Your very own PaaS Create Droplet Create new droplet with Ubuntu 16.04. Be sure to use an SSH key. Install Dokku And visit your server’s...| ankane.org
:elephant: Get running with the last version of Postgres in minutes Set Up Server Spin up a new server with Ubuntu 16.04. Firewall Automatic...| ankane.org
In under 5 minutes Get Started Here’s the flow: You can install PgBouncer on the same server as Postgres or a separate server. For Amazon RDS, you...| ankane.org
Note: This approach is now packaged into a gem :gem: One of the easier ways to scale your database is to distribute reads to replicas. Desire...| ankane.org