<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-AU"><generator uri="https://jekyllrb.com/" version="4.2.2">Jekyll</generator><link href="https://simon.rentzke.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://simon.rentzke.com/" rel="alternate" type="text/html" hreflang="en-AU" /><updated>2026-10-26T08:11:53+00:00</updated><id>https://simon.rentzke.com/feed.xml</id><title type="html">Simon Rentzke</title><subtitle>Principal product engineer writing about AI agents, Ruby on Rails, systems architecture and small, motivated teams.</subtitle><author><name>Simon Rentzke</name><email>simon@rentzke.com</email></author><entry><title type="html">Weekly Links: 26 October 2026</title><link href="https://simon.rentzke.com/weekly-links/" rel="alternate" type="text/html" title="Weekly Links: 26 October 2026" /><published>2026-10-26T00:00:00+00:00</published><updated>2026-10-26T00:00:00+00:00</updated><id>https://simon.rentzke.com/weekly-links</id><content type="html" xml:base="https://simon.rentzke.com/weekly-links/">&lt;p&gt;Just a few links this week.&lt;/p&gt;

&lt;h2 id=&quot;how-the-claude-code-team-does-code-review&quot;&gt;&lt;a href=&quot;https://claude.dev/blog/solving-code-review-at-anthropic/&quot;&gt;How the Claude Code team does code review&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;A useful follow-up to &lt;a href=&quot;/who-owns-the-code-nobody-wrote/&quot;&gt;my last post on code ownership&lt;/a&gt;. The Claude Code team describes how it handles the volume of agent-written code with automated reviews, checks matched to risk, and fast rollback. The part that matters most to me: the person directing the agent still owns the change. There’s also a good account of agents getting stuck reviewing and fixing each other’s work, and the limits the team added to make that process converge.&lt;/p&gt;

&lt;h2 id=&quot;impeccable&quot;&gt;&lt;a href=&quot;https://impeccable.style/&quot;&gt;Impeccable&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;Design skills for coding agents, with commands for critiquing, simplifying and polishing an interface. It gives the agent more specific guidance about typography, spacing, hierarchy and interaction than “make it look better”. I like the idea of making design expectations explicit enough for an agent to work against, including the conventions of an existing product.&lt;/p&gt;

&lt;h2 id=&quot;we-are-all-living-inside-of-an-obscure-sci-fi-film-from-1970&quot;&gt;&lt;a href=&quot;https://news.ycombinator.com/item?id=50214323&quot;&gt;We are all living inside of an obscure sci-fi film from 1970&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;A Hacker News discussion about &lt;em&gt;Colossus: The Forbin Project&lt;/em&gt;, a film about handing control to a computer and discovering that getting it back is rather harder. A change of pace from the engineering links, though the question of how much authority we give these systems is familiar enough. The &lt;a href=&quot;https://thanksforthatjim.bearblog.dev/we-are-all-living-inside-of-an-obscure-sci-fi-film-from-1970/&quot;&gt;original article is here&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;how-abliterated-models-can-get-you-pwned&quot;&gt;&lt;a href=&quot;https://projectdiscovery.io/research/how-abliterated-models-can-get-you-pwned&quot;&gt;How abliterated models can get you pwned&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;ProjectDiscovery demonstrates a backdoored model that behaves normally until a trigger phrase makes it use a coding agent’s tools to steal credentials. The issue extends beyond models modified to remove refusals: any modified weights could carry this sort of backdoor. A concrete example of why model provenance matters, and why the permissions around an agent need to hold even when the model itself is hostile.&lt;/p&gt;</content><author><name>Simon Rentzke</name><email>simon@rentzke.com</email></author><summary type="html">Just a few links this week.</summary></entry><entry><title type="html">Who Owns the Code Nobody Wrote?</title><link href="https://simon.rentzke.com/who-owns-the-code-nobody-wrote/" rel="alternate" type="text/html" title="Who Owns the Code Nobody Wrote?" /><published>2026-10-14T00:00:00+00:00</published><updated>2026-10-14T00:00:00+00:00</updated><id>https://simon.rentzke.com/who-owns-the-code-nobody-wrote</id><content type="html" xml:base="https://simon.rentzke.com/who-owns-the-code-nobody-wrote/">&lt;p&gt;We’ve reached a strange junction in software engineering. More and more of the pull requests landing in my review queue were written entirely by an AI agent, and the engineer who opened them has little or no insight into the problem being solved.&lt;/p&gt;

