TrickJarrett.com

Posts Tagged: programming

Adding Commenting to Glowbug

I find myself thinking about adding comments to the blog in an effort to foster it's community growth. If I did it I would want the following:

  1. Identity - Some sort of identity tie. Not trying to force real names, but something that lets me force a user to be identifiable across comments. - Lessens spam and furthers the growth of site.
  2. Lightweight - ie not Javascript driven - I could turn to 3rd party tools (like Disqus), but speed is a big part of this blog. The whole reason I switched to it being that every page is its own html file and not a server built page. So loading big external JS is not interesting to me.
  3. Threading - I would want a simple level of threading of comments. Maybe it caps at 2 or 3 depth, but I don't want just an endless scroll.
  4. End of life - As with my Twitter, I am growing to believe that a lot of content is not useful or beneficial to remain available forever. I haven't implemented an EOL for posts on the blog, but I have been thinking about it. And in that same vein, I am thinking about it for comments.
  5. Upvotes - A way for viewers to promote and support a comment they like. I don't just want a thumbs up or up arrow. Right now I'm thinking there are two options "Interesting" and "Informative." Readers could vote for one or both.
  6. Troll Fighting - To be big enough to get trolls is still a ways away for the blog, but it would be prudent to plan for it now and have tools in place to avoid brigading, spamming, hate, etc. whenever it did eventually arrive.

I'm also trying to divorce myself from the standard model of comments where the comments are just at the end of a post. What if the comments were set up like page highlights and folks could comment on specific sections? What would that look like? How would that work?

This is what I'm pondering. We'll see what, if anything, comes from it.

Share to: | Tags: programming, glowbug, discussion

PHPDesktop

A framework that allows you to use PHP for developing desktop apps. As PHP is my primary coding language these days, I am definitely going to have to give this a look. I don't have a project I want to dive into with it right now, but I'm sure something will come.

Share to: | Tags: programming, php

Morning Blog Coding

This morning I spent a little time tweaking the CSS on the site. It started just because I noticed a quirk with my embedded code blocks, if the line goes too long it breaks the layout. I'm still trying to figure out the fix for it. As I was working on it, I also realied I was not loving the font of the site - especially when it was used for code. So, I spent a little while tweaking it. Still not perfect, but better.

As part of this it has also become clear to me that I need to change how CSS is handled. Currently it's a template file, so updating it required publishing the entire site. That got annoying. So I finally took the first step toward section publishing, the idea that when I post an article, I don't need to rebuild the entire site.

For today, I just added the ability to define specific classes of templates I wanted to publish. So now I can specify if I want to just publish the frontpage, or the dates archives, or the individual posts, etc. Primarily this is useful for things like this morning, where I am focusing on modifying templates and want to just refresh what I'm working on - but it is a step towards the smart publishing I want.

Share to: | Tags: glowbug, programming, php, css

Unshortening URLs in PHP

In an effort to expedite my posting of links from my phone, yesterday I added a function which expands shortened URLs in the blog, so I don't have to do that on my side. It took a little testing to get it to work right. I found examples online were incomplete, often written only for cases that definitely used shortened links and that did not handle when the link wasn't shortened, etc.

Sharing where I landed, in case it is useful to others.

function unshorten($url) {
    //Checks if the variable appears as a URL
    if (!filter_var($url, FILTER_VALIDATE_URL) === false) {
        //Fetch the headers of that URL, requires PHP 5+
        $headers = get_headers($url, true);
        //If the URL is being forwarded, it will have the 'location' set in the headers
        if (isset($headers['location'])) {
            //Overwrite the provided URL with the new destination
            $url = $headers['location'];
        }
    }
    return $url;
}
Share to: | Tags: glowbug, php, programming

And voila. After less than 30 minutes of coding work, I adapted the publishing of the RSS feed into also having the blog output a JSON feed.

I suspect the JSON Feed formatting will prove especially useful when I get around to making an Android app for myself so I can more easily post and share things from my phone to the blog.

Share to: | Tags: programming, glowbug

A somewhat trippy and psychedelic thread of cellular automata

Share to: | Tags: programming

How to make a chess engine

Saving this for a future project. I've had an idea that there is a teaching tool waiting to be made for chess. Have an engine evaluate positions and identify squares of frequent conflict in the lines it examines, as well as pieces most likely to be traded, etc.

I have no idea if that would actually be useful. But it seems to me, a training tool which had players learn to identify these things, might be good? No idea honestly.

Share to: | Tags: programming, chess, project

Today has been spent doing chores in preparation for our BBQ tomorrow. In addition to those though, I've also done a repair on my La-Z-Boy recliner, something I plan to write up or record a video about for other La-Z-Boy owners.

