Do non-proc-shots fired by elemental weapons still carry the weapon's element?

Question: TL:DR: If my slag weapon procs its slag effect, should I switch to another non-slag weapon or will my majority of non-proc-bullets be sufficient to make use of the slag.
If a weapon is of the Slag element, does this make every bullet it fires of said element, or just the shots that proc the effect?
In field concept, say I'm using this here rifle:

If I shoot a critter with the above weapon, and I shoot a burst of say 10 rounds, (ignore the mag size you see above) assuming round #4 procs the slag effect and is the only round to proc the effect, will the other rounds fired after round #4 do extra damage due to their not being slag, or will they count as alternate sources of slag despite not proc-ing the weapons effect.
Comment: You can probably simplify your title to "Do elemental weapons always fire elemental shots/ammo?" Bullet is an exclusive class of projectile (and I'm not sure you mean to be exclusive), "it's" is grammatically incorrect, and you don't define "charged with it's parent element". Granted, my rephrasing may still beg definition of "elemental shots/ammo".
Comment: At the time of this questions inception, I was unaware of the firing range area's availability in the game for repeated use. Forgive the question's 'lack of research'
Comment: Ceci n'est pas un fusil! X) Also, if you did do the research, there probably would have been less of a question.
Comment: Which would have been bad, because your question has value, so diminishing the question would have diminished Arqade. In this ironic way, I'm asserting that your lack of research contributed to Arqade.
Answer:

If a weapon is of the Slag element, does this make every bullet it fires of said element, or just the shots that proc the effect?

Judging from the damage-numbers colour, if a weapon is of the Slag element, this makes every bullet that it fires of said element. The same goes for the other elements, except for explosive, which always procs.

If I shoot a critter with the above weapon, and I shoot a burst of say 10 rounds, (ignore the mag size you see above) assuming round #4 procs the slag effect and is the only round to proc the effect, will the other rounds fired after round #4 do extra damage due to their not being slag, or will they count as alternate sources of slag despite not proc-ing the weapons effect?

If you shoot a critter with your illegitimate weapon, and you shoot a burst of say 10 rounds, (ignoring the mag size I see above) assuming round #4 procs the slag effect and is the only round to proc the effect, the other rounds fired after round #4 will not do extra damage due to their not being slag. I'm not sure what you mean by "count as alternate sources of slag".
Exception:

In Ultimate Vault Hunter Mode, [...] [s]lag on slag damage is also increased by 50%.

http://borderlands.wikia.com/wiki/Slag#Effectiveness
"By" is probably supposed to be "to", because 0% * 150% is still 0%.

TL:DR: If my slag weapon procs its slag effect, should I switch to another non-slag weapon or will my majority of non-proc-bullets be sufficient to make use of the slag.

If your slag weapon procs its slag effect, you should switch to another non-slag weapon. Your majority of non-proc-bullets will not be sufficient to make use of the slag.

Thanks to galacticninja for the extra information. ;)
Answer: Elemental weapons deal damage on hit and also have a chance of triggering a status effect per hit (this is a damage-over-time effect for non-slag weapons). An exception are Explosive weapons, which don't have DoT and always trigger their Explosive splash damage - more info here).
A slag weapon like in your example will always deal slag damage on hit, and will also have a chance to trigger the slag status effect on the enemy (or "slag" an enemy) per hit.
In Ultimate Vault Hunter Mode (UVHM), slag on slag will deal a 50% damage bonus. In your example, if "round #4 procs the slag effect and is the only round to proc the effect", rounds 5-10 will gain a 50% damage bonus while the enemy is still under the slag status effect. This makes slag weapons more useful in UVHM. However, this is not the case in non-UVHM playthroughs (slag on slag will deal no bonus damage).
It is preferable to switch to any non-slag weapon once your slag weapon has slagged (procs the slag effect on) an enemy, as the bonus damages for hitting a slagged enemy with non-slag damage are 100% for non-UVHM, and 200% for UVHM.
Comment: (1) If something "always procs", 'proc' is not an appropriate word (programmed RANDOM occurrence). (2) Ooh yeah, explosive. (3) 'Didn't know about the different playthrough stuff.
Comment: @NiteCyper I thought 'proc' was short for 'process'. Anyway, I removed that phrase to avoid misunderstanding.
Comment: Nice, although I was teasing. The etymology of 'proc' is not well-established, so my parenthetical expansion may not be correct. The WoWWiki states, "Proc was originally short for "spec_proc" (spec_proc is short for "special process")".


LoopBack WARNING: id property cannot be changed from to

Question: I'm using LoopBack with MongoDB as my datasource and have a simple model defined as:
{
    "name": "restaurant",
    "plural": "restaurants",
    "base": "PersistedModel",
    "idInjection": false,
    "options": {
        "validateUpsert": true
    },
    "properties": {
        "name": {
            "type": "string",
            "required": true
        },
        "address": {
            "type": "string",
            "required": true
        }
    },
    "validations": [],
    "relations": {},
    "acls": [],
    "methods": {}
}

I have an auto-migrate script in my /server/boot which creates two simple test data.
After that when I try to update one of those entries with PUT request using LoopBack's API explorer I get a warning
WARNING: id property cannot be changed from ... to ... for model:restaurant in 'before save' operation hook
WARNING: id property cannot be changed from ... to ... for model:restaurant in 'loaded' operation hook
and redundant id field (same as mongo's _id field) is created in DB.
I was able to prevent the creation of the redundant id field by setting idInjection to false and defining another property in model definition as:
"_id": {
  "id": true,
  "generated": true
}

However, I still get the warning after doing a PUT request from LoopBack's API explorer.
How should the mongo's _id field be defined in model definition properly?
Thanks.
Answer: You could hide the id by adding a "hidden" field to your model JSON. And add "id" to the array to be hidden.
{
"name": "restaurant",
"plural": "restaurants",
"hidden": [
    "id"
 ],
"base": "PersistedModel",
"idInjection": false,
"options": {
    "validateUpsert": true
},
"properties": {
    "name": {
        "type": "string",
        "required": true
    },
    "address": {
        "type": "string",
        "required": true
    }
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}

}


Pivot in BigQuery

Question: When i use pivot function in BigQuery, something as snippet below
CALL fhoffa.x.pivot(
  'bigquery-public-data.ghcn_d.ghcnd_2019' # source table
  , 'fh-bigquery.temp.test_pivotted' # destination table
  , ['id', 'date'] # row_ids
  , 'element' # pivot_col_name
  , 'value' # pivot_col_value
  , 30 # max_columns
  , 'AVG' # aggregation
  , 'LIMIT 10' # optional_limit
);

The pivoted column name has a prefix e_

id
date
e_PRCP
e_TMIN
e_TMAX
e_SNOW

1
27-01-2021
1
2
5
8

2
28-01-2021
3
5
9
3

3
29-01-2021
5
7
4
1

Is there any way to get rid of this e_ prefix?
Answer: Update 5/12/2021
Bigquery now has native PIVOT support, please check documentation here.

Here's full definition of the procedure, you can create one in your own dataset and modify as you see fit. You can see the e_ was added inside the first EXECUTE IMMEDIATE.
CREATE OR REPLACE PROCEDURE `fhoffa.x.pivot`(table_name STRING, destination_table STRING, row_ids ARRAY<STRING>, pivot_col_name STRING, pivot_col_value STRING, max_columns INT64, aggregation STRING, optional_limit STRING)
BEGIN
  DECLARE pivotter STRING;
EXECUTE IMMEDIATE (
    "SELECT STRING_AGG(' "||aggregation
    ||"""(IF('||@pivot_col_name||'="'||x.value||'", '||@pivot_col_value||', null)) e_'||fhoffa.x.normalize_col_name(x.value))
   FROM UNNEST((
       SELECT APPROX_TOP_COUNT("""||pivot_col_name||", @max_columns) FROM `"||table_name||"`)) x"
  ) INTO pivotter
  USING pivot_col_name AS pivot_col_name, pivot_col_value AS pivot_col_value, max_columns AS max_columns;
EXECUTE IMMEDIATE (
   'CREATE OR REPLACE TABLE `'||destination_table
   ||'` AS SELECT '
   ||(SELECT STRING_AGG(x) FROM UNNEST(row_ids) x)
   ||', '||pivotter
   ||' FROM `'||table_name||'` GROUP BY '
   || (SELECT STRING_AGG(''||(i+1)) FROM UNNEST(row_ids) WITH OFFSET i)||' ORDER BY '
   || (SELECT STRING_AGG(''||(i+1)) FROM UNNEST(row_ids) WITH OFFSET i)
   ||' '||optional_limit
  );
END;

Comment: can add a prefix  as parameter like ="e_"  and can add a COALESCE for case sum o count ?

Pivot in BigQuery


Get right zoom area for CLPlacemark

Question: I'm using MKLocalSearchto search for certain places like cities or streets in cities to shown them on an MKMapView
I show the placemark like this
let loc = placemark.location! //CLLocation of CLPlacemark
var mapRegion = MKCoordinateRegion()
mapRegion.center.longitude = loc.coordinate.longitude
mapRegion.center.latitude = loc.coordinate.latitude
mapRegion.span.latitudeDelta = 0.03 // I choose 0.03 by trying
mapRegion.span.longitudeDelta = 0.03
mapView.setRegion(mapRegion, animated: true)

This works good when the place marks are cities as it shows a larger area at a reasonable zoom level. But when I want to show a specific street (which is the CLPlacemarks Location) in the city it is to far away.
Now I'm looking for a way to calculate the right span according to the "detail" of your CLPlacemark (Note that you don't know the type of the CLPlacemark upfront)
Is there a way to do this?
Comment: Have you checked this question https://stackoverflow.com/questions/9164920/updating-mkmapview-to-clplacemark-returned-from-clgeocoder ?
Comment: For me it is not clear what you want to do. Do you want to know why placemark for specific street in the city it is to far away? Or. How to calculate span according to the "detail" of the placemark?
Comment: @Ramis I want to calculate the detail of the placemark
Comment: Code which you posted for me shown in the centered of the map with span. I can not reproduce or I do not understand where is problem.
Comment: I want the right span for the detail of the placemark. If the placemark is a certain street in the city then I want to zoom closer as if it is just the city
Answer: Let me explain it fully.
First of all, you need to retrieve proper CLPlacemark objects.
If you would like to search for CLPlacemarks at some specific CLLocationCoordinate2D, then use this approach:
CLLocationCoordinate2D theCoordinate = CLLocationCoordinate2DMake(37.382640, -122.151780);
CLGeocoder *theGeocoder = [CLGeocoder new];
[theGeocoder reverseGeocodeLocation:[[CLLocation alloc] initWithLatitude:theCoordinate.latitude longitude:theCoordinate.longitude]
                  completionHandler:^(NSArray *placemarks, NSError *error)
 {
      CLPlacemark *thePlacemark = placemarks.firstObject;
 }];