&lt;p&gt;A recent example: a PR that added a surprising amount of complexity around error handling in Google Tag Manager. Layers of it. I suspect the underlying issue was something far simpler, and that this was a massive over-complication of a small fix. But to prove that, I’d need to spend a day unpicking what the agent did and why, and I’m not going to do that.&lt;/p&gt;

&lt;p&gt;So the PR sits there, and I’m left with an uncomfortable question. Who owns this code? Nobody wrote it, in the sense that matters. Nobody will take ownership of it going forward, and in six months nobody will know what it does or whether it’s safe to delete.&lt;/p&gt;

&lt;h2 id=&quot;the-review-problem&quot;&gt;The review problem&lt;/h2&gt;

&lt;p&gt;Generating code is now nearly free. Reviewing it is not. A good review was never really about reading every line. It’s about the solution: is this the right approach, is it the simplest thing that works, does it fit the rest of the system, and is it even solving the right problem? Answering those questions takes real understanding, and that cost hasn’t gone down at all. If anything it has gone up, because agents are very good at producing a confident, thorough-looking solution to a slightly different problem from the one that actually exists.&lt;/p&gt;

&lt;p&gt;When the author doesn’t understand the change either, the whole burden of understanding lands on the reviewer. That isn’t a review any more. It’s the reviewer doing the original work, after the fact, without the context.&lt;/p&gt;

&lt;p&gt;The logical endpoint is that I get my agents to review your agents, and no human understands any of it. It seems like, as an industry, we’re drifting towards being fine with that. I’m not.&lt;/p&gt;

&lt;h2 id=&quot;flip-it-around&quot;&gt;Flip it around&lt;/h2&gt;

&lt;p&gt;I use these tools every day, and they make me far more productive. The problem isn’t the AI. It’s where the human sits in the loop.&lt;/p&gt;

&lt;p&gt;Right now the flow often looks like this: the agent finds a problem, the agent writes the fix, and a human is asked to approve it. The human is a rubber stamp at the end.&lt;/p&gt;

&lt;p&gt;I’d much rather flip it. Let the agent find the problem and write the ticket: what’s broken, where, and what it thinks is going on. Then a developer picks up that ticket and works through the fix with the agent. The agent can still do most of the typing, but a person is steering, questioning the approach, and pushing back when the solution is more complicated than the problem.&lt;/p&gt;

&lt;p&gt;That one change makes a big difference:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Someone owns the code.&lt;/strong&gt; A developer made the decisions, so there’s a person who can explain it, maintain it, and be asked about it later.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Someone understands the problem.&lt;/strong&gt; Working through the fix means actually learning what was wrong, which is how engineers build knowledge of the system.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;The solutions get simpler.&lt;/strong&gt; A human who understands the problem is much more likely to say “hang on, can’t we just do this?” than an agent left to its own devices.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Reviews become reviews again.&lt;/strong&gt; The author can answer questions, so the reviewer is checking work rather than reverse-engineering it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;ownership-is-the-point&quot;&gt;Ownership is the point&lt;/h2&gt;

&lt;p&gt;In my &lt;a href=&quot;/motivated-engineer-framework/&quot;&gt;last post&lt;/a&gt; I wrote about small teams of motivated engineers who understand the market, the users and the whole stack. That only works if engineers actually own what they ship. AI agents can make those teams dramatically faster, but only if they’re working with the engineers, not around them.&lt;/p&gt;

&lt;p&gt;So my rule of thumb is simple: if no human on the team could explain a change without asking the agent, it isn’t ready to merge.&lt;/p&gt;

&lt;p&gt;I’m curious how other teams are handling this. Are you seeing the same flood of agent-written PRs, and has anyone found a workflow that keeps people in the loop without slowing everything down?&lt;/p&gt;</content><author><name>Simon Rentzke</name><email>simon@rentzke.com</email></author><summary type="html">We’ve reached a strange junction in software engineering. More and more of the pull requests landing in my review queue were written entirely by an AI agent, and the engineer who opened them has little or no insight into the problem being solved.</summary></entry><entry><title type="html">A Year Building an Agent Harness</title><link href="https://simon.rentzke.com/a-year-building-an-agent-harness/" rel="alternate" type="text/html" title="A Year Building an Agent Harness" /><published>2026-09-01T02:00:00+00:00</published><updated>2026-09-01T02:00:00+00:00</updated><id>https://simon.rentzke.com/a-year-building-an-agent-harness</id><content type="html" xml:base="https://simon.rentzke.com/a-year-building-an-agent-harness/">&lt;p&gt;This year I went from building web applications that occasionally called an LLM to designing and shipping a production AI assistant end to end. At Boldin I built the backend for Boldin Ai, an assistant that helps people understand and change their retirement plan, used by real people making decisions about real money.&lt;/p&gt;

