uxCATling - how i get the value of my 100% vote using linux shell script and steemdb (v0.00)

in rudyardcatling •  7 years ago  (edited)

cooltext283730875837378.png

please note the edit at the bottom of post : 20180423 - 0352am


please note : edit : 20180427 - 1307am i have no idea if the script is working because either the guy doesnt like it or he keeps changing faster than i can care to shake a hat so ... the next one will site independent and work directly from steemit, thing is, the documentation is SO friendly i just myself, this post, on the first page of google, looking for methods to use in calls, so ... it might be lag or whatever since the site itself gives errors too, assuming i get it fixed before this post cant be edited i'll link, the explanations are still valid, the script most likely is not .... ah and the witness ? i noticed cos im digging ... i voted once cos someone asked me, thats all, personally i dont think its a good idea to have duly elected officials if you want a free system but its not my call, not my business and not my problem, i find many who want to be sounding like they want revenge, so i think thats pretty scary ... and face it, duly elected government has proven not to work
(and in response to your reaction a few times later in this post : the only thing you need is to copypaste and run the script after changing my @rudyardcatling for your handle, but if you're curious there's some intel too) Something's that been bugging me for quite a while now. "*When will i see my vote actually do something ?*" ... so i looked around and asked and dug and found eventually ofcourse and since the people who invented computers are inherently lazy basterds i thought if i spent a few hours on it, no matter how rusty or braindead i've become, i can save myself some time by ending up with few lines of merlins magical spell i can re-use as many times as i like...

Screenshot from 2018-04-21 08-16-10.png

Now before i get to the 'splainin , allow me to elaborate one paragraph here : on linux
i was looking for something i could do without trying because if i have to try then i will get bored very fast so this is the first time i found something (lol yes <-lazy, what can i say). I will always advocate linux, everyone should have a €150 linux pc at home. After the initial phase in which one realises that its not only at least as easy to navigate as windows, it has all the functionality, it costs ZERO, you can mess with it as much as you want and no one will sue you, it's faster, and the desktops are more efficient (did i say it's free yet ?) it also in my case runs on a celeron system with a minimal gfx on board mobo, which is something i can't even imagine windows 10 doing even if it only had to work one virtual desktop at a time). However i will try , if i make this to a recurring series to stay on topic (to the best of my ability) and keep TFA in this case on how to get your power using linux shell script ...

Screenshot from 2018-04-21 08-36-07.png

Introductory i should probably make a few premises on what i try to communicate in TFA, so

  • the formula used i got from this post https://steemit.com/steem/@yabapmatt/how-to-calculate-the-value-of-a-vote by @jabapmatt , its 6 months old so no longer votable or resteemable but the guy ofcourse deserves at least the honourable mention of providing me with the means to actually sit down and go for it
  • i talk here about linux mint, the desktop system used is irrelevant and not in the scope of this little diddy to explain but the workings and includes are not, although it should run perfectly on the more popular ubuntu
  • some time and about 275k xp in ds3 later i realize i used curl again and you don't get curl on a standard install so what you would need to do is either look for curl in the software center (the thing with 1000s of free stuff) or open a terminal and go hard, like : sudo apt install curl after which it will prompt your for your user password (which you will have if you installed the system which i can certainly document later in another galaxy at a certain point in spacetime relative to the amount of energy required distance might not be the problem), if not, you'll have to ask your administrator but what i WILL do if and/or when i re-write into an easier to adapt format (where all potential patterns and variables are declared on top for easy editing) i'll use wget, which comes standard on install and should do the trick just fine
  • this is not the most efficient way, this is what i dug up in a few hours using me and the 1e100, i stick to it since it works, i will probably refine it later, in which case i might edit the post or make v0.01
  • i am not an expert, i think syntax is a waster of brainspace but programming logic is the same thing all over so without google at my hands i could probably write about nothing in code, which in the end will probably end up with something closer to human than what i have to decypher on the forums
  • linux distros are, due to the nature of the system, not all the same, but most should work with the base, thats why i always try to stick to shell, people get hot on python and ruby and what not but i never found any reason (for myself) to use anything other than shell script for my needs in these, its VERY powerful (thats why microsh*t is having a linux console in their system)
  • and so on ... i use here bash (dash), not sh as is declared in the first line of the script, it makes not much difference but possibly some, its also possible there's different versions of grep (a command you cant help but love if you use linux) which dont all include the exact same options so i state clearly : this is run on linux mint, latest version as per date of writing