And in between those things, I've also done a little bit of coding. Most of it was behind the scenes stuff, such as fixing my image uploader (it was supposed to be auto rotating and resizing images, but hasn't been) as well as coding in for the blog to try to include favicons of domains when linking to another site (only from the homepage, for now.)

It works 100% for sites which follow the standard structure and formatting, but it isn't yet smart enough to catch when sites take shortcuts or don't exactly follow the prescribed formatting. I'll keep fiddling with it, as always.

Share to: | Tags: glowbug, programming

No More Google Analytics And Upcoming Coding Plans

Google Analytics is mainly for my own validation at seeing the handful of people who come by. But I removed it, and am instead testing a more privacy friendly alternative called Clicky.

I am taking the next week off of work. I am not yet sure my coding plans for that week. For Glowbug this blog's backend system), I have three things that are sort of sitting front-of-mind. Automated email newsletter generation, archive pages for tags (if you wanted to see all the entries I have about NASA, for example, you can't currently), and making the publish functionality smarter (currently when I make a post, the site rebuilds everything. I think I can do better than that.)

I also have a few other coding projects in mind, one new one which I've codenamed 'BEHEMOTH' - But, it's definitely named that because I think it will turn into a big project and I'm not sure I'm ready to tackle it yet.


Edit:

A few more ideas / thoughts while I was making quiche this morning. I wonder if I should add the ability to thread posts? For example, I could do a post about the Supreme Court in the morning, and then later the day thread a link to another post under it. Or for example, this edit would be its own post and would instead thread under the above post. Not sure it's actually better, and I would need to figure out how it is handled for things like the RSS feed, etc. But an interesting thought.

It would also be interesting to thread under a post from a previous day, etc. But again, how is that represented / displayed?

Also, while I like the backend's Markdown text editor I use to compose entries, it does not work well for me on mobile. I need to decide what I'm going to do. I am toying with the idea of making a simple mobile app that lets me post to the blog, primarily as a coding exercise, but also it would allow me to more easily share links to the blog from other apps. Where now the workflow is rather convoluted.

Share to: | Tags: glowbug, programming

As I play with my watch this morning and consider how I might use it, I found myself wondering about updating this blog with the power levels of my various electronics. But, would that prevent some very opaque attack vector? Could people surmise when I'm not at home based on the battery levels?

I don't think it presents much of a risk, though obviously it isn't zero risk. I'll have to think more about it. The idea tickles me enough that I'm interested in it. The idea I have a page on the site which just gives you my laptop, phone, earbuds, and watch's various battery levels. It's pointless, but fun. Which is my favorite kind.

Share to: | Tags: android, programming, website

Question I woke up pondering today: How can I measure the popularity of words or phrases comparatively through third-party tools? I don't want to build a massive database and derive it myself. I am looking to find smart ways to use tools that already exist.

The first use case I'm thinking about for this is, again, the automated tweets I put out about what I'm writing about. I used very simple logic to determine which tags it chooses to use as an example: the most frequently used on the site. The logic being that that means they are things I (theoretically) write about more commonly.

But, if my intent is to use those keywords to draw people's attention, and in light of the frequency with which I'm writing about current events. Having the ability to check if a keyword is "hot" right now, would be useful for the automation.

I have two thoughts:

So, at some point I'll dig in and play around with these.

Share to: | Tags: programming, glowbug, api

A New RSS Reader For Me

I have, for over a year now, scanned and read tens of thousands of items from RSS feeds through my FreshRSS installation. As of this writing, I am subscribed to 114 different feeds which I break into eight different categories. Though, the truth is, I don't use the category organization nearly at all. And part of that is because, it isn't relevant to my consuming the feed, the categories are there for me to manage my feed.

I will check my reader several times throughout the day, usually seeing between 50 and 200 posts when I do. And I don't bother going site by site or anything. I just use hotkeys and quickly jump to each entry, scanning through them for interesting stuff. I'd wager 80% of the links I post here originate in my RSS feed now. I love it.

That said, I've had a germinating idea for a new RSS reader-esque site/tool sitting in my head for weeks now. I had a few different pieces and ideas, and today's blog post by Dave Winer stirred it back up for me.

Within an hour, I had a list of features & ideas jotted down. The original idea was something more akin to a Tweetdeck style multi-column layout social bookmarking site.

But Dave's post caused me to reframe the idea and repurpose the UI. I do think this idea is more than just an RSS feed reader. I think of it more as a personal information hub. I'd integrate other API services, such as social platforms (pulling tweets in?), sports, weather updates, etc. Maybe even email.

The screen layout is in columns, though I don't yet have sizing or design concepts really in mind. I think there are two main columns and the ability to add more.

