Hi,
I have my power input going to three feeds. wh accumilator, power to kwh/d, and power to kwh. As of Saturday the power to kwh feed has stopped incrementing but the other two feeds are working as expected.
If I create a new feed it increments as expected but if I import my data using the useful script power_to_kwh.php it stops pretty quickly. There seem to be a rounding error from my brief look at the logs. I've just ran the power_to_kwh.php script and here you can see the feed is stuck jumping between 1018.240 and 1018.241.
2015-12-07 17:48:01.140|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510481 feedtime=1449510481 value=1018.2429833333 arg=join
2015-12-07 17:48:01.142|INFO|PHPFina.php|post() id=3 timestamp=1449510481 value=1018.2429833333 padding=join
2015-12-07 17:48:11.047|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510491 feedtime=1449510491 value=1018.2408666667 arg=join
2015-12-07 17:48:11.049|INFO|PHPFina.php|post() id=3 timestamp=1449510491 value=1018.2408666667 padding=join
2015-12-07 17:48:21.058|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510501 feedtime=1449510501 value=1018.241275 arg=join
2015-12-07 17:48:21.059|INFO|PHPFina.php|post() id=3 timestamp=1449510501 value=1018.241275 padding=join
2015-12-07 17:48:31.067|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510511 feedtime=1449510511 value=1018.2409916667 arg=join
2015-12-07 17:48:31.069|INFO|PHPFina.php|post() id=3 timestamp=1449510511 value=1018.2409916667 padding=join
2015-12-07 17:48:41.075|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510521 feedtime=1449510521 value=1018.2409916667 arg=join
2015-12-07 17:48:41.077|INFO|PHPFina.php|post() id=3 timestamp=1449510521 value=1018.2409916667 padding=join
2015-12-07 17:48:51.085|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510531 feedtime=1449510531 value=1018.2412277778 arg=join
2015-12-07 17:48:51.087|INFO|PHPFina.php|post() id=3 timestamp=1449510531 value=1018.2412277778 padding=join
2015-12-07 17:49:01.144|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510541 feedtime=1449510541 value=1018.2409916667 arg=join
2015-12-07 17:49:01.146|INFO|PHPFina.php|post() id=3 timestamp=1449510541 value=1018.2409916667 padding=join
2015-12-07 17:49:11.108|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510551 feedtime=1449510551 value=1018.2411722222 arg=join
2015-12-07 17:49:11.110|INFO|PHPFina.php|post() id=3 timestamp=1449510551 value=1018.2411722222 padding=join
2015-12-07 17:49:21.105|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510561 feedtime=1449510561 value=1018.2410472222 arg=join
2015-12-07 17:49:21.107|INFO|PHPFina.php|post() id=3 timestamp=1449510561 value=1018.2410472222 padding=join
2015-12-07 17:49:31.128|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510571 feedtime=1449510571 value=1018.2409694444 arg=join
2015-12-07 17:49:31.130|INFO|PHPFina.php|post() id=3 timestamp=1449510571 value=1018.2409694444 padding=join
2015-12-07 17:49:41.129|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510581 feedtime=1449510581 value=1018.2412666667 arg=join
2015-12-07 17:49:41.131|INFO|PHPFina.php|post() id=3 timestamp=1449510581 value=1018.2412666667 padding=join
2015-12-07 17:49:51.135|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510591 feedtime=1449510591 value=1018.2409777778 arg=join
2015-12-07 17:49:51.137|INFO|PHPFina.php|post() id=3 timestamp=1449510591 value=1018.2409777778 padding=join
2015-12-07 17:50:01.154|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510601 feedtime=1449510601 value=1018.2410055556 arg=join
2015-12-07 17:50:01.156|INFO|PHPFina.php|post() id=3 timestamp=1449510601 value=1018.2410055556 padding=join
2015-12-07 17:50:11.137|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510611 feedtime=1449510611 value=1018.2412222222 arg=join
2015-12-07 17:50:11.139|INFO|PHPFina.php|post() id=3 timestamp=1449510611 value=1018.2412222222 padding=join
2015-12-07 17:50:21.152|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510621 feedtime=1449510621 value=1018.2412333333 arg=join
2015-12-07 17:50:21.154|INFO|PHPFina.php|post() id=3 timestamp=1449510621 value=1018.2412333333 padding=join
2015-12-07 17:50:31.163|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510631 feedtime=1449510631 value=1018.241025 arg=join
2015-12-07 17:50:31.165|INFO|PHPFina.php|post() id=3 timestamp=1449510631 value=1018.241025 padding=join
2015-12-07 17:50:41.168|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510641 feedtime=1449510641 value=1018.2409916667 arg=join
2015-12-07 17:50:41.170|INFO|PHPFina.php|post() id=3 timestamp=1449510641 value=1018.2409916667 padding=join
2015-12-07 17:50:51.161|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510651 feedtime=1449510651 value=1018.2413138889 arg=join
2015-12-07 17:50:51.164|INFO|PHPFina.php|post() id=3 timestamp=1449510651 value=1018.2413138889 padding=join
2015-12-07 17:51:01.168|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510661 feedtime=1449510661 value=1018.2409944444 arg=join
2015-12-07 17:51:01.169|INFO|PHPFina.php|post() id=3 timestamp=1449510661 value=1018.2409944444 padding=join
2015-12-07 17:51:11.208|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510671 feedtime=1449510671 value=1018.241175 arg=join
2015-12-07 17:51:11.210|INFO|PHPFina.php|post() id=3 timestamp=1449510671 value=1018.241175 padding=join
2015-12-07 17:51:21.217|INFO|feed_model.php|insert_data() feedid=3 updatetime=1449510681 feedtime=1449510681 value
If anyone needs a copy of my data or to test a patch let me know.
Thanks,
Kev
Re: emoncms 9.2 - power to kwh feed stopped incrementing
i had the same problem and i described it somewhere near the end of the first page on this thread (openenergymonitor.org/emon/node/11009#comment-35658) it's a huge thread so scroll down till you see my screenshots a bit further in the post. On one of the screenshots you can see a straight line while after recalculating kwh using the script that was gone. This was the same problem as you are describing. Ii also found out the culprit and a solution. basically it's a mysql problem. value is defined as float which has a precision of .XXX which is not precise enough following statements alters the value in the feeds table to be more precise to be 12 points after the decimal point and 14 before
try this statement ALTER TABLE `feeds` CHANGE `value` `value` FLOAT(26,12) NULL DEFAULT NULL;
or ALTER TABLE `feeds` CHANGE `value` `value` DECIMAL(26,12) NULL DEFAULT NULL;
it will change the precision of float or switch to decimal. for more info look up my posts in that thread above
just make sure 26 total digits is enough (the 1st value is total digit's the 2nd number, digit's after decimal point) so this should give you 26-12 14 number before decimal point (could be 13 also if decimal point is included) so<PHONE_NUMBER>9999.999999999999 is the max value then (for all feeds)
Edit - fixed link to point to relevant comment in thread - Moderator, BT
Re: emoncms 9.2 - power to kwh feed stopped incrementing
Having to edit the DB is one hell of a change. I'd like to know what chaveiro thinks of this issue and fix and how it will affect future updates.
Re: emoncms 9.2 - power to kwh feed stopped incrementing
Hi JumpMaster, there is no problem altering the feeds table to increase precision.
This problem can be mitigated by using redis in alternative.
Anyway can you add this log line to process_processlist.php about line 289 to get more details:
if ($time_elapsed>0 && $time_elapsed<7200) { // 2hrs
// kWh calculation
$kwh_inc = ($time_elapsed * $value) / 3600000.0;
$new_kwh = $last_kwh + $kwh_inc;
$this->log->info("power_to_kwh() feedid=$feedid last_kwh=$last_kwh kwh_inc=$kwh_inc new_kwh=$new_kwh last_time=$last_time time_now=$time_now");
} else {
Re: emoncms 9.2 - power to kwh feed stopped incrementing
Hi,
Thanks for replying Chaveiro. I did previously use redis but must have left it disabled after having to replace the settings.php file.
I changed the feeds table as Joyrider suggested and it did indeed fix the issue. This was easily reverted using update and check database button from the administration menu. I have now enabled redis and hopefully the accuracy will return without having to modify the database.
Thanks for your help,
Kev
Re: emoncms 9.2 - power to kwh feed stopped incrementing
Hi,
I just wanted to confirm that enabling redis seems to have fixed the issue and the kwh is incrementing as expected and matches the kwh/d feed in myelectric or the android app.
Thanks everyone for your help!
Kev
Re: emoncms 9.2 - power to kwh feed stopped incrementing
No problem Kev.
Re: emoncms 9.2 - power to kwh feed stopped incrementing
since not all of us are using redis, any chanse to get more precision on the feed value column in the official version, or would i need to change it myselve with every new emoncms release ?
if redis is used the precision on the last value in redis is probably good enough but if redis is not used mysql is used to get the last value from the feed table and then we can stumble upon this problem.
Since i've seen already 3 people, including myselve and jumpmaster that had this problem when redis is not used it might be a good idea to increase precision on the official version in mysql as well.
Re: emoncms 9.2 - power to kwh feed stopped incrementing
Hi.
On another thread I was advised to make this change because I was having problems with KWh calculations
ALTER TABLE `feeds` CHANGE `value` `value` DECIMAL(26,12) NULL DEFAULT NULL;
But, today I noticed that I was having wrong values again and it was changed again to float.
I suspect that it was the last updates of EmonCMS that "undone" that change.
Wasn't it a good idea to change the distribution to the correct value in order to avoid this kind of errors?
Cheers.
Re: emoncms 9.2 - power to kwh feed stopped incrementing
@CidiRome
this is what i do before each database update i do from a new version i make sure that in \Modules\feed\feed_schema.php the value is not defined as float but as decimal(26,12) instead of float. If you only do the statement in mysql it will revert to float as soon as you hit the update database button in the administration section. making the change in that file above will make sure that it won't revert to float. But it's possible, depeninding how you update your version that you need to do it with each new install
Re: emoncms 9.2 - power to kwh feed stopped incrementing
I haven't been home for a couple of weeks and noticed that my power usage was also so low that it was unbeievable (0.3-0.6kWh/day). I just spent about 2 hours tracking down what was happening, suspecting the PHPFina engine was having a problem with single precision floats. Turns out it is fine, because the running total is actually stored on in the MySQL server! I was trying to go from 1257.77 to 1257.7721511111 and MySQL was doing me a favor and rounding that back to 1257.77 despite there being plenty of bits of precision in a 32 bit float to store that increment.
I couldn't imagine I was the only person with this issue so google brought me here. I actually updated my mysql feeds table to type "double". I really think this should be what emoncms uses as well, because everyone's kWh feeds will fail eventually once the value gets high enough (unless they're using redis).
Re: emoncms 9.2 - power to kwh feed stopped incrementing
Yes, I've noticed the same, since February 3rd/4th my kwh accumulated values have significantly dropped too. See the attached screenshot, from that date onwards the graph almost flattens.
The process has been in place since last September, and the increments have remained fairly consistent since then, until 3/4 Feb. I'm presuming that was the date that I updated emoncms, because nothing else has changed locally....
Something has changed...
I saw this issue flagged in github, but then I'm using Redis so doesn't apply to me.
Paul
Re: emoncms 9.2 - power to kwh feed stopped incrementing
Paul - do you know when you last updated emoncms prior to the "change" ? Could it have been before the 26th Jan?
See "Power to kWh feed playing up" thread too. Despite there being no PV installed (ie no reason for a reverse flow) the log clearly shows the running total reducing slightly in places, having now read this thread I think "rounding" could cause the same effect, if the last value is rounded down and very little is consumed between the "last" and "now" reading then the rounded "last" could well be less than the unrounded "now" value.
2 days ago a comment was added to the feeds db schema that suggests the stored feed precision is linked to this value, shouldn't the precision of this "last value" always be a double to ensure accurate input calculations? I would think we always want highest precision for input calcs regardless of storage size.
Paul
Re: emoncms 9.2 - power to kwh feed stopped incrementing
Paul, afraid not, this is my main system which I don't update that regularly, I'll have a look tonight and see if there is anyway I can get the local update history via git.
i seem to recall that the accumulator only uses MySQL for increments if Redis is not running. I'm running Redis.
Paul
Re: emoncms 9.2 - power to kwh feed stopped incrementing
I have also experienced a problem with power to kWh feed suddenly not counting right.
I have also a powdr to kwh/d on the same input.
When i pull a daily graph from both feeds the graph from the power to kWh shows a couple days with a lot less data counted compared to the graph from the power to kWh/d.
I have since done the database change AND enabled redis.
Seems to count fine now i think. Should check more thorougly now.
Re: emoncms 9.2 - power to kwh feed stopped incrementing
Paul - Possibly, but don't ask me how though!
The trouble is making sense of any info you find, not only will it matter when you updated but also from which branch, when the branches were last merged at the repo, when the changes were merged into the emoncms repo and the original commit date - it's a proper maze! But had you been religiously updating every day (eg a dev machine) then that may of ruled out a link with the other thread.
Paul
Re: emoncms 9.2 - power to kwh feed stopped incrementing
Reference the comment added to the feeds db schema,
'value' => array('type' => 'float'), // use double for more precision, database space will double
Surely the use of float or double can only impact that db table by a max of 4bytes per feed defined, as it only has one "last value" per feed. Since the phpTimeseries engine is hardcoded as 9 bytes per datapoint this field setting cannot effect the file size (on the most space constrained sdcard installs), surely it can only double the storage size of pure SQL feeds.
IF this is the case I suggest the default is made "double" and if any mySQL users are concerned about storage space then reduce the size of the data feeds but not in the feed schema, if it is linked to the "feeds" schema then that link should be removed so that the more precise calcs are always used and then rounded for storage only.
Paul
Re: emoncms 9.2 - power to kwh feed stopped incrementing
Hi pb66, you are correct on your last statement, will only affect mysql feeds.
As a note, use of redis eliminate the problem because last value is cached in it with highest precision.
Re: emoncms 9.2 - power to kwh feed stopped incrementing
I may of found the issue that's caused my problem;
Redis is installed and running, but when I last updated (copying default.settings.php to settings.php) I neglected to re-enable redis in settings, so it was falling back to using MYSQL.
Should the default redis setting be changed to 'true' in default.settings.php?
Paul
Re: emoncms 9.2 - power to kwh feed stopped incrementing
In default.settings.php ? I wouldn't because it's optional and not every body will install redis...
Just ensure your own settings.php is correct for your install options.
Re: emoncms 9.2 - power to kwh feed stopped incrementing
Yup exactly. If you have redis, then enable it in settings.php. If not, then edit the modules/feed/feed_schema.php and switch the float to double and update your schema from the administration page.
I'm not sure why float is used in the database, I know all the feed data storage is float and that's fine, but each feed only has one "last value" in the database so the storage cost of expanding that to double precision is the same as storing /a single point in the feed file/. For systems where we're storing hundreds of thousands of points per feed, storing one more is nothing.
Re: emoncms 9.2 - power to kwh feed stopped incrementing
Agree, but should the process be allowed to run if it's results are grossly inaccurate?
IMO there are two options;
1) Fix MYSQL so that the same results are obtained with, or without Redis.
2) Disable the process if Redis is not installed and enabled.
Consider newbies to emoncms, where does it say that you have to enable Redis for the power to kwh process to work?
Also, as in my case, with the frequent updates to the settings file, it's easy to overlook the Redis enablement, which may not become apparent for some considerable time thereafter...
Thoughts please...
Paul
Re: emoncms 9.2 - power to kwh feed stopped incrementing
I don't think the process is supposed to be grossly inaccurate, or that redis is supposed to be required for this to work. The issue only surfaces at this level (1000 kwh) if your (power usage) * (update frequency in hours) is less than a certain amount. A less frequent update period (say every 5 minutes) or a higher power usage (say 500W) all properly increment the counter At 10,000 total kwh you'll again need an order of magnitute increase in the power usage to keep it ticking on.
Eventually at some point, everyone's kwh feeds will stop updating. This is true for even redis or double precision feed "last values", however for those people it will be when their total accumulated kwh is in the billions (enough to consume 100 kwh a day for over 25,000 years). I think it is really just an oversight because the feeds table is supposed to store tha latest value, which is inserted as an absolute number. With normal feeds eventually the input value will be high enough to tick it to the next rounding point or way beyond. However, in this case the code is trying to do its own tallying and given the size of the increment it just can't overcome rounding errors.
Having redis enabled handles it properly because its datatypes are wide enough. The MySQL feeds table just needs to have its own data type widened to match redis and the precision needed to perform the math that emoncms is trying to do on it.
Re: emoncms 9.2 - power to kwh feed stopped incrementing
What is Redis? I see it mentioned a lot but have no idea what it does.
It is obviously an optional element but why? What are the pros and cons?
I'm on a custom install V 9.2
{edit}
2 other things; How do I know if it is installed and is it a service that should be running?
Cheers
Re: emoncms 9.2 - power to kwh feed stopped incrementing
I don't think the process is supposed to be grossly inaccurate
Well no, but it is grossly inaccurate if Redis is not activated.
Just to give you an idea of the magnitude of error, I've examined the data recorded on the same 'power to kWh' feed over 2 different '10 day' periods, the first with Redis enabled, the second with Redis disabled;
25th Jan - 4th Feb - Redis enabled - 59.1kWh
5th - 15th Feb - Redis not enabled - 8.6kWh
Since re-enabling Redis, the increments are again looking realistic, and as expected.
Paul
Re: emoncms 9.2 - power to kwh feed stopped incrementing
@borpin123: redis is a caching server process, used to store data in RAM instead of a database. If you haven't actively installed it, you don't have it. I don't think it is part of any default distribution. It isn't something made for desktop users and usually is used on server systems as a caching mechanism. For a single user emoncms system, there is no reason to install it because its purpose it is to increase performance on high load systems.
@Paul Reed: I'm noticing the same thing, even with feeds which don't have lot of power running through them. I have a monitored outlet that pulls 50 watts pretty consistently (especially because I haven't been home in 2 weeks).
Calculated 50W x 24h = 1.2kWh/day
Feeds table float, Feb 8-13th: 0.9kWh/day
Feeds table double, Feb 14-15th: 1.2kWh/day
There is a 30% loss due to the rounding down. I've just started this feed a few months ago, but once it reaches the 100 kWh mark it would lose more or stop updating completely.
It really seems to be a no-brainer to just increase the size of the field to 8 bytes in the feeds table. The recent commit that says "database space will double" is technically accurate, the size of the _field_ will double, but the row is 54 bytes at a minimum. This would bump it up to 58 bytes or AT MOST a 7% space increase (it is actually much less because the feed names and node tags add another 15+ bytes). Again, we're on a system that is storing THOUSANDS OF POINTS OF DATA per feed, however seems to be concerned about adding the storage equivalent of a single point to actually make the "power to kwh" feed actually work (redis or not). Doesn't literally every user use the power to kwh feed? One might argue that the storage space of the feed data for that feed is wasted space if the value isn't correct at all! :-D
Re: emoncms 9.2 - power to kwh feed stopped incrementing
@capnbry seems though that redis was originally used to reduce the wear on sd cards. It is also part of the install instructions so I have it installed.
Can I simply enable redis in the settings then reboot?
{edit}
Actually, will enabling Redis solve anything if none of my feeds are sql. They are all phpfina.
Re: emoncms 9.2 - power to kwh feed stopped incrementing
Can I simply enable redis in the settings then reboot?
Yes
Actually, will enabling Redis solve anything if none of my feeds are sql. They are all phpfina.
Yes, if you are using a 'power to kWh' process, no if you aren't. (see the posts above!)
Paul
Re: emoncms 9.2 - power to kwh feed stopped incrementing
O dear not sure why I did not pick up on this earlier! Thanks for all the debugging work
Given that the key here is the last value stored in the mysql feeds meta data table if redis is not present then I cant see an issue with setting the value field to be a double in the feeds table schema as you identified Paul:
https://github.com/emoncms/emoncms/blob/master/Modules/feed/feed_schema....
Would someone running emoncms without redis be able to confirm if changing the datatype here to double and running the emoncms database update to apply the change solves the issue?
'value' => array('type' => 'float'), to 'value' => array('type' => 'double'),
Re: emoncms 9.2 - power to kwh feed stopped incrementing
I don't have a test-bed system at the moment, but have made the necessary changes to my main system (I need to rebuild the feed later anyway!), so I'll report back in a couple of days with the results.
Could do with a few more volunteers to try though!
Paul
Re: emoncms 9.2 - power to kwh feed stopped incrementing
@trystanlea I have been running the code that way since Sunday. @joyrider3774 had suggested that the schema file just be changed and I thought it was a pretty sweet piece of coding that the generator file could just be changed and emoncms could figure out what it needed to change. Brilliant!
Since updating the file to change it to a double type and updating the database, ALL my kwh/day fields are incrementing differently now. The good news is that they are more accurate! I have an outlet pulling a constant 6W,one that pulls 50W pretty consistently, and my whole house power usage.
6w x 24h, was reading <0.1kwh/d, now 0.14kwh/d
50w x 24h, was 0.9kwh/d, now 1.2kwh/d
House (peak 350w), was 0 kwh/d, now 6.9kwh/d
The difference in resolution of error is because of the accumulated kwh value. The house has a much larger total so its error is peaked at recording no data unless the watt usage was high enough. This point would be reached by the other outlets once their values got high enough as well.
I've seen no down sides to the double value in the feeds table and the values I took for granted were calculating out properly actually are accurate now given the fixed power usage while I am away from home!
Re: emoncms 9.2 - power to kwh feed stopped incrementing
I've tried the fix since Wednesday, and with Redis deactivated I'm getting much more realistic readings.
So yes, I would say that it does solve the problem.
Paul
Re: emoncms 9.2 - power to kwh feed stopped incrementing
I have to agree with CaptBry that the float v double decision is a "no-brainer", there is no justifiable reason to not use AT LEAST a double, the size of the persisted data should not be directly linked to the calculation precision, we want the highest accuracy for calculations and the smallest size for storage.
float rounding should only affect persisted datapoints until the rounding ticks over to the next step i.e. from round down to round up for example. Using floats in the calcs could easily result in a low power reading read in frequently always being rounded to the point that a known power consumption could register as zero consumed energy forever, an essential element of an energy monitor is that it monitors energy, wouldn't you agree?
Also see "Rounding on large incrementing counter values" this issue also impact high meter readings as well as small unit/time increments too.
That thread links to "SQL rounds my inputs" which also puts forward a good case for using "decimal" over float or double, I do not like the way floats work in calculations and using decimal should not only eliminate any platform or OS influence due to the defined sizes (something that can affect floats) but it also makes a clear distinction between a value persisted for calculations from those persisted as dataponts, reducing confusion, adding cross-platform consistency and improving accuracy too, what's not to like, especially as there is no downside beyond a few bytes per feed, not per datapoint.
As for the settings, as OEM recommends the use of redis and all it's guides seem to recommend it, it would seem daft to me to then assume no one is using it and default to "not installed", that seems contradictory to me. Given Paul was given no indication that redis was not being used and that Borpin123 was not made aware he could benefit from it, it would seem a better choice to assume it is being used (as recommended) and those that cannot use it (windows & shared servers) disable it, mainly because if it is there is should be used if it isn't there emoncms would raise an error to alert the user "install it or disable it!" rather than fail silently with it installed and not used.
Paul
Re: emoncms 9.2 - power to kwh feed stopped incrementing
The 'master' branch has just been updated to change the database value to a 'double' instead of 'float'.
Don't forget to update your database following a git pull.
Paul
Re: emoncms 9.2 - power to kwh feed stopped incrementing
@pb66, I agree about setting the default to redis enabled and then providing a "install it or disable it" notification, shall I go ahead and do this?
I'd be also happy to change the meta table value to decimal as you suggest Paul if it is the best way to go. What would you suggest for the decimal value? We would need sub Watt hour resolution probably down to around 0.000001 kWh. DECIMAL (20,9)? Should give plenty?
Re: emoncms 9.2 - power to kwh feed stopped incrementing
I do think it's the right thing to do, a double may have the scope for massive numbers but at a cost of precision, to me there is no point having the facility to store 100's of billions of kW's if we cannot see every kW increment, we could just as easily use a megawatt feed instead if the precision wasn't important.
What are the implications of not getting the decimal size right first time? if it can be changed as easy as the float to double I would say lets just try it and see, I would however, probably increase the overall size to allow 20 places to the left of the decimal point to accommodate an unsigned LongLong (Datacode Q) so perhaps (29,9). The 9 seems plenty as that will allow precision down to a microWatt even on a kW feed although there is a recommendation to use 12 decimal places in a few posts towards the end of the first page in the EmonCMS 9.31 | 2016.02.13 released..
will this mean that the accuracy will be greater on a non-redis setup? what defines the data type used by redis, is it governed by the feed meta or will it remain a double?
Would it be possible to consider "double" php datafeeds as mentioned here? perhaps allow other types too, I have various feeds tracking on/off status, this could be done in a single byte char rather than a 4byte float so the data feed could easily be a quarter of the size.
Paul
Re: emoncms 9.2 - power to kwh feed stopped incrementing
@Trystan - didn't want this thread to get buried without a final decision!
Is this to be changed to decimal, or are we sticking with double?
Paul
Re: emoncms 9.2 - power to kwh feed stopped incrementing
Apologies for the delay on this, I have not forgotten. There's more I need to get a handle on here, reading through this page http://php.net/manual/en/language.types.float.php
Thinking aloud: Do we ideally need to avoid floating point math all together and have a bucket that accumulates up to 3600 Joules and then increases a watt hour count which is then stored as a long / unsigned long. I'll do some more reading on this.
If we move over to doing this on the emontx as standard: https://github.com/openenergymonitor/emonTxFirmware/blob/master/emonTxV3...
then the requirement would be to store a watt hour value up to a maximum amount...


New Zealand 12-8 Great Britain: 5 talking points as Lions fall to second straight tour defeat
Wayne Bennett’s side again flatter to deceive in attack as a late Daryl Clark try is not enough to avoid defeat
by Gareth Walker, https://www.facebook.com/GarethWalkerMirror/Great Britain fell to a second defeat in eight days as Kenny Bromwich’s stunning late cover tackle earned New Zealand victory.
Lions winger Jermaine McGillvary looked a certain scorer when Wayne Bennett’s side fashioned a rare chance with less than four minutes remaining.
But back rower Bromwich produced a superb effort to knock the ball from McGillvary’s grasp as he dived for the line to preserve the Kiwis’ lead.
Great Britain made minimal errors throughout, but again lacked a cutting edge, having gone in level at half-time at 2-2.
Tries to Jamayne Isaako and Corey Harawira-Naera then put New Zealand in control, and despite Daryl Clark’s late response the Lions fell short again after losing to Tonga last weekend.
Here are five talking points from the game....
1. Toothless Lions
Just two tries in two matches tells its own story.
Great Britain had more possession and field position than they enjoyed against Tonga seven days earlier, but could do little with it.
Time after time poor last tackle options and a lack of cutting edge saw promising positions come to nothing.
With the game on the line the tourists became more expansive in the closing stages with Jackson Hastings increasingly prominent and Daryl Clark poaching a try - but it was not enough.
The Lions have looked short on ideas throughout the tour so far despite picking a wealth of playmaking options - and now have minimal time to turn it around.
2. RTS magic
A key difference between the teams was undoubtedly brilliant Kiwis full-back Roger Tuivasa-Sheck.
The New Zealand Warriors star made over 100 metres in the first half alone, with his quick feet too much for the Lions defence at times.
He came up with a key play to escape from his own in goal area, and then produced a blistering second half break to create Jamayne Isaako’s opening try.
In short, RTS - as he is known Down Under - was the line breaker Great Britain were lacking.
3. Foran’s heartache
New Zealand stand-off Kieran Foran was pulling a Kiwis shirt on for the first time since May 2017 after forcing his way back into contention at the expense of Shaun Johnson.
But his return was cruelly cut short when he was forced from the field in just the sixth minute after dislocating his shoulder.
It looked a devastating blow for the Kiwis to lose a key playmaker so early in the contest.
But Michael Maguire’s side adapted well with Melbourne Storm’s Jahrome Hughes stepping up alongside Benji Marshall.
4. Ruck frustrations
Throughout the game, Wayne Bennett’s side were regularly frustrated by the speed of the play-the-balls as they attempted to build some momentum up front.
The issue boiled over in the closing stages when John Bateman objected to another messy ruck and ended up grappling with Roger Tuivasa-Sheck.
James Graham was asked about the issue after the game and made reference to the fact international matches only have one referee as opposed to the two in the NRL.
But, as Graham pointed out, it was the same for both sides - and New Zealand seemed to cope better.
5. What now for Lions?
Skipper Graham was also asked about needing a response next weekend, and answered that the Lions have little option.
After 12 years without playing, the triumphant return of Great Britain rugby league is in danger of fizzling out forgettably.
Consecutive defeats to Tonga and New Zealand are bad enough, but the style of play has failed to enthuse supporters and matches have been played in half empty stadiums.
The tour now moves to Christchurch and it needs a major lift on all fronts


- Game - Class in <Unnamed>
-
A Game object is an instance of NordicTraveller.
- Game() - Constructor for class Game
-
Instantiates a new Game object with a random seed.
- Game(int) - Constructor for class Game
-
Instantiates a new Game object with a given seed.
- generateGame(int, String) - Static method in class Generator
-
- Generator - Class in <Unnamed>
-
Creates an instance of NordicTraveller based on a String representation of the internal network.
- Generator() - Constructor for class Generator
-
- getCities() - Method in class Country
-
Retuns the cities in this country in a sorted list.
- getCity(String) - Method in class Country
-
Checks for the city is in this country
- getCity(String) - Method in class Game
-
Gets a specific City object, based on its name (findOne).
- getColor() - Method in class GreedyPlayer
-
- getColor() - Method in class Player
-
Gets the display color of this Player object.
- getColor() - Method in class RandomPlayer
-
- getColor() - Method in class SmartPlayer
-
- getCountries() - Method in class Game
-
Get a list of all countries within this Game instance.
- getCountry() - Method in class City
-
Returns the country for this city
- getCountry() - Method in class Player
-
Gets the Country object this Player currently resides in.
- getCountryFrom() - Method in class Player
-
Gets the Country object this Player currently resides in.
- getDistance() - Method in class Position
-
Returns the distance left to the "to" city
- getFrom() - Method in class Position
-
Returns the city that is currently "from"
- getFrom() - Method in class Road
-
Where the road is starts/is from
- getGame() - Method in class Country
-
Returns the current game.
- getGameSpeed() - Method in class Settings
-
Gets the current game speed:
0: STOP
1: SLOW
2: MED
3: FAST
4: SONIC
- getGUIPlayer() - Method in class Game
-
Gets the GUI Player (the one controlled by the GUI).
- getLength() - Method in class PlayerPath
-
Returns the length (in units) of this path.
- getLength() - Method in class Road
-
Returns the length of the road
- getLoss() - Method in class Game
-
Determines how badly a Player gets robbed.
- getMaxRobbery() - Method in class Settings
-
Gets the maximum robbery amount (can't be robbed for anything more than this).
- getMinRobbery() - Method in class Settings
-
Gets the minimum robbery amount (can't be robbed for anything less than this).
- getMoney() - Method in class Player
-
Gets how much money this Player has collected.
- getName() - Method in class City
-
Returns the name for this city
- getName() - Method in class Country
-
Returns name of this country.
- getName() - Method in class GreedyPlayer
-
- getName() - Method in class Player
-
Gets the display name of this Player object.
- getName() - Method in class RandomPlayer
-
- getName() - Method in class SmartPlayer
-
- getNetwork() - Method in class Country
-
Retuns the network of the cities and roads in this country
- getPlayers() - Method in class Game
-
Gets a list of all players associated with this Game instance.
- getPosition(City) - Method in class Game
-
Get the GUI position of a given City.
- getPosition() - Method in class Player
-
Gets the current position of this Player instance.
- getRandom() - Method in class Game
-
Get the global Random object.
- getRandomStartingPosition() - Method in class Game
-
Returns a random position within this Game instance.
- getRisk() - Method in class Settings
-
Gets the current risk of being robbed (in %).
- getRoad() - Method in class PlayerPath
-
Returns the uppermost Road in this path.
- getRoads(City) - Method in class Country
-
Returns the roads that is in a specific city in this country.
- getSettings() - Method in class Game
-
Get the Settings object.
- getStepsLeft() - Method in class Game
-
Gets the number of steps remaining in this Game instance.
- getTo() - Method in class Position
-
Returns the city that is currently "to"
- getTo() - Method in class Road
-
Where the road is going to/ends
- getTollToBePaid() - Method in class Settings
-
Gets the current toll size (in % as an integer).
- getTotal() - Method in class Position
-
Returns the total distance between the cities
- getTotalTimeLeft() - Method in class Game
-
Gets how much time this game had at its conception.
- getValue() - Method in class City
-
Returns the value for this
- getValue() - Method in class PlayerPath
-
Returns the value (in €) of this path.
- GreedyPlayer - Class in <Unnamed>
-
An AI player which greedily chooses its path at each city (looks only one city ahead).
- GreedyPlayer(Position) - Constructor for class GreedyPlayer
-
Instantiates a new GreedyPlayer with the specified position.
- GUI - Class in <Unnamed>
-
A GUI written in Java Swing which wraps around a Game instance.
- GUI() - Constructor for class GUI
-
Constructor for the GUI class.
- setActive(int, boolean) - Method in class Settings
-
Sets whether or not a given AI Player is active.
- setGame(Game) - Method in class Country
-
Changes this game to a specific game.
- setGameSpeed(int) - Method in class Settings
-
Sets the current game speed:
0: STOP
1: SLOW
2: MED
3: FAST
4: SONIC
- setGUIPlayer(Player) - Method in class Game
-
Associates the GUI player with some specific Player instance.
- setMinMaxRobbery(int, int) - Method in class Settings
-
Changes the bounds for robbery.
- setPendingPosition(Position) - Method in class Player
-
Sets the pending position of this GUI Player.
- setPosition(Position) - Method in class Player
-
Sets the position of this Player instance.
- setRisk(int) - Method in class Settings
-
Sets the current risk of being robbed (in %).
- setSpeed(int) - Method in class GUI
-
Changes the game speed
- Settings - Class in <Unnamed>
-
Settings represents the current settings at a given time.
- Settings(boolean[], int, int, int, int, int) - Constructor for class Settings
-
Instantiates a new Settings object based on its values.
- Settings(Settings) - Constructor for class Settings
-
Performs a deep copy of the specified Settings object.
- Settings() - Constructor for class Settings
-
Instantiates a Settings object with the default values.
- Settings(String[]) - Constructor for class Settings
-
Instantiates a Settings object based on a list of strings.
- Settings(String) - Constructor for class Settings
-
Instantiates a Settings object based on its string representation.
- SettingsException - Exception in <Unnamed>
-
- SettingsException(String) - Constructor for exception SettingsException
-
- setTollToBePaid(int) - Method in class Settings
-
Sets the current toll size (in %).
- setTotalTimeLeft(int) - Method in class Game
-
Changes the total time left of this Game instance.
- setUp() - Method in class CGTest
-
Sets up the test fixture.
- SmartPlayer - Class in <Unnamed>
-
A smart AI player which uses a depth-first search to determine the optimal PlayerPath.
- SmartPlayer(Position) - Constructor for class SmartPlayer
-
Instantiates a new SmartPlayer with the specified position.
- speed - Static variable in class GUI
-
The current game speed (0 = stop, 1 = slow, .. )
- step() - Method in class Game
-
Advances this Game instance one step.
- step() - Method in class GreedyPlayer
-
- step() - Method in class Player
-
Advances this Player one step.
- step() - Method in class RandomPlayer
-
- step() - Method in class SmartPlayer
-


Color Generator
RGB:
HEX:
CMYK:
Add to Favorite
Add to Favorite
Add to Favorite
Add to Favorite
Add to Favorite


We would really like to hear your opinion about the Toaster Fridge you just bought. Click below to be able to win a teddy bear
Protip: Look at the top-left corner to see the status of the submit event


{% extends "_m/pages/add.html" %} {% import "macros.html" as formmacros with context %} {% block content %} {% block title %}


Theming
Theming is handled using CSS custom properties. The properties that are supported are listed here. There are three main ways you can set these properties.
Styles
You can set custom properties in the style tag of your component:
<style>
:root {
--info-color: purple;
}
</style>
When setting custom properties in the style tag, you need to make sure you set all related colors (e.g. if you set --info-color, you will also need to set --info-hover-color).
loadTheme
Alternatively, you can pass an object into the loadTheme method in the onMount method of your component:
import { loadTheme } from "svelte-toolkit";
onMount(() => {
loadTheme({
"--info-color": "purple"
});
});
The loadTheme method will set related colors (e.g. in the example above it will set --info-hover-color as well as --info-color) but as it's called on onMount the original colors will be displayed briefly before the theme colors are loaded. It's most useful for applying user custom themes or other dynamic themes.
You can use the getTheme method to get all colors that have been set (including related colors if set through loadTheme):
import { getTheme } from "svelte-toolkit";
onMount(() => {
alert(getTheme());
});
Script
Svelte Toolkit also comes with a script that you can use to override the styles in the component files themselves. It requires a bit of setup.
Install `node-sass` as a dependency:
yarn add -D node-sass
Add a `stk.config.json` file to the root of your site, with content in the following format:
{ "theme": { "--info-color": "purple" } }
Add the script entry to your `package.json` file:
"scripts": { "theme": "stk theme" }
Run the script:
yarn theme
The script will only build the theme when the config file has changed or the svelte-toolkit dependency has been updated, so you can put it into your `package.json` as a predev or prebuild script without impacting performance.
The script will set related colors (e.g. in the example above it will set --info-hover-color as well as --info-color), just like using loadTheme.
Behind the scenes, this script injects new styles directly into the components, so you can also change some properties that are impossible to do as CSS custom properties, including media query breakpoints.


Did you know that you can navigate the posts by swiping left and right?
Linux is not only a very convenient enviroment to develop but also is the best way to take adventange of all posibilities provided for a personal computer. An operative system based on Linux allow customize the enviroment and the use of a very complete compedium of tools. On the other hand, Awesome Windows Manager is a level more to get the best experience with your system and your activity with Linux. This one is a dynamic window manager for the X Window System developed in the C and Lua programming languages. Lua is also used for configuring and extending the window manager. Its development began as a fork of dwm. It aims to be extremely small and fast, yet extensively customizable and make it possible for the user to productively manage windows with the use of keyboard. It is another world.
As operative system based on Unix is possible use anyone but he most convenient would be an OS the most ligth as possible. For this reason I have choosen XUbuntu, an operative system derivated of Ubuntu. This one uses the Xfce desktop environment, instead of Ubuntu’s Unity. It is recommended the last LTS version with all software updated to not be any problem with the wifi driver.
Download package (64bits):
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
Install the package, forcing install of dependencies:
sudo dpkg -i --force-depends google-chrome-stable_current_amd64.deb
In case any dependencies didn’t install (you would have a warning or failure message for this), you can force them via:
sudo apt-get install -f
Just before install the new WM, it is interesting uninstall those apps not usefull to keep clean the OS.
Install package:
sudo apt-get install awesome awesome-extra
Remove XUbuntu desktop:
sudo apt-get autoremove --purge xubuntu-* && sudo apt-get autoremove --purge xfce*
Set Awesome as the default windows manager:
sudo xfconf-query -c xfce4-session -p /sessions/Failsafe/Client0_Command -t string -s "awesome" -a
Restart lightdm service:
sudo service lightdm restart
Copy awesome WM config file yo home directory:
mkdir -p ~/.config/awesome/
sudo cp /etc/xdg/awesome/rc.lua ~/.config/awesome/
sudo chown YOURUSERNAME ~/.config/awesome/rc.lua
Finally, to get Awesome WM start automatically:
Open:
nano ~/.bash_profile
and include:
# startx automatically
if [ -z "$DISPLAY" ] && [ $(tty) = /dev/tty1 ]; then
startx
fi
And open:
nano ~/.xinitrc
including:
# ~/.xinitrc
# This file is sourced when running startx and
# other programs which call xinit
# Start the window manager
exec awesome
Reboot:
sudo reboot
After of this, you can enjoy with your new system.
The most interesting feature of awesome windows manager is the possibility to be customized freely. Awesome 3 uses a configuration file based on the Lua language. Lua is a simple language but very powerful becuse offers more control. Firstly it maybe intimidate but finally it is enough a litle bit number of notions to start to include changes in the original file.
In my case I don’t have include many changes firstly. Specially I have focused in widgets for my tool bar.
In order to customize the windows manager it is necessary edit the file rc.lua. This one is normally stored in ~/.config/awesome/ but also it is possible access browsing into the default menu: menu > awesome > edit config
Before working with this file it is recommended check it previously to understand specially different parts of code to know where includes the piece of code of our new feature. These parts are fundamentally:
After including any change is required update. For this is possible reboot or use in the default menu the option: menu > awesome > reboot
Currently, this is my rc.lua file but now it is very simple.
Awesome WM it is possible be used with a convencional way (mouse, graphical file manager, etc) but really the most interesting way is use terminal and keyboard (shortcuts). OS based on Unix provide many tools to work from a terminal and Awesome WM allow to configure many terminals in the same screen.
For me, these maybe some interesting tools to start to operate with this system.
sudo apt-get install htop
sudo apt-get install eog # open pictures
This tooll allow open any picture from terminal.
# a possible dependece
sudo apt-get install libhunspell-1.3-0 libhunspell-dev
# download package
wget https://github.com/zhangshine/MdCharm/releases/download/1.2.0/mdcharm_1.2_amd64.deb
# install
sudo dpkg -i mdcharm_1.2_amd64.deb
sudo apt-get -f install
This tool for me is one of the best Markdown editor. It is easy to use and the markdown conversor is really good.
sudo add-apt-repository -y ppa:webupd8team/sublime-text-3
sudo apt-get update; sudo apt-get install -y sublime-text-installer
I think it is not necessary speak about this text editor. It is so good.
sudo apt-add-repository ppa:izx/askubuntu
sudo apt-get update
sudo apt-get install libnotify-bin
This tool launch customized OS reminders or advices setup for the user. For example, I use to remember me the time o’clock after to be included in CRON.
sudo apt-get install multitail
This is a very interesting tool. It is the same than command ‘tail’ but also allow the possibility to show in the same time several files. This one is very useful for monitoring sevelar logs of several applications running in streaming.
#Install node:
sudo apt-get install nodejs npm
#Make a symlink:
sudo ln -s /usr/bin/nodejs /usr/bin/node
#Then install how2:
npm install -g how2
Stackoverflow is a website reference for developers. In order to fix any code problem or remember any forgotten command, this is a good place to be consulted. So, how2 it is very interesting because provide a very simple way to consult in Stackoverflow from terminal.
Despite of Telegram is not the most used messenger tool, I think many people know about this one. For me is the best.
Requeriments:
sudo apt-get update
sudo apt-get install libreadline-dev libconfig-dev libssl-dev lua5.2 liblua5.2-dev sudo apt-get install libevent-dev
sudo apt-get install libjansson*
Install:
sudo apt-get install git
# download package
git clone --recursive https://github.com/vysheng/tg.git
# enter in folder and install
./configure
make
The executable is inside of ‘bin’ folder.
Install:
sudo apt-get install speedometer
Usage from terminal:
speedometer -l -r <<name_network>> -t <<name_network>> -m $(( 1024 * 1024 * 3 / 2 ))
This tool allow monitoring our network very easily. There are very similar tools available, any of these, sure more powerful, but speedometer keep the best equilibrium between easiness and usefulness.
sudo apt-get install nautilus
sudo apt-get install nautilus-open-terminal
sudo apt-get install nautilus-actions
Working with terminal, it is not necessary use service as Nautilus, but for me, sometimes, it is confortable.
For many years, users prefer work with their information storaged into own hard-drive. But, currently and I think in the future, the use of cloud storage service will be extended and our personal computers will be more slim, more ligth and with a bigger connectivity. Mega cloud services provide free 50GB, the possibility to be used from browser or directly from our file manager after installing any extension. Work and sincronize very good. Of course, it is necessary donwload any packages.
Install:
sudo apt-get install libcrypto++9
sudo dpkg -i megasync-xUbuntu_14.04_amd64.deb
sudo dpkg -i nautilus-megasync-xUbuntu_14.04_amd64.deb
Now it is neccesary launch ‘megasync’ and logging to add in Nautilus the “Mega” folder and syncronize with cloud.
Firstly is necessary install:
sudo apt-get install libtranslate-bin
This library use online the google translate engine.
Usage:
echo "what are you doing" | translate-bin -s google -f en -t es
#" onmouseover="this.style.backgroundColor='#ebeff9'" onmouseout="this.style.backgroundColor='#fff'">Qué estás haciendo
But maybe this bash command is not easy to remember or write every time. For this reason it is possible iinclude a function alias into .bashrc file.
## translater
mytranslater() {
echo $3 | translate-bin -s google -f $1 -t $2
}
alias translate=mytranslater # $1=language 1 / $2=language 2 / $3=text to be tr$
For this function alias, the usage would be:
translate en es "what are you doing"
#" onmouseover="this.style.backgroundColor='#ebeff9'" onmouseout="this.style.backgroundColor='#fff'">Qué estás haciendo


Problem 01
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << (n+4)/5 << "\n"; }
We are trying to find the minimal amount of steps, so it is optimal to try and cover as much distance as possible using as little steps as possible, so this means we will use 5 position forward steps as much as possible until we can't anymore. When we can't move 5 positions forward anymore that means the house is 1 to 4 positions in front of us, which means we can cover it in another step. This method leads to our answer being ceil(x/5), which is equivalent to (x+4)/5 using integer division.
Problem 02
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; for (int i = 1; i < n; i++) { cout << i+1 << " "; } cout << 1 << "\n"; } }
One way to make a permutation of length n such that no value is equal to its index is to take 1,2,3,...,n and shift it over by 1, which makes 2,3,4,...,n,1. You can easily do this with a for loop and some print statements.
Problem 03
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; string alp = "abcdefghijklmnopqrstuvwxyz"; string res = ""; for (int i = 0; i < n; i++) { res += alp[i%k]; } cout << res << "\n"; }
We have to create a string such that it has a length of n, is made of k distinct lower case letters, and no two adjacent letters are distinct. There are many ways to do this but the most obvious one is to use the first k letters of the alphabet and repeat the sequence until you reach n. For example, n = 7 k = 3 would lead to abcabca. Now this might be a little difficult to implement for a beginner, but this would entail having a string alp = "abcdefghijklmnopqrstuvwxyz" and a string ans = "". You then do for each i in the range 0 to N-1 (a total of n times) and add to ans, alp[i%k]. If you don't understand why this works try performing a small version of this loop by hand and seeing what occurs.
Problem 04
#include <bits/stdc++.h> using namespace std; int main() { string a, b; cin >> a >> b; if (a == b) cout << a << "\n"; else cout << "1" << "\n"; }
We have to find the gcd of the numbers from a, a+1, ..., b-1, b. The first observation to solve this problem is to realize that the of gcd(a, a+1) = 1. And the gcd of 1 and any number is also 1. So if we have more than 1 value in in our interval then the answer is 1. Now lets see what happens if the two bounds are the same, gcd(n, n) = n, so if the two numbers are the same the answer is n. So input two strings into your program, compare the two, if they are the same return the string, else return 1.
Problem 05
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int cnt = 0; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; if (a == b) cnt++; else cnt = 0; if (cnt >= 3) { cout << "Yes\n"; return 0; } } cout << "No\n"; }
For this problem, make sure to iterate through both of the inputs at the same time, and keep a count variable to store the current size of the equal subarrays of the two inputs. If the two current elements are equal increase count by one, else set count to 0, and if the count variable is ever >=3, you can just break out of the loop and print “Yes”. If this never happens, print “No”. This can be done with a single loop.
Problem 06
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { ll n; cin >> n; while (n > 1) { if (n%2 == 0) n /= 2; else break; } if (n == 1) cout << "NO\n"; else cout << "YES\n"; } }
The key observation here is that if a number has no odd divisors, then its only prime factors can be 2. In other words, if the number is a power of 2, then the answer is no, otherwise the answer is yes. There are multiple ways to implement this:
probably the most basic one is to keep dividing by 2 until the number is odd, then notice that if the result is 1 the number was a power of 2.
you can also use a built in method like __builtin_popcount(n) in C++ to find the number of 1's in a number's bit representation (if it's 1, the number is a power of 2).
there's also a neat bit manipulation trick: n&-n returns the highest power of 2 that divides n (won't go into it in depth, but you can read about it here). If n is a power of 2, then n&-n == n.
a similar trick takes advantage of the fact that n&(n-1) erases the lowest 1 bit in n, so if n is a power of 2 then n&(n-1) == 0.
Problem 07
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << 0 << " " << 0 << " " << n << "\n"; }
There are a couple ways to solve this problem. One method takes advantage of the fact that 0 is a Fibonacci number, so 0 + 0 + F_n = F_n. You could also do something like 0 + F_(n-1) + F_(n-2), which just uses the formula for Fibonacci numbers. Finally, if using zeroes was not allowed, you could use the formula for Fibonacci numbers multiple times, by noticing that F_n = F_(n-1) + F_(n-2) = (F_(n-2) + F_(n-3)) + F_(n-2).
Problem 08
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int t; cin >> t; while (t--) { ll a, b; cin >> a >> b; ll x, y; cin >> x >> y; ll n; cin >> n; ll a2 = a, b2 = b, n2 = n; ll ans1, ans2; ll e = min(a-x,n); a -= e; n -= e; b -= min(b-y,n); ans1 = a*b; ll f = min(b2-y,n2); b2 -= f; n2 -= f; a2 -= min(a2-x,n2); ans2 = a2*b2; cout << min(ans1,ans2) << "\n"; } }
The main observation is to realize that if you decrease one of the numbers a, it is optimal to decrease this number as much as possible, before moving onto b. Lets see why our original product is a*b if we decrease a twice we subtract 2*b from our product, but if we decrease a once then b we subtract b+(a-1) from our product, and finally if we decrease b twice we subtract 2*a from our product, This is a then b or b then a is less optimal because the -1 exists, and making our difference less than it could be.
So now we know its better to subtract one completely before moving on to the other. We have two methods to use we completely subtract a, then try to subtract b or completely subtract b, then subtract a. We simulate the answers we get from these two scenarios and then return their minimum.
Problem 09
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll a, b; cin >> a >> b; if ((b-a) >= 10) cout << 0 << "\n"; else { ll ans = 1; for (ll i = a+1; i <= b; i++) { ans *= i; ans %= 10; } cout << ans << "\n"; } }
Notice that if there is a multiple of 10 between a and b. Then 10 is included in the final product which means the last digit will be 0. To see if 10 is included in the final product we can just check if (b-a) >= 10, if this is true output 0. Now notice that if (b-a) < 10, we can just loop through from a+1 to b and multiply and modulo by 10 to find the final product and output that.
Problem 10
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int t; cin >> t; while (t--) { ll x, y; cin >> x >> y; if (x == 1) { if (y == 1) cout << "YES\n"; else cout << "NO\n"; } else if (x == 2 || x == 3) { if (y == 1 || y == 2 || y == 3) cout << "YES\n"; else cout << "NO\n"; } else cout << "YES\n"; } }
If x == 1, realize that you can't perform either of the spells, so the only possible way to output YES is if y == 1, else output NO. Now for x == 2 or x == 3, you can make x either 3 or 2 or 1, but you can't make any moves after this point, so if y == 1 or y == 2 or y == 3 output YES else output NO. Now realize that for any x >= 4, you can obtain any number (test this out in your head), so the output is always YES. These are all the cases that we have to go through for this problem, so now we have officially solved it :).


