<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: nico_lrx</title>
    <description>The latest articles on DEV Community by nico_lrx (@nicolrx).</description>
    <link>https://dev.to/nicolrx</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F67208%2F18a1f200-ad5d-4b73-89db-6530fe93ad1d.jpeg</url>
      <title>DEV Community: nico_lrx</title>
      <link>https://dev.to/nicolrx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nicolrx"/>
    <language>en</language>
    <item>
      <title>Any thoughts on how AI is going to change language learning?</title>
      <dc:creator>nico_lrx</dc:creator>
      <pubDate>Sat, 11 Jan 2025 10:52:20 +0000</pubDate>
      <link>https://dev.to/nicolrx/any-thoughts-on-how-ai-is-going-to-change-language-learning-5g6o</link>
      <guid>https://dev.to/nicolrx/any-thoughts-on-how-ai-is-going-to-change-language-learning-5g6o</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/nicolrx" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F67208%2F18a1f200-ad5d-4b73-89db-6530fe93ad1d.jpeg" alt="nicolrx"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/nicolrx/5-ways-ai-is-reshaping-language-learning-apps-eed" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;5 Ways AI Is Reshaping Language Learning Apps&lt;/h2&gt;
      &lt;h3&gt;nico_lrx ・ Jan 10&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#ai&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#app&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#language&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>5 Ways AI Is Reshaping Language Learning Apps</title>
      <dc:creator>nico_lrx</dc:creator>
      <pubDate>Fri, 10 Jan 2025 10:14:54 +0000</pubDate>
      <link>https://dev.to/nicolrx/5-ways-ai-is-reshaping-language-learning-apps-eed</link>
      <guid>https://dev.to/nicolrx/5-ways-ai-is-reshaping-language-learning-apps-eed</guid>
      <description>&lt;p&gt;I’m a language nerd who speaks six languages. I’ve been using Duolingo for the past six years and love trying out new language learning apps.&lt;/p&gt;

&lt;p&gt;Over the years, I’ve seen the shift from textbooks to online courses &amp;amp; gamified apps, but now artificial intelligence is taking things to a whole new level.&lt;/p&gt;

&lt;p&gt;AI isn’t just speeding things up, it’s changing how we learn, practice, and memorize languages altogether. Here are 5 examples on how AI is quietly—but completely—reshaping the language learning experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Duolingo Max
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.duolingo.com%2Fcontent%2Fimages%2Fsize%2Fw1600%2F2024%2F04%2FDuolingoMax_HeroImage-Light.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.duolingo.com%2Fcontent%2Fimages%2Fsize%2Fw1600%2F2024%2F04%2FDuolingoMax_HeroImage-Light.png" title="Duolingo Max" alt="Duolingo Max" width="800" height="430"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://blog.duolingo.com/duolingo-max/" rel="noopener noreferrer"&gt;&lt;strong&gt;Duolingo Max&lt;/strong&gt;&lt;/a&gt; is a new subscription tier above Super Duolingo that gives learners access to two brand-new features and exercises: Explain My Answer and Roleplay. Both are powered by OpenAI’s models.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.duolingo.com%2Fcontent%2Fimages%2Fsize%2Fw1600%2F2024%2F04%2FEMA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.duolingo.com%2Fcontent%2Fimages%2Fsize%2Fw1600%2F2024%2F04%2FEMA.png" title="Explain My Answer" alt="Explain My Answer" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explain My Answer&lt;/strong&gt; is a feature in Duolingo that helps learners understand why their answers are right or wrong.&lt;/p&gt;

&lt;p&gt;If you make a mistake and can’t figure out the correct answer—or if you keep repeating the same error—the AI gives you instant feedback.&lt;/p&gt;

&lt;p&gt;After certain exercises, you can also tap a button to start a chat with Duo AI assistant. Duo explains the reasoning behind your response, whether it was correct or incorrect, and can provide examples or extra clarification if needed.&lt;br&gt;
It’s like having a personal tutor built into the app, ready to clear up any confusion and help you learn from your mistakes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.duolingo.com%2Fcontent%2Fimages%2Fsize%2Fw1600%2F2024%2F04%2FRoleplay.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.duolingo.com%2Fcontent%2Fimages%2Fsize%2Fw1600%2F2024%2F04%2FRoleplay.png" title="Roleplay" alt="Roleplay" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Roleplay&lt;/strong&gt; is another AI-powered feature that lets learners practice real-world conversations with characters in the app.&lt;/p&gt;

