Automation Scripts for Developers and Makers

in #utopian-io6 years ago

Automation Scripts for Developers and Makers



I love automatisms. Every developer should put more into automatisms.
For quite some time now I have been building scripts which take over a lot of work.
Since the scripts are getting more and more I started a repository where I collect all my scripts.

Repository

New Features

What feature(s) did you add?

  • Auto vote script for Steemit
  • Get all users for makerlog
  • Tweet Maker of the day from Makerlog
  • Auto vote script for Twitter
  • Tweet random tweets at Twitter

How did you implement it/them?

Here I would like to show you the newest script. The newest script is an auto vote script for Steemit. So you don't have to give your keys to services. Everything is up to you and therefore more secure.

You can find the script itself under:
https://github.com/dehenne/automation-scripts/tree/master/steem/auto-vote

The whole script is designed to run with Cron.
This was supported by the latest patch patch 0ca7c94

What do you need now

  • NodeJS
  • NPM

How to install it

git clone git@github.com:dehenne/automation-scripts.git

  • Execute npm installation

npm install

  • Fill in all config parameters

Please fill in all settings in the config.js file.


// which users should be voted
let USERS = ['username', 'username', 'username'];

// Weighting of votes
const CONFIG_WEIGHT = 10000;

// User name of the voter
const USERNAME = 'YOUR-USERNAME';

// Password of the voter
const PASSWORD = 'YOUR-PASSWORD';

  • Run the script by nodejs run.js

If you want to run the whole thing automatically you can use cron to do this.
I recommend to run this every 5 minutes.

*/5     *       *       *       *       cd PATH_TO_THE_SCRIPT; nodejs run.js

A good explanation on how to use cron can be found at https://wiki.ubuntuusers.de/Cron/.

The Run Script

The run script is quite simple. It votes only on posts that are older than 15 minutes, noticed if you voted already and votes only posts that are younger than 5 days.

The complete source code is documented as usual.
The most important functions are:

GitHub Account

For further ideas of some automation scripts you are welcome to write me an issue.

Thanks for reading
Hen

Sort:  

First of all, welcome back! I think most developers create similar scripts that automate stuff - it's only natural since we are so lazy. ;) Some cool scripts there, but I've never heard of Makerlog. It looks pretty interesting, so I might check it out!

As for the code (I used this link to check the changes), here are some thoughts:

  • The indentation and naming of variables are weird imo. Lining up all = isn't necessary, and things aren't consistently camelCase, but I guess that's up to you.
  • Small inconsistencies like mixing of let when const can be used.
  • Better to use forEach instead of a normal forloop, since you aren't actually counting anything and it's a lot more readable.
  • Maybe it's better to use a separate configuration file instead of having them as variables in the JavaScript file itself.

All in all, it could be pretty useful for some people! However, since programmers themselves probably already have something like this (the autovoter), I think the target audience is more than likely people who don't code, and so it could be more user friendly in my opinion. Anyway, as I said before, it's great to have you back, and I hope to see more contributions from you (and the rest of the PCSG guys) in the future!


Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

First of all, thanks for the suggestions for improvement. With let and const I'm just learning. Since I manage very large systems, there is usually no ES6 available, so I am not yet quite so rutinized there.

We try to be here more often now :D I had 4 months a projects, which now comes to the end and my work there is done since this week. \(^^)/

To your suggestions:

The indentation and naming of variables are weird imo. Lining up all = isn't necessary, and things aren't consistently camelCase, but I guess that's up to you.

wooooooooooot :D ... it's much prettier. code = art :P

Better to use forEach instead of a normal forloop, since you aren't actually counting anything and it's a lot more readable.

With forEach I have a veto. forEach is a lot slower, I taught myself that and it saved me more often than not. :-) the same topic with len = var.length at a for() loop.

When you querying it once, these are only miliseconds, but 10000 times you can feel it. I have already protected web applications from crashing with this little fixes.
I know it's more readable but I haven't found a good middle way yet either.

Maybe it's better to use a separate configuration file instead of having them as variables in the JavaScript file itself.

🤔 ... it is? 🤔

I even mentioned that.

Please fill in all settings in the config.js file.

Thanks again for the review. With let and const I look what is the best practise

greetings
Hen

My bad, I complete missed the configuration file, and saw that you had constants in run.js (why are you redefining them instead of using the constants directly?).

Also, I know that a for loop is more efficient than forEach, but does that really affect your auto-voter? It's generally a good rule of thumb to write maintainable code first, and optimise after if needed, but I'm sure you already know this. It's not a big deal either way, since in the end it's up to your personal preference!

As for let and const; simply put, use let when the variable will be reassigned, otherwise use const.

why are you redefining them instead of using the constants directly?

Refactoring 😁

but does that really affect your auto-voter?

🤔 You got a point. It doesn't really affect my script. 🤔🤔

Thank you for your review, @amosbastian! Keep up the good work!

Hi @dehenne!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @dehenne!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

New to Steemit?