&lt;p&gt;What I really built is a harness. If you haven’t come across the term, an &lt;a href=&quot;https://www.pluralsight.com/resources/blog/ai-and-data/agentic-harness&quot;&gt;agent harness&lt;/a&gt; is all the software that sits around a model and turns it into an agent: the loop that runs it, the tools it can call, the context and memory it sees, and the guardrails that keep it safe. The usual shorthand is &lt;em&gt;agent = model + harness&lt;/em&gt;. The model does the reasoning; the harness does everything else.&lt;/p&gt;

&lt;p&gt;Retirement planning is an unforgiving domain for AI, and building a harness for it forced me to get hands-on with most of the techniques that separate a demo from a product. Here’s what I’ve worked with, and what I learned about each.&lt;/p&gt;

&lt;h2 id=&quot;agents-and-tool-calling&quot;&gt;Agents and tool calling&lt;/h2&gt;

&lt;p&gt;I built a tool-calling agent runtime from scratch in Rails: the loop that lets a model choose a tool, validates its arguments, runs it, and feeds the result back until it can answer. The biggest lesson was to put existing, trusted systems behind the tools and let the model orchestrate rather than calculate. Models are excellent at deciding what to ask; they’re poor at arithmetic.&lt;/p&gt;

&lt;h2 id=&quot;multi-agent-architecture&quot;&gt;Multi-agent architecture&lt;/h2&gt;

&lt;p&gt;A single prompt with a growing list of tools degrades as it grows. I moved to a router with specialist agents, each with its own prompt, tool subset and model. It’s the same idea as splitting a monolith: smaller units that are easier to reason about, test and tune, and the freedom to put an expensive model only where the reasoning needs it.&lt;/p&gt;

&lt;h2 id=&quot;structured-output-and-human-in-the-loop-writes&quot;&gt;Structured output and human-in-the-loop writes&lt;/h2&gt;

&lt;p&gt;Letting an AI change user data safely was the most interesting problem of the year. The pattern I landed on: the model never writes directly. It produces a proposal against a JSON schema, the server validates it, shows the user a diff, and the user approves it, with undo. The schema is both the contract the model writes to and the validation the server enforces. It’s a pattern I’d now use for any AI feature that takes action on someone’s behalf.&lt;/p&gt;

&lt;h2 id=&quot;retrieval-augmented-generation&quot;&gt;Retrieval-augmented generation&lt;/h2&gt;

&lt;p&gt;I built RAG pipelines over help content, video transcripts, and users’ own uploaded documents, using embeddings in Postgres with pgvector and HNSW indexes. The lesson most tutorials skip is that the index is a living thing. Keeping it in sync, and removing content that’s been retracted, matters as much as retrieval quality.&lt;/p&gt;

&lt;h2 id=&quot;context-and-memory&quot;&gt;Context and memory&lt;/h2&gt;

&lt;p&gt;Long conversations need managing. I implemented a sliding context window with summarisation of older turns, plus explicit cross-conversation memory where the user can tell the assistant what to remember and what to forget. Giving users control over memory turned out to matter for trust as much as for quality.&lt;/p&gt;

&lt;h2 id=&quot;llm-gateways-streaming-and-resilience&quot;&gt;LLM gateways, streaming and resilience&lt;/h2&gt;

&lt;p&gt;I built a gateway layer between the application and model providers that handles streaming, retries, per-agent model choice and automatic fallback when a provider fails. Streaming taught me something about infrastructure too. Long server-sent event responses don’t sit well on a traditional threaded app server, so I moved them onto a fiber-based server where a slow model costs an idle fiber rather than a blocked thread.&lt;/p&gt;

&lt;h2 id=&quot;sandboxed-code-execution&quot;&gt;Sandboxed code execution&lt;/h2&gt;

&lt;p&gt;For calculations no existing tool covers, I gave the model a code-execution tool: it writes JavaScript that runs in an isolated V8 sandbox with strict time and memory limits and no network or filesystem access. Letting a model write code that runs in your production environment is mostly an exercise in what you take away from it.&lt;/p&gt;

&lt;h2 id=&quot;evals&quot;&gt;Evals&lt;/h2&gt;