&lt;p&gt;It’s designed to simulate real-life scenarios—like ordering coffee at a café in Paris, planning a vacation, or shopping for furniture—so learners can build confidence using the language in practical situations.&lt;/p&gt;

&lt;p&gt;During the interaction, the AI adapts to the learner’s responses, making each conversation unique. After finishing, Duo provides personalized feedback on grammar, vocabulary, and sentence complexity, along with suggestions for improvement.&lt;/p&gt;

&lt;p&gt;It’s like chatting with a teacher who’s always available and endlessly patient, no matter how many mistakes you make!&lt;/p&gt;

&lt;h2&gt;
  
  
  2. La langue française Automated Quizzes and Interactive Dictation Exercises
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lalanguefrancaise.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;La langue française&lt;/strong&gt;&lt;/a&gt; is the leading website for improving your French online. In addition to a wealth of articles on the complexities of French grammar, it offers a wide range of interactive exercises to help learners practice and refine their skills.&lt;/p&gt;

&lt;p&gt;Over the past year, the website has leveraged cutting-edge AI technologies, including MistralAI and OpenAI’s models, to produce new &lt;strong&gt;quizzes&lt;/strong&gt; and &lt;strong&gt;dictation exercises&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fadmin.lalanguefrancaise.com%2Fwp-content%2Fuploads%2F2025%2F01%2Fquiz-llf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fadmin.lalanguefrancaise.com%2Fwp-content%2Fuploads%2F2025%2F01%2Fquiz-llf.png" title="LLF Quiz" alt="LLF Quiz" width="800" height="483"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With over 2,000 grammar questions crafted by professional French teachers, they trained a model to generate &lt;strong&gt;new quiz questions&lt;/strong&gt; quickly. Explanations of the quiz mistakes are also generated based on the site’s grammar content before being meticulously reviewed by the La langue française team.&lt;/p&gt;

&lt;p&gt;Another standout feature is the &lt;strong&gt;“Dictée”&lt;/strong&gt;, a classic French exercise where learners listen to a text and have to type it out without errors. These dictations are brought to life using AI voices powered by &lt;strong&gt;ElevenLabs&lt;/strong&gt;, enabling the site to publish new dictation exercises almost instantly.&lt;/p&gt;

&lt;p&gt;Since integrating AI to streamline the creation of its exercises, La langue française has seen an impressive 278% increase in engagement.&lt;/p&gt;

&lt;p&gt;This serves as a prime example of how AI can be used creatively to boost productivity and deliver even greater value to customers.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Aimigo AI Learning Coach
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Gymglish&lt;/strong&gt; is a French company that specializes in teaching languages through fun and interactive lessons.&lt;/p&gt;

&lt;p&gt;Their latest innovation, &lt;a href="https://www.aimigo.coach/en" rel="noopener noreferrer"&gt;&lt;strong&gt;Aimigo&lt;/strong&gt;&lt;/a&gt;, is an AI-powered personal language learning coach designed to provide tailored coaching sessions based on your skill level—similar to Duolingo’s Roleplay feature.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fadmin.lalanguefrancaise.com%2Fwp-content%2Fuploads%2F2025%2F01%2Faimigo-examples.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fadmin.lalanguefrancaise.com%2Fwp-content%2Fuploads%2F2025%2F01%2Faimigo-examples.png" title="Aimigo" alt="Aimigo" width="800" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Aimigo offers a wide range of personalized activities, including conversational practice, speaking exercises, original stories, cultural insights, and more. It adapts to your level, learning goals, and pace, ensuring a fully customized learning experience to help you confidently master a new language.&lt;/p&gt;