Screenshot from 2018-04-21 08-54-43.png

the goodies ...

#!/bin/bash

varvar=$(curl -s https://steemd.com/@rudyardcatling |grep -oP '(?<=(Vesting shares</th><td>")).*(?=( VESTS"</td></tr><tr><th>D))')
echo $varvar
varvar=$(echo "$varvar * 1000000 * 0.02" |bc)
totvar=$(curl -s https://steemd.com/ |grep -oP '(?<=(recent_claims</samp></th></tr><tr><td><i>)).*(?=(</i></td></tr><tr><th><samp>l))')
echo $totvar
totvar=${totvar//,}
echo $varvar
echo $totvar
#bc -l to use some lib or else i get result "0" which shows how much my vote is worth actually already
morvar=$(echo "$varvar / $totvar" |bc -l)
echo $morvar
lastvar=$(curl -s https://steemd.com/ |grep -oP '(?<=(reward_balance</samp></th></tr><tr><td><i>)).*(?=( STEEM))')
lastvar=${lastvar//,}
echo $lastvar
finalvar=$(echo "$morvar * $lastvar" |bc -l)
echo $finalvar
basevar=$(curl -s https://steemd.com/ |grep -oP '(?<=(base</samp></th><td><i>)).*(?=( SBD))')
echo $basevar
quotevar=$(curl -s https://steemd.com/ |grep -oP '(?<=(quote</samp></th><td><i>)).*(?=( STEEM))')
echo $quotevar
ratiovar=$(echo "$basevar / $quotevar" |bc -l)
echo $ratiovar
sbdvar=$(echo "$finalvar * $ratiovar" |bc -l)
echo "100 % vote is worth:"$sbdvar

now if that looks like a mess, then you should have seen what i deleted , thing with efficient stuff like shellscript here or perl is that it doesn't need obfuscating, a script written by an actual expert to the naked eye probably looks like a dump from a binary file or a pile of special characters knitted together, this really ain't half bad and is far from the shortest possible amount of characters use (far from, trust me ... )

the nice thing is, it will not ask you for any password so the worst you can do is mess up your homedirectory , which it won't.

So i'll try some explaining. Please bear with me, i have never done this, and everything i do it for me i start by using either script i have or praying to the 1e100 for enlightenment, most likely a combo of both, if you could have seen how it went , the first bits were really slow cos i had no clue how to write it, but once a few commands fell in place it's quite easy because you only need to adapt the filters and the variables after you get the syntax of the day down

some explanation

  • basically you can copy paste the code provided into a blank text file and run it after you change only my steemit handle @rudyardcatling ... with .. YOURS ! ... basically .. so that would require navigating to your homedir (preferably), right-clik context menu -> new file, name file (preferably some extension but i dont think that matters if the executable flag is set the icon will show), set executable (chmod +x in terminal) and after that right-click , open terminal (if linuxmint-cinnamon it will open one in the directory you are in in the visual navigator, then simply type ./nameofscript.extension and press enter ... and wait, the latency depends on your connection and the number of hops, not on your systems processing power) but all that is outside scope of TFA
  • the code
  • #!/bin/bash this basically tells the parser to use bash for interpreting the script, unless you want to go far then this is simply something you need to know as 'it has to be there or my computer won't know what to do ... computers are fast and efficient, but not very smart when it comes to decsion making
  • varvar=$(curl -s https://steemd.com/@rudyardcatling |grep -oP '(?<=(Vesting shares")).*(?=( VESTS"D))')

    programming logic is way outside the scope and intention of TFA, im not writing a book here, however, what you would need to do in order to find yours, not mine is change @rudyardcatling by atwhateveryourhandle is, my suggestion is this is simply and best done by a find and replace, which is the same principle as doing that in notepad, or word or whatever tickled your fance, if you dont know how to search and replace in a visual environment then i think we should rewind and get back to that in some other FA, you could also manually do it ofcourse, however, as typo's go , find and replace is your better option there.
    small explanation here : this is variable assignment, it basically puts the output of a command string into a variable that can be used anywhere later in the script, possibly passed on to others too but i wasnt going to go 11-dimensional i promised myself in this one here
    another part : the filters used Vesting shares</th><td>" and VESTS"</td></tr><tr><th>D (i should say 'patterns') are literal bits of the webpage from steemd, in order for the script to find and filter out exactly the needed characters between. If the guy at steemd changes one tag inthere, then it will need re-vision, if it does i might do a v0.01, and if after total completion i can make it shorter or use top vars for easy editing then i will make v0.01

  • never mind all the echo statements, they are there for debugglez and arent actually needed to get the end result, however they do show you all numbers involved and they helped me iron out every line since i had no clue how to when i started. Also, the patterns gained from curl and grep are 'as is', there's no need for escape characters when using that syntax on that system, and if you don't know what an escape character is, you shouldnt bother with it since they're not needed here
  • varvar=$(echo "$varvar * 1000000 * 0.02" |bc) this one ... this one tells the parser to basically divide your vests (steem power expressed in shares in the blockchain there) by 50, which is the same thing as 2 percent , which is the amount of voting power used when you make one vote at 100 percent power, totally irrelevant if you just want to use linux to figure it out, all you need is to replace my handle @rudyardcatling with yours and run it in a terminal

    the pipe symbol | followed by the bc command (which comes installed with linux mint) basically tells the system to push the result, or string from the first expression into the bc command. Now why would you do that ?
    Linux is all about streams and you can pipe as much as you like in fact, its how its done, its why its so absolutely supreme but also why its completely unreadable, which is good because the moment you get to more readable language you ALWAYS give up an amount of performance

    so here it say something like:
    print the literal string $varvar * 1000000 * 0.02 to the screen or standard whatever its pointed at at the moment , THEN
    push that to the bc command, the bc command is needed because standard shell scripting doesnt do floating point mathematics (things with numbers behind dots or commas), the bc command treats the string , sorry, parses the string as a math language, which results in a number

    which is actually eventually attributed to the label varvar, or $varvar if you use it again
    (way too much info for a first FA, i know but mwell, keep in mind you can just copypaste and replace and its the first time i write an 'article' like this or is that essay ? or what is it ? ramblings of a raving lunatic?)

  • one more thing here i think totvar=${totvar//,} THIS (headache yet ? because this is what you CAN do with standard linux install without any extra program to buy or install ... other than curl which is needed to get webpages although im not sure but i think potentially you could use the wget command and then you dont have to install any package at all, so this is NOT what you have to do with linux, if you just install it, its a perfectly normal fast and reliable desktop system that has all the multimedia functionality you will ever need ... ! ! !for free ! ! !) where was i ? ah ... this snippy is used to replace characters in strings, the point is that a number like 100,000.00 is unreadable, well 'unusable as is' more like, what it needs to be is 100000.00, which is what this statement does, expression if you like it says to replace all instance of ',' in the given string (or variable named totvar in this case) by '' (nothing) as stated between the two // (theres nothing)) which gives you a string that can be used as a floating point number by bc ... complicated ? well look at the number of lines required, its not really complicated
  • and all wus gud after a few hours of git'n


    pardon my darksouls junkie speak but in essence that explains all commands used, it goes through the webpages required, digs out the numbers so you get your number of vests (steem power), the recent claims and reward balance, and the sbd to steem ratio, sticks those in variables and does the math, ending you with a nice

    echo "100 % vote is worth:"$sbdvar telling you how much more you'll need to get enough power for your 100% vote to be worth $0.01

    endings


    in my case i would need approximately three times what i have now so unless i get some infusion or mighty inspiration that will take me about another year heh heh (for a 100% vote to be worth $0.01 to the person i vote for that is)

    mind you these are all variables, prices fluctuate and the total fund is not the same for a whole second i suppose

    this is also a 'hack' if you like, because out of pure laziness i simply parse webpages from a site that has already done the math directly through the steemit api (i suppose they have) which means the numbers acquired are only as accurate as the data fed to the script from the pages parsed. If the dude from steemd feels funny and misplaces a dot somewhere you could get really funny things

    but all in all i'm not too dissatisfied with the fact that i actually got off my arse and stopped asking but DID something lol

    i'm now one hour into markup and formatting and i'm close to getting bored lol .. but i think if i just stick through i wont have to look it up again, the display of code clearly doesnt work out too well, i get blacks with background on places im not asking for it .. too many backticks and arrows i can only guess ...


    sooow, posts like this arent dependent on how much they earn, but more on how much i feel like it, but if any then probably it will be mostly anything from Ux-stuff to whatever, php javascript, gamecreator LUA or appgamekit ... i dont think i can do music of any kind right now, im totally amazed i held out to actually type this out lol, but i HAD to know how many years before my vote means something ...

    i'll be using the #uxcatling tag for any of these wether its linux related or not, and i doubt this qualifies for stem tags but we'll see , i'll post it and when i think theres no more to do, work on the formatting for maximum seven days and if i alter the script enough then i'll re-post it

    gonna get cup-ajoe before re-reading but for some reason the highlighted blocks seem to have gone where they shouldnt be, well

    i'm TRYING lol ... uh oh, daylight ... rising chickens close the windows before barking dogs get on my system

    actual execution and runtime?

    Screenshot from 2018-04-22 05-56-11.png

    mh well ... if you focus on the finger you need to check bruce lee more, my vast collection of asian lollipops and supermodels has nothing to do with this ... that's the actual output of the script and like i said : runtime is defined by connection speed since it needs to get webpages from a distant node which means latency depending on network connection speed and number of hops, not processing time, processing time is negligible

    as far as i can see, this FA is done for other than some finetune formatting, it leads to a lot of potential links that would be there if i were a structured person and had started at the bare requirements like von neumann architecture but maybe later or maybe not, and it doesnt depend on revenue, only on my state of mind, which is highly dependent on here, and here is where i'm stuck ...
    well, if you offer me a million dollar to convert 20 lines of code to scratch so yo momma can read it, i might be inclined to consider the offer (see, thats me being funny, not cocky ,not big head, ya hurr ?)

    like my main man Paracelsus used to say "I am different, let this not upset you" (and they all though he meant gay ofcourse ... duuuh)

    otherwise maybe or definitely a webpage frontend which i wont make accessible on my own celeronserver here, which runs fine but not for thousands of people ofcourse but a zipfile isnt hard to share is it, and i dont know how the steemit api goes but i guess that would be php / javascript anyway and then there's always appgamekit which has one code to rule them all since it compiles for whinedos, Uxtux AND phones ... but you can't ask the willo-wisps wether or where it will or wont , sooo .. i spent hours doing SOMETHING lol

    but i knew i could, behind my castle walls with my cat in reach, between the hour of the witch and the hour of rising chickens

    so that means time for dark souls now. I'll be re-reading this several times for some minor tweaks ... i just ran the script at 606am on 20180422 (efficient and very usable way of writing dates) and it works , doesnt mean it will tomorrow since when i started this morning there were no brackets on the page at steemd xD

    thats why i'll need the api anyway or i'll be stuck running after the steemd dude for every minor adjustment he (or she) makes to the pages, so i suppose i'll get to that sometimes but if i do this then basic architecture and programming logic would probably be not too shabby to use as internal reference

    what do you think , precious?

    ... precious says nothing

    oh dear ... maybe i should do some crazy stuff before the natives get restless

    double and triple sub huh, now we're getting somewhere, i suppose simple css like style=color:#eee or background: isnt an option
    yet ?


    at this time i just see that the code i had to alter due to 2 brackets has reverted since last time i checked so the script now is (until i get it sorted into variables for substitute or better)
    #!/bin/bash
    
    ##################################
    ACCOUNTHANDLE='@rudyardcatling'
    ##################################
    
    DOMAIN='https://steemd.com/'
    CURLURL="$DOMAIN$ACCOUNTHANDLE"
    
    varvar=$(curl -s "$CURLURL" |grep -oP '(?<=(Vesting shares</th><td><i>)).*(?=( VESTS</i></td></tr><tr><th>D))')
    
    echo "pls wait for connection to get pages"
    
    varvar=${varvar//,}
    varvar=$(echo "$varvar * 1000000 * 0.02" |bc)
    totvar=$(curl -s https://steemd.com/ |grep -oP '(?<=(recent_claims</samp></th></tr><tr><td><i>)).*(?=(</i></td></tr><tr><th><samp>l))')
    echo "..."
    totvar=${totvar//,}
    morvar=$(echo "$varvar / $totvar" |bc -l)
    lastvar=$(curl -s https://steemd.com/ |grep -oP '(?<=(reward_balance</samp></th></tr><tr><td><i>)).*(?=( STEEM))')
    lastvar=${lastvar//,}
    echo ".."
    finalvar=$(echo "$morvar * $lastvar" |bc -l)
    basevar=$(curl -s https://steemd.com/ |grep -oP '(?<=(base</samp></th><td><i>)).*(?=( SBD))')
    echo "."
    quotevar=$(curl -s https://steemd.com/ |grep -oP '(?<=(quote</samp></th><td><i>)).*(?=( STEEM))')
    ratiovar=$(echo "$basevar / $quotevar" |bc -l)
    sbdvar=$(echo "$finalvar * $ratiovar" |bc -l)
    #roll the drums
    echo "100 % vote is worth:"$sbdvar
    
    


    also as i was thinking as i was outside and ran into actual people who don't live on the internet, this is not a 20 line DOS-script even if it could be if you ran it on 100.000 nodes at once (maybe less) since it uses someones node which clearly states there's limited bandwidth, in case i need to be your morals, don't use this thing more than once a week, if you use it at all, see to me, as always i'm not trying to convey what i think you want, i found something other than my cat that kept me occupied for a measurable amount of time and that is progress (or regress if you consider it going back to a state of mind where that was possible for chunks of 30 minutes lol), so that's worth talking about for me, theres info in it, it's chaotic, its nothing an expert would be impressed with although it woldnt be the first time formal Ed eyeballs me like "hmz ... i ne'er thought of it like that" which is or is not and makes no difference to me since they potential joy was in discovery and something you discover yourself sticks a lot better than something someone tries to teach you , HENCE

    if someone can figure out how to run a game on a sequential file linked by hashes where every shackle opens after another one is cracked ... i always fancied re-booting TDU, best racing game ever to me, since atari kicked the devs like they were tooth ache ... open source ofcourse but if it runs on a chain it can has coin so ...
    not that i'm the l33T but i'm twisted in corners where humans dont seem to come (and i talk a lot when i get started but im usually quite silent)

    so dont just (d)DOS the dude since if you have access to 100k nodes im sure you can write a shorter script to do that, once i figure out how to access just the chunks i need from somewhere without needing to run a machine at home that holds the whole chain etc but until then consider it gedanken

    thank you

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  
  ·  7 years ago (edited)

i'm a programmer i could create a bot everyday but who needs another bot? ever heard of steemnow.com?
i first worked with LINUX when Walnut creek was released taught to everyone including my kids, they grew up on it:) i grew up on Dos.

not so much about who needs one, its about how i could do it by googling really :) but thanks for the link
its not really a bot is it, just a script you could put in crontab and i grew up on a commodore 64, i never had a pc until i was past 20

i just saw the source in the pages at steemd.com changed (two brackets) putting it back to the first script i had so if it changes back im gonna assume the guy at steemd is trying to block this, which is whatever

i enjoyed trying, finding and then trying to explain some of it in my own chaotic way, im not a programmer or expert in any thing at all, no one so far would tell me how i find out what my votes are worth so i found a formula and cooked this up by the grace of the 1e100, i didnt find any on steemtools.com and this is the first time i hear about steemnow.com , not everybody is as helpful i'm afraid, thanks
and you have to admit compared to the standard linux shell dos is a bit low on options , took me a few years before i met someone who was like geek extraordinaire on linux and i let him use an old p60 with root access as a firewall for my other stuff (i had a few lives ...) and whatever else he wanted to do on it and gradually i got to see the beauty of it :)

if i find any more lines that work i'll post them anyway, pictures of puppies is not really my thing lol

thanks for the interest, and thanks for the link, when i get 6sbd to spare i'll get a bot account too, i can think of one now to use it without asking people for money. The small enjoyment for me would be to figure it out myself, but i dont tell anyone what to do ofcourse

besides, so far i find most posts on the api lacking for noobs like me, so i can only assume what that means to absolute laymen, which doesnt mean i'm on a mission to educate, it's FFA after all

  ·  7 years ago (edited)

never heard of puppy linux? look it up:) ps. on github you casn find source code for bots and such stuff.

Loading...

o yea sites used for refrence and research ... the post is already clogged enough so :

https://unix.stackexchange.com/
https://stackoverflow.com/
https://www.linuxquestions.org/
https://www.shell-tips.com/
https://www.unix.com/
https://ubuntuforums.org/
https://mathblog.com/floating-point-arithmetic-in-the-bourne-again-shell-bash/
https://superuser.com/

(well, told you i had no clue how or what, only that id need grep and curl hah)


styling :

https://steemit.com/stylinggiude/@ladyluck/size-your-text-and-photos-how-many-you-want-micro-sizing

microsizing !!! ftw

https://steemit.com/steemit/@sandalphon/tips-on-formatting-and-styling-your-post-on-steemit

and also ... i think i spent more time formatting this bitch than i did prayting to the 1e100 getting this little scrib together ... its a mess, the break tags dont break so i need horizontal rulers, its c00 okay, but not really what im used to when html-ing