The main (to me, that means left, but we'll see how it ends up) column of this is the "Fast Lane" (working title) - which would be the most recent unread feed of stuff sorted chronologically. It's the firehouse of information.

I think the next column becomes a "Queue" list. You can flag content in the fast lane, and it gets pulled to the right so you have more time to peruse it. But the stuff in that column has an expiration. I've toyed with this idea when I was using Glowbug's draft post functionality as a quasi "to read" list. I didn't want to get to overwhelmed with things, so I was instituting a 48 hour timeout for this column, after that time it got dropped, assuming that since the item was not worth the effort to read in that time, that it was no longer important. If I really wanted to read something, I'd either read it immediately, or save it more permanently to come back to. I think that same idea would go into effect on the Queue. Though you'd customize the timeout time.

As I said, you would also have the ability to make different lanes. Maybe you want to filter on keywords, or a lane just filled with specific data sources. Or if it does integrate email, then you have a dedicated email inbox. That should be doable.

Now, also as above, sometimes I will just want to save things for a longer term purpose. Maybe it's a future blog post or maybe it's another project. That's when things get parked. And Parking is the more full "let's archive it, tag it, categorize it, etc." Save snapshots of the page, etc.

That's the core of the idea.

All of that could be just for an RSS reader style implementation. But I think this idea could also be more of a central hub. As someone who hungrily consumes information and data, this structure would really appeal to me. And it would allow me to combine my RSS reader and my Wallabag/Pocket content. You could come across a page or article outside of it, and then immediately queue or park it. The focused reading would need to be aces, optimized for ease and comfort of reading across devices.

And who knows what else there would be. Lots of integration ideas to play with and this is already quickly becoming a behemoth project. But... I'm not intimidated. I'm excited. God help me.

Share to: | Tags: rss, project, programming

Adding Screenshots to the morning TrickBot Tweet & Talking about Tags

Alright, wrapping up my coding for the night. Spent tonight finally figuring out how to post images on tweets via the API. Specifically so that the morning TrickBot tweet, updating followers on my posts, would include a screenshot of the top of the frontpage.

I've had the screenshot stuff worked out for a week or so, thanks to screenshotmachine.com. They have a free API which permits 100 calls a month. And since I am planning to do it once daily, the math there works out in my favor.

I have been using the old TwitterAPIExchange PHP library. I can't say definitely the issue I was dealing with was because of it, but after I switched to the http://TwitterOauth.com library, it was a fairly quick change over and it worked perfectly almost immediately.

I think the next bigger project for me with Glowbug is to really give the taxonomy and tags a rework. What I have works fine, but I think it can be better. A few ideas / questions:

All that said, these are going to sit on the task list for a while. I have two new bigger ideas in mind. I'm taking the week of the 4th of July off, and while I plan to spend much of it with family - I also intend to dive into a new project.

Edit: I just thought of another feature I need to add to the automated tweets. I need to thread replies which link to posts I make which have direct links. I don't do this often, but usually for longer posts. Adding it to the backlog.

Share to: | Tags: programming, glowbug

Ran an update on my "ToListen" script this morning. This is the code from last week which turns a YT playlist into an MP3 podcast. In the words of Marie Kondo, it sparks joy.

Share to: | Tags: python, programming, youtube, podcast

After yesterday's frustrating coding day, I'm back at this morning. First was email, now working on Twitter API and trying to figure out why I can't programmatically attach an image to a tweet.

Share to: | Tags: programming

Somewhere on the Internet, there is a gif of someone stepping on endless rakes and getting smacked in the face. That has been my morning of coding today. First I can't get some email code to work right. Then I run into problems with code for the Twitter API.

Maybe I'll have more luck tonight.

Share to: | Tags: programming

Free services for Web Developers

This page is a collection of web services which are offered with free tiers. It's proven to be a fantastic resource for me.

Share to: | Tags: programming, cloud, web app

Thinking about my coding projects to work on. Just in the order they're in my head, not necessarily in the order I'll tackle them.

To Listen

This is the new script I hammered out last night for taking a YT playlist and making a podcast. It still needs more work. So I want to hammer on it a bit more, smooth it out and fix some bugs with it.

Glowbug

There are some quality of life bug fixes I need to do. I also need to finish implementing 'Chapters' - though, as I did it, I began questioning if it was something I honestly needed.

Pick'em

This is the most pressing, because right now it isn't sending emails. I had been sending emails via Gmail using SMTP, but Google has closed that functionality. Ostensibly they did that for security reasons, but honestly I think they were just having too many people like me using it programmatically. So I need to investigate solutions.

Kontakto

I also started a very early version of this. A web app designed to be used on mobile. I need to get back in it and finish the functionality. Even though it's a web app, I think I have a way for it to send notifications to my phone.

Clerk 2

Not the Kevin Smith movie. But I have a simple app that I call Clerk which I use for tracking weight and some other daily stuff. I am planning to rebuild it from the ground up using the PHP Laravel framework. It's, overall, a pretty simple project and I think it would be a good project for getting used to the library.

Next Project

I think the next "big" project from the ground up will be the collection manager. I've been thinking a lot about it recently and really trying to delve into the database design as that is going to be critical to this project.


I don't know how much I'll get to work on projects this weekend. I'm hoping 8-ish hours in the morning and evenings. We'll see.

Share to: | Tags: programming, glowbug, pick'em

It's Alive!

After roughly three hours of coding I have a 130 line Python script that will snag the videos on my "To Watch" YouTube playlist, convert the files to mp3s, generate a podcast XML file, and then upload them all to my server.

Now I can use a podcast app while I'm driving and listen to these files. I had a way of listening to them while I drove but it was a process which required me picking up and interacting with my phone, it didn't integrate with Android Auto. This script will now allow that.

This is definitely an MVP hacky solution. But, it's a hacky solution that gets the job done. As of now, I'll just run it from my laptop. No need to set this up on the server as an automated script. The frequency is such that I add 1-3 videos to the list in a week. Right now it has 19 videos on it. So plenty of backlog and I can probably just do it as a weekly task and I'll be fine.

Also, jeez, I forget how easy Python is to work in. I do the majority of my web coding in PHP, but it was nice to lean heavily on the existing Python libraries for this one.

Share to: | Tags: programming, python

To Build: YT Feed -> Podcast Feed

Edit: The Podsync Github project looks promising, will have to investigate.

Share to: | Tags: programming, youtube, podcast

Bugs are a central part of coding. And, honestly, how you debug, triage, and fix bugs is - to me - one of the most important things for coders. This morning I was alerted to an issue with my Pick'em, the leaderboard had mysteriously stopped updating.

I set in and began exploring to figure out the issue. My first assumption was the code which is used for generating the leaderboard, but that quickly showed that it was reporting what was in the database correctly.

Next, I suspected the scoring system, which after working through all seemed to be working correctly.

After that I went to the process for making a Pick on the site. And there was the issue. For some reason, a few weeks ago, it had stopped assigning picks to the current season (I call them 'Crowns' for players to avoid confusion with 'Seasons' for MLS, since we're now running multiple Crowns in a single Season.) So, why was it going wrong?

I began debugging, and suddenly in debugging, it began working correctly. As I described it to friends, "this is the equivalent of a mechanic fixing an engine by banging on it with a wrench." It shouldn't really work, but it did. I can only guess that somehow an out of date file had made it onto live and in debugging I updated it to the correct version, which fixed it.

Who knows. Computers are mysterious that way.

Edit: Also, I just noticed that the Glowbug bot that tweets out post reminders is finally operating as intended, which is that it deletes the previous bot tweet when it posts a new one. I no longer have to have the tweets cluttering my timeline.

Share to: | Tags: mystery, debugging, pick'em, programming

At first I planned to spend this evening working in the garage but my motivation for that died quickly. After watching some TV with Katie I'm now learning about a PHP framework called Laravel. Normally, I don't use a framework, but I think I will for my next project. Laravel, so far, looks very interesting.

Share to: | Tags: programming, php, framework, laravel

Today is a Tuesday which VERY much feels like a Monday. I have come to resent short weeks as I find when Monday is a day off it ends up making the rest of the week feel rougher.

That said, today I've made the decision that this week is the last week I can let myself focus on Glowbug as a project. I have a number of ideas and things I want to add, but ultimately it's at a solid point in development and I want to move onto other projects. I'm not sure which one I'll go to next, but it will have been almost 2.5 weeks of me focusing on Glowbug and it's time I move to another project.

Share to: | Tags: glowbug, programming, time management

As is tradition and simply part of my morning routine, this morning has been spent with a bit more coding.

Today's coding has been mostly cleaning up code. I moved every variable, or API key, etc. from their place in code and moved to a new file which is not stored in GIT. I should have done this a long time ago, but oh well.

Last night I fixed the code for publishing the blog. When I first wrote it, I used entirely relative server paths. It worked perfectly for normal publishing. But with my recent updates and changes, I was trying to publish from a different script and it was dumping all the files in the wrong location. Now, that is fixed.

If it works, this embed is going to not work:

Also this morning I'm attempting to update my twitter bot code. Primarily, the intent is to delete my previous automated tweet when I make a new one. It should be set up to do it. But we'll see when the cron runs in a little bit.

Share to: | Tags: twitter, glowbug, programming

AI Attempts Converting Python Code To C

This is an interesting idea. Just last week, when I was exploring Markdown stuff in preparation of working on the conversion for the blog, I came across a fantastic Markdown library from Stripe written for Nodejs. And I was bemoaning I didn't have access to it. A future where we have AI systems to do porting between platforms or systems is an exciting future.