&lt;p&gt;Once again, Aimigo proves that, with the right content, AI can serve as an effective coach for mastering new skills.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. TurkishFluent’s News Converter
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;TurkishFluent&lt;/strong&gt; is an online course that teaches Turkish through real-life dialogues and interactive exercises.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fadmin.lalanguefrancaise.com%2Fwp-content%2Fuploads%2F2025%2F01%2Ftnc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fadmin.lalanguefrancaise.com%2Fwp-content%2Fuploads%2F2025%2F01%2Ftnc.png" title="TNC" alt="TNC" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Leveraging AI, it offers an innovative feature designed to help learners improve their reading skills. Powered by OpenAI, &lt;a href="https://turkishfluent.com/turkish-news-converter" rel="noopener noreferrer"&gt;&lt;strong&gt;the Turkish News Converter&lt;/strong&gt;&lt;/a&gt; simplifies news articles to match different proficiency levels (A1, B1, and C1), making advanced content accessible to learners at any stage.&lt;/p&gt;

&lt;p&gt;In addition, the converter provides instant word translations and an English summary to further help comprehension.&lt;/p&gt;

&lt;p&gt;By using AI to adapt complex texts for beginners, TurkishFluent allows learners to start reading from day one, turning real-world content into an engaging and motivating resource.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Your Best Accent: AI Voice Cloning for Pronunciation Training
&lt;/h2&gt;

&lt;p&gt;I recently came across &lt;a href="https://www.yourbestaccent.com/en?utm_source=indiehackers&amp;amp;utm_medium=blog&amp;amp;utm_campaign=referral" rel="noopener noreferrer"&gt;&lt;strong&gt;Your Best Accent&lt;/strong&gt;&lt;/a&gt; on Reddit. This app uses AI-powered voice cloning technology to help you refine your accent in any language.&lt;/p&gt;

&lt;p&gt;By creating a digital replica of your voice, the AI allows you to hear yourself speaking your target language with native-like pronunciation, offering a unique and effective way to improve your speaking skills.&lt;/p&gt;

&lt;p&gt;In addition to voice replication, the app provides real-time feedback on your pronunciation, making it an invaluable tool for learners striving for fluency. &lt;/p&gt;

&lt;p&gt;Your Best Accent is yet another example of how AI is revolutionizing language learning!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I believe we’re only scratching the surface of how AI will revolutionize language learning. As AI become more advanced, we’ll likely see even more personalized, interactive, and immersive experiences that make mastering a new language faster and more accessible than ever.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What other use cases do you imagine? How can we harness AI to make language learning even more effective? Share your thoughts in the comments!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>app</category>
      <category>language</category>
    </item>
    <item>
      <title>How the tagging system work in Forem?</title>
      <dc:creator>nico_lrx</dc:creator>
      <pubDate>Fri, 09 Dec 2022 08:09:15 +0000</pubDate>
      <link>https://dev.to/nicolrx/how-does-the-tagging-system-work-in-forem-17a4</link>
      <guid>https://dev.to/nicolrx/how-does-the-tagging-system-work-in-forem-17a4</guid>
      <description>&lt;p&gt;Hello Dev Community!&lt;br&gt;
I am building a Rails App and I need to add a tagging system for articles. I tried to analyze how tagging works in &lt;a href="https://github.com/forem/forem"&gt;Forem&lt;/a&gt; but it's quite hard to understand the logic.&lt;/p&gt;

&lt;p&gt;I see there is an index in the Article table called &lt;code&gt;cached_tag_list&lt;/code&gt;. I guess the idea is to have a bridge between the Tags table and the Articles table, with a connection table for each article with a specific tag (article_id, tag_id).&lt;/p&gt;

&lt;p&gt;Can anyone explain to me the logic to create an efficient tagging system with Rails? Thanks.&lt;/p&gt;

</description>
      <category>forem</category>
      <category>tagging</category>
      <category>rails</category>
    </item>
    <item>
      <title>How to Use Stripe Checkout From a Rails Controller (Without Javascript)</title>
      <dc:creator>nico_lrx</dc:creator>
      <pubDate>Tue, 23 Nov 2021 14:25:41 +0000</pubDate>
      <link>https://dev.to/nicolrx/how-to-use-stripe-checkout-from-a-rails-controller-without-javascript-106i</link>
      <guid>https://dev.to/nicolrx/how-to-use-stripe-checkout-from-a-rails-controller-without-javascript-106i</guid>
      <description>&lt;p&gt;As I was launching my &lt;a href="https://formation.lalanguefrancaise.com"&gt;first French online course&lt;/a&gt;, I needed to use Stripe to process payments. The course was built using Ruby on Rails as it's the technology I am most proficient with.&lt;/p&gt;

