Yearly Archives: 2021

GeneratePress to McLuhan

It was a bold decision, but I had to do this.

Lately, I’ve figured out even a premium theme like GeneratePress is overkill for me. My GP customizations get bloated at times, and I’ve realized most of the visitors of this website doesn’t give a shit or two about the styling. I write guides and tutorials. For me, any theme works OOB if the font rendering and navigation are precise.

Rediscovering McLuhan

I knew Anders Norén’s McLuhan ever since its inception on WordPress repository. At that time I wasn’t good at getting comfortable around the theme. I wanted to tweak and tone it down a bit to meet my needs.

Kudos to GeneratePress. GP helped me focus and learn more on front-end coding. I love how it forces you to push the limits. I liked the idea. But, as I’ve said before, I don’t need it now. I want to spend more effort on writing instead of wasting my time on tweaking and WP customization. I’ve decided to settle down.

Goodbye classic editor, my old friend.

Another milestone in my WP journey.

I’ve uninstalled the Classic Editor WordPress plugin. I’ve always preferred the classic editor over Gutenberg for a long (really long) time. But recently, I’ve learned to live with Gutenberg. It’s neat and it gets the job done. I’m happy with it.

What have you done with McLuhan?

A bit of pure CSS edits. And a few PHP edits. For example, I’ve:

  • Removed Google fonts completely.
  • Set to render system fonts (Avenir on Apple devices).
  • Removed the search option. 
  • Converted front page to a minimal landing page.
  • Added the updated on filter to single posts.
  • Changed the position of category meta information.

The additional CSS for the time being

.entry-content li {
	margin-top: 5px;
}

.wp-video {
    margin-bottom: 20px;
}

.page-id-5931 .site-header {
	display: none;
}

.page-id-5931 .entry-title {
	display: none;
}

.page-id-5931 .site-footer {
	display: none;
}

.page-id-5931 {
	height: 50%;
	min-height: 50%;
	background: #121212;
	color: #ececec;
	padding-left: 0px;
}

.page-id-5931 a {
	border-bottom: 1px dotted #ececec;
}

@media (min-width:728px) {
	.page-id-5931 {
		margin-top: 7.33%;
	}
}

@media (max-width:728px) {
	.page-id-5931 {
		margin-top: 7.33%;
	}
}

blockquote p {
	font-weight: 400;
	hanging-punctuation: first;
}

h2 {
	font-size: 25px;
	letter-spacing: -0.35px;
}

h3 {
	font-size: 23px;
	letter-spacing: -0.25px;
}

h4 {
	font-size: 20px;
	letter-spacing: -0.25px;
}

.site-title {
	animation: myanimation 25s infinite;
	font-size: 130%;
	font-weight: 700;
	font-family: avenir, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

pre,
code {
	font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
	font-size: 90%;
}

.meta.bottom p.tags a {
	margin-right: 5px;
}

#side-pointer,
.button-dark {
	padding-top: 10px;
	padding-left: 10px;
	padding-right: 15px;
	padding-bottom: 10px;
	font-size: 0.9rem;
	font-weight: 600;
	background: #ececec;
	letter-spacing: .1px;
	text-transform: uppercase;
	border-radius: 10px;
}

#side-pointer a {
	border-bottom: none;
}

.social-menu .social-search-wrapper {
	display: none;
}

.main-menu .toggle-mobile-search-wrapper {
	display: none;
}

.page-title {
	font-size: 17px;
}

strong {
	font-weight: 600;
}

body,
button,
input,
select,
textarea,
h1,
.h1,
h2,
.h2,
h3,
.h3,
h4,
.h4,
h5,
.h5,
h6,
.h6 {
	text-rendering: optimizeLegibility;
	font-family: avenir, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.entry-title {
	font-weight: 700;
}

Some habits should change.

Deploy Facebook Bot in Python

Let’s love every word (hmm) in the English language.

Here’s a small bash script to run your own Every Word Bot variant on Facebook. Instead of “fu*k+ word”, we’ll stick to “love+word.”

The script will install Python and necessary modules required to run the bot. You may bookmark this page as well. I will write more Facebook automation scripts in the near future.

Prerequisites

  1. Create a Facebook page
  2. Sign up with DigitalOcean or a cloud-provider of your choice, and set up a low-tier Ubuntu 20.04 instance.

You’ll get 100USD credit on DigitalOcean if you register with the link I shared.

Recommended Settings for DigitalOcean

Deploy Your Facebook Bot with Python

Proceed if you meet the requirements listed in prerequisites.

  1. Generate a non-expiring access token.

    maxbots.ddns.net/token is a tool designed to let you get an access token to allow a Facebook bot to autopost. You use this access token in your API requests for authentication purposes. The access token you receive never expires, unless your account or page gets zucced.

  2. Download fb-bot-starter v1.0 Bash script.

    fbs.sh is a Bash script I created to help you install Python, supporting modules, and set up the bot in action.

    Login to the server, and run wget https://chipfuzz.com/fbs.sh

  3. Make fbs.sh executable.

    In order to run a file directly, we’ll need to change the permissions to allow the script to be executable for the user. chmod is a command that changes permissions on a file, and +x will add execute rights to the script.

    Run chmod +x fbs.sh to make fbs.sh executable.

  4. Execute .fbs.sh.

    Type in ./fbs.sh and press enter.

  5. Enter the access token.

    Enter the access token when the script prompts you to do so.

Yep, that’s it. The script will create a tmux session named lewbot, which will run in the background and automate the page.

Why tmux?

tmux is a terminal multiplexer. The tool allows you to have multiple terminal commands and applications running visually next to each other without the need to open multiple terminal emulator windows.

nohup is another option, but I feel tmux is nice and sleek enough to run FB bots.

main.py script breakdown

Let’s have a look at the main script that powers the Facebook page.

The modules

import random
import facebook
import schedule
import time

random: to cut a line randomly from the words.txt and so on.

k = 1
filename = 'words.txt'
with open(filename) as file:
    lines = file.read().splitlines()

if len(lines) > k:
    random_lines = random.sample(lines, k)
    chosenline = "\n".join(random_lines)
    chosenlinestr = str(chosenline)
    message = "Love " + chosenlinestr 
    print(message)

    with open(filename, 'w') as output_file:
        output_file.writelines(line + "\n"
                               for line in lines if line not in random_lines)

facebook: to interact with the Facebook Graph API
schedule and time: No Shit, Sherlock.

Access Token

#FB Access Token = 'acesstoken'

Post to Facebook

#let's post it
def post():
    #Facebook stuff
    graph = facebook.GraphAPI(accesstoken)
    post_id = graph.put_object(parent_object='me', connection_name='feed', message = message)
    print(f"Submitted \"{message}\" on Facebook successfully!")
    

if __name__ == '__main__':
    schedule.every().hour.do(post).run()
    while 1:
        schedule.run_pending()
        time.sleep(1)

Tip Me

Support if you’d like by referring my resume or donating through PayPal.