Universally catching a keystroke
C# Mono - Low Level Keyboard Hook
Since I can't find any alternative to Linux'  elevation command, I have the following question:  How to define a PowerShell function which requires elevation? I mean UAC prompt.  Say, such function follows:  function system-check {     SFC /ScanNow }   System:  Windows 8.1 Pro 64-bit  PowerShell:   Major  Minor  Build  Revision -----  -----  -----  -------- 5      0      10586  117    EDIT1:  To be 100% understandable let me rephrase:   I run PowerShell as user I run the aforementioned function system-check I want the function to elevate in order to be able to execute the command; note, that I want the UAC prompt to appear To perform a bit flipping attack, the previous block is modified by using XOR. This results in an altered plaintext. However, now the ciphertext of the previous block is altered, hence it will result in an invalid format. Am I correct or am I missing something?   For example, suppose I have the following plaintext name=jcconvenant;photo=picture.jpg;admin=false;colour=red;  and the correspoding ciphertext c26a5697689463d662f540e55e2a1ecef9c5df20133dfe49d6d3c369679a95ff4f4c5a490f530b2a2f25db40da64f1e9302724ce61b9a435e23f4d600252a143  Suppose we perform a bit flipping attack and get the following ciphertext c26a5697689463d662f540e55e2a1ecef9c5df20133dfe49d6c1d07071c495ff4f4c5a490f530b2a2f25db40da64f1e9302724ce61b9a435e23f4d600252a143  Then the resulting plaintext will still look corrupted.   ¶ä╚°  h8ì│►Nƒz│Ioé¤ßkü2KÀQiý4I@pg;admin=true;;colour=red;  Is there a way to perform bit flipping while still obtaining a valid plaintext? How to find the inverse modulo $m$? For example: $$7x \equiv 1 \pmod{31} $$ In this example, the modular inverse of $7$ with respect to $31$ is $9$. How can we find out that $9$? What are the steps that I need to do? Update If I have a general modulo equation: $$5x + 1 \equiv 2 \pmod{6}$$ What is the fastest way to solve it? My initial thought was: $$5x + 1 \equiv 2 \pmod{6}$$ $$\Leftrightarrow 5x + 1 - 1\equiv 2 - 1 \pmod{6}$$ $$\Leftrightarrow 5x \equiv 1 \pmod{6}$$ Then solve for the inverse of $5$ modulo 6. Is it a right approach? Thanks. How to repair a broken .EXE file association After (hopefully) scrubbing viruses out of a Windows 7 installation (after deciding not to simply run over the laptop repeatedly with my car), I've got everything almost back to normal. The only lingering issue I have is that for my non-admin users, the ".exe" file extension doesn't work. That is, clicking on the various desktop application links results in a "How do you want to open this?" dialog.  I've been through the alleged registry fixing from "winhelponline" and that had absolutely no effect.  I've tried running "assoc" for the affected users, but it reports the .exe association to be "exefile" even though it persistently does not work.  Right-clicking on a desktop icon and then choosing "start" does successfully open an application, but that's clearly a terrible situation.  For my admin user, things seem to work fine.  What do I need to do to get things working? Story [novel, novella?] that featured faster-than-light or hyperdrive gained from observing distant drive use, also had a sentient star I have little recollection when I read this, but it started with people observing indications of some special engine use many lightyears away, and it led them to 'reverse-engineer' the traces to create their own drive.  Had the usual tropes of international crew-selection for first-voyage.  Somewhere in the travel, they encounter a sentient star or quasar.  When they get back hundreds/thousands of years later, they arrive to an uncaring Earth that no longer pursues space-travel. Show/Hide  dropdown, with jQuery, based on value I've got a list of Python objects that I'd like to sort by an attribute of the objects themselves.  The list looks like:  &gt;&gt;&gt; ut [&lt;Tag: 128&gt;, &lt;Tag: 2008&gt;, &lt;Tag: &lt;&gt;, &lt;Tag: actionscript&gt;, &lt;Tag: addresses&gt;,  &lt;Tag: aes&gt;, &lt;Tag: ajax&gt; ...]   Each object has a count:  &gt;&gt;&gt; ut[1].count 1L   I need to sort the list by number of counts descending.  I've seen several methods for this, but I'm looking for best practice in Python. HashSet vs. List performance It's clear that a search performance of the generic HashSet&lt;T&gt; class is higher than of the generic List&lt;T&gt; class. Just compare the hash-based key with the linear approach in the List&lt;T&gt; class.  However calculating a hash key may itself take some CPU cycles, so for a small amount of items the linear search can be a real alternative to the HashSet&lt;T&gt;.  My question: where is the break-even?  To simplify the scenario (and to be fair) let's assume that the List&lt;T&gt; class uses the element's Equals() method to identify an item. I want to automatically split all lines in a QGIS layer at their vertices (). I've done a Google search and found , which is quite close but the workflow is complicated. Because I'll have to train my co-workers (who are unfamiliar with GIS) to use this tool, I want something as simple as a plugin or something that doesn't require GRASS. Since it's been a long time from 2010 - the time of , I wonder if there is any better way to achieve the same result? Let $\mu(\Omega)$ be a probability measure (i.e. $\mu(\Omega) = 1$), and let $f,g$ be non-negative measurable functions on $\Omega$ such that $fg \geq 1$. Show that $1 \leq (\int f^p )(\int g^p)$ for all $0 &lt; p &lt; \infty$   I'm a bit at a loss of what to do. I know that since $fg \geq 1$, we may obtain:  $$\int_{\Omega} d\mu = \mu(\Omega) = 1 \leq \int_{\Omega} fg = \int_{\Omega} |fg|$$ The right-most integral is true since $fg$ is positive and it is equal to $||fg||_1$.  By Hölder's inequality, we obtain:  $$1 \leq \int |fg| \leq ||f||_p ||g||_q = (\int f^p)^\frac{1}{p}(\int g^q)^\frac{1}{q}$$  where $p$ and $q$ satisfy $\frac{1}{p} + \frac{1}{q} = 1$. Raising the left-most and right-most sides of this inequality to the power $p$, I may obtain:  $$1 \leq (\int f^p)(\int g^q)^\frac{p}{q}$$  I now wish to show that $(\int g^q)^\frac{p}{q} \leq \int g^p$, but I've been at a loss of how to do it. Any tips or hints would be greatly appreciated. Why does no one notice the Joker's presence as a policeman during the mayor's speech? I have found that for only one page (so far) the spacing between the header and content is different from the spacing on all the other pages. You can see this behavior in the images below (from pages 2 and 3 of the document):     My .tex file contents are shown below.  \documentclass[a4paper]{report} \usepackage{fullpage} \usepackage{lipsum} \usepackage{fancyhdr} \pagestyle{fancy} \setlength{\headsep}{0.5cm}  \begin{document} \renewcommand{\headrulewidth}{0.4pt} \renewcommand{\chaptermark}[1]{\markboth{\thechapter. #1}{}} \fancyhead[L]{\bfseries \leftmark} \fancyhead[R]{\bfseries \rightmark}  \chapter{Version Control} \lipsum \lipsum \lipsum \lipsum  \end{document} Is it possible to change the linkage of Nether portals? describes how to get the changelog for a given package. However, it's the whole changelog.  What I'd like is a way to see what will be changed in whatever I'm about to upgrade. For example, I was imagining something like:  $ sudo apt-get upgrade --show-changelogs Reading package lists... Done Building dependency tree        Reading state information... Done Calculating upgrade... Done The following packages will be upgraded:   foo     -- adds the bar feature for better snazziness     -- removes the deprecated baz feature  1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 8,864 kB of archives. After this operation, 285 kB disk space will be freed. Do you want to continue [Y/n]?    Unfortunately, I don't see anything like that in the man pages for apt-get. Does this or something similar exist?  UPDATE: I've written a  talking about apt-listchanges and Debian changelogs in a little more depth that incorporates some of the feedback in this question. Create Generic method constraining T to an Enum I'm building a function to extend the Enum.Parse concept that  Allows a default value to be parsed in case that an Enum value is not found Is case insensitive  So I wrote the following: public static T GetEnumFromString&lt;T&gt;(string value, T defaultValue) where T : Enum {     if (string.IsNullOrEmpty(value)) return defaultValue;     foreach (T item in Enum.GetValues(typeof(T)))     {         if (item.ToString().ToLower().Equals(value.Trim().ToLower())) return item;     }     return defaultValue; }  I am getting a Error Constraint cannot be special class System.Enum. Fair enough, but is there a workaround to allow a Generic Enum, or am I going to have to mimic the Parse function and pass a type as an attribute, which forces the ugly boxing requirement to your code. EDIT All suggestions below have been greatly appreciated, thanks. Have settled on (I've left the loop to maintain case insensitivity - I am using this when parsing XML) public static class EnumUtils {     public static T ParseEnum&lt;T&gt;(string value, T defaultValue) where T : struct, IConvertible     {         if (!typeof(T).IsEnum) throw new ArgumentException(&quot;T must be an enumerated type&quot;);         if (string.IsNullOrEmpty(value)) return defaultValue;          foreach (T item in Enum.GetValues(typeof(T)))         {             if (item.ToString().ToLower().Equals(value.Trim().ToLower())) return item;         }         return defaultValue;     } }  EDIT: (16th Feb 2015) Christopher Currens has posted  below, which is well worth a look, and an upvote. I will remove this edit if the solution bubbles further up the page. EDIT 2: (13th Apr 2021) As this has now been addressed, and supported, since C# 7.3, I have changed the accepted answer, though full perusal of the top answers is worth it for academic, and historical, interest :) Is $R^2$ useful or dangerous? I was skimming through  by Cosma Shalizi (in particular, section 2.1.1 of the ), and was reminded that you can get very low $R^2$ even when you have a completely linear model.  To paraphrase Shalizi's example: suppose you have a model $Y = aX + \epsilon$, where $a$ is known. Then $\newcommand{\Var}{\mathrm{Var}}\Var[Y] = a^2 \Var[x] + \Var[\epsilon]$ and the amount of explained variance is $a^2 \Var[X]$, so $R^2 = \frac{a^2 \Var[x]}{a^2 \Var[X] + \Var[\epsilon]}$. This goes to 0 as $\Var[X] \rightarrow 0$ and to 1 as $\Var[X] \rightarrow \infty$.  Conversely, you can get high $R^2$ even when your model is noticeably non-linear. (Anyone have a good example offhand?)  So when is $R^2$ a useful statistic, and when should it be ignored? I had to take ownership of the special folder C:\Program Files\WindowsApps to fix . The issue is now resolved, so I'd like to reset the permissions to the way they were before I took ownership of the folder.  I reverted NT SERVICE\TrustedInstaller to the owner and removed my account's permission entries:     But I still have full control of the folder and can browse the folder in Explorer without getting the usual warning that I would have to take ownership:     Is it possible to restore the default permissions of this folder? If perimeter of a triangle is $2d$, what is the length of sides so the triangle has maximal area?    I found some solution using circle and angles, but I think I have to use derivatives.    I need help. How can one Identify a Magic Item? I had a disagreement with one of my groups recently: They believe that the  spell is the only way to identify a magic item, while I believe a high enough Intelligence (Arcana) check is able to do the same.   What I came here to ask is: What are all the possible ways to identify a magic item? I'm calling a function in Python which I know may stall and force me to restart the script.   How do I call the function or what do I wrap it in so that if it takes longer than 5 seconds the script cancels it and does something else?