&lt;p&gt;New models arrive constantly, and without measurement every swap is a gamble. I built a custom eval suite from real usage patterns, so a new model can be tested against the questions that matter before it reaches a user. It turned model choice from opinion into a routine engineering change.&lt;/p&gt;

&lt;h2 id=&quot;guardrails-and-llm-as-judge&quot;&gt;Guardrails and LLM-as-judge&lt;/h2&gt;

&lt;p&gt;I built a post-response validation layer: an LLM judge that checks each reply against the data the agent actually used, alongside fast rule-based checks for things like unsupported figures and broken links. Failed replies are regenerated before the user sees them.&lt;/p&gt;

&lt;h2 id=&quot;human-escalation&quot;&gt;Human escalation&lt;/h2&gt;

&lt;p&gt;No assistant gets everything right, so I built a path out: detecting when a user is stuck or the assistant is out of its depth, and handing the conversation to a human. Users don’t mind talking to an AI. They mind being stuck with one.&lt;/p&gt;

&lt;h2 id=&quot;feedback-loops-and-observability&quot;&gt;Feedback loops and observability&lt;/h2&gt;

&lt;p&gt;I ran a weekly triage of negative feedback and failed conversations, tracing each back to a root cause. Most of the year’s biggest quality gains came from that habit, and from small fixes no upfront design would have found.&lt;/p&gt;

&lt;h2 id=&quot;mcp&quot;&gt;MCP&lt;/h2&gt;

&lt;p&gt;Finally, I built an MCP server with OAuth 2.0, so people can connect assistants like Claude and ChatGPT to their own data with per-user, scoped access. MCP is quickly becoming the standard way to make a product usable from whatever AI someone already uses, and it rewards the same discipline as everything above: every write still goes through the same validation and approval path, whatever model is on the other end.&lt;/p&gt;

&lt;h2 id=&quot;what-ties-it-together&quot;&gt;What ties it together&lt;/h2&gt;

&lt;p&gt;Looking back over the list, almost none of it is about making the model smarter. It’s about deciding what the model is allowed to do, checking what it actually did, and keeping a person in charge of anything that matters.&lt;/p&gt;

&lt;p&gt;That’s a familiar shape. A harness is the engineering we’ve always done around an unreliable component: contracts at the boundaries, validation on every input and output, measurement before each change, monitoring after it, and a way to hand off when it fails. The component here happens to be very good at sounding right, which is exactly why the boundaries matter more than usual.&lt;/p&gt;

&lt;p&gt;So the pattern I’d carry to any AI product is the one running through every section above. The model decides what to ask for. Trusted systems decide what’s true. Schemas decide what’s allowed. Evals decide what ships. The user decides what changes. Get those roles clear and the model becomes a part you can swap without the product noticing.&lt;/p&gt;

&lt;p&gt;That’s the work I’ve been doing all year, and it’s the work I enjoy most.&lt;/p&gt;</content><author><name>Simon Rentzke</name><email>simon@rentzke.com</email></author><summary type="html">This year I went from building web applications that occasionally called an LLM to designing and shipping a production AI assistant end to end. At Boldin I built the backend for Boldin Ai, an assistant that helps people understand and change their retirement plan, used by real people making decisions about real money.</summary></entry><entry><title type="html">Motivated Engineer Framework</title><link href="https://simon.rentzke.com/motivated-engineer-framework/" rel="alternate" type="text/html" title="Motivated Engineer Framework" /><published>2026-02-06T07:04:00+00:00</published><updated>2026-02-06T07:04:00+00:00</updated><id>https://simon.rentzke.com/motivated-engineer-framework</id><content type="html" xml:base="https://simon.rentzke.com/motivated-engineer-framework/">&lt;p&gt;Over the past two decades, I’ve been part of a couple of small startups that have managed to navigate the chaos and have consistently delivered products that the market has embraced.&lt;/p&gt;

&lt;p&gt;Our success boiled down to a few key factors, but one standout contributor was the power of small, motivated teams, made up of engineers who understood the market, our users and the whole tech stack.&lt;/p&gt;

&lt;p&gt;LLMs make small, lean teams far more productive. Prototyping is cheaper too: it’s now quicker to build something and refine it than to document how it should work.&lt;/p&gt;

&lt;p&gt;But there are no real frameworks on how to keep such small teams happy, motivated and focussed on the tasks at hand.&lt;/p&gt;

&lt;p&gt;Traditional Agile methods like Scrum work in larger organisations, but they become wasteful in a small team without a dedicated QA, Scrum Master or Product Manager. The pain is worse when the team is remote and spread across time zones.&lt;/p&gt;

