<?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: remix</title>
    <description>The latest articles on DEV Community by remix (@androidhate).</description>
    <link>https://dev.to/androidhate</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%2F111613%2Fb654d7dc-c0a8-4c3d-b01b-7c0a85e864cc.png</url>
      <title>DEV Community: remix</title>
      <link>https://dev.to/androidhate</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/androidhate"/>
    <language>en</language>
    <item>
      <title>How do you manage not used images in website like cms?</title>
      <dc:creator>remix</dc:creator>
      <pubDate>Fri, 28 Oct 2022 08:04:16 +0000</pubDate>
      <link>https://dev.to/androidhate/how-do-you-manage-not-used-images-in-website-like-cms-1jpl</link>
      <guid>https://dev.to/androidhate/how-do-you-manage-not-used-images-in-website-like-cms-1jpl</guid>
      <description>&lt;p&gt;I'm making website and I have different entities: users, comments, forum threads. It's something like wordpress with simple forum but  I built it myself with laravel.&lt;/p&gt;

&lt;p&gt;I use storage like s3.&lt;/p&gt;

&lt;p&gt;Everything is great but users can upload images in posts, comments, forum threads and have avatar.&lt;/p&gt;

&lt;p&gt;With avatar everything is fine: &lt;br&gt;
Event: user uploads avatar&lt;br&gt;
Action: system (cms) will upload image to s3 storage and on success delete previous avatar and change user row in database to use new avatar. Perfecto!&lt;/p&gt;

&lt;p&gt;The hardest part is for forum comments, threads.&lt;br&gt;
Event: user uploads image on comment form or thread form.&lt;br&gt;
Action: system (cms) will upload image to s3 storage, add bbcode to textarea in form and add to images table row for uploaded image.&lt;/p&gt;

&lt;p&gt;User can after leave page without posting.&lt;br&gt;
User can remove markdown code if he doesn't like image.&lt;/p&gt;

&lt;p&gt;So there are some zombie images. Every week I have a cron job to remove zombie images.&lt;br&gt;
System will foreach images in my images table will search that image in comments, threads using lame &lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT COUNT(*) FROM posts WHERE body LIKE %{image}%&lt;br&gt;
SELECT COUNT(*) FROM comments WHERE body LIKE %{image}%&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And if it doesn't find it will delete it.&lt;/p&gt;

&lt;p&gt;I'm considering to improve it - to loop through posts and comments updated after NOW() and parse with preg_match_all all images used, add to array and then foreach images in my images table will check if image in_array, otherwise delete image.&lt;/p&gt;

&lt;p&gt;I'm not sure but this still feels not perfecto.&lt;/p&gt;

&lt;p&gt;How do yall manage this kind of things?&lt;/p&gt;

</description>
      <category>images</category>
      <category>database</category>
      <category>help</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Quick Tip. Don't use Fragment.setRetainInstance(true)!</title>
      <dc:creator>remix</dc:creator>
      <pubDate>Fri, 16 Nov 2018 15:27:40 +0000</pubDate>
      <link>https://dev.to/androidhate/quick-tip-dont-use-fragmentsetretaininstancetrue-ndl</link>
      <guid>https://dev.to/androidhate/quick-tip-dont-use-fragmentsetretaininstancetrue-ndl</guid>
      <description>&lt;p&gt;I'm developing android app for few months.&lt;/p&gt;

&lt;p&gt;TL;DR&lt;br&gt;
just don't. don't use it. don't create zombie. let them die.&lt;/p&gt;

&lt;p&gt;Long story.&lt;br&gt;
I was making nice feed in android app, using fragments. And I thought if I rotate my phone my feed is recreating. That's bad. So I used setRetainInstance(true). And it solved this trouble for short period of time. But then it brings million others. Your fragment that survived rotation is attached to old activity which is dying slowly. (yeah, android is such a retarded in this way but nvm). And so when you try to do smth with it after some period it will die.&lt;br&gt;
Also you can't run any of the method of this fragment from your activity. For example survivedFragment.doSomth() -  when you run this android will tell fragment that his context is dead and you can't reattach new activity to it. But even without running command, the dying activity will eventually die and your fragment will too.&lt;/p&gt;

&lt;p&gt;So I come to conclusion that you shouldn't use setRetainInstance(true) on a fragment that has at least 1 view object.&lt;/p&gt;

&lt;p&gt;Thanks, and shoutout to google: I hate android lifecycle. I think android lifecycle wasted some trillion of human life hours. &lt;/p&gt;

</description>
      <category>android</category>
    </item>
  </channel>
</rss>