Now that you got some proper CLPlacemark, you can use its .region property. Please note that documentation says that .region is CLRegion, but actually it is CLCircularRegion.
CLCircularRegion *theRegion = (id)thePlacemark.region;

However, MKMapView doesn't work with CLCircularRegion, while it works with MKMapRect. You can use the solution below:
How to convert CLCircularRegion to MKMapRect
MKMapRect theMapRect = [self rectForCLRegion:theRegion];

Now that we got our MKMapRect, we can pass it to our MKMapView like so:
[theMapView setVisibleMapRect:[theMapView mapRectThatFits:theMapRect]
                     animated:YES];

Or, if you would like to adjust the screen offsets a bit further, you can use:
[theMapView setVisibleMapRect:[theMapView mapRectThatFits:theMapRect]
                  edgePadding:UIEdgeInsetsMake(50, 50, 50, 50)
                     animated:YES];

Conclusion:
Code seems to work fine and adjusts the span automatically, using information provided via CLCircularRegion .radius property.
The picture below shows the result if you pass (37.382640, -122.151780)

To compare, this is the picture if you pass (37.382640, -12.151780)
Comment: This is the perfect answer - you totally deserve the reward! Thanks for taking the time - on whatever I looked or searched for I couldn't figure it out

Get right zoom area for CLPlacemark


Advice on over range microwave venting duct

Question: We are replacing an old hood with an over range microwave where the circular vent hole is dead center in the cabinet above. The microwave we just purchased has the designated hole towards the back and is shaped like a rectangle. The duct is also not flexible.
2 things... Would we have to change out the entire duct for a flexible duct?
How would I go about patching the circular hole to prepare for the rectangular hole for the new vent?
Answer: No one ever has to use flex duct. You simply need an adjustable elbow (or possibly two) to act as an offset, and a 3x10 boot (or whatever your unit calls for) to terminate.
How you patch the cabinet is at your discretion. If you position the duct boot properly it's not required, but I imagine you'd want to clean up the cabinet floor for appearance and convenience.
Comment: You're very welcome. "Thanks" comments aren't necessary, though.


MySQL Server 5.7 not installing correctly

Question: I am receiving the following message when trying to install MySQL Server 5.7 on a server after updating to Ubuntu 16.04.1. Doe anyone know how I can correct this?
Renaming removed key_buffer and myisam-recover options (if present)
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Thu 2018-05-17 17:03:09 UTC; 7ms ago
  Process: 7392 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 7391 ExecStart=/usr/sbin/mysqld (code=exited, status=2)
  Process: 7382 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 7391 (code=exited, status=2)

May 17 17:03:09 systemd[1]: Failed to start MySQL Community Server.
May 17 17:03:09 systemd[1]: mysql.service: Unit entered failed state.
May 17 17:03:09 systemd[1]: mysql.service: Failed with result 'exit-code'.
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

journalctl -xe shows this:
May 17 17:21:21 mysqld[10831]: It is possible that mysqld could use up to
May 17 17:21:21 mysqld[10831]: key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68195 K  bytes of memory
May 17 17:21:21 mysqld[10831]: Hope that's ok; if not, decrease some variables in the equation.
May 17 17:21:21 mysqld[10831]: Thread pointer: 0x0
May 17 17:21:21 mysqld[10831]: Attempting backtrace. You can use the following information to find out
May 17 17:21:21 mysqld[10831]: where mysqld died. If you see no messages after this, something went
May 17 17:21:21 mysqld[10831]: terribly wrong...
May 17 17:21:21 mysqld[10831]: stack_bottom = 0 thread_stack 0x40000
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(my_print_stacktrace+0x3b)[0xe907ab]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(handle_fatal_signal+0x489)[0x789b49]
May 17 17:21:21 mysqld[10831]: /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7ff8de0a8390]
May 17 17:21:21 mysqld[10831]: /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7ff8dd461428]
May 17 17:21:21 mysqld[10831]: /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7ff8dd46302a]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0x75f3e0]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_ZN2ib5fatalD1Ev+0x145)[0x1128eb5]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z20buf_page_io_completeP10buf_page_tb+0x3b4)[0x1167514]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z13buf_read_pageRK9page_id_tRK11page_size_t+0x4e2)[0x1199412]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z16buf_page_get_genRK9page_id_tRK11page_size_tmP11buf_block_tmPKcmP5mtr_tb+0x4f1)[0x1165b71]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0xfc2696]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z29ibuf_merge_or_delete_for_pageP11buf_block_tRK9page_id_tPK11page_size_tm+0x7e0)[0xfcc0b0]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z20buf_page_io_completeP10buf_page_tb+0x460)[0x11675c0]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z13buf_read_pageRK9page_id_tRK11page_size_t+0x4e2)[0x1199412]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z16buf_page_get_genRK9page_id_tRK11page_size_tmP11buf_block_tmPKcmP5mtr_tb+0x4f1)[0x1165b71]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0x11eac06]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z14fseg_free_stepPhbP5mtr_t+0x18d)[0x11ef85d]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0x113a16e]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z18btr_free_if_existsRK9page_id_tRK11page_size_tmP5mtr_t+0x8a)[0x113a44a]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z20dict_drop_index_treePhP10btr_pcur_tP5mtr_t+0x131)[0x119e221]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0x10b0982]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z7row_updP10upd_node_tP9que_thr_t+0x6b)[0x10b243b]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z12row_upd_stepP9que_thr_t+0x8b)[0x10b26eb]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z15que_run_threadsP9que_thr_t+0x7e5)[0x103a065]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z12que_eval_sqlP11pars_info_tPKcmP5trx_t+0x94)[0x103ac04]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z24row_drop_table_for_mysqlPKcP5trx_tbbP12dict_table_t+0xa34)[0x107bbe4]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0x1211ab8]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0x1213f3f]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z24fts_drop_orphaned_tablesv+0x6ce)[0x121472e]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z29recv_recovery_rollback_activev+0x33)[0xfee763]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z34innobase_start_or_create_for_mysqlv+0x5195)[0x10d1eb5]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0xf91f5f]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z24ha_initialize_handlertonP13st_plugin_int+0x51)[0x7d7291]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0xc706c5]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z40plugin_register_builtin_and_init_core_sePiPPc+0x318)[0xc73ae8]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0x781f5f]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z11mysqld_mainiPPc+0xa49)[0x783949]
May 17 17:21:21 mysqld[10831]: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7ff8dd44c830]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_start+0x29)[0x779de9]
May 17 17:21:21 mysqld[10831]: The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
May 17 17:21:21 mysqld[10831]: information that should help you find out what is causing the crash.
May 17 17:21:21 systemd[1]: mysql.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
lines 986-1035/1035 (END)
May 17 17:21:21 mysqld[10831]: It is possible that mysqld could use up to
May 17 17:21:21 mysqld[10831]: key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68195 K  bytes of memory
May 17 17:21:21 mysqld[10831]: Hope that's ok; if not, decrease some variables in the equation.
May 17 17:21:21 mysqld[10831]: Thread pointer: 0x0
May 17 17:21:21 mysqld[10831]: Attempting backtrace. You can use the following information to find out
May 17 17:21:21 mysqld[10831]: where mysqld died. If you see no messages after this, something went
May 17 17:21:21 mysqld[10831]: terribly wrong...
May 17 17:21:21 mysqld[10831]: stack_bottom = 0 thread_stack 0x40000
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(my_print_stacktrace+0x3b)[0xe907ab]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(handle_fatal_signal+0x489)[0x789b49]
May 17 17:21:21 mysqld[10831]: /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7ff8de0a8390]
May 17 17:21:21 mysqld[10831]: /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7ff8dd461428]
May 17 17:21:21 mysqld[10831]: /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7ff8dd46302a]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0x75f3e0]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_ZN2ib5fatalD1Ev+0x145)[0x1128eb5]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z20buf_page_io_completeP10buf_page_tb+0x3b4)[0x1167514]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z13buf_read_pageRK9page_id_tRK11page_size_t+0x4e2)[0x1199412]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z16buf_page_get_genRK9page_id_tRK11page_size_tmP11buf_block_tmPKcmP5mtr_tb+0x4f1)[0x1165b71]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0xfc2696]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z29ibuf_merge_or_delete_for_pageP11buf_block_tRK9page_id_tPK11page_size_tm+0x7e0)[0xfcc0b0]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z20buf_page_io_completeP10buf_page_tb+0x460)[0x11675c0]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z13buf_read_pageRK9page_id_tRK11page_size_t+0x4e2)[0x1199412]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z16buf_page_get_genRK9page_id_tRK11page_size_tmP11buf_block_tmPKcmP5mtr_tb+0x4f1)[0x1165b71]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0x11eac06]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z14fseg_free_stepPhbP5mtr_t+0x18d)[0x11ef85d]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0x113a16e]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z18btr_free_if_existsRK9page_id_tRK11page_size_tmP5mtr_t+0x8a)[0x113a44a]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z20dict_drop_index_treePhP10btr_pcur_tP5mtr_t+0x131)[0x119e221]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0x10b0982]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z7row_updP10upd_node_tP9que_thr_t+0x6b)[0x10b243b]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z12row_upd_stepP9que_thr_t+0x8b)[0x10b26eb]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z15que_run_threadsP9que_thr_t+0x7e5)[0x103a065]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z12que_eval_sqlP11pars_info_tPKcmP5trx_t+0x94)[0x103ac04]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z24row_drop_table_for_mysqlPKcP5trx_tbbP12dict_table_t+0xa34)[0x107bbe4]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0x1211ab8]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0x1213f3f]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z24fts_drop_orphaned_tablesv+0x6ce)[0x121472e]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z29recv_recovery_rollback_activev+0x33)[0xfee763]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z34innobase_start_or_create_for_mysqlv+0x5195)[0x10d1eb5]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0xf91f5f]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z24ha_initialize_handlertonP13st_plugin_int+0x51)[0x7d7291]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0xc706c5]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z40plugin_register_builtin_and_init_core_sePiPPc+0x318)[0xc73ae8]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld[0x781f5f]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_Z11mysqld_mainiPPc+0xa49)[0x783949]
May 17 17:21:21 mysqld[10831]: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7ff8dd44c830]
May 17 17:21:21 mysqld[10831]: /usr/sbin/mysqld(_start+0x29)[0x779de9]
May 17 17:21:21 mysqld[10831]: The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
May 17 17:21:21 mysqld[10831]: information that should help you find out what is causing the crash.
May 17 17:21:21 systemd[1]: mysql.service: Main process exited, code=exited, status=2/INVALIDARGUMENT