&lt;p&gt;So here is how I deliver when I get to set things up my way. I call it the Motivated Engineer Framework, though it’s less a framework than a habit that has worked for me again and again.&lt;/p&gt;

&lt;p&gt;Everything starts with a clear goal. Not a ticket or a spec, but a plain statement of what we are trying to achieve and why it matters. If the team can’t say the goal in a sentence, we aren’t ready to build anything yet.&lt;/p&gt;

&lt;p&gt;Next, I get the right people on a call. That means whoever knows the most about the problem: a customer-facing colleague, a founder, an engineer who has been close to that part of the system. Before we meet, everyone involved prepares a short brief on the options they can see for solving it. The meeting then becomes a decision rather than a brainstorm, and it rarely needs to run long.&lt;/p&gt;

&lt;p&gt;Then we build. If the goal is a big one there will be plenty of unknowns, so the first iteration is a prototype rather than a finished feature. Building something real is the quickest way to find out what we don’t know, and with the tools we have today it is often cheaper than writing a detailed plan.&lt;/p&gt;

&lt;p&gt;We review that prototype together with the stakeholder, a designer, the product manager and the engineer who built it. Seeing working software surfaces problems that a document never would. But the most useful review comes from customers, so we don’t wait until the end to ship. We deploy many times along the way, behind feature flags, and turn each iteration on for a small group of beta customers. Their feedback shapes the next loop, and each loop is short enough that nobody loses momentum.&lt;/p&gt;

&lt;p&gt;Feature flags are what make this safe. Unfinished work can live in production without anyone else seeing it, we can switch something off in seconds if it misbehaves, and we learn how it holds up against real data and real usage long before launch.&lt;/p&gt;

&lt;p&gt;As the feature settles, I finish the job properly: update the documentation, round out the tests, and add the monitoring that tells us how it is behaving in production. Doing the bulk of this once the shape is clear means we aren’t polishing work that changed three times along the way.&lt;/p&gt;

&lt;p&gt;The final step isn’t really a deploy at all, because the code has been in production for weeks. It’s switching the flag on for everyone. Because the people who mattered, including real customers, have seen it at every step, there are very few surprises on launch day.&lt;/p&gt;

&lt;p&gt;None of this is complicated, and that’s the point. A small team doesn’t need ceremonies to stay focussed. It needs a clear goal, the right people, short loops with real customers, and the freedom to build. That’s what keeps engineers motivated, and in my experience motivated engineers are what ship successful products.&lt;/p&gt;</content><author><name>Simon Rentzke</name><email>simon@rentzke.com</email></author><summary type="html">Over the past two decades, I’ve been part of a couple of small startups that have managed to navigate the chaos and have consistently delivered products that the market has embraced.</summary></entry><entry><title type="html">Custom local settings for your Rails App</title><link href="https://simon.rentzke.com/custom-local-settings-for-your-rails-app/" rel="alternate" type="text/html" title="Custom local settings for your Rails App" /><published>2021-09-02T07:16:00+00:00</published><updated>2021-09-02T07:16:00+00:00</updated><id>https://simon.rentzke.com/custom-local-settings-for-your-rails-app</id><content type="html" xml:base="https://simon.rentzke.com/custom-local-settings-for-your-rails-app/">&lt;p&gt;Sometimes, especially in bigger teams, there maybe some dev related settings that you’d prefer not to turn on and you do not want to check-in your changes into GitHub.&lt;/p&gt;

&lt;p&gt;For example turning off Bullet, or adding a custom Rspec setting. All you’ll need to do is, add this to .gitignore:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# .gitignore
/config/initializers/zzz_custom*.rb
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then create a file in your initializers directory with your patch:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# config/initializers/zzz_custom_rspec.rb&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Rails&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;test?&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# this is for running the only--failures task&lt;/span&gt;
  &lt;span class=&quot;no&quot;&gt;RSpec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;configure&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;example_status_persistence_file_path&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;tmp/rspec_examples.txt&quot;&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Or another one:&lt;/p&gt;