&lt;p&gt;However, I felt it was hard to create a simple experience for the end-user:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The user visits the Devise Registration page to create an account&lt;/li&gt;
&lt;li&gt;When he/she clicks on the button to submit the form, he/she is redirected to Stripe Checkout to perform the payment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you follow Stripe's logic, an event listener in Javascript will listen to the submission of the form, perform an Ajax call to create the Stripe session, and then redirect to Checkout.&lt;/p&gt;

&lt;p&gt;However, this will prevent the normal submission of Devise's registration form. You will have to submit the Devise form using Ajax, which is not the easiest.&lt;/p&gt;

&lt;p&gt;Here are a few steps to implement a simpler solution, using no Javascript. The whole Stripe logic is managed in a Rails controller.&lt;/p&gt;

&lt;h2&gt;
  
  
  Move Stripe's logic to Devise's Registration controller
&lt;/h2&gt;

&lt;p&gt;After setting up &lt;a href="https://github.com/heartcombo/devise/"&gt;Devise&lt;/a&gt;, you will have to generate Devise's controllers to be able to customize them. Just run the following command in your terminal:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rails generate devise:controllers users&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then, change the controllers to the &lt;code&gt;devise_for&lt;/code&gt; routes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;devise_for :users, controllers: { registrations: 'users/registrations' }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we are all set to customize the &lt;code&gt;after_sign_up_path_for&lt;/code&gt; method of the Registration controller.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;First, we initialize the Stripe API Key.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then, we create a session with our product's parameters.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally, we return the session URL. This will make the page to be automatically redirected to the Checkout generated URL.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def after_sign_up_path_for(resource)
    super(resource)

        Stripe.api_key = "#{ENV['STRIPE_API_KEY']}"

        # See https://stripe.com/docs/api/checkout/sessions/create
        # for additional parameters to pass.
        # {CHECKOUT_SESSION_ID} is a string literal; do not change it!
        # the actual Session ID is returned in the query parameter when your customer
        # is redirected to the success page.
        session = Stripe::Checkout::Session.create(
            success_url: "success_url",
            cancel_url: "cancel_url",
            payment_method_types: ['card'],
            mode: 'payment',
            line_items: [{
                # For metered billing, do not pass quantity
                quantity: 1,
                price: ENV['STRIPE_PRICE_ID']
            }],
            locale: "fr",
            customer_email: current_user.email
        )

        return session.url

  end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Listen to Stripe's webhook
&lt;/h2&gt;

&lt;p&gt;After setting up the logic to redirect the user to Checkout, we need to listen to Stripe's events to make sure he/she completed the payment of the product.&lt;/p&gt;

&lt;p&gt;Stripe has &lt;a href="https://stripe.com/docs/webhooks"&gt;a comprehensive documentation&lt;/a&gt; about setting up webhooks so I won't enter into details here.&lt;/p&gt;

&lt;p&gt;In our routes, we add the following line (assuming you have created a Stripe controller):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;post 'webhook', to: "stripe#webhook"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In order to make it work, you need to initialize Stripe's API key. Add the following method to your Stripe controller, with a before action so it's called before the &lt;code&gt;webhook&lt;/code&gt; method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;before_action :set_stripe_api, only: [:webhook]