REVIEW: PLAYING BY HEART
Starring: (in Alphabetical order) Gillian Anderson, Ellen Burstyn, Sean Connery, Anthony Edwards, Angelina Jolie, Jay Mohr, Ryan Phillippe, Dennis Quaid, Gena Rowlands, Jon Stewart, Madeleine Stowe
Written and Directed by: Willard Carroll
Review by: Joy Wyse, the SILVER Screen Critic
Playing by Heart has something for everyone. There's a love story for just about every age of viewer. Unfortunately, that's also its main drawback. If you identify with one couple, you'll probably be bored or upset by another one of the stories. It does show how much the problems facing lovers have changed. The oldest couple, played by Sean Connery and Gena Rowlands, fell in love and grew older without the issues facing the younger lovers. Their main concern centers on a possible affair that he may have had numerous years before. Most of the younger couples must face AIDS or homosexuality, all too prevalent in today's society.
Remarks have been made that the dialogue wasn't real; that no one really speaks that way. Strange because Connery and Rowlands spoke just like my husband and I speak. In fact, there is at least one `joke' that we created over 40 years ago and have used often every since. It is when Sean says that "he never knew what true happiness was until he got married….then it was too late!'
As to the younger couples, I couldn't help wonder what some of them saw in each other. Angelina Jolie (Jon Voight's daughter) stands out as a free spirited, fun-loving club-goer. Her initial attraction to Ryan Phillippe seems odd.  As she got to know him, he does become more loveable.
The most desirable of the guys has to be Jon Stewart. Again, I wonder what he saw in Gillian Anderson enough to endure the pangs of the courting process. Randy Quaid's role is bizarre and seems a strange choice for him. Anthony Edwards' scenes are mostly in bed or the bedroom, and he isn't all that likeable. There's not enough nudity or sex scenes to disturb anyone.
A different type of love story is the one between Ellen Burstyn and Jay Mohr as a mother and son. It is filled with memorable moments. The `game' that they play might be beneficial to a lot of people who are hiding deep dark secrets in their lives.
It's not a great movie. It's not a bad movie. I wouldn't mind seeing it again, but I'll probably wait until it's on free TV. I give it a B-.
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


| home |
|
/ |
home.html |
|
| knowledge |
knowledge |
knowledge |
knowledge.html |
|
| X4300 |
knowledge |
X4300.html |
|
| K4300 |
knowledge |
K4300.html |
|
| X7600 |
knowledge |
X7600.html |
|
| K7600 |
knowledge |
K7600.html |
|
| smart UX center |
knowledge |
Smart-UX-Center.html |
|
| Business Core Printing Solutions |
knowledge |
Business-Core-Printing-Solutions.html |
|
| PrinterOn Hosted |
knowledge |
PrinterOn-Hosted.html |
|
| Genuine Samsung Toner |
knowledge |
Genuine-Samsung-Toner.html |
|
| Samsung Smart Service |
knowledge |
Samsung-Smart-Service.html |
|
| marketing-support |
download center |
marketing-support |
download.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
K4350LX.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
K4300LX.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
K4250RX.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
X4300LX.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
X4250LX.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
X4220RX.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
K7600LX.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
K7600GX.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
K7500LX.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
K7500GX.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
K7400LX.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
K7400GX.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
X7600LX.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
X7600GX.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
X7500LX.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
X7500GX.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
X7400LX.html |
|
| marketing-support |
Copier Configurator |
marketing-support |
X7400GX.html |
|


A passionate web aplications developer from Bangladesh. Bringing beautiful designs to life with code makes me happy!.
I just started working fulltime for Cardinity. They are a payment gateway company from Europe.
I have been freelancing on upWork since 2010. Worked with java did some illustration with inkscape. Finally started fullime freelancing as a PHP developer in 2013.
Until recently I led the software development team for an uprising company named LumexTech. I was also responsible for PHP training provided by the company
I also worked full time as chief engineer at Byteship for 2 years. I was focused on implementing the companies ideas and enriching them. My focused approach and dedication towards my work has served me and my clients well through out the years.

I follow a number of sci-fi and fantasy genre movies and cartoons, I love animation movies, and I spend a large amount of my free time exploring the advancements in latest technolgy.
As a Beta Thalassemia Major patient from a country where treatment is difficult. I try to do my part in helping other Thalassemia patients.
I try to spread awareness about the disease and its prevention wherever I can


|| .::News PHP Shell Injection::. ||
Url to index.php:
Server Path to Shell:
Full server path to a writable file which will contain the Php Shell


Toggle navigation
My Photo Album
Home
Categories
Filter by location
{% for location in locations %}
{{location.name}}
{% endfor %}


 Hanif (8th sem)Iram (6th sem)Saniya (4th sem)
Date : 10/4/18
Venue : A301
Faculty Co-ordinators : Prof. Poornima
Student Co-ordinators : Deekshitha (8th sem)Deekshitha (6th sem)Abida (4th sem)
Faculty Co-ordinators : Prof. Nithin salian
Student Co-ordinators : Sinan (8th sem)
Venue : Main Stage
Faculty Co-ordinators : Prof. Prashanth Kumar
Student Co-ordinators : Safrina (8th sem)Rafeedha (6th sem)Rabiya (4th sem)
Venue : CS LAB
Faculty Co-ordinators : Prof. Abdul Khader
Student Co-ordinators : Shawoor (8th sem)Ziyan (6th sem)Faizal (4th sem)
Time : 10:45 AM
Faculty Co-ordinators : Prof. Sandeep
Student Co-ordinators : Swadiqa (8th sem)Rizwana (6th sem)
Faculty Co-ordinators : Prof. Sudesh
Student Co-ordinators : Aysha M Y (8th sem)Shareeh (6th sem)
Faculty Co-ordinators : Prof. Najma
Student Co-ordinators : Kausar (8th sem)Irshad (6th sem)Nabeeha (4th sem)
Time : 11:15 AM
Time : 11:45 AM
Faculty Co-ordinators : Prof. Harshith
Student Co-ordinators : Safwan (8th sem)Poornesh (6th sem)
Time : 12:15 PM
Venue : A302
Faculty Co-ordinators : Prof. Shashi Kumar G
Student Co-ordinators : Mubeen (8th sem)
Time : 12:30 PM
Faculty Co-ordinators : Prof. Akshatha
Student Co-ordinators : Shabam (8th sem)Wasim (6th sem)
Time : 1:00 PM
Faculty Co-ordinators : Prof. Imran MukhashiProf. Muhammed Kafil
Student Co-ordinators : Hakeem (8th sem)
Faculty Co-ordinators : Prof. Vasanth Kumar
Student Co-ordinators : Faizan (8th sem)
Venue : B203
Faculty Co-ordinators : Prof. SunithaProf. Najma
Student Co-ordinators : Ismath Jahan (8th sem)Ranima (6th sem)Safnaz (6th sem)
Venue : Main stage
Faculty Co-ordinators : Prof. ArpanaProf. Ankitha
Student Co-ordinators : Muhsina (8th sem)Thuhara (6th sem)Madeeha (4th sem)
Faculty Co-ordinators : Prof. Jalaluddeen
Student Co-ordinators : Thasrifa (8th sem)Famidha (6th sem)Naziya (4th sem)


- data - Variable in class com.smarthome.emulator.design.JRowEditorModel
-
row editors
- dataset - Variable in class com.smarthome.emulator.simulations.PerformanceSimulation
-
chart dataset
- deactivateSensor() - Method in class com.smarthome.emulator.simulations.basis.Adapter
-
Decrease number of active sensors
- DECIMAL_NUMBER - Static variable in class com.smarthome.emulator.design.JNumberTextField
-
- DECIMAL_SEPARATOR - Static variable in class com.smarthome.emulator.design.JNumberTextField
-
possible chars
- decrementSensorsCount() - Static method in class com.smarthome.emulator.simulations.DetailedSimulation
-
Decrease number of sensors
- decrementSensorsCount() - Static method in class com.smarthome.emulator.simulations.PerformanceSimulation
-
Decrease number of sensors
- DEFAULT_ADDRESS - Static variable in class com.smarthome.emulator.simulations.forms.AddNewAdapter
-
default address
- DEFAULT_ID - Static variable in class com.smarthome.emulator.simulations.forms.AddNewAdapter
-
default adapter id
- DEFAULT_NAME - Static variable in class com.smarthome.emulator.simulations.forms.AddNewAdapter
-
default adapter name
- DEFAULT_PORT - Static variable in class com.smarthome.emulator.simulations.forms.AddNewAdapter
-
default port
- DEFAULT_PROTOCOL - Static variable in class com.smarthome.emulator.simulations.forms.AddNewAdapter
-
default protocol
- defaultProperties - Variable in class com.smarthome.emulator.simulations.basis.Sensor
-
information about sensor used for creating sensor
- defaultProperties - Variable in class com.smarthome.emulator.simulations.panels.SensorPanel
-
properties set holding information about sensor
- delete() - Method in class com.smarthome.emulator.simulations.basis.Adapter
-
Delete adapter and all it's components
- delete() - Method in class com.smarthome.emulator.simulations.basis.Logger
-
Removes text area created in constructor from JScrollPane
's view ports.
- delete() - Method in class com.smarthome.emulator.simulations.panels.AdapterDetailsPanel
-
Sets data model to default state with 0
rows
- delete() - Method in class com.smarthome.emulator.simulations.panels.AdapterPanel
-
Removes all visual adapter's visual components from simulation, removes all
instances of classes needed to run adapter's emulation
- delete() - Method in class com.smarthome.emulator.simulations.panels.SensorPanel
-
Removes all visual components for displaying sensor panel
- delete() - Method in class com.smarthome.emulator.simulations.panels.ServerPanel
-
Sets data model to default state with 0
rows
- deleteAdapters() - Method in class com.smarthome.emulator.simulations.PerformanceSimulation
-
Clears adapters list
- deleteBtn - Variable in class com.smarthome.emulator.simulations.panels.SensorPanel
-
- deleteCurrentAdapter() - Method in class com.smarthome.emulator.simulations.DetailedSimulation
-
Removes all visual components and data of currently active adapter panel
- deleteMessagesFromSensor(Sensor) - Method in class com.smarthome.emulator.simulations.basis.Adapter
-
When sensor has unsent messages, removes them.
- deleteSensor(int) - Method in class com.smarthome.emulator.simulations.basis.Adapter
-
Deletes sensor of given id.
- deSelectColor - Variable in class com.smarthome.emulator.design.JCustomTabbedPaneUI
-
- DetailedSimulation - Class in com.smarthome.emulator.simulations
-
Creates environment for server detailed testing.
- DetailedSimulation() - Constructor for class com.smarthome.emulator.simulations.DetailedSimulation
-
Creates and initializes all visual components needed to perform detailed simulation
- detailedSimulationLabel - Variable in class com.smarthome.emulator.simulations.DetailedSimulation
-
- detailsModel - Variable in class com.smarthome.emulator.simulations.panels.AdapterDetailsPanel
-
newly created model for table
- detailsPanel - Variable in class com.smarthome.emulator.simulations.panels.AdapterPanel
-
detaiels table assign for adapter
- detailsTable - Variable in class com.smarthome.emulator.simulations.panels.AdapterDetailsPanel
-
table for new table model
- dev - Variable in class com.smarthome.emulator.simulations.basis.Value
-
deviation for generating value
- disableAdapter() - Method in class com.smarthome.emulator.simulations.panels.AdapterPanel
-
Sets adapter to inactive state
- disableAdapterBtn - Variable in class com.smarthome.emulator.simulations.panels.AdapterPanel
-
- disableConfigurationChange() - Method in class com.smarthome.emulator.simulations.PerformanceSimulation
-
Disables all configuration fields
- disconnect() - Method in class com.smarthome.emulator.simulations.basis.Sensor
-
- disconnectBtn - Variable in class com.smarthome.emulator.simulations.DetailedSimulation
-
- disconnectBtn - Variable in class com.smarthome.emulator.simulations.panels.SensorPanel
-
- disconnectBtn - Variable in class com.smarthome.emulator.simulations.PerformanceSimulation
-
- document - Variable in class com.smarthome.emulator.simulations.utilities.StyledDocumentPrinter
-
Document to print.
- dumpResponses - Variable in class com.smarthome.emulator.simulations.basis.Logger
-
indicator of dumping saved responses
- dumpResponses() - Method in class com.smarthome.emulator.simulations.basis.Logger
-


The Research Revealed newsletter brings you behind the scenes so you can make the most of the vast research operations support network at BU. Please submit your newsletter ideas, and visit the Research Support website for more information.
The Global Development Policy Center and BU Federal Relations hosted a panel discussion on April 13 featuring Jin Liqun, president of the Asian Infrastructure Investment Bank, and José Antonio Ocampo, co-chair of the Central Bank of Colombia. Titled "Brighter Prospects or Rose Colored Glasses? New Views on the Global Economy," the event coincided with meetings of the World Bank and the International Monetary Fund.
Before taking audience questions, Siegel described his research into state firearm laws and their effectiveness. Watch the video.
STAT is seeking nominations for its annual recognition of postdocs, medical residents, interns, medical fellows, and industry scientists. Qualified nominees have finished their terminal degrees and are in their first job/training program. Deadline for nominations is June 30.
The BU Nanotechnology Innovation Center is seeking proposals for projects focused on nanotechnology, nanobiotechnology, nanofabrication, etc. The amount of available funding ranges from $50-$100k per project and can be used for student/postdoctoral support, supplies, and equipment. Application deadline is June 1.
Dr. David Henderson, chair of psychiatry at the School of Medicine, won a $30,000 seed grant from BU Global Programs and BU Foundation–India for research that will study pathways to homelessness among people with serious mental illness in India and Boston.
Beta Bionics, a company founded and led by BU Professor of Biomedical Engineering Ed Damiano, received approval from the Food and Drug Administration to begin recruiting participants for a home-use study of its iLet bionic pancreas system. The bionic pancreas is driven by mathematical dosing algorithms developed in Damiano's BU lab.
The Charles River Campus IRB has updated its policy on recruitment and advertising to offer more flexibility when recruiting BU student and employee research participants.
New IACUC software that will bring protocol management at both the Medical and Charles River Campuses into one system is scheduled for a June launch.
Research Information Management System (RIMS) will undergo an upgrade June 4.
Radiation Safety has begun the process of migrating radioisotope use (RAM) permits to BioRAFT.
In anticipation of the high volume of proposal submissions for the fast approaching NIH summer deadlines, Sponsored Programs is asking that researchers notify the office of their intent to submit a proposal and adhere to the University’s Proposal Submission Policy.
Researchers planning to host summer students should ensure that they complete lab safety training and secure medical clearance from the Research Occupational Health Program.