I build mouse and keyboard recorder for my program. I write all user events and save in serializable object. Information about mouse and keyboard events I get from other program part with protected fields. That's why for getting values I use reflection like this: foreach (var item in events) {     // Get all protected fields by reflection for EventArgs.      var allProps = item.EventArgs.GetType().GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).OrderBy(pi =&gt; pi.Name).ToList(); }  After this I saved all in serialized object like this. string MouseButton = Convert.ToString(allProps[0].GetValue(item.EventArgs));  But now I found out, that I should use mouse and keyboard simulator. It works fine, but works only with enum MouseButton and Key types. (something like this) public enum MouseButton {     Left = 0x2,     Right = 0x8,     Middle = 0x20 }  public static void MouseDown(MouseButtons button) {     switch (button)     {         case MouseButtons.Left:             MouseDown(MouseButton.Left);             break;         case MouseButtons.Middle:             MouseDown(MouseButton.Middle);             break;         case MouseButtons.Right:             MouseDown(MouseButton.Right);             break;     } }  How I can convert my string MouseButton type to enum MouseButton type for mouse simulator? P.S. i tried get right type for allProps, but it always return object type for me, not real events type.
What's the best way to convert a string to an enumeration value in C#? I have an HTML select tag containing the values of an enumeration. When the page is posted, I want to pick up the value (which will be in the form of a string) and convert it to the corresponding enumeration value. In an ideal world, I could do something like this: StatusEnum MyStatus = StatusEnum.Parse(&quot;Active&quot;);  but that isn't a valid code.
Baffling Elevation Profile out of Profile Tool Plugin When using the Profile Tool plugin I get a graph that looks like the 2nd derivative of what I want. That is, it looks like the rate of change of the slope of the elevation profile. I just want the elevation profile! The data is present for good 1' contour lines. Why is the Profile Tool interpreting the data in such a bizarre way? What am I missing? And what are the Min and Max units? A book with two twins and a difficult relation, a room where time flows slower than the outside and a mysterious monster coming from a sink There was this pocket book, back when I was a teenager (20 years ago), with these two twins discovering a room (it was something like a tool shed) where time flowed slower (1 hour inside was equal to 1 minute outside if i remember correctly).   Inside the shed there was a sink and a strange snake-ish metallic monster was slowly coming out from it.  One of the twins, the one with the "less marked" personality, decides to spend one year (during a whole night) inside the room in order to get out older than his twin.  I don't remember what happens with the monster, I think they destroyed the whole shed in the very end. Computing $ \int_0^\infty \frac{\log x}{\exp x} \ dx $ A company is any form of business whether it is small or large. Generally the term &quot;company&quot; indicates a particular kind of business dealing in a specific product. An organisation is the larger form and generally comprises of a number of companies.  Simply, a company is an organization, but an organization is not just a company. An industry is the combination of companies in same line of business. Firm, corporation and business  are synonyms of &quot;company&quot;. An Agency is a particular kind of company, which serves as an intermediary between clients (other companies or individuals).  Is this correct? Why my differential equations become True? How are virtual functions and vtable implemented? We all know what virtual functions are in C++, but how are they implemented at a deep level?  Can the vtable be modified or even directly accessed at runtime?  Does the vtable exist for all classes, or only those that have at least one virtual function?   Do abstract classes simply have a NULL for the function pointer of at least one entry?  Does having a single virtual function slow down the whole class? Or only the call to the function that is virtual?  And does the speed get affected if the virtual function is actually overwritten or not, or does this have no effect so long as it is virtual. Prove that $\mathbb Z^n$ is not isomorphic to $\mathbb Z^m$ for $m\neq n$ Prove that $\mathbb Z^n$ is not isomorphic to $\mathbb Z^m$ for $m\neq n$.   My try:  Let $\mathbb Z^n\cong \mathbb Z^m $. To show that $m=n$.  Case 1: Let $m&gt;n$. Now that $\mathbb Z^m$ has $m$ generators whereas $\mathbb Z^n$ has $n$  generators and an isomorphism takes a generator to generator ; that is the contradiction.  Please correct me if I am wrong.  The case  $m&lt;n$ also follows similarly. Anime about a boy and a girl who ride ostrich-like creatures through a valley I'd like to find the files in the current directory that contain the text "chrome".  $ find . -exec grep chrome find: missing argument to `-exec'   What am I doing wrong? Which comes first: cat or dog? Which comes first in a sentence?  I know some word pairs such as bacon and eggs, where bacon always comes first. E.g:     Make me bacon and eggs for dinner, honey.   Cats and dogs are the two most common pets I know of. What is the preferred order?   Dogs are superior.     Don't put dogs and cats together, they might fight!  Cats are superior.     Don't put cats and dogs together, they might fight! continuous function: preimage of closure of a set is closure of preimage Repair disk from single user mode (fsck fails) Unfortunately MyApp has stopped. How can I solve this? Let $A$ be a diagonalizable matrix and $\lambda$ be an eigenvalue of A. Prove that rank($\lambda I - A$) = rank(($\lambda I - A)^2$). Let $A$ be a diagonalizable matrix and $\lambda$ be an eigenvalue of A. Prove that rank($\lambda I - A$) = rank(($\lambda I - A)^2$).  The hint they provided is that for any invertible matrix B, rank(AB) = rank (A) and rank(BA) = rank(A). Added activities, now names and labels and strings aren't registering Android Manifest file We know that wizards in the Harry Potter universe are subject to regular physical harm (e.g. witness injuries from being hit by Bludgers or just colliding with things when playing Quidditch).  Therefore, it's almost a certainty that an average wizard would be vulnerable to, say, a bunch of bullets.   There may likely be spell(s) to protect from projectiles - witness Dumbledore's  deployed when Voldemort sent a bunch of glass at him during the  at the end of Harry Potter and the Order of the Phoenix (according to , possibly an unusually powerful Protego or the Silver shield).   But:   those spells obviously take effort/energy/time to cast (not everyone's Dumbledore) AND more likely than not most Death Eaters wouldn't recognize a Muggle gun for a threat (or realize what kind of threat) till too late.   So, the guns should at best allow an over-matched OotP member (e.g. Harry or Hermione) to greatly equalize the power between any regular Death Eaters and themselves, and even perhaps help against Voldemort (who can't be killed with a bullet, but, at best, would need to expend magical energy and time into conjuring a shield, and, at worst, be stopped/interrupted/driven off).  So I'm looking for an explanation - ideally in-universe, but possibly just some statement by JKR - of why the Muggle-born OotP - who are likely very much at ease AND familiar with Muggle technology and live in the late 20th century - do not use guns. Or, for that matter, ANY Muggle technology of the late 20th century? Cue Arthur C. Clarke's "indistinguishable from magic" meme.  Even if they are on some kind of idiotic moral crusade to never kill their opponents (even the Jedi aren't this dumb), given the time-frame, non-lethal weapons would have already existed, such as rubber bullets and tasers.  NOTE: Please don't offer the "if they do it, Death Eaters would start using guns as well" theory. First, Death Eaters would have used the guns if they knew how to, anyway. Second, the guns, like any "secret weapon", could be reserved for strategic battles, say the defense of Hogwarts in Deathly Hallows.    The origin of the question stems from two things.  First, Harry's fascination with all things that are different in the magical world (e.g. moving photographs), based on his knowledge of the Muggle material world, as well as the somewhat amusing cluelessness of the "Muggle artifacts" expert, Mr. Weasley, regarding Muggle items and how they work.   Basically, from the books, it's clear that the Wizarding world wouldn't know details about guns or what they are for or how they work.  The second thing is it's clear, at least initially, that wizards are afraid of Muggles finding out about them. Hence all the efforts to cloak their society (basically, do you REALLY want every Muggle gunning for you, even with Magic)? The idea of how control over the Muggle world seems to be more indirect, by Death Eaters asserting mind-control over the government. This means there's an implicit understanding by Death Eaters that they don't stand a chance against armed Muggles even given the magical disparity.  Considering Harry and Hermione's overall adaptability and inventiveness (and brains in the latter case), it's mind-boggling that the idea of fighting Death Eaters with modern technology completely slipped their mind. I mean, it's a basic part of human myth (see Steel vs. Magic themes in Conan books, or Beowulf, or heck, A Yankee in King Arthur's Court). So it's not like the idea of using technology against magic would be impossible to come up with. The question begs itself - why not? Considering the fact that Rowling generally tried to be logical and consistent in building the HP universe, I feel like there must be some in-universe explanation for this that I just didn't notice.   (in-universe answers only unless there are some authoritative out-of-universe statements that are part of canon). In Ubuntu 18.04, when moving the windows there is a resize effect that occurs when accidentally touching one of the screen edges.  This control was available in CCSM and Ubuntu Tweak in previous versions with Unity.  I'm not finding it in GNOME Tweaks.  I also searched the repository with:  apt search ubuntu.*tweak Metadata and appstream Error while Updating I am getting an error while updating as a root. After Update log below error was shown in terminal.   AppStream system cache was updated, but problems were found: Metadata files have errors: /var/cache/app-info/xmls/fwupd.xml Reading package lists... Done E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/cache/app-info -a -e /usr/bin/appstreamcli; then appstreamcli refresh-cache &gt; /dev/null; fi' E: Sub-process returned an error code   I followed  answer and executed sudo apt install appstream/xenial-backports.  My appstream package is already updated:-  $ appstreamcli --version AppStream CLI tool version: 0.10.6   After, force refreshing the cache data. I am getting the following error:-  $ sudo appstreamcli refresh --force AppStream system cache was updated, but problems were found: Metadata files have errors: /var/cache/app-info/xmls/fwupd.xml One post with multiple questions or multiple posts? I want to ask several questions about the same problem domain but each question is independent from the others. Should I put all the questions in a single post or should I split them and send multiple posts? test class with Batch and Callout I have a problem with FeedItems in my Test class, it's very weird behaviour Does someone explain to me why this happens?  Callout Class  public with sharing class Callout {  public static void runProccess(Case[] records) {     Database.executeBatch(new CalloutBatch(records), 10); }  public static void send(Case[] records) {     Case[] toUpdate = new Case[]{};       for (case record : records) {         HttpRequest req = new HttpRequest();         req.setEndpoint('callout:test/SOME_URL');         req.setMethod('POST');         req.setHeader('Content-Type', 'application/json');         req.setBody('');         Http http = new Http();         HTTPResponse res = http.send(req);          Map&lt;String, Object&gt; response = (Map&lt;String, Object&gt;) JSON.deserializeUntyped(res.getBody());          toUpdate.add(new Case(Id = (Id) response.get('Id'), Status = (String) response.get('Status')));     }      update toUpdate;  } }   CalloutBatch Class  global with sharing class CalloutBatch implements Database.Batchable&lt;Case&gt;, Database.AllowsCallouts{  private final Case[] records;  global CalloutBatch (Case[] records) {     this.records = records; }  global Iterable&lt;Case&gt; start(Database.BatchableContext BC) {     return records; }  global void execute(Database.BatchableContext BC, Case[] scope) {     Callout.send(scope); }  global void finish(Database.BatchableContext BC) { } }   Test Class  @IsTest  private class CalloutTest { @IsTest static void shouldReaciveData() {     String status = 'Closed';     Case caseRecord = new Case(Type = 'Web', Status = 'New');     insert caseRecord;      //insert new FeedItem(ParentId = caseRecord.Id, Visibility='AllUsers', Type = 'TextPost', Body = '');      System.assertEquals(0, [SELECT Count() FROM Case WHERE Id = :caseRecord.Id AND Status = :status]);      Test.startTest();     Test.setMock(HttpCalloutMock.class, new CalloutTestMock(caseRecord.Id, status));     Callout.runProccess(new Case[]{caseRecord});     Test.stopTest();      System.assertEquals(1, [SELECT Count() FROM Case WHERE Id = :caseRecord.Id AND Status = :status]); } }   Mock Class  public with sharing class CalloutTestMock implements HttpCalloutMock {  private Id recordId; private String status;  public CalloutTestMock(Id recordId, String status) {     this.recordId = recordId;     this.status = status; }  public HTTPResponse respond(HTTPRequest req) {     HttpResponse response = new HttpResponse();      response.setStatusCode(200);     response.setBody('{"Id": "' + recordId + '", "Status": "' + status + '"}');      return response; } }   This code works, but when I uncomment insert FeedItem in Test Class I receive an error message:     System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out   Class.Callout.send: line 23, column 1   Class.CalloutBatch.execute: line 20, column 1   FeedItem doesn't have an impact on this functionality, (I don't have any Process Builders, triggers etc. on FeedItem object)