...

  private 

  def set_stripe_api
    Stripe.api_key = "#{ENV['STRIPE_API_KEY']}"
  end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, we add the &lt;code&gt;webhook&lt;/code&gt; method to the Stripe controller. We use here a case / when loop to process the events we are listening to (don't forget to register them in Stripe's webhook dashboard):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    def webhook
        payload = request.body.read
        event = nil

        begin
            event = Stripe::Event.construct_from(
                JSON.parse(payload, symbolize_names: true)
            )
        rescue JSON::ParserError =&amp;gt; e
            # Invalid payload
            respond_to do |format|
                format.json { render json: { error: e }, :status =&amp;gt; :bad_request } 
            end
        rescue Stripe::SignatureVerificationError =&amp;gt; e
            # Invalid signature
            respond_to do |format|
                format.json { render json: { error: e }, :status =&amp;gt; :bad_request } 
            end
        end

        data_object = event.data.object

        case event.type
        when 'charge.succeeded'
            # get the data (see doc)
            customer_id = data_object["customer"]
            email = data_object["billing_details"]["email"]
            # do something with the customer_id and email
            # ...
        else
            puts "Unhandled event type: #{event.type}"
        end

        respond_to do |format|
            format.json { render json: {}, :status =&amp;gt; 200 } 
        end
    end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Voilà ! You have a working Stripe Checkout implementation without using any Javascript. When the user will submit the Devise registration form, he/she will be redirected automatically to Stripe Checkout!&lt;/p&gt;

</description>
      <category>rails</category>
      <category>stripe</category>
      <category>checkout</category>
    </item>
    <item>
      <title>Is clearing session data for edge caching mandatory?</title>
      <dc:creator>nico_lrx</dc:creator>
      <pubDate>Mon, 25 Oct 2021 14:05:11 +0000</pubDate>
      <link>https://dev.to/nicolrx/is-clearing-session-data-for-edge-caching-mandatory-62e</link>
      <guid>https://dev.to/nicolrx/is-clearing-session-data-for-edge-caching-mandatory-62e</guid>
      <description>&lt;p&gt;I try to replicate the Forem caching system for my Rails app. I just wonder if there is any security issues with keeping Session cookies while caching a page?&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://github.com/forem/forem/blob/main/app/controllers/concerns/caching_headers.rb"&gt;Forem's controller concern&lt;/a&gt;, which sets cache headers, &lt;code&gt;request.session_options[:skip] = true&lt;/code&gt; is skipping session cookies.&lt;/p&gt;

&lt;p&gt;Could someone explain to me why? I use session data in order to redirect the user after login to the last page visited.&lt;/p&gt;

&lt;p&gt;Thanks for your help, I am quite a noob about caching!&lt;/p&gt;

</description>
      <category>help</category>
      <category>caching</category>
      <category>forem</category>
      <category>rails</category>
    </item>
    <item>
      <title>Wordpress Cron Job is not running</title>
      <dc:creator>nico_lrx</dc:creator>
      <pubDate>Wed, 20 Nov 2019 17:21:28 +0000</pubDate>
      <link>https://dev.to/nicolrx/wordpress-cron-job-is-not-running-87f</link>
      <guid>https://dev.to/nicolrx/wordpress-cron-job-is-not-running-87f</guid>
      <description>&lt;p&gt;Related to &lt;a href="https://dev.to/nicolrx/how-to-automatically-share-your-wordpress-articles-on-social-media-with-buffer-and-cron-3d77"&gt;this post&lt;/a&gt; where I shared on DEV how to schedule articles using Buffer and the Wordpress Cron, it seems I misunderstood something about how Cron works...&lt;/p&gt;


&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;h1&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7Gn-iPj_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
            &lt;a href="https://stackoverflow.com/questions/58960024/wordpress-cron-job-is-not-running" rel="noopener noreferrer"&gt;
              
            &lt;/a&gt;
        &lt;/h1&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Nov 20 '19&lt;/span&gt;
            &lt;span&gt;Comments: 4&lt;/span&gt;
            &lt;span&gt;Answers: 1&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/58960024/wordpress-cron-job-is-not-running" rel="noopener noreferrer"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y9mJpuJP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          0
        &lt;/div&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wif5Zq3z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;I set up a Wordpress Cron Job to run every 5 minutes and execute a function called &lt;code&gt;bulk_update()&lt;/code&gt;. When I run the function manually through the admin, it works. &lt;/p&gt;