systemctl status mysql.service shows this:
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (start-post) (Result: exit-code) since Thu 2018-05-17 17:25:21 UTC; 26s ago
  Process: 11554 ExecStart=/usr/sbin/mysqld (code=exited, status=2)
  Process: 11545 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 11554 (code=exited, status=2);         : 11555 (mysql-systemd-s)
    Tasks: 2
   Memory: 312.0K
      CPU: 2.152s
   CGroup: /system.slice/mysql.service
           └─control
             ├─11555 /bin/bash /usr/share/mysql/mysql-systemd-start post
             └─11625 sleep 1

May 17 17:25:23 mysqld[11554]: /usr/sbin/mysqld(_Z24ha_initialize_handlertonP13st_plugin_int+0x51)[0x7d7291]
May 17 17:25:23 mysqld[11554]: /usr/sbin/mysqld[0xc706c5]
May 17 17:25:23 mysqld[11554]: /usr/sbin/mysqld(_Z40plugin_register_builtin_and_init_core_sePiPPc+0x318)[0xc73ae8]
May 17 17:25:23 mysqld[11554]: /usr/sbin/mysqld[0x781f5f]
May 17 17:25:23 mysqld[11554]: /usr/sbin/mysqld(_Z11mysqld_mainiPPc+0xa49)[0x783949]
May 17 17:25:23 mysqld[11554]: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f30c2384830]
May 17 17:25:23 mysqld[11554]: /usr/sbin/mysqld(_start+0x29)[0x779de9]
May 17 17:25:23 mysqld[11554]: The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
May 17 17:25:23 mysqld[11554]: information that should help you find out what is causing the crash.
May 17 17:25:23 systemd[1]: mysql.service: Main process exited, code=exited, status=2/INVALIDARGUMENT

Answer: After googling I did find the answer, the solution was to first remove all MySQL files from /var/lib/ and /etc/, then do a clean install. Full solution at the link.
https://askubuntu.com/a/1024310/831153


Designing price list for suppliers

Question: I would like to provide a list of prices and discounts for our products for internal and potentially external use. My original idea is to use an Excel spreadsheet with list of items, prices and discounts and a separate tab for each customer. Then I would have a front sheet whereby the user could search for a product to bring up prices, discounts. However this would only be used for internal use.
Another thought is some sort of online table using a mix of XML and DataTables jQuery Plugin which would make it very easy to bring up the latest items based on customer, price etc. The issue with this is it would take more time to set up this system and if we wanted it for external use it would require a login screen so suppliers can only see their own lists.
I'm looking for any tips or advice on the best way to accomplish this task with main constraints being time and setup. I can set up code it all myself.
Answer: Excel spreadsheets (in fact, any file-based solution) are very limited (you find the file blocked when you want to modify something, lots of people can make changes without warnings, you have issues with remote locations due to bandwith/latency).
You can create one as an internal prototype so you get feedback about fields needed and so on, but always aim to the server based solution (let it be webapp or just ODBC). In fact, an Excel spreadsheet connecting by ODBC to your DB would be way better (as long as you keep it internally).
If you offer it externally then yes, go for the web-based solution. And anyway, any service you provide externally should be login based (in fact I would say internal services should be login based too, but for small bussiness it is not that important).
Comment: If you want something quick and easy, A Google Docs spreadsheet would work.  This is not ideal, but it has some nice features like version history, shared editing, login support.
Comment: Thanks is there a way I can quickly set up a online solution with logins and which I can maintain fairly simply? Happy to do some coding but dont want to start from scratch.
Comment: For what I see I would go for some FOSS solution already packaged; I do not know of something like that but I bet there are some alterntives. In the end it is you who must select the application who better fits your needs and experience.

Designing price list for suppliers


Gstreamer video stream has very high latency

Question: I am trying to establish a video stream from my usb camera connected to a Raspberry Pi 3. I use a gstreamer pipeline but get a very high latency.
How do I improve my latency?
I have used the following pipeline to establish a video stream, it worked but the latency was around 5 seconds.
gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! x264enc ! rtph264pay ! udpsink host=192.168.2.1 port=5600
In order to improve latency I tried to reduce quality, bitrate, framerate and resolution however the issue persists. The pipeline I tried was the following.
gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=320,height=240,fps=10/1 ! videoconvert ! x264enc bitrate=250 qp-min=22 qp-max=28 qp-step=4 key-int-max=5 ! h264parse ! rtph264pay pt=96 ! udpsink host=192.168.2.1 port=5600 sync=false
Answer: I use tune=zerolatency and it does the trick for me (200ms latency):
gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! \
x264enc tune=zerolatency bitrate=250 ! rtph264pay ! udpsink host=192.168.2.1 port=5600

Comment: Thank you for your fast reply.
It definitely works a lot faster now. However there is still a perceivable 1 second delay. Do you have any other suggestions for reducing latency. If you don't thanks once again for your reply.
Comment: how are you playing it back? (on the udp receiver side I mean)
Comment: The raspberry pi is running a Raspbian based system called Ardusub. I am linking the documentation: https://www.ardusub.com/reference/companion/camera.html The gstreamer options for the reciever side is the following.
!h264parse ! queue ! rtph264pay config-interval=10 pt=96 !udpsink host=188.8.131.52 port=5600


Unmounting network file system on shutdown