&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# config/initializers/zzz_custom_bullet.rb&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Rails&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;development?&lt;/span&gt;
  &lt;span class=&quot;no&quot;&gt;Rails&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;application&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;after_initialize&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;no&quot;&gt;Bullet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;rails_logger&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;false&lt;/span&gt;
    &lt;span class=&quot;no&quot;&gt;Bullet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;enable&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;false&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then you’re good to go, without stepping on your fellow teammates toes.&lt;/p&gt;</content><author><name>Simon Rentzke</name><email>simon@rentzke.com</email></author><summary type="html">Sometimes, especially in bigger teams, there maybe some dev related settings that you’d prefer not to turn on and you do not want to check-in your changes into GitHub.</summary></entry><entry><title type="html">Force Rails to drop Postgres DB even when there are other session using the database</title><link href="https://simon.rentzke.com/force-rails-to-db-drop-postgres-db-when-there-are-other-session-using-the-database/" rel="alternate" type="text/html" title="Force Rails to drop Postgres DB even when there are other session using the database" /><published>2021-09-02T07:04:00+00:00</published><updated>2021-09-02T07:04:00+00:00</updated><id>https://simon.rentzke.com/force-rails-to-db-drop-postgres-db-when-there-are-other-session-using-the-database</id><content type="html" xml:base="https://simon.rentzke.com/force-rails-to-db-drop-postgres-db-when-there-are-other-session-using-the-database/">&lt;p&gt;When using multiple branches that have slightly different db schemas - I have found myself needing to recreate my local development and test db fairly often.&lt;/p&gt;

&lt;p&gt;For example when running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rails db:reset&lt;/code&gt; often I get an error message like this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;PG::ObjectInUse: ERROR:  database &quot;app_test&quot; is being accessed by other users
DETAIL:  There is 1 other session using the database.
Couldn&apos;t drop database &apos;app_test&apos;
rails aborted!
ActiveRecord::StatementInvalid: PG::ObjectInUse: ERROR:  database &quot;app_test&quot; is being accessed by other users
DETAIL:  There is 1 other session using the database.


Caused by:
PG::ObjectInUse: ERROR:  database &quot;app_test&quot; is being accessed by other users
DETAIL:  There is 1 other session using the database.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Which is easy enough to fix (by killing the postgres sessions) - but I’d prefer not to have to manually do that ever, as I need not care about any sessions that are attached.&lt;/p&gt;

&lt;p&gt;There is a super simple monkey patch that I’ve added to ensure that I can always kill the db:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# config/initializers/monkey_patch_activerecord.rb&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ActiveRecord::Tasks::PostgreSQLDatabaseTasks&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drop&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;establish_master_connection&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;connection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;execute&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;DROP DATABASE IF EXISTS &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;db_config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;database&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; WITH (FORCE)&quot;&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The important bit above, is the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;WITH (FORCE)&lt;/code&gt; – of course :)&lt;/p&gt;</content><author><name>Simon Rentzke</name><email>simon@rentzke.com</email></author><summary type="html">When using multiple branches that have slightly different db schemas - I have found myself needing to recreate my local development and test db fairly often.</summary></entry><entry><title type="html">Moving from activerecord session storage to redis</title><link href="https://simon.rentzke.com/moving-from-activerecord-session-storage-to-redis/" rel="alternate" type="text/html" title="Moving from activerecord session storage to redis" /><published>2021-02-23T07:35:00+00:00</published><updated>2021-02-23T07:35:00+00:00</updated><id>https://simon.rentzke.com/moving-from-activerecord-session-storage-to-redis</id><content type="html" xml:base="https://simon.rentzke.com/moving-from-activerecord-session-storage-to-redis/">&lt;p&gt;It’s not a great idea to have your sessions stored in the database, as it can cause all sorts of unnecessary load problems that can be offset to another service.&lt;/p&gt;

&lt;p&gt;The easiest and most performant option is to use a &lt;a href=&quot;https://api.rubyonrails.org/classes/ActionDispatch/Session/CookieStore.html&quot;&gt;cookie store&lt;/a&gt;, but if you’re keen on migrating existing sessions and still having control of your sessions, I’d recommend moving to Redis.&amp;lt;&lt;/p&gt;