&lt;p&gt;However, it seems the Cron job is not executing the function. I added &lt;code&gt;error_log(print_r("EXECUTION OF BULK_UPDATE"));&lt;/code&gt;to the beginning of…&lt;/p&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    
      &lt;a href="https://stackoverflow.com/questions/58960024/wordpress-cron-job-is-not-running" rel="noopener noreferrer"&gt;Open Full Question&lt;/a&gt;
    
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Any help appreciated ;)&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Automatically Share Your Wordpress Articles with Buffer and Cron</title>
      <dc:creator>nico_lrx</dc:creator>
      <pubDate>Mon, 18 Feb 2019 12:30:12 +0000</pubDate>
      <link>https://dev.to/nicolrx/how-to-automatically-share-your-wordpress-articles-on-social-media-with-buffer-and-cron-3d77</link>
      <guid>https://dev.to/nicolrx/how-to-automatically-share-your-wordpress-articles-on-social-media-with-buffer-and-cron-3d77</guid>
      <description>

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QJtBD3yq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/2ol73s93ufo8lpdiw531.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QJtBD3yq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/2ol73s93ufo8lpdiw531.png" alt="Wordpress Buffer Cron"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For bloggers writing a lot of articles, it's a kind of a headache when it comes to sharing them on Social Media. We usually do it after publishing and then forgot to share it again on a regular basis, hence losing a whole bunch of potential readers.&lt;/p&gt;

&lt;p&gt;That's why I decided to automatize the Social Media publications for my Wordpress blog, using &lt;a href="https://codex.wordpress.org/Function_Reference/wp_cron"&gt;Cron&lt;/a&gt; and &lt;a href="https://buffer.com/developers/api"&gt;the Buffer API&lt;/a&gt;. Cron in Wordpress allows you to schedule time-based tasks. Buffer is a service to schedule posts on Social Media.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's set up the new cron job
&lt;/h2&gt;

&lt;p&gt;First, we need to set up the new Wordpress cron job. The cron system comes with default intervals of &lt;code&gt;hourly&lt;/code&gt;, &lt;code&gt;twicedaily&lt;/code&gt;, and &lt;code&gt;daily&lt;/code&gt;. However, it's possible to define your own interval:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// We add a new interval running the task every three hour
add_filter( 'cron_schedules', 'example_add_cron_interval' );
function example_add_cron_interval( $schedules ) {
    $schedules['three_hours'] = array(
        'interval' =&amp;gt; 10800,
        'display'  =&amp;gt; esc_html__( 'Every Three Hours' ),
    );

    return $schedules;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The parameter &lt;code&gt;interval&lt;/code&gt; is an integer for the duration in seconds. With this code, you can now use the new cron interval "three_hours". &lt;/p&gt;

&lt;p&gt;Then, we need to add the new cron task. We can add a button in our admin menu in order to do that:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function buffer_init_cron() {
    if ( ! wp_next_scheduled( 'buffer_cron_hook' ) ) {
    wp_schedule_event( time(), 'three_hours', 'buffer_cron_hook' );
        echo '&amp;lt;pre&amp;gt;'; print_r( _get_cron_array() ); echo '&amp;lt;/pre&amp;gt;'; // to confirm that the new cron job is scheduled
    }
}

function add_buffer_menu_item_cron() {
  // $page_title, $menu_title, $capability, $menu_slug, $callback_function
  add_menu_page(__('Schedule Cron Buffer Posts'), __('Schedule Cron Buffer Posts'), 'manage_options', 'buffer_menu1', 'buffer_init_cron');
}
add_action('admin_menu', 'add_buffer_menu_item_cron');
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Pressing the button "Schedule Cron Buffer Posts" in the admin menu will initialize the cron job.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;wp_schedule_event&lt;/code&gt; takes three parameters: the first time that you want the event to occur, the recurrence (three hours in that case), and the function to call that links the cron to a function to execute. For this last parameter, we need to add this action:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add_action( 'buffer_cron_hook', 'buffer_schedule_posts' );
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you want to be able to manage your cron intervals and cron jobs, you can install the &lt;a href="https://wordpress.org/plugins/wp-crontrol/"&gt;WP Crontrol plugin&lt;/a&gt;. This plugin will allow you to create new intervals, to run your cron jobs directly in the admin panel, to create and remove cron jobs. &lt;/p&gt;

&lt;h2&gt;
  
  
  Create the function to schedule posts with the Buffer API
&lt;/h2&gt;

&lt;p&gt;In the &lt;code&gt;buffer_schedule_posts&lt;/code&gt; function we want to get a random post:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        $args = array(
                'post_type' =&amp;gt; 'post',
                'orderby'   =&amp;gt; 'rand',
                'posts_per_page' =&amp;gt; 1,
                );

        $the_query = new WP_Query( $args );
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then, we want to extract the relevant information in order to create the text of the Social Media publication. In my case, I wanted to get the title of the post, the excerpt for the description of Social Media's rich cards, and of course the URL.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    if ( $the_query-&amp;gt;have_posts() ) {
            while ( $the_query-&amp;gt;have_posts() ) {
                $the_query-&amp;gt;the_post();
                $page_title = get_the_title();
                $page_description = get_the_excerpt();
                $link = get_permalink();
                $text = $page_title . " " . $link;
            }
        }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The Buffer API provides &lt;a href="https://buffer.com/developers/api/oauth"&gt;an access token&lt;/a&gt;. I create a function with the code above in order to return a &lt;code&gt;$fields&lt;/code&gt; variable containing the POST parameters needed for the API to run.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    // we get a random pages
    function wpb_rand_posts() {

        $args = array(
                'post_type' =&amp;gt; 'post',
                'orderby'   =&amp;gt; 'rand',
                'posts_per_page' =&amp;gt; 1,
                );

        $the_query = new WP_Query( $args );

        if ( $the_query-&amp;gt;have_posts() ) {

            while ( $the_query-&amp;gt;have_posts() ) {
                $the_query-&amp;gt;the_post();
                $page_title = get_the_title();
                $page_description = get_the_excerpt();
                $link = get_permalink();
                $text = $page_title . " " . $link;

                $fields = "access_token=YOUR_TOKEN&amp;amp;text=" . $text . "&amp;amp;profile_ids[]=YOUR_PROFILE_ID&amp;amp;media[link]=".$link."&amp;amp;media[description]=".$page_description."&amp;amp;now=false";

        }
            return $fields;
            /* Restore original Post Data */
            wp_reset_postdata();
        }
    }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Great, we get a random page with all the information needed for the Social Media publication! One last step is to perform the Buffer API call, using Curl:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    $ch = curl_init();

    $page_fields = wpb_rand_posts();

    curl_setopt($ch, CURLOPT_URL,"https://api.bufferapp.com/1/updates/create.json");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $page_fields);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));

    // Receive server response ...
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $server_output = curl_exec($ch);

    curl_close ($ch);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Voilà! We have our &lt;code&gt;buffer_schedule_posts&lt;/code&gt; function, running every three hours to publish a post via Buffer. Sit back and relax 😎&lt;/p&gt;