Question: I am having a problem with the system hanging on shutdown for a minute or two. I started tracking it down, and I assume the reason is the following: I have a davfs2 network mount in /etc/fstab, and this should be automatically unmounted at shutdown by /etc/init.d/umountnfs.sh. However, davfs2 is not listed as one of the known network file systems (like nfs, smbfs, etc.) in this script, and although the script checks for the mount option _netdev (which is given in /etc/fstab), it does so in /etc/mtab, which is a symlink to /proc/self/mounts and does not have the _netdev option listed. (See https://people.debian.org/~spaillard/Debian_Release_Notes/mtab.html for a short explanation.)
Obviously I can write my own little workaround with a custom shutdown script, but did anyone else come across this, or has some suggestion what to do, like file a bug against some package?
Answer: Either try adding davfs2 to /etc/init.d/unmountnfs.sh, and, once you get it working submit a patch against davfs2, or
Try the workaround in the resource you linked to, "For filesystems which do rely on _netdev for correct unmounting at shutdown, for example when using an NBD, a static mtab will be the only way to use _netdev in wheezy" May apply, with the consequences listed.
Comment: Thanks for the answer, I'll try working something out. There is a little bit of an issue as the file system listed in /etc/mtab is "fuse", not "davfs2", and "fuse" is not always a network file system. It seems that davfs2 used /var/mount/utab as a workaround instead of /etc/mtab to get user unmounting work at all. Also, the file unmountnfs.sh is part of package initscripts, not davfs2, so maybe the bug should be filed against that package, reading the info from utab instead of mtab.


How to remove tap with too much tape

Question: i think i've screwed this up and put too much tape on and can't for the life of me, turn it the other way round so that the tape isn't exposed so much. Anyway ideas?
Comment: How to remove *excess* PTFE tape from the threads of a pipe fitting?
Answer: The fact that you can see the tape has no bearing on the success of the job. If it doesn't leak consider the job well done. If the exposed tape gives you worry that someone will see the tape and say it is a bad job, tell them that is how much you had to use to get a tight seal. If you really want to remove the excess tape, take a wire brush and carefully use it to remove the excess tape.
Comment: Not sure what a wire brush would do to the finish even if used carefully. I'd use a utility knife and gently/lightly run it around the fitting following the threads and then you can just lift the excess tape off.
Comment: 'If it doesn't leak consider the job well done' - solid advice.
Comment: @d.george many thanks, really appreciate the feedback.
Comment: A razor blade can be used to cut the tape at the join. The seal is further up so no worries. Then just unroll the extra.
Comment: If you decide to use a vise or some type of clamp, pipe wrench or other, screw a nipple into the open end of the brass fitting to give it strength to resist smashing or bending the soft brass fitting. Or just leave it alone and use a wire brush as I mentioned earlier.
Comment: If you do mess up the finish, mess up *all* the finish. It's called a *scratch finish*, like on stainless steel sinks (just use a fresh scotch brite pad). But not on that valve; it's still rough from casting, not shiny; you'd just make it look worse. But a few scratches is better than glaring white, no? or taking it back apart.... and if you can't see any tape, it doesn't pass inspection anyway.
Answer: Expand the stuck female part with heat.
You could try heating up the part without the handle (female part).  Start with boiling water (I worry flame will oxidize and discolor that fancy brass).  Just that female part, not the whole thing because you don't want the male part to expand.  When heated the metal will expand and grip less tightly.
Alternatively you could try the same thing with cold on the male part - shrink it down.  I had luck with dry ice for something like that once.
Comment: +1 for answering the title, but no...
Comment: @Mazura - you think it won't work, or you think I misunderstood the question?
Comment: It'll work, that's just penultimate to throwing it away.
Comment: Dipping a plumbing part in hot water is penultimate to throwing it away?  I'm not following this logic either.
Comment: If you use flame you will destroy the rubber joint inside the tap.
Answer: easy work to undo if you own a vice, monkey wrench, or even a good set of workshop clamps... simply clamp the end and let the levarage work for you.
if you have a vice, use some wood to protect the brass from damage.
That tape has a great way of gripping the seal, but once broken, it will be easy to undo.
Answer: Before trying to unscrew it, why not check if that's needed?
The male thread on these taps is often quite long, so look into the hole...

...and check how many threads you managed to screw in. If that's enough, then, you're done.
If the female part has a separator in the middle:

...and the threads reached the separator, then there's no need to screw it in more.

How to remove tap with too much tape


The decomposition of open set

Question: If $U$ is an open set in $\mathbb R^n$, then there exists a sequence of open sets $\{U_i\}$, such that a.$U_i\subset  \subset U_{i+1}$ (that is, ${\overline U _i}$ is compact and ${\overline U _i} \subset {U_{i + 1}}$), b.$U = \bigcup\limits_i {{U_i}}$.
My question is , can we choose all $U_i$ to have smooth boundary?
I come out this question as I was reading my PDE book, since we can in this way "approximate" a solution to an equation when $\partial U$ is rough.
Answer: For any smooth manifold $M$, according to Morse Theory, we can find a smooth function $f$ on $M$ such that $f$ contains no degenerate critical point and for any $a$, $\{x \in M : f(x) \leq a\}$ is a compact set in $M$.
Now since non-degenerate critical points are isolated, we can choose a sequence of numbers $\{c_{i}\}$ such that $c_i \rightarrow \infty$ and the sets $\{x\in M:f(x)=c_i\}$ contain no critical points.
Therefore we can see sets $U_i=\{x\in M:f(x)< c_i\}$ satisify all the assumptions and especially they have smooth boundary $\{x\in M:f(x)=c_i\}$.

The decomposition of open set


Remainder Theorem

Question: Suppose $P(x)$ is a polynomial of degree greater than two. If $P(x)$ is divided by $(x-a)(x-b)$, the remainder is $$\Big( \frac{P(a) -P(b)}{a-b} \Big)(x-a) + P(a)$$
Proof:
By the remainder theorem, $P(x) = q_1(x)(x-a) + P(a)$ and $P(x) = q_2(x)(x-b) + P(b)$. Similarily, $P(x) = q_3(x)(x-a)(x-b) + cx + d$. We know that $P(a) = ca +d$ and $P(b) = cb +d$, therefore $$c = \frac{P(a) - P(b)}{a-b}$$. Solving for $d$ in the previous equation yields $$d =P(a) -a \Big( \frac{P(a) - P(b)}{a-b} \Big)$$ Now since the remainder is simply $cx+d$, we obtain $$cx + d \to P(a) -a \Big( \frac{P(a) - P(b)}{a-b} \Big) + x\Big( \frac{P(a) - P(b)}{a-b} \Big) + P(a) $$ which is trivially rewritten as $$(x-a)\Big( \frac{P(a) - P(b)}{a-b} \Big) + P(a)$$
Now is it possible to derive such an identity for something of the form
$P(x) = q_1(x)(x-r_1) + P(r_1)$
$P(x) = q_1(x)(x-r_1) + P(r_2)$
            .
            .
.
$P(x) = q_1(x)(x-r_1) + P(r_n)$
Therefore $$P(x) = q_I(x) \prod_{i\in I} (x-i) + \sum_{|I| - 1} a_wx^w + d$$ ?
  Because you'd get a system of equations like
$$P(r_1) = \sum_{|I| -1} a_w (r_1)^w + d$$
$$P(r_2) = \sum_{|I| -1} a_w (r_n)^w +d $$
.
.
.
$$P(r_n) = \sum_{|I| -1} a_w (r_n)^w +d$$
Comment: Do you know the lagrange interpolation formula?
Comment: @CalvinLin No sir
Comment: [Here](https://brilliant.org/assessment/techniques-trainer/lagrange-interpolation-formula/) is a link to a writeup. The remainder has degree $r-1$, and you know $r$ of it's values at the points $r_i$, so you have enough information to create the polynomial uniquely.
Answer: By the remainder theorem we have
$$P(x)=Q(x)(x-a)(x-b)+R(x)\tag{1}$$
where $$\deg R<\deg (x-a)(x-b)=2$$
hence $R$ is a polynomial that has at most the degree $1$ so we can put $R$ on the form
$$R(x)=\alpha(x-a)+\beta,\qquad \alpha,\beta\in \mathbb R$$
We substitute in $(1)$ $x$ by $a$ we find that $\beta=P(a)$ then we substitute in $(1)$ $x$ by $b$ we find $$\alpha=\frac{P(b)-P(a)}{b-a}$$
hence we conclude.

Remainder Theorem


convert a onan 110v generator to 220v

Question: My RV has roof-top air conditioning units.  The generator will run 2 units.  I would like to convert the RV to a mini-split system with 2 air handlers. They require 220V, and draw 25 amps; however my Onan generator is 120V.
I can convert from 120V to 220V with a transformer, right?  What is the proper transformer spec.?
Comment: For sale - 110V generator. Wanted to buy - 220V generator.
Answer: You almost certainly don't want to do that. You'd need a transformer that can handle over five kilowatts, and will probably be too big to hide on your RV (I've seen similar ones for over a thousand dollars, almost two hundred pounds, and that are a 20" cube.)
But, if you change your generator from a 110VAC to a 220VAC, you'll have to figure out another way to power your local 120VAC appliances. Maybe you'll need a 220VAC to 110VAC transformer, but the power requirements for that would be far lower than for what you're asking.
If these min-splits are meant for RV use in the US, then the manufacturer will have dealt with exactly this problem again and again and again. Call them and find out what they suggest.
Comment: North American 240VAC generators are virtually all set up to provide 120VAC, same as the North American Grid. *(120/240 is more accurate for the actual grid supply here than 110/220)*

convert a onan 110v generator to 220v


Re-generating Postman request from C#

Question: I'm having an issue creating a POST request from C# to generate a token. There's nothing wrong with the service because I can consume it using Postman.
Can someone help my out.
Following my coding. Every time I get a 403 error.
<code>public async Task<string> LoginAsync(string userName, string password)
    {
        try
        {
            var keyValues = new List<KeyValuePair<string, string>>
            {
            new KeyValuePair<string, string>("grant_type", "client_credentials")
            };

            var request = new HttpRequestMessage(HttpMethod.Post, login_url);
            request.Content = new FormUrlEncodedContent(keyValues);

            var client = new HttpClient();

            var authenticationBytes = System.Text.Encoding.ASCII.GetBytes("----------username-------- : ----------pwd----------");

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(authenticationBytes));
            //request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(authenticationBytes));

            var response = await client.SendAsync(request);

            var jwtResponse = await response.Content.ReadAsStringAsync(); // contains access token

            JObject jwtDynamic = JsonConvert.DeserializeObject<dynamic>(jwtResponse);

            accessToken = jwtDynamic.Value<string>("access_token");
            Debug.WriteLine(jwtResponse);
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }

        return accessToken;

    }
</code>
Following are the screenshots of Postman.

Thanks a lot.
Comment: Use [Fiddler](https://www.telerik.com/fiddler) to watch the requests from Postman and your C# app. Compare them and see what Postman is doing that your app is not. This will tell you the problem.
Comment: Perhaps the spaces between username:password?
Answer: you can use generating code from postman using RestSharp Library for .Net as you can see  by clicking on code button below in the picture .
best regards
Comment: It did the trick. Found an additional header line in my code. Had to add the following line to get it right. client.DefaultRequestHeaders.ExpectContinue = false;
Comment: Your "answer" is unhelpful because the question says nothing about RestSharp.
Comment: I did try that, but it also failed, giving the same error.
Comment: @Sayah "The remote server returned an error: (403) Forbidden." is the error I'm getting.

Re-generating Postman request from C#


How can I record screen (gameplay) video capture alongside controller inputs in PS4?

Question: I would like to record some of my own gameplay for training purposes. This includes video capture of the screen as well as controller actions during the gameplay (what buttons are pressed and the directions of the thumb pads).
Then I can replay what was recorded (gameplay alongside controller inputs).
Can this be done, and how?
(Pretty sure some professional gamers would do something like that as part of their training?)
Comment: Not sure if this warrants it's own question but does anyone know if it's possible to connect to the pc wirelessly while also being simultaneously connected wirelessly to ps4. Basically it's kind of a drag to be physically plugged into my pc anytime I want to stream.
Answer: The GamepadViewer provides what you are looking for.
However, you will need to record your PS4 gameplay footage on your PC using a capture card or something similar. Also you need to connect your gamepad to both your console and your PC by bluetooth binding it to the console and then plugging it into a USB port of your PC.
In your recording program, you can then setup a capture for your browser window, chroma key out the background and layer it on top of your footage. If there is some input lag, you can adjust the delay using in-url settings, e.g.
<code>https://gamepadviewer.com/?delay=2000
</code>
This is and more settings are explained on the info page of the tool. You can also change the skin of the controller to PS4 (black or white) or remap the buttons (e.g. if you changed the mapping through accessibility settings of your PS4). There even is a URL-generator that let's you pick all your options very easily.
I tested this on my PS4 Pro and Chrome under Windows 10 Pro and it worked flawlessly.
Comment: Thanks! I'll try this out, looks like just what I need. Don't think I need to capture gameplay footage via a PC capture card though. I suppose I can record it separately on the PS4, and then overlay the 2 videos later.
Comment: Definitely! Think about a way to sync both captures. Maybe a certain rhythmic button sequence that you will easily recognize to match them together.
Answer: Consider using the PS4 Camera aimed at your DS4.  If setup up correctly the PS4 will stream the game with your controller in the picture-n-picture instead of your beautiful mug.


Tool to explain C code

Question: I remember from some time ago reading about a commandline tool that explains C code, does anyone know what it might be named?
Comment: What kind of explanation are you talking about? A little more specifics, please :)
Comment: More on-topic question: https://stackoverflow.com/questions/1448849/how-do-i-understand-complicated-function-declarations
Answer: Perhaps you mean cdecl, a program that can translate complicated declarations to English and back?
e.g.
<code>cdecl> explain int (*(*foo)(int ))(float )
declare foo as pointer to function (int) returning pointer to function (float) returning int
</code>
Comment: That's a very nice program by the sound of it. Does it have a home page somewhere?
Comment: It is a small program and you will find several versions of the source floating around.  Most Linux systems that I have encountered seem to have it installed.  I believe K&R is the original source.  The book uses the program as tool to explain complicated declarations.
Comment: Is there a similar program for parsing complex / obfuscated expressions per chance? (with operator precedence & stuff)
Answer: If you mean explaining then I think the answers already been given. If you mean looking for potential problems then there's lint and its variants, first stop in any code review.
Answer: http://en.wikipedia.org/wiki/Lint_programming_tool
Edit:
C/C++ Free alternative to Lint?
HTH

Tool to explain C code


Is it possible to get CSS style values in Rvest?

Question: Is it possible to get color codes and other css styles in Rvest?
For example, from Color:Wikipedia there is word Help:Using colors, how can I find the color code '#0b0080' after using rvest::read_html('https://en.wikipedia.org/wiki/Color') ? Looking for something similiare to getCssValue from Selenium.
Answer: 'rvest' queries static HTML documents. It does not parse or apply CSS information. So no, it cannot tell you the elements' style information. At best it can tell you if an element has a static style attribute. But most styling isn't applied this way.
There are other libraries, such as 'rselenium', which emulate the evaluation of a website in an actual browser. This is mostly used to crawl dynamically generated web contents, but it should also apply stylesheets, so there may well be a way of retrieving style information using that route.
If there is no direct way for this, at worst you could use 'rselenium' to execute the Window.getComputedStyle JavaScript function on your target element.
Comment: Thanks for the explanation. In RSelenium you can use elem$getElementValueOfCssProperty


How do you access Gardens of Briar in the Sorcery! series?

Question: In Sorcery! 2, there is an area on the bottom of the Upper Kharé map labelled Gardens of Briar. It appears to have a path going through it and a cave/mine, but attempting to follow the path there doesn't give you the option to go that way at the fork, as far as I can tell. There is a house at the fork, though, that seems to be pointless during my playthroughs, so perhaps there is an option there that I have not realized.
These tweets seem to indicate that somehow, there is a way.
I've read hints that it is not accessible until Sorcery! 4, so an answer from that game, or any other Sorcery! game, is acceptable as well.
Answer: This response contains minor spoilers:

After playing it, I can assert that in Sorcery 4 you DO get to visit the gardens of briar. I'll explain how to get there in the following spoiler.

Here's how (more spoilers):

When entering Mampang via the goblin kitchen, and exiting through the tunnel to the alley, you'll be approached by a beggar who'll take you back to the gardens, and even explain why you weren't able to enter it before.
Comment: While this is the most useful answer so far, the whole point of the spoiler tag is to be able to write full spoilers, so adding more details would only improve the answer.
Comment: @ZAD-Man Fair enough, I'll update the answer with _yet another_ spoiler
Answer: ZAD-man, I have inquired the same thing as you but asked Inkle's support email, and they responded by stating that it is currently not possible to get into the Gardens of Briar, however in the future there will most likely be a way. I can post screenshots if you need proof of this.
Comment: Oh, that's perfect! I don't _need_ proof per say, but that would definitely make the answer complete. Also, it would finally demonstrate the answer for the Internet at large, so people with the same question can see.
Comment: Any chance of getting those screenshots? Apparently this question has been bumped, so it'd be good to have them in your answer.
Answer: Can't find the stone fruit where the foot is myself but the green ring is dropped by the blind goblin in the mines in the first game (spoilers)
Only achievable in new game plus you first need to get the skull cap from the first guy in cantopi then go to the mines encounter the blind goblin and cast tel give him a message don't get greedy and he drops a green ring doesn't drop if you kill him
Answer: You need the green metal ring to cast ZIp; cast it near the "foot" and box full of stone fruit.
Comment: What "foot" are you referring to? And stone fruit, for that matter. If you could give a more detailed location that would be a big improvement, and pointing out where you can get a green metal ring would be even better.


Angular reading data from

Question: I'm using VS Code and I'm getting warnings in my code. I suppose I'm doing something wrong however the application is working as expected

  <input
    (keyup)="onKeyup($event)"
    type="search"
    id="searchInput"
    placeholder="Search..."
  />
  <button class="icon" (click)="clear()"></button>

import { Component, OnInit } from "@angular/core";
import { SearchService } from "../services/search.service";

@Component({
  selector: "app-search",
  templateUrl: "./search.component.html",
  styleUrls: ["./search.component.scss"]
})
export class SearchComponent implements OnInit {
  constructor(private fs: SearchService) {}

  ngOnInit() {}

  onKeyup(event) {
    this.fs.updateFilter(searchInput.value);
  }

  clear() {
    this.fs.updateFilter("");
    searchInput.value = "";
  }
}

Problem is with reading value from input tag. As you can see in the code I'm just using the id to get access to the data but VS Code is showing me a warning that Cannot find searchInput. The code is working fine but since I'm getting the warning I assume I'm doing something wrong.
Comment: Setting aside Angular for a moment, you would grab an event target's value via `event.target.value`. That being said, if you can should manipulate the input's value either through binding with `ngModel` or via FormGroup/FormControl methods if it's a Reactive Form. At a basic level, `searchInput` is not a property that exists on the `SearchComponent` class or in the scope of `clear()` as a variable so you will always get that error as it simply does not exist in the current context.
Comment: You're supposed to use Template Driven Forms or Reactive Forms to access data from any type of input. The warning that throw you is about the definition of the variable, because it isn't declared in any part of the component
Answer: What is searchInput in your class ? If you think it's refers to id="searchInput" you wrong.
To access a DOM element from your class you should do what's described here: document.getElementById replacement in angular4 / typescript? .
Otherwise in onKeyup function, you can access to the value from the event by event.target.value.

Angular reading data from


(Solved) Electrical receptacle box has only 2 wires (white and black, no ground), but both are hot so no neutral? Can't figure out why?

Question: Edit - Solved. Thank you @Harper - Reinstate Monica!
A light connected to the same breaker was wired incorrectly upstream from the problem receptacle.
I think I might be a little over my head trying to DIY some electrical work in my 60's home. I am trying to replace my old 2 prong receptacles with GFCI protected receptacles following this Sparky Channel video https://www.youtube.com/watch?v=16KObgI44UE. To find the most upstream receptacle in the circuit, I removed all the receptacles (7 on this breaker, also 3 lights), capped all the wires, then tested with a non contact tester to see which line was still hot.
Oddly enough, 3 of the boxes still had hot black wires. 3 of the boxes also have no load wires (so only 1 set of black and white wires) and in one of those boxes both white and black wires are hot. There are only 2 wires in this box and both of them are hot. How?
I tested again with a (cheap) multimeter and got 120v from black to the metal box and also got 120v from white to the metal box. I am not knowledgeable at all about how to use a multimeter so not sure if that proves anything. The old receptacle was wired normally (white to neutral, black to hot) and did not work for as long as I can remember.
I plan on hiring an electrician eventually to take a look at this but unfortunately I cannot afford it at the moment. In the meantime, I plan on capping the 2 wires and covering it with a blank wall plate. Pretty curious as to how this happens. Greatly appreciate any enlightenment!
Answer: Wait, are they metal boxes?  Are the wires in conduit or AC cable?  The conduit/cable is a valid ground path.
Your neutral is that way because neutral is disconnected somewhere between this point and your panel.  Somewhere on this side of it, you have a load plugged in, and it's pulling the voltage up toward 120V.
Comment: @user116503 Good. Pull stuff back, take some good photos, and ask another question.... also don't overlook the neutral bar in the service panel, that's a top place for trouble and nobody thinks about it...
Comment: Wow, thanks for the info. I did not think to check the cables. Yes, the boxes are metal and yes the original wires are in flexible metal conduit. I just assumed no ground wire = no ground. I'll check the wiring again to see if there are any issues. Could be one of the lights. Appreciate the response!
Comment: Checked the light downstairs (closest to the breaker box). Fairly positive this is where the problem is coming from. It has 5 sets of wires. I assume 1 from breaker, 3 branches to the room above, and one to the switch. It is wired beyond my capability to figure out. 3 whites capped together with 1 black. 4 blacks connecting to the black from the light fixture and the 2 remaining whites connected to the white from the light fixture. Glad to at least know where the issue with the receptacle stems from at least. Thanks  for pointing me in the right direction.
Comment: I isolated all the lines and was able to find the hot black coming from the breaker. Then I checked each black line with the hot line to see where they led to downstream. Capped all the white lines together except for the white from the switch and included a pigtail. Connected the light - white to pigtail, black to the white (now taped black) from the switch. I am pretty sure this is correct? The white line in the problem receptacle is neutral again and everything is working. Kind of amazed the light worked the way it was previously wired.Learned a lot. Hope I didn't miss anything. Thank you!
Answer: When wires run parallel the hot can induce a voltage on the non energized wire. Put your meter on voltage and measure the potential from the black wire to the white wire as long as you have 120v you have a hot and a neutral.
Connect up the GFCI with the black wire on the gold screw and the white wire on the neutral (both on the load side of the GFCI) turn the breaker back on press the test and reset and when the GFCI receptacle works all is well. You will need to identify the breaker for each chain of receptacles and sometimes you may find a chain branching 2 or 3 directions , in these cases a GFCI breaker in the panel will work for them all or one at the start of each break out. Don't put multiple GFCI's in 1 chain or a GFCI feeding another GFCI even if there are a few outlets in between 1 is all that is needed 2 may become difficult to reset and cause more false trips.
Comment: I tried black to white and did not get 120v (seemed to be jumping around the <1 range). Going to check to see if there is a disconnected neutral somewhere. Thank you for the advice on the GFCI installation. I wasn't expecting the multiple branches.


vim-fugitive automatically gdiff on enter from gstatus

Question: When using vim-fugitive if you issue :Gstatus it splits the screen and gives you the would be git commit editor and you can move over different files that have changes and press enter to see them in the other half of the screen. I believe it is like issuing :Gedit .
I then need to issue a :Gdiff manually to split the editor in half and see the side by side diff of the file to review and or stage it.
My question is is there a way to make it automatically go to :Gdiff when I press enter, while my cursor is on a file name that has changes.
Basically trying to save some time when going through a large list of files.
Comment: Have you tried `dd` or `D` in the `:Gstatus` window?
Comment: This is the correct answer, where did you find it, did I miss it in :h ?
Is there a difference between `dd` and `D`? by the way that is a odd choice? Just checked and it is in the help file `D` is.  @PeterRincker Would you please make it an answer rather than a comment
Answer: You can use D or dd inside the :Gstatus window to run :Gdiff on the file under the cursor. See :h :fugitive-:Gstatus or use g? inside the :Gstatus window.
For additional help you may wan to look at Vimcasts, which has some very nice fugitive.vim series.

A complement to command line git
Working with the git index
Resolving merge conflicts with vimdiff
Browsing the git object database
Exploring the history of a git repository


DOCUMENT_ROOT set but can't get it in script. Why?

Question: I have php scripts that were working ok since Ocober last year, last I remember was 2 months ago and today while executing them I have problems with _SERVER['DOCUMENT_ROOT'] variable.
If I look at the _SERVER array, it is not set. While if I execute in a script:
phpinfo();

Then the variable is there and set.  But calling it:
$_SERVER['DOCUMENT_ROOT']

Returns null
What is the reason for this? How can I use it again in my scripts? I figure the cause was a php or apache update, but both have been updated few times in the last 2 months.
Also, I don't see DOCUMENT_ROOT in php.ini file. I do see doc_root, which is different.
My php:
    PHP Version 5.3.5-1ubuntu7.7
apache:
    PHP Version 5.3.5-1ubuntu7.7
Comment: As I wrote, that contains an empty string in DOCUMENT_ROOT
Answer: DOCUMENT_ROOT is an environment variable normally set by the (apache) webserver before calling you script via CGI. If your webserver has a bug or is misconfigured, it can happen that this environment variable is not set any longer.
You can try to debug and/or hotfix that with mod-rewrite, mod-cgi, mod-setenv or similar. If that is all above your head, please contact your server administrator and discuss the issue because it can have many reasons.
Comment: Yes, it turns out that the var was empty because I was calling the script from terminal - thus skipping apache. Thanks!
Answer: try print_r($_SERVER) , and see if it's really set
Comment: are you calling the script from the command line ? instead of regular call from a browser ?
Comment: Yes, and that was it, thanks :). Tried with browser and that works
Then I guess like Hakre said, this var comes from apache thus since calling in terminal skips that, var is then empty.
Answer: If may be an Apache configuration issue : did you define a document root in your Apache configuration file ?
Otherwise, you can bypass it by using :
dirname(__FILE__)

or :
substr($_SERVER['SCRIPT_FILENAME'], 0, -strlen($_SERVER['SCRIPT_NAME']));


My pen drive not working after I removed unfortunately while it is formating

Question: When i connected my pen drive it is not showing any icon such that pen drive is connected. I am using ubuntu 16.04. It is not showing even in windows
Comment: What's your question?
Comment: I have used testdisk program in similar case and it solved my problems.
Answer: First, see if it's showing up in /dev.  To do this, UNPLUG the device, and type:
sudo partprobe
ls /dev/sd*

Then, PLUG IN the device and type that command, again.  Notice what's different.  You should have an additional sdX letter, and perhaps some partitions on that device, such as sdX1.  (Replace X with b, c, d, e, etc., as appropriate.)
If you do, indeed, see a new device, that means the device is still working!  Does it have a partition on it (number after the letter)?  If so, that means it's still partitioned, and may still have a formatted, working partition on it.  Let's find out if that's true.  Replace "sdX" with the correct entry, such as, "sdb" or "sde".
sudo blkid -d | grep /dev/sdX

If something shows up, you will see a filesystem type (like vfat, exfat, fat32, ntfs, ext4, hfsplus, etc.), which means that the partition is showing up as being formatted.  Let's find out if we can actually read that partition.  I'm assuming that you're not using /mnt for anything (by default, it's empty).  If you ARE using it for something, pick a different directory.  As before, replace "sdX#" with something like "sdb1" or "sdd1", as appropriate.  Also replace "type" with the filesystem type you saw with the above blkid command.
sudo mkdir /mnt/test
sudo mount /dev/sdX# /mnt/test -t type