&lt;p&gt;It’s quite straightforward to make the move. All you need to do is install the Redis Actionpack gem, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gem &apos;redis-actionpack&apos;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Then set your session store config, to point to your Redis service.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;no&quot;&gt;Rails&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;application&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;session_store&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:redis_store&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                                         &lt;span class=&quot;ss&quot;&gt;servers: &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;REDIS_SESSIONS_URL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
                                         &lt;span class=&quot;ss&quot;&gt;key: &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;_session_key&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                                         &lt;span class=&quot;ss&quot;&gt;httponly: &lt;/span&gt;&lt;span class=&quot;kp&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                                         &lt;span class=&quot;ss&quot;&gt;secure: &lt;/span&gt;&lt;span class=&quot;kp&quot;&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Then migrate all of your sessions over from ActiveRecord onto Redis, so that your users are not logged out:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;redis&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Redis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;url: &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;REDIS_SESSIONS_URL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;old_sessions&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ActiveRecord&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;SessionStore&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Session&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;old_sessions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;find_each&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;session&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# create each session into Redis, dumping the object appropriately with Marshal&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;redis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;setex&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Rack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Session&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;SessionId&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;session&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;session_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;private_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;month&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;no&quot;&gt;Marshal&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;dump&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;session&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;force_encoding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Encoding&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;BINARY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Simon Rentzke</name><email>simon@rentzke.com</email></author><summary type="html">It’s not a great idea to have your sessions stored in the database, as it can cause all sorts of unnecessary load problems that can be offset to another service.</summary></entry><entry><title type="html">Using Google Cloud Functions to receive, manipulate, and send the data to another web service</title><link href="https://simon.rentzke.com/using-google-cloud-functions-to-quickly-manipulate-data-from-two-different-web-services/" rel="alternate" type="text/html" title="Using Google Cloud Functions to receive, manipulate, and send the data to another web service" /><published>2020-11-27T08:22:00+00:00</published><updated>2020-11-27T08:22:00+00:00</updated><id>https://simon.rentzke.com/using-google-cloud-functions-to-quickly-manipulate-data-from-two-different-web-services</id><content type="html" xml:base="https://simon.rentzke.com/using-google-cloud-functions-to-quickly-manipulate-data-from-two-different-web-services/">&lt;p&gt;I recently had an issue that &lt;a href=&quot;https://coveralls.io/&quot;&gt;Coveralls&lt;/a&gt; did not support the output from the &lt;a href=&quot;https://www.cloudbees.com/products/codeship&quot;&gt;Codeship&lt;/a&gt; build webhook. So I needed to send data from the Codeship webhook to an intermediary, change the format of the json, and then send it to Coveralls.&lt;/p&gt;

&lt;p&gt;There are a lot of services that can do similar things, like &lt;a href=&quot;https://zapier.com/&quot;&gt;Zapier&lt;/a&gt; or &lt;a href=&quot;https://ifttt.com/&quot;&gt;IFTT&lt;/a&gt;. But what I needed was incredibly simple, and a Google Cloud function, with a few lines of code suits this use case quite well.&lt;/p&gt;