</description>
      <category>wordpress</category>
      <category>php</category>
      <category>cron</category>
      <category>socialmedia</category>
    </item>
    <item>
      <title>How to Easily Avoid Hitting the Memory Limit on Heroku</title>
      <dc:creator>nico_lrx</dc:creator>
      <pubDate>Thu, 12 Apr 2018 16:01:04 +0000</pubDate>
      <link>https://dev.to/nicolrx/how-to-easily-avoid-hitting-the-memory-limit-on-heroku-2mha</link>
      <guid>https://dev.to/nicolrx/how-to-easily-avoid-hitting-the-memory-limit-on-heroku-2mha</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmpvivned267mvqfnqmx1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmpvivned267mvqfnqmx1.jpg" alt="Heroku Memory Leak" width="800" height="294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Heroku is a great tool to launch a new app easily. However, dynos can quickly reach their limit if your app is memory intensive. It was the case of my Rails app and I started to spend way more money than expected!&lt;/p&gt;

&lt;p&gt;If you have already optimized memory &lt;a href="https://devcenter.heroku.com/articles/optimizing-dyno-usage#basic-methodology-for-optimizing-memory" rel="noopener noreferrer"&gt;following those Heroku tips&lt;/a&gt;, it's time to find another solution to avoid spending too much money.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to restart Heroku dynos periodically
&lt;/h2&gt;

&lt;p&gt;One efficient workaround is to restart dynos when the memory limit is close. Unfortunately, you will have to pass the whole day (and night!) in front of your computer if your app is leaking memory! &lt;/p&gt;