Did that command produce an error?  If so, the filesystem is dead, and you need to reformat it using Gparted or your preferred command-line utility.  If it produced no error message, you can then look in /mnt/test to see what's on the partition.  First, let's assume the mount command worked, and we want to look and see what's in there.
cd /mnt/test
ls

Are your files and directories there?  If so, great!  If not, you have a blank partition, and, hopefully, you didn't care about anything on that drive...but if you did, you can turn to some forensic tools like testdisk, dd/ddrescue, etc.  There are plenty of forum posts out there on data recovery; Google is your friend (good luck...).  If you have a blank directory, let's just double-check to make sure it's really mounted.
mount

Do you see your partition (/dev/sdX#) as being mounted on /mnt/tmp?  If so, then you simply have a blank partition.  If you want to be doubly-sure that the partition erased and fully-functional, you can reformat it with Gparted by doing this (see note, below):
sudo gparted /dev/sdX#

Note: you should probably clean up /mnt BEFORE you repartition/reformat/relabel anything.  To do that, close all programs, terminals, and windows that might be using the drive or mount point, and type:
cd ~
sudo umount -f /mnt/test
sudo rmdir /mnt/test

Then, right-click on the partition and format it as desired.  Alternatively, you can use mkfs.whatever to format it from the command line.  Replace "whatever" with ntfs, ext2, exfat, etc.  I STRONGLY encourage you to read the manual page before attempting this:
man mkfs.whatever

or
man mkfs

If you want to be doubly-extra-sure that it's empty and functional, you can create a new disk label, repartition, and then reformat it in gparted (or using your favorite command-line tools, such as parted, gdisk, mkfs.whatever, etc.).
Please keep in mind that, anytime you repartition, create a new disk label (partition table), or format something, if you do that on the wrong drive or partition, you can lose ALL your data!  Be careful, and get it right.
Good luck.
Answer: Try using gparted! It usually works for me. Or use lsusb to see what's attached. fdisk -l for more info
Comment: Can you please explain how these tools can reveal the USB drive?


convert python to dart

Question: I want to know how I can write the following python code in dart.
encrypt = str.maketrans({'a': '1', 'b': '2', 'c': '3', 'd':  '4', 'e': '5',
           'f': '6', 'g': '7', 'h': '8', 'i': '9', 'j': 'A',
           'k': 'B', 'l': 'C', 'm': 'D', 'n': 'E', 'o': 'F',
           'p': 'F', 'q': 'H', 'r': 'I', 's': 'J', 't': 'K',
           'u': 'L', 'v': 'M', 'w': 'N', 'x': 'O', 'y': 'P',
           'z': 'Q', ' ': 'X'})

text = input('Enter Text: ')
text_lower = text.lower()
enc_text = text_lower.translate(encrypt)
print(enc_text)

Comment: Well, what have you tried so far? That doesn't seem like a very complex piece of code.
Answer: From my understating, you are trying to encrypt a text and convert each letter into a new one. In dart there is no such method like maketrans, but you can use a normal key-value map for this purpose:
import 'dart:convert';
import 'dart:io';

main() {
  Map<String, String> letterMap = {
    'a': '1',
    'b': '2',
    'c': '3',
    'd': '4',
    'e': '5',
    'f': '6',
    'g': '7',
    'h': '8',
    'i': '9',
    'j': 'A',
    'k': 'B',
    'l': 'C',
    'm': 'D',
    'n': 'E',
    'o': 'F',
    'p': 'F',
    'q': 'H',
    'r': 'I',
    's': 'J',
    't': 'K',
    'u': 'L',
    'v': 'M',
    'w': 'N',
    'x': 'O',
    'y': 'P',
    'z': 'Q',
    ' ': 'X'
  };

  print('Enter Text: ');
  String text = stdin.readLineSync(encoding: utf8) ?? "";
  text = text.toLowerCase();

  String encodedText = "";
  for (var letter in text.split('')) encodedText += letterMap[letter] ?? "";
  print(encodedText);
}

convert python to dart


Light Switch with no ground

Question: I'm replacing my light switches with Lutron Caseta switches. When I pull the old ones out I noticed they don't have grounds. The box they are in is plastic. Is it okay to not ha e a ground in the new light switch?
Also are there switches where the wire is part of the switch. I loosened the screws but the wire wouldn't come out. I'm assuming it's attached to the switch itself and that I'll need to cut the wire.
Comment: Those wires are the unreliable "back stab" connections".  It is best to avoid them altogether and use the side screws.  Note also how they left exposed bare wire outside the backstab, very sloppy and hazardous. You can tell the work was amateur done, because pros don't pay 79 cents for a switch.  Backstabs, once released, are ruined and you must throw the device in the trash (or use the screws from then on).  Do what most of us do; never use backstabs. Screw-and-clamp is alright.
Comment: When you loosen a screw, it will start to bind about 3/4 of the way out.  Don't power past that.  This binding is intentional, it is a "captive screw", a useful feature that means you don't need to fumble with screws.
Answer: Yes, they should be grounded. You have ground wire in the box. Just twist some bare copper on to it for each switch and then nut it off
Comment: Is that what the bare twisted wire is going to the bottom right of the box is?
Comment: Correct. Bare wires are always ground
Answer: Insert a screwdriver in the small rectangular opening in the back of the switch, just below the wire, and push / twist until the old black plastic switch breaks into pieces. Eventually the wire will come out. I despise these back stab switches and outlets, which the builder of this 1989 home I purchased in 2012 used exclusively.
Comment: Hello, and welcome to Home Improvement. Thanks for the answer; you'll have a lot of company in your feelings towards backstab switches. And, you should probably [take our tour](//diy.stackexchange.com/tour) so you'll know how best to contribute here.
Answer:
Is it okay not to have a ground in the new light switch?

Not really great, but it is not unusual for older homes to have been wired without one. I believe that an alternative and acceptable safety "work around" in the absence of the ground would be to install GFCI breaker(s) on the circuit(s), maybe someone will comment further on that.

I loosened the screws but the wire wouldn't come out

Those wires are connected with "stab in" type terminals. If you look closely you will see a small rectangular opening in the back of the switch, near where the wires are inserted. There is a metal tab in there that acts as a spring, holding the wire in. Gently and carefully insert a small tool (flat screwdriver) and push the metal spring inward whilst simultaneously pulling gently on the wire, to release.
Comment: His picture shows a bare ground wire in the back.  He should use that.
Comment: @ rrauenza, yes of course, I did not see that before, thanks.
Comment: The missing ground terminal on the old switches versus what you find on new switches reflects progress in NEC and UL standards. I prefer to remove wires in stab-in-the-back devices by crushing the switch with my T&G pliers, that way nobody is tempted to put the switch back in service.

Light Switch with no ground


Delete an element in a list at a specified index

Question: I need your help! Can you help me with this: delete an element in a list at a specified index in Prolog.
For example:
    delete(List,Index,NewList).
    ?-L=[1,5,7,4],delete(L,2,L2),write(L2).
    L2 = [1,7,4]

I don't know how to do this.
Solved!
   away([G|H],1,H):-!.
   away([G|H],N,[G|L]):- N > 1, Nn is N - 1,!,away(H,Nn,L).
   ?-away([1,2,3,4,5],3,X), write(X).

Answer: Use the built-in function nth0/4 (which uses 0-based indexing) or nth1/4 (which uses 0-based indexing) to do this. In your case, since you use 1-based indexing, nth1 should be used:
nth1(Index, List, _, Remainder)

Supply Index and List, since you don't need the deleted element, you can ignore it, then the resulting list will be in Remainder.
This is the source code of nth1 taken from lists.pl library in SWI-Prolog, rewritten to remove dependency:
% Case 1: Index not specified
nth1(Index, In, Element, Rest) :-
    var(Index), !,
    generate_nth(1, Index, In, Element, Rest).
% Case 2: Index is specified
nth1(Index, In, Element, Rest) :-
    integer(Index), Index > 0,
    find_nth1(Index, In, Element, Rest).

generate_nth(I, I, [Head|Rest], Head, Rest).
generate_nth(I, IN, [H|List], El, [H|Rest]) :-
    I1 is I+1,
    generate_nth(I1, IN, List, El, Rest).

find_nth1(1, [Head|Rest], Head, Rest) :- !.
find_nth1(N, [Head|Rest0], Elem, [Head|Rest]) :-
    M is N-1,
    find_nth1(M, Rest0, Elem, Rest).

Comment: +1. `nth1/4` also has the 1-based indexing that OP is requesting.
Comment: Thank you, but I need to do it in Strawberry Prolog or at least in Turbo Prolog. And there is no built-in functions
Comment: @mat: I think your answer is also helpful - since it shows the way to do it without library.
Comment: @Tanya: Edited to include the source code from lists.pl of SWI-Prolog. I modified it a bit to remove some functions not available in Strawberry Prolog, but not yet tested.
Comment: @nhahtdh I've just tried myself and get this: away([G|H],1,H):-!.
away([G|H],N,[G|L]):- Nn=N-1,!,away(H,Nn,L).
?-away([1,2,3,4,5],3,X), write(X). But here's an error at 2 line: No sense at line 3, after clause 1.
Comment: @Tanya: `Nn is N - 1` (test that expression on RHS evaluates to that of LHS, and with same type of integer or same type of float) rather than `Nn=N-1` (unification)
Comment: @nhahtdh Oh God. I'm so stupid! Arrr. Adding N > 1 and it works perfect! Thank you darling! xoxo
Answer: A bit outdated, but still (especially if you wanted a bit more elegant solution):
del([X|XS], CNT, [X|RES]) :- NEXT is CNT - 1,
                             del(XS, NEXT, RES).
del([_|XS], 1, XS).

Comment: The goal `del(Xs,1,Ys)` loops. It should terminate universally.


I'm trying to implement DMD concept of java.But not getting the output as expected

Question:      class Rectangle extends Tri{
       public void draw() {
         System.out.println("Rectangle");
       }
     }

     class Tri {
      public void draw() {
        System.out.println("Triangle");
       }
     }

    class Circle extends Rectangle{
     public void draw() {
      System.out.println("Circle");
      }
     }

    class rect
    {
     public static void main(String[] args)
     {
      Circle c=new Circle();
      Tri t=new Tri();
      Rectangle r=new Rectangle();

      r.draw(); //Rectangle
      r=c;
      r.draw();  //Circle
      t=r;
      t.draw(); // Rectangle expected.But getting Circle as output.
       }
     }

In "t.draw" where I'm giving reference to "t=r", it should display "Rectangle" but i'm getting output as "Circle".May be that is because of earlier referencing r=c.
But it is still a doubt.
Answer: You've previously assigned c to the variable r.
By the time you get to the line t = r, r = c already ... so now t = c.
Why would you create the variable t just to assign r and c to it?  Why not just deal with r and c directly to make things more clear?
Answer: This behaviour is as expected because you have assigned r = c and then t = r so the object t reference holding is of c i.e. circle. Hence it is printing output as Circle. I hope this explains the behaviour of JAVA.


trouble importing pytz module after upgrade

Question: I recently upgraded from using Python 2.7.6 to 2.7.12. In my 2.7.6 code (that was working) I had the following import:
from pytz import timezone
def get_curr_time():
  pst = timezone('US/Pacific')
  cur_time = datetime.now(pst)
  return cur_time.strftime('%Y-%m-%d, %H:%M:%S')

On 2.7.12 it straightaway gives an error saying pytz no such module.
ImportError: No module named pytz

I changed pytz to time but it didn't work (I think the function get_curr_time() broke). Any way around this, if possible keeping the get_curr_time() as is?
Answer: pytz is currently not installed on your machine. You need to firstly install it. To install it via. pip, you may simply do:
sudo pip install pytz

Comment: I solved my issue by uninstalling pytz and reinstalling pytz (thanks for the answer, it helped point me in the right direction)
Comment: Are you running your code in any virtual environment? OR, you are installing `pythz` in any/other virtual environment?
Comment: Are you having multiple `pip` version on you machine? Make sure the python version you are using and the `pip` you used to install `pytz` are of same version. Another issue might be as mentioned [here](http://stackoverflow.com/a/14970445/2063361)
Answer: weirdly, i was having same issue.
i did
pip uninstall pytz

then did
pip install pytz

and that worked


Eliminating moth flies (and larvea) of unknown origin found mostly in kitchen

Question: I've been battling some relatively slow-moving flying pests and their larvae. Based on my Internet research I'm 90% certain that these are "moth flies".
They are found mostly on the ceiling or on the walls near the ceiling. When they are in a resting state (or when they are larvae) they don't see me coming and they are easy to capture with a napkin. When flying they move a bit slower than flies so I can usually catch them with moderate effort.
The problems I'm having are:

No matter how many I capture or kill, they keep coming back within a couple of hours - I've currently killed an estimated 200 - 300 of them over the course of a week
I can't pinpoint their origin
Fly paper and an indoor UV electric solution perform poorly - I got maybe 10 that way
I can't use chemical sprays or poisons, because I have a young puppy in the house and I'm not willing to risk it

The Internet led me to believe they probably came from drain pipes, so I bought an insecticide made specifically for drains. Not only did it do nothing, when I went to clean and inspect the sink pipes I somehow created a leak. On top of that, I tried to further clean the sink pipe and make the slow drain fast by buying a high pressure air gun made for that, which somehow made the drain pipes totally clogged (I digress - the point is that this option won't work for me). I don't actually see any evidence that they came from the drains at all.
Any thoughts on how to safely eliminate them and/or where else their source might be? I suppose if I found where they keep coming from I could kill their nest or egg sacs or whatever, but they seem to appear from thin air.
Comment: You can kill them instantly with a safe homemade spray: 4 parts water, 1 part Murphy's Oil Soap. Drops those suckers right out of the sky, dead before they hit the ground. You won't find a nest or egg sacs, they come from maggots, which live in moist out of the way places rich with food.
Comment: @dandavis Thanks. Are maggots the same thing as the larvae? Maybe originally they grew in some garbage bags I was keeping in the sun room waiting for trash day, but those are gone now and I don't see where they keep coming from. The rest of the food in my house is sealed up in the refrigerator. Anyway, will this eventually eliminate all of them? I'm able to kill them 1 by 1 already with napkins and fly swatters, but they just seem to keep coming and coming.
Comment: They could be from a dead animal in the wall, still around from the trash, or the fatberg in your drain. If you cannot locate the source, you will have to deal with them until the nutrient source is depleted, usually a week or two. Fix the drain, then dump some bleach down it.
Answer: Really if it is like that you can do two things:

As Dandavis suggested - water+murphy's oil takes care of it fast.   It works, I have used it multiple times.

You need to do a thorough cleaning.   This is emptying under the sink, moving oven out and cleaning under, same with fridge, trash can (I had an insert in my last trash can and in between the insert and the bottom was food and it was a nightmare - so perfectly clean kitchen and one clump of food hidden), take out all bottom drawers and make sure nothing is under them, all cabinets, pantry, and on top of cabinets.

There is always a chance that you could have a dead animal in the wall but it usually isn't the case.
Answer: Could be pantry moths.  They often show up in dry goods (e.g. rice, oatmeal) purchased from outside.
My solution was

Place all food in hard sided sealed containers.
Clean all shelving.
Clean all ceilings and walls.
Deploy pantry moth traps.
Wait a couple of weeks, making sure that all starchy items are in jars/hard sided containers.
Inspect jars and hard sided containers for moths -- they sometimes lay eggs on the insides of the jar lips.

It takes months to get rid of them.
Comment: Very helpful. Could've been an old dog food bag. I've thrown it out now.
Answer: I have no doubt these pests came from the sewer. (I've heard them called sewer flies, and I see them all the time when I pop sewer manhole lids for work) They can't swim, so my first guess is that the trap under your sink isn't holding enough water to block gas exchange from the sewer, so they might be flying up and through the trap. My second guess is there's a break in the vent stack somewhere that allows them entry.
You mention having a slow drain, and that you "somehow created a leak" by working on it. That leak could easily be draining the water from the trap so I would start there.
Edit: Here's a good youtube video on how a p trap works. It also mentions that if the vent stack is clogged the water can be sucked out of the trap, which is something I didn't consider!
https://www.youtube.com/watch?time_continue=10&v=zGofkKOP2SU&feature=emb_logo
Comment: Thanks much, I will check it out


Problem with Samba/Raspberry/Nemo

Question: Goodmorning everyone.
I have a problem with the 'windows network' in Nemo (default cinnamon file manager).
I configured samba on raspberrypi with Raspbian.
From a client with Ubuntu 18.10 and cinnamon I can see the connection using 'connect to the server ...' and entering the ip address of the raspberry, but if I try to use the menu item of Nemo: 'File / Network' and in the right panel I select the 'Windows Network' icon I see NOTHING.
I hope someone can explain where I'm wrong.
Thanks.
Answer: Samba network discovery for NetBIOS hosts has issues as described here: https://bugs.launchpad.net/ubuntu/+source/gvfs/+bug/1778322?comments=all
The Good News: Linux and MacOS machines do not have to use NetBIOS for host discovery. It can be replaced with Avahi.
Make sure avahi-daemon is installed on the Pi:
sudo apt install avahi-daemon

Make sure it's running:
sudo service avahi-daemon status

Create a file on the Pi at: /etc/avahi/services/samba.service
With this content:
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
   <name replace-wildcards="yes">%h SMB</name> ## Display Name
   <service>
       <type>_smb._tcp</type>
       <port>445</port>
   </service>
</service-group>

You may need to restart the daemon: sudo service avahi-daemon restart
Nemo will show the Pi under Network but not under Windows Network since it's not using the Windows discovery protocol.

Problem with Samba/Raspberry/Nemo


How to partition a Advanced Disk HDD properly using Gparted or similar

Question: I have one of these fancy hard drives that use the "revolutionary" Advanced Disk format. I partitioned my HDD for Ubuntu 11.10 from scratch and checked with Ubuntu's disk utility for errors. However, after installation of Ubuntu 11.10, I have a warning in the disk utility saying about one partition
The partition is misaligned by 1024 bytes. This may result in very poor performance. Repartitioning is suggested.
I pretty much understand the cause of the issue since there are many posts here about this error message, but how exactly do I partition my harddrive properly to avoid these kind of misalignment errors?
I got rid of the misalignment warning by booting Ubuntu from a Live CD. I reduced the preceding partition by one 1 MB and resized the misaligned one by one megabyte with the option "align to MB".
Answer: I found this info from Western Digital, reading through it the kernel should support the drive without any problems - I suggest you have a good read through the site and also have a read of the article on Kernel.Org.
Answer: Newer versions of GParted (certainly the one which comes with 11.10) have "align partition to" option, default being 1MB - agreeing with GParted's choices will result in optimal alignment.
The links in Mark Rooney's answer have a lot of useful background info on the subject.
Comment: This solved the misalignment warning, however, my question is how do I partition my HDD right away using the proper sector sizes etc. such that no misalignment occurs.
Comment: @R3s3t: when using GParted, the default settings give you the optimal alignment. When allowing Ubuntu installer to do the partitioning, it also does the right thing by default. So the question is - how exactly did you manage to mis-align your partitions? :) What tool did you use?
Comment: I used Gparted on an Ubuntu 11.10 Live CD, that is exactly why I am asking
Comment: So, when using GParted initially - do you remember changing the default alignment settings?
Comment: Good point, I might have used align to cylinder. However, for all the other partitions it worked.


Add keys and values to array with foreach

Question: $arr = array(

      foreach($data as $i => $c):
            $sub[$i] = $c;
      endforeach;

);

What is wrong with the construction of this loop?
Comment: It's not clear what you're trying to accomplish here.
Comment: What are you trying to achieve here..?
Comment: i would like add new keys for my array
Comment: Looks like a funky attempt to do `$arr[$sub] = $data;` or something.
Comment: depending on what the original keys are: print_r(array_values($array));
Answer: You want:
  $sub = array();
  foreach ($data as $i => $c):
        $sub[$i] = $c;
  endforeach;

or
  $sub = array();
  foreach ($data as $i => $c) {
        $sub[$i] = $c;
  }

Your code is invalid beacause you cannot use statements (like foreach) as array argument.
What's more, your code just copies one array into another, I don't want what's the purpose. I think you should read some good PHP manual.
Comment: @webarto true, I mentioned it. I just wanted to show valid PHP code version OP wrote in question (with foreach loop).
Answer: I would say, simply becuase it's wrong.
You can't execute code within the array() arguments.
What you want to do is to inject the data, in your empty array, like this:
  $sub = array();
  foreach($data as $i => $c)
        $sub[$i] = $c;


A train traveled at a constant rate of $f$ feet per second. How many feet did it travel in $x$ minutes?

Question: I know the correct answer is (D), however, I don't understand why (D) is correct. Can someone explain it to me; I struggle with math?
Comment: @MartinSleziak: thanks for removing the tag; but while you   do this, please consider the title as well. So we don't have two separate bumps. Robert: a title should describe the actual mathematical content of your question, not the circumstantial details.
Comment: `homwork` tag is going to say Good bye.
Comment: If $f$ feet in $1$ second, how many feet in $1$ minute?
Answer: There are sixty seconds in a minute, so to convert $x$ minutes to seconds, we must multiply by 60 to get $60x$.  Now, we're given that the train is traveling at a constant speed of $f$ feet per second.  Thus, by multiplying by the number of seconds, we will know how many feet the train has gone, which is $60xf=60fx$.
Answer: The first step is to write out any relationships given. In this case, the train traveled at a constant rate, or speed of $f$ ft./s. So our relationship would be
$$f=\frac{\Delta d}{\Delta t}$$
where $\Delta d$ is the change in distance in feet, and $\Delta t$ is the change in time measured in seconds. Solving for the change in distance we have
$$\Delta d=f\Delta t$$
It looks easy, but we are given time in minutes, not seconds, so we need to multiply by a conversion factor as follows
$$\Delta d=f \frac{ft}{s}\cdot x\:min\cdot\frac{60\:s}{1\:min}$$
which may be easier to read if I express it like this
$$\Delta d=\frac{f\:ft}{1\:s}\cdot \frac{x\:min}{1}\cdot\frac{60\:s}{1\:min}$$
Notice how the units cancel giving us
$$\Delta d=60fx\:min.$$
I call this method chaining, and it makes conversions really easy. I just wanted to complete a couple more direct examples before finishing my post. Suppose we wish to calculate the number of seconds in a three dozen years.
$$3\text{ dozen years}\cdot\frac{12\text{ years}}{1\text{ dozen year}}\cdot\frac{365.24\text{ days}}{1\text{ year}}\cdot\frac{24\text{ hours}}{1\text{ day}}\cdot\frac{60\text{ minutes}}{1\text{ hour}}\cdot\frac{60\text{ seconds}}{1\text{ minute}}$$
Notice how all of the units cancel out except for $seconds$, giving us
$$(3)(12)(365.24)(24)(60)(60)\text{ seconds}=1136042496\text{ seconds}$$
Finally, consider a conversion ratio that doesn't have 1 as a denominator. Suppose that 3 miles is approximately 5 kilometers. Convert 25 miles to kilometers.
$$25\text{ mi.}\cdot\frac{5\text{ km}}{3\text{ mi.}} = \frac{25\cdot5}{3}\text{ km}\approx41.7\text{ km}$$
Read $\displaystyle\frac{5\text{ km}}{3\text{ mi.}}$ as 5 kilometers per 3 miles.


How to sort a table according to the order of another by "mirror effect"?

Question: I know there are already a lot of answers to this on SO (like this one), but before to close this post, I would like to have an answer to my question.
I have an array that has a relationship with the order of another array, for example: A=[1, 0, 2] and B=[4, 1, 3]. I would like to sort array A and keep the order of B relative to A (in the context of my work, the two arrays are the left and right values of an "arrow", so here: 1 0 2 -> 4 1 3). The result will be as follows: A=[0, 1, 2] and B keep the order defined by A: B=[1, 4, 3].
The code I use is:
struct Combined
{
    int a;
    int b;
};

int cmp(void *a, void *b)
{
    struct Combined *x = (struct Combined *)a;
    struct Combined *y = (struct Combined *)b;

    return x->a - y->a;
}

void order(int *left, int len1, int *right, int len2)
{
    // The two tables are not always of same size
    unsigned int len = max(len1, len2);
    struct Combined *combined = malloc(len * sizeof(struct Combined));

    int i;

    for (i = 0; i < len1; i++)
        combined[i].a = left[i];

    for (i = 0; i < len2; i++)
        combined[i].b = right[i];

    // We sort 'combined' according to the first table only
    qsort(combined, len, sizeof(struct Combined), cmp);

    // The values are then reassigned

    for (i = 0; i < len1; i++)
        left[i] = combined[i].a;

    for (i = 0; i < len2; i++)
        right[i] = combined[i].b;

    free(combined);
}

I'm pretty sure it works, but I've noticed a behaviour I don't want: when arrays A and B are the same but reversed, then, once the sorting is done, the two resulting arrays are no longer the inverse of each other, so I imagine that the algorithm I'm using is not the one I want (hence "mirror effect" in the title).
To illustrate, if A=[1, 2, 0] and B=[0, 2, 1], the resulting will be A=[0, 1, 2] and B=[1, 0, 2]. But I want B=[2, 1, 0]...
How to adapt this algorithm to such a behaviour while remaining general with respect to any two tables?
EDIT
Here is a more abstract but contextual explanation of what I want to achieve:
In my programme, I manipulate "arrows". This is a data structure that represents an input as a series of numbers and represents an output as a series of the same numbers (but in any order).
The processes that manipulate these arrows can perform all sorts of tasks often leading to a result that is not spontaneously intuitive to read because the different numbers are not always sorted at the end of them.
To illustrate, a resulting arrow may have the following form: 1 2 0 -> 0 2 1. In this example, we can see that the output is the inverse of the input; another example: 2 0 1 -> 1 2 0 (and there is no particular relationship between the two sets of numbers).
To make the result easier to read, I would like to be able to reorder the numbers so that the input is easy to read (i.e. sorted) and of course keeping the same relationship to the output. The easiest way to do this seemed to be the way I presented above, but, as said above and in the comments, this relationship between inpout and output is no longer preserved as I would like. The question is therefore how to modify this algorithm to achieve the desired result.
Comment: Re "*The two tables are not always of same size*", Your solution doesn't work, then. In fact, what you are trying to do makes no sense. What output do expect for `a = { 3,2,1,0 }` and `b = { 2,1,0 }`? The current result is `{ {0,uninitialize}, {1,0}, {2,1}, {3,2} }`, so you end up with `a = { 0,1,2,3 }` and `b = { undefined_behaviour,0,1 }`
Comment: I think you need to explain what an inverse relationship is. Does it mean that B[A[i]] == i? Because that is not what happens in the [4,1,3] example. Does it mean that A goes up and B goes down? Because for that, you would sort each array separately.
Comment: I don't understand the problem.  [1,0,2] is the correctly sorted B. It has kept the same order in relation to A. A0->B1, A1->B0, A2->B2 before and after.
Comment: Indeed, it is correct according to the algorithm used, however, in the context I am using it, this result is not correct because the inversion relation of the two arrays is not preserved, therefore my question is more of an algorithmic nature, namely how to modify this code in order to preserve the inversion in the particular case where the arrays are inverted from each other. I could check this quite trivially, but perhaps there is a name for what I am trying to do, or another method...
Comment: You seem to want two different answers.  One is to sort the arrays in parallel, using the keys from array A.  The second is to sort the two arrays independently, eliminating the relationship between the two.  Pick one.  You can't have both.  In your last example, if `A` is sorted to `[0, 1, 2]` and `B` is sorted to `[2, 1, 0]`, then the mapping between the two arrays is not preserved.  E.g., `1` -> `0` becomes `1` -> `1`.  So, organize your thoughts, decide what you want, *then* determine if you need help to achieve it.  At present, you don't know what you want, so there is no question.
Comment: FWIW, the short answer to the second version of your question is simple:  Sort array `A` in ascending order, and sort array `B` in descending order.  It's up to you to decide which version you want.
Comment: In the [4,1,3] example it looks like you are doing what this algorithm does, but nobody here can understand why you want [1,4,3] in the first example and you don't want [1,0,2] in the second example
Comment: I don't think you are explaining what you want very well. Do you want a new routine that looks similar to your original routine, or do you want your original routine to somehow magically detect it needs to perform mirror transformations instead?
Comment: I have edited the question to show the context of what I want, I hope it is clearer... If it still isn't, then what I want is, as some have said, not clear enough for me either and we can close the question.
Comment: You are sorting arrows, so len1 **must be** equal to len2. (there are no arrows without a head or without a tail). So, you only need the array of `combined` structs, and you can omit the separate arrays.
Answer: You can create the "mirror effect" as you call it by mapping the index to the mirror index.
If you don't want the mirror effect, the mapping index of i is the identity, i. If you want the mirror effect, the mapping index of i would be (len - 1 - i).
#define MAP(I, LEN, MIRROR)  \
        ((MIRROR)            \
         ? ((LEN) - 1 - (I)) \
         : (I))

Then, before sorting, when creating the combined array, use the mapping for the right.
for (i = 0; i < len2; i++)
    combined[i].b = right[MAP(i, len2, mirror)];

And after sorting, use the mapping when restoring right.
for (i = 0; i < len2; i++)
    right[i] = combined[MAP(i, len2, mirror)].b;

How it works
When mirror is true, combined associates left[i] with right[len2 - 1 - i]. So, when sorting, the mirror of right is what gets re-ordered as left is sorted. After sorting, right needs to be restored, but it is the contents of combined need to be mirrored back.
Caveats
The routine works fine if left and right have the same number of elements. However, if they do not, strange effects might occur. When len2 is smaller, some of the associated values of right might be associated to values in left that are beyond len2, and combined is left containing uninitialized values. When len2 is larger, the elements of right beyond len1 will not get sorted.
Answer: Finally, the question assumed that the approach used was in the right direction for the context mentioned, but this is not the case, because, as stated in the comments and in @jxh 's answer, this method assumes that the tables are of the same length and furthermore involves an intermediate structure.
So I present here an alternative way of doing things that meets the context.
The aim being to reorder the elements of the two arrays in the same logical order, it is sufficient to sort the first array and then create a new array which, for each new value, will check which one was in the original location and replace it with the value from the first sorted array if it exists (if not, the original value from the second array is placed).
Here is the function:
int cmp(const void *a, const void *b)
{
    const int *A = a;
    const int *B = b;
    return (*A > *B) - (*A < *B);
}

void order(int *left, int len1, int *right, int len2)
{
    int *sortedLeft = malloc(len1 * sizeof(int));
    memcpy(sortedLeft, left, len1 * sizeof(int));
    qsort(sortedInames, len1, sizeof(int), cmp);

    int *rightOrdered = malloc(len2 * sizeof(int));

    for (int i = 0; i < len2; i++)
    {
        bool assigned = false;
        for (int j = 0; j < len1; j++)
        {
            if (right[i] == left[j])
            {
                rightOrdered[i] = leftSorted[j];
                assigned = true;
                break;
            }
        }
        if (!assigned)
            rightOrdered[i] = right[i];
    }

    memcpy(left, leftSorted, len1 * sizeof(int));
    memcpy(right, rightOrdered, len2 * sizeof(int));

    free(sortedLeft);
    free(rightOrdered);
}

Comment: Assumes the arrays do not contain repeated values. But, if this works for you, good job!