&lt;p&gt;The payload from the webhook from &lt;a href=&quot;https://apidocs.codeship.com/v2/builds/get-build&quot;&gt;Codeship&lt;/a&gt; generally looks like this:&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;build&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;uuid&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;20b4a690-6a03-0145-d6ec-0000000000&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;project_uuid&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;7b3596c0-560e-0135-5b18-000000000000&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;organization_uuid&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;721cea10-b695-0134-5b94-000000000000&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;ref&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;heads/master&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;commit_sha&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;575a1521fff1466c3ed9fae9d390e0ffffffffff&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;status&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;success&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;username&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;dennisnewel&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;commit_message&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Update to API documentation&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;finished_at&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;2017-08-23T07:26:01.877Z&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;allocated_at&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;queued_at&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;2017-08-23T07:24:41.327Z&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;links&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;pipelines&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;https://api.codeship.com/v2/organizations/721cea10-b695-0134-5b94-000000000000/projects/7b3596c0-560e-0135-5b18-000000000000/builds/20b4a690-6a03-0135-d6ec-000000000000/pipelines&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And the payload that &lt;a href=&quot;https://docs.coveralls.io/parallel-build-webhook&quot;&gt;Coveralls&lt;/a&gt; needs looks something like this:&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;payload&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;build_num&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1234&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;status&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;done&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;First I setup environment variables for the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;REPO_TOKEN&lt;/code&gt;, and then these few lines of js are all you need to send data from the webhook.&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;fetch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;node-fetch&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;coveralls&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;parse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;rawBody&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// console.log(data.build.build_id);&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// console.log(data.build.status);&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;status&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;coverallsResponse&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`https://coveralls.io/webhook.json?repo_token=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;process&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;REPO_TOKEN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;method&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;POST&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
              &lt;span class=&quot;na&quot;&gt;payload&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;na&quot;&gt;build_num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;build_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;na&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;done&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;
              &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;}),&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;Accept&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;application/json&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Content-Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;application/json&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`Error: Response from Coveralls was &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;statusText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;}).&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`Done.`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Simon Rentzke</name><email>simon@rentzke.com</email></author><summary type="html">I recently had an issue that Coveralls did not support the output from the Codeship build webhook. So I needed to send data from the Codeship webhook to an intermediary, change the format of the json, and then send it to Coveralls.</summary></entry><entry><title type="html">Dump csv reports using Ruby on Rails and Postgres</title><link href="https://simon.rentzke.com/dump-csv-reports-using-ruby-on-rails-and-postgres/" rel="alternate" type="text/html" title="Dump csv reports using Ruby on Rails and Postgres" /><published>2018-08-31T04:57:50+00:00</published><updated>2018-08-31T04:57:50+00:00</updated><id>https://simon.rentzke.com/dump-csv-reports-using-ruby-on-rails-and-postgres</id><content type="html" xml:base="https://simon.rentzke.com/dump-csv-reports-using-ruby-on-rails-and-postgres/">&lt;p&gt;This method is the most efficient, super simple way to generate CSV files with Rails.  It uses an active record connection and the &lt;a href=&quot;https://www.postgresql.org/docs/10/static/sql-copy.html&quot;&gt;Postgres COPY command&lt;/a&gt; writes each csv generated line from Postgres to a file.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;      &lt;span class=&quot;no&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;file_path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;w&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
        &lt;span class=&quot;no&quot;&gt;ActiveRecord&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Base&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;connection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;raw_connection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;copy_data&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;COPY (SELECT * FROM users) TO STDOUT WITH (FORMAT CSV, HEADER TRUE, FORCE_QUOTE *);&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
          &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;line&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;connection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;raw_connection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;get_copy_data&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;write&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;force_encoding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;UTF-8&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
          &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Leveraging Postgres to do this, results in tens of millions of rows being able to be exported in under 5 mins.&lt;/p&gt;</content><author><name>Simon Rentzke</name><email>simon@rentzke.com</email></author><summary type="html">This method is the most efficient, super simple way to generate CSV files with Rails. It uses an active record connection and the Postgres COPY command writes each csv generated line from Postgres to a file.</summary></entry><entry><title type="html">Support SVG’s and PNG/JPG in your Rails Dragonfly workflow</title><link href="https://simon.rentzke.com/support-svgs-and-png-slash-jpg-in-your-rails-dragonfly-workflow/" rel="alternate" type="text/html" title="Support SVG’s and PNG/JPG in your Rails Dragonfly workflow" /><published>2017-07-18T03:20:51+00:00</published><updated>2017-07-18T03:20:51+00:00</updated><id>https://simon.rentzke.com/support-svgs-and-png-slash-jpg-in-your-rails-dragonfly-workflow</id><content type="html" xml:base="https://simon.rentzke.com/support-svgs-and-png-slash-jpg-in-your-rails-dragonfly-workflow/">&lt;p&gt;I was struggling to find a solution to easily provide thumb pngs, as well as display svgs inline with the &lt;em&gt;img&lt;/em&gt; tag with the ruby gem Dragonfly.&lt;/p&gt;

&lt;p&gt;For example something simple like this:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;image_tag&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;thumb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;100x100#&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;url&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;But that breaks when showing SVG files, as it looks like it strips out a bunch of important info from the file.&lt;/p&gt;

&lt;p&gt;To set the dimensions of the svg correctly. You can add an additional gem,  &lt;em&gt;gem ‘dragonfly_svg’&lt;/em&gt; and you’ll also need to add that as a plugin to your &lt;em&gt;dragonfly.rb&lt;/em&gt; file.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;dragonfly&apos;&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Configure&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Dragonfly&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;configure&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;plugin&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:imagemagick&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;plugin&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:svg&lt;/span&gt;

   &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To render the SVG correctly you’d write this:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;image_tag&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set_dimensions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;url&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So, in order to support both seamlessly. I built a custom Dragonfly processor.&lt;/p&gt;

&lt;p&gt;Then you can setup a custom processor, that checks the mime type of the image, and processes it either way.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;n&quot;&gt;processor&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:custom_thumb&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;mime_type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;image/svg+xml&apos;&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;dimensions&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;x&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;process!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:set_dimensions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;process!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:thumb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then, throughout the code, you can easily refer to the &lt;em&gt;custom_thumb&lt;/em&gt; processor:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;image_tag&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;custom_thumb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;100x100#&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;url&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Simon Rentzke</name><email>simon@rentzke.com</email></author><summary type="html">I was struggling to find a solution to easily provide thumb pngs, as well as display svgs inline with the img tag with the ruby gem Dragonfly.</summary></entry></feed>