&lt;p&gt;The solution is to create a scheduled task to restart the dynos consuming too much memory before they hit the limit. &lt;/p&gt;

&lt;h3&gt;
  
  
  Write a task in your app
&lt;/h3&gt;

&lt;p&gt;First, add &lt;a href="https://github.com/heroku/platform-api" rel="noopener noreferrer"&gt;the platform-api gem&lt;/a&gt; to your Rails app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem 'platform-api'

bundle install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create an OAuth token using the heroku-oauth toolbelt plugin:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ heroku plugins:install heroku-cli-oauth
$ heroku authorizations:create -d "Platform API example token"
Created OAuth authorization.
  ID:          2f01aac0-e9d3-4773-af4e-3e510aa006ca
  Description: Platform API example token
  Scope:       global
  Token:       e7dd6ad7-3c6a-411e-a2be-c9fe52ac7ed2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, create a &lt;code&gt;scheduler.rake&lt;/code&gt; file in the lib/tasks folder of your Rails app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;  &lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'platform-api'&lt;/span&gt;

  &lt;span class="n"&gt;task&lt;/span&gt; &lt;span class="ss"&gt;:restart_dyno&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="ss"&gt;:environment&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"task restart_worker is on"&lt;/span&gt;
    &lt;span class="n"&gt;heroku&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;PlatformAPI&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect_oauth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;YOUR&lt;/span&gt; &lt;span class="no"&gt;OAUTH&lt;/span&gt; &lt;span class="no"&gt;TOKEN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;heroku&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dyno&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;restart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"APP_NAME"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"web.1"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can specify which dyno you want to restart by passing its name. According to &lt;a href="http://heroku.github.io/platform-api/PlatformAPI/Dyno.html" rel="noopener noreferrer"&gt;the documentation&lt;/a&gt;, you can also restart all dynos at the same time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;  &lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'platform-api'&lt;/span&gt;

  &lt;span class="n"&gt;task&lt;/span&gt; &lt;span class="ss"&gt;:restart_dyno&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="ss"&gt;:environment&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"task restart_worker is on"&lt;/span&gt;
    &lt;span class="n"&gt;heroku&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;PlatformAPI&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect_oauth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;YOUR&lt;/span&gt; &lt;span class="no"&gt;OAUTH&lt;/span&gt; &lt;span class="no"&gt;TOKEN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;heroku&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dyno&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;restart_all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"APP_NAME"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Schedule your task
&lt;/h3&gt;

&lt;p&gt;In order to perform a task on a repetitive basis, you will have to install the &lt;a href="https://elements.heroku.com/addons/scheduler" rel="noopener noreferrer"&gt;Heroku Scheduler add-on&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;The Scheduler comes with a frequency limitation: you can only choose between "Daily", "Hourly" or "Every 10 minutes". &lt;/p&gt;

&lt;p&gt;In case those frequencies are not ideal regarding your memory consumption, you can add a condition in your task to match the frequency you want. For example, if you want to restart your dyno twice a day:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;  &lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'platform-api'&lt;/span&gt;

  &lt;span class="n"&gt;task&lt;/span&gt; &lt;span class="ss"&gt;:restart_dyno&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="ss"&gt;:environment&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strftime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'%H'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"07"&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"14"&lt;/span&gt;
        &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"task restart_worker is on"&lt;/span&gt;
        &lt;span class="n"&gt;heroku&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;PlatformAPI&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect_oauth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;YOUR&lt;/span&gt; &lt;span class="no"&gt;OAUTH&lt;/span&gt; &lt;span class="no"&gt;TOKEN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;heroku&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dyno&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;restart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"APP_NAME"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"web.1"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you have defined your frequency, add a new job to the Scheduler: &lt;code&gt;rake restart_dyno&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn2g29y94v4dvz1v28jov.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn2g29y94v4dvz1v28jov.png" alt="Heroku Memory Leak" width="800" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, you will have your dynos restarting automatically before hitting the memory limit. If you have any questions, feel free to contact me &lt;a href="https://twitter.com/nico_lrx" rel="noopener noreferrer"&gt;on Twitter&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>heroku</category>
      <category>memory</category>
      <category>rails</category>
      <category>ruby</category>
    </item>
  </channel>
</rss>
