How to optimize this code

Question: it has a property:
string Code
and 10 other.
common codes is list of strings(string[] )
cars a list of cars(Car[])
filteredListOfCars is List.
for (int index = 0; index < cars.Length; index++)
{
    Car car = cars[index];
    if (commonCodes.Contains(car.Code))
    {
         filteredListOfCars.Add(car);
    }
}

Unfortunately this piece of methodexecutes too long.
I have about 50k records
How can I lower execution time??
Answer: The easiest optimization isto convert commonCodes from a string[] to a faster lookup structure such as a Dictionary<string,object> or a HashSet<string> if you are using .Net 3.5 or above.  This will reduce the big O complexity of this loop and depending on the size of commonCodes should make this loop execute faster.
Answer: Jared has correctly pointed out that you can optimize this with a HashSet, but I would also like to point out that the entire method is unnecessary, wasting memory for the output list and making the code less clear.
You could write the entire method as:
var commonCodesLookup = new HashSet<int>(commonCodes);
var filteredCars = cars.Where(c => commonCodesLookup.Contains(c.Code));

Execution of the filteredCars filtering operation will be deferred, so that if the consumer of it only wants the first 10 elements, i.e. by using filteredCars.Take(10), then this doesn't need to build the entire list (or any list at all).
Comment: The Linq Join method does the lookup logic for you so that you do not have to specify the HashSet. cars.Join(commonCodes, car=>car.Code, code => code, (car, code) => car)
Comment: @DRBlaise: It is true that `Join` uses a hash table, but it is also an implementation detail, and it is risky to rely on such things as they are subject to change (even if change is unlikely).  If you want to guarantee a certain level of performance, then you should be explicit about the semantics.
Comment: @phenevo: Yes, it is correct, I just didn't notice the part of your question where you said that the codes was a `string[]` and assumed it was an `int[]`.  Obviously the `T` should be whatever type your `Code` is (in this case `string`).
Answer: To do what you want, I would use the Linq ToLookup method to create an ILookup instead of using a dictionary.  ToLookup was made especially for this type of scenario.  It is basically an indexed look up on groups.  You want to group your cars by Code.
var carCodeLookup = cars.ToLookup(car => car.Code);

The creation of the carCodeLookup would be slow but then you can use it for fast lookup of cars based on Code. To get your list of cars that are in your list of common codes you can do a fast lookup.
var filteredCarsQuery = commonCodes.SelectMany(code => carCodeLookup[code]);

This assumes that your list of cars does not change very often and it is your commonCodes that are dynamic between queries.
Answer: you could use the linq join command, like
var filteredListOfCars = cars.Join(commonCodes, c => c.Code, cC => cC, (car, code) => car).ToArray();

Answer: Here's an alternative to the linq options (which are also good ideas): If you're trying to do filtering quickly, I would suggest taking advantage of built in types. You could create a DataTable that has two fields, the id of the car in your array, and the code (you can add the other 10 things if they matter as well). Then you can create a DataView around it and use the filter property of that. It uses some really fast indexing internally (B-trees I believe) so you probably won't be able to beat its performance manually unless you're an algorithms whiz, which if you were, you wouldn't be asking here. It depends what you're doing and how much performance matters.
Answer: It looks like what you're really checking is whether the "code" is common, not the car.  You could consider a fly weight pattern, where cars share common instances of Code objects. The code object can then have an IsCommon property and a Value property.
You can then do something to the effect of updating the used Code objects whenever the commoncodes list changes.
Now when you do your filtering you only need to check each car code's IsCommon property

How to optimize this code


Pitch correction on pitch correction

Question: I'm working on an American movie that was dubbed in German for PAL. Since there is a lot of music and singing it was pitch corrected to sound right at PAL speed.  Now we're doing a blu ray version at NTSC speed (slower). Obviously since there was pitch correction introduced into the PAL the NTSC will be not only slower and a lower pitch but slightly off key. I can correct with my Pro Tools audio suite Pitch Shift, (1.047:1 with speed correction) but there are anomalies.  I'm hearing pulsing in steady notes and some my tracks drift and create echos.  My Accuracy setting is at zero. I know there is software and plug-ins that do this job much better.  Any recommendations?
Comment: Is there a reason an NTSC version is being made from the PAL version, when there's apparently already an NTSC version out there in the world?
Comment:  There is an NTSC M&E but without the specific vocals per language well as the rest of the foreign dialogue. This is a mixed 5.1 German print master. A whole new recording of the vocals would have to be made and the original German dialogue stem added to create the new German NTSC print master. Very expensive. It appears all PAL languages were pitch corrected.  Oh well.
Answer: Seratto Pitch 'n Time has been the defacto plug in for this type of work. However, you will still have some aretfacts as a result of this process.
I am assuming that this is something like an old MGM musical or the like, where the singing wasn't dubbed in German. If so, I would suggest doing so editorial - using the non pictch corrected NTSC English for the musical numbers and the German newly pitch corrected track for the remainder of the film.
Randall Smith
Comment: It's actually a new direct to video animated movie, released domestically today.  Unfortunately there's no budget for remixes of the foreigns for Bluray.
Answer: I have learnt that there are variances in the algorithms used for the same function by different Audio Products. You can use the same Auto Pitch correction in Adobe Audition. I am sure these look familiar to you. In Audtion you can access this by Selecting the Sound Clip and Effects -> Automatic Pitch Correction

If you think you have Pitch Shifts (Pitch is changing linearly as a function of time) you can use Effects -> Time and Pitch -> Stretch & Pitch
If you still have imperfect results. You will have to do manual Pitch correction. A very good tutorial is here

. I don't know about your S/W but audition's graph make it really easy to edit the pitch on a section by section basis as it gives a good idea of the original pitch in comparison.

Pitch correction on pitch correction


How can I use a USB keyboard or mouse to wake from suspend?

Question: I am using GNOME 3.36.6 on Arch Linux. By default, GNOME's automatic suspend option is enabled and it works as expected. However, I have to press the power button to wake the computer from suspend. I want to use my USB keyboard, which works by default on Windows.
The Linux kernel documentation describes how /sys/devices/.../power/wakeup files control whether or not a device is supposed to signal system wakeup. According to the documentation:

The initial value in the power/wakeup file is "disabled" for the majority of devices; the major exceptions are power buttons, keyboards, and Ethernet adapters whose WoL (wake-on-LAN) feature has been set up with ethtool.

This is not the case on my system. When I run grep . /sys/bus/usb/devices/*/power/wakeup, I can see that wakeup is disabled for all USB devices. I found the question Wake up from suspend using wireless USB keyboard or mouse (for any Linux Distro) on the Ubuntu Stack Exchange, which explains how to identify the correct device in /sys/bus/usb/devices and use /etc/rc.local to apply the correct configuration on boot.
All of this seems pretty complicated, difficult to remember, and error-prone. Using /etc/rc.local is discouraged on systemd-based distributions like Debian, Ubuntu, Arch and Fedora. Researching this problem turns up lots of outdated advice (systemd became Debian's default init system in 2015), as well as questions about suspend itself being broken over the years. As of 2020, GNOME seems to lack user-friendly configuration for wake-on-USB; on Windows, this is accessible from the Power Management tab of the device's hardware properties.
What is the simplest and most reliable way to enable wakeup for a specific USB keyboard or mouse, on a modern systemd-based Linux distribution?
(The Arch Linux Wiki page on suspend and hibernate suggests that the answer is probably to automatically configure the appropriate /sys/devices/.../power/wakeup file using systemd-tmpfiles, but identifying a graphical or simple command line tool that makes it easy to select the correct USB device, and is packaged in popular distributions, would be even better.)
See also

Need /proc/acpi/wakeup tweaks to enable mousepad and USB to wake up from suspend: bug logged against Ubuntu's gnome-power-manager package in 2007

Understanding /proc/acpi/wakeup: thread on ubuntuforums.org dating back to 2008

How do I make Ubuntu resume from suspend mode by pressing a key on the keyboard?: unanswered Ubuntu-specific question on superuser.com from 2010

How do I make changes to /proc/acpi/wakeup permanent?: question on Ubuntu Stack Exchange dating back to 2012
Answer: Write the
 echo enabled > /sys/bus/usb/devices/usb1/power/wakeup
 echo enabled > /sys/bus/usb/devices/usb2/power/wakeup
 .....................................................

part of Ask Ubuntu in a script and try it adding it in crontab for root.
Answer: In my opinion the best way is to setup the BIOS for that.
I did it several years ago and it works very well with the keyboard. I never succeeded with the mouse, but it may depend upon your BIOS.
However, for me, pressing any key on the keyboard wakes up the system. You can set on the OS whether you need or not your password to enter your session.
Answer: One solution is to use a udev rule to enable wakeup based on USB vendor and product ID, e.g. add a /etc/udev/rules.d/usb-wake.rules file containing something like:
ACTION=="add", ATTR{idProduct}=="c542", ATTR{idVendor}=="046d", \
    RUN="/bin/bash -c 'echo enabled > /sys%E{DEVPATH}/power/wakeup'"


Op amp non-inverting circuit mystery

Question: I'm working on a project with lots of op amps and so far had no problem but this one is driving me nuts. I need a 1:2 non-inverting amplifier which I built on breadboard but doesn't work as expected. The circuit is trivial, I tried different op amps (LM741,TL072,LM358), use a rail-splitter or just a voltage divider for the bias DC, with our without the DC decoupling caps and yet it doesn't work. It seems that negative half of the signal is gone (yellow being the output signal while the incoming signal is from a signal generator). Thank you for your help in advance!
Comment: What is the label "virtual ground" connected to? Is it left open?
Comment: What power supply voltages are you using and what is the DC offset at the opamp output?
Comment: The power supply is 9V DC and the virtual ground comes from a TLE2425 rail splitter and it's 4.5V.
Comment: The signal comes from the scope's signal generator. It's 3.3V and I tried 0-3.3V DC and did not make much difference.
Answer: You have nothing setting the operating point of your positive input to the op-amp. As such the input bias current of the op-amp is causing C1 to charge up to one of the rails, and it's therefore cutting off part of your signal.
This issue will likely be exaggerated in simulations as well, since few simulations properly account for the input bias currents and input networks of their virtual op-amps. If you are using a simulation, try measuring the voltage on the + input of the op-amp. I suspect you'll find it exceeds the supply rails when the output does so as well.
You need a large-value resistor from the + input of the op-amp to the virtual ground. That resistor will set the operating point for the + input pin, and fix the issue.

Issue as described

Fixed
Comment: The cap on the input *will* block DC, as will the cap on the output. Isn't that why you put them there? If you need your circuit to work at DC, you can't have any caps in the signal path at all.
Comment: It seems to work fine with audio range signal but unfortunately the signal I need the amp for is stepped voltages (control voltage) and the frequency is very low. I'm concerned that the cap on the input might block the DC (which is here unwanted!). Any ideas?
Comment: Thank you!!! I needed to add a resistor from the positive input to the ground (V-) to 'shift' the signal down. You were right!
Comment: If you are trying to measure a signal that exceeds your supply voltages, you will indeed need some way to apply a DC offset correction to it. Your resistor to V- is likely doing this, but you should be aware if you don't have a series resistor inline with the input, you are relying on the signal-source's impedance to form part of a resistor divider. This *can* be a bad idea, if the source impedance can vary, or you have multiple source-devices with different internal resistances.
Answer: It appears that you are referencing ground for V1 (which implies that V1 goes negative at some point), and you are using a virtual ground for a reference and a rail-splitter to set the reference at 4.5V. I am assuming that this means you are using a single-supply setup (op amp Vcc is connected to 9V and Vee is connected to ground). If this is the case, then the op amp is clipping because it can't drive the signal below ground when the sine wave goes below 4.5V. When Vin is below 4.5V (or the virtual ground reference value), the input is negative relative to it, so the op amp will try to drive a negative voltage so that V+ and V- (voltages at the non-inverting and inverting inputs, respectively) are equal.
You have the input source referenced to ground right now (ex. the sine wave input has the minus side connected to ground). Try connecting it to 4.5V. That should allow you to get to 0V on the input source before clipping occurs. Ideally, you would offset it by half of the peak-to-peak voltage, which gives you equal room on both sides. Keep in mind that with a gain of 2 (though as you have drawn the circuit, you have a gain of 4), you should ideally offset the input source by 4.5V, and the peak-to-peak voltage should be no larger than 4.5V, or an amplitude of 2.25V.
Hopefully that helps.

Op amp non-inverting circuit mystery


Map from a curve to the projective plane

Question: I am working on a exercise and I would like to ask you for your help because I am terrible lost. Let us suppose that $C\subset \mathbb{P}^2_k:=\text{Proj}(k[x_0,x_1,x_2]$ is an algebraic curve given by the equation $x_0^2+x_1^2-x_2^2=0$, where $k$ is an algebraically closed field of characteristic zero. We have  a natural map $\phi$ from $C$ to the set of lines of $\mathbb{P}^2$, being this latter space identified with $\mathbb{P}(H^0(\mathbb{P}^2,\mathcal{O}(1))\simeq \text{Proj}(k[y_0,y_1,y_2])$, by sending each point $p$ of $C$ to the line passing through $p$ and the infinity point $(1,0,0)$. My guess is that working in coordinates, the above map is defined as
$$\phi(a,b,c):=(a+1:b:c)$$
But, I would like to know, what is the induced map between the rings, that is
$$k[y_0,y_1,y_2]\rightarrow k[x_0,x_1,x_2]/(x_0^2+x_1^2-x_2^2)$$
I would like to know what is the equation of the image $Y$ of the map $\phi$, and if the morphism $C\rightarrow Y $ is a morphism of algebraic curves, and if the morphism induced between its field of fractions $\Sigma_Y\hookrightarrow\Sigma_X$ has degree 2. Moreover, is it true that $\phi^{\ast}\mathcal{O}(1)\simeq\mathcal{O}(2)?$
Answer: Let $(\mathbb{P}^2)^*$ denote the projective space of lines in $\mathbb{P}^2$. Let $[y_0:y_1:y_2]$ be the coordinates of $(\mathbb{P}^2)^*$, where $[y_0:y_1:y_2]$ denotes the line $$ y_0x_0+y_1x_1+y_2x_2=0. $$
If $p=[x_0:x_1:x_2]\in C$ then the line spanned by $p$ and $[1:0:0]$ is $$
0*x_0+(x_2)*x_1+(-x_1)*x_2=0,
$$ i.e., the map $\varphi$ you define sends $p$ to $[0:-x_2:x_1]$. (Note that $x_1=x_2=0$ is impossible since otherwise $p=[1:0:0]$ which is not on the curve). The image of this map is the variety $$
Z = \{l\in (\mathbb{P}^2)^*\mid [1:0:0]\in l\},
$$ i.e., the variety of all lines that passes through a fixed point (which is itself a line in $(\mathbb{P}^2)^*$). You may see it in the affine patch $\mathbb{C}^2\subset\mathbb{P}^2$ of points with $x_0\neq 0$. Then $C$ is a hyperbola, $[1:0:0]$ is the origin and the corresponding affine patch of the variety $Z$ is the set of all lines in $\mathbb{C}^2$ that passes through the origin.
The induced map between the rings is $k[y_0,y_1,y_2]\rightarrow k[x_0,x_1,x_2]/(x_0^2+x_1^2-x_2^2)$ which maps $y_0\mapsto 0, y_1\mapsto x_2, y_2\mapsto -x_1$.


Services vs Service Application

Question: What is the difference between Services and Service Applications in SharePoint with regards to Distributed Cache? Why is Distribution Cache Service applicable only on Services Level and not as a Service Application level?
Answer:
What Is It?
The SharePoint Distributed Cache service provides additional caching support beyond the options that already exist and have been carried over from SharePoint 2010 and SharePoint 2007 before it (i.e., the Object Cache, BLOB Cache, and Page Output Cache).
The Distributed Cache service is actually built on top of the Windows Server AppFabric Cache. You don't know anything about the Windows Server AppFabric Cache, you say? No worries: SharePoint 2013's prerequisites installer takes care of installing the Windows Server AppFabric and configuring it for cache operations on your behalf. There is no initial action required on the part of administrators to get the Distributed Cache service installed and operational in their SharePoint 2013 environment.

If for some reason you've already installed the Windows Server AppFabric on one or more of your SharePoint servers, it is recommended that you uninstall it and let the prerequisite installer take care of installation and configuration for you as part of the SharePoint 2013 setup process. If for some reason you really want (or need) to set up the Windows Server AppFabric manually, be sure to follow the steps laid-out on TechNet to ensure that the it is configured correctly for SharePoint's usage.

This is very different from Service Applications, where the most common ones isn't preconfigured or setup by installing SharePoint. The SharePoint Administrator/Architect/Business Analyst have to decide whether or not to use a Managed Metadata Service Application, a User Profile Service Application or a Search Service Application.
A SharePoint farm can live without the above mentioned applications, but it can't live well and prosper without a Distributed Cache. And (in the best of worlds) you should not have to care about the Distributed Cache (services on server page), AppFabric Caching Service (services.msc) or the Get-CacheClusterHealth (PowerShell).
To conclude very general (and not always true): Services live and function by themselves, Service Applications need to be configured.
Answer: **Services:**Perform a single or a few specialized operations.Most often accessed by other programs.Often (but not always) targets part of a larger problem domain.
Service Application: Services that are deployed are named service applications. A service application provides a resource that can be shared across sites throughout a farm, and can be accessed by users through a hosting web application. Service applications are associated to web applications by service application connections. Some services can be shared across farms.
What i think why DC is not service application, because it is not giving anything directly to user rather other Service Applications use DC to giving the information to end user. i.e User profile Service's Social feature totally depend upon the DC.
check this: https://social.technet.microsoft.com/Forums/en-US/ceb64350-5fe3-4d55-ba96-13e8142cca78/sharepoint-2010-difference-between-service-and-service-application?forum=sharepointadminprevious

Services vs Service Application


Can SteerMouse sensitivity be automated?

Question: I have to adjust the cursor sensitivity in SteerMouse every time I switch between my home mouse and my work mouse. Is there a way to do this programmatically?
Answer: You should check if SteerMouse supports applescript by opening applescript editor and then clicking File -> Open Dictionary. If it does, please reply back.
In the meantime, there is a indirect solution, which is to have two separate preferences files for work and home and switching between them.
First, set your home settings. You'll find the preferences file at ~/Library/Preferences/SteerMouse.prefs. Copy that and rename the copy to SteerMouse_home.prefs. Then adjust them for work and copy those preferences and name them SteerMouse_work.prefs.
Then, in applescript editor, copy this code and save it as an application.
property myLocation : ""

if myLocation is "" then
    set myLocation to "Home"
end if

if myLocation is "Home" then
    do shell script "mv -f ~/Library/Preferences/SteerMouse_home.prefs ~/Library/Preferences/SteerMouse.prefs"
    set myLocation to "Work"

else if myLocation is "Work" then
    do shell script "mv -f ~/Library/Preferences/SteerMouse_work.prefs ~/Library/Preferences/SteerMouse.prefs"
    set myLocation to "Home"
end if

#You'll only need this part if the app needs to be restarted for the changes to occur.
tell application "SteerMouse"
    quit
    activate
end tell

Comment: In short, move the prefs file and restart the app. Obviously! Thanks! :)
Answer: While @frediemathews answered the question, I wanted to post the code I ended up using.
SteerMouse saves its preferences instantly, so I adjusted the settings three times and copied the preference file each time. I have three AppleScripts which contain code like this:
tell application "SteerMouse Manager" to quit

do shell script "cp ~/Misc/steermouse-prefs/fast ~/Library/Preferences/SteerMouse.prefs"

tell application "SteerMouse Manager" to activate

(SteerMouse Manager is an application which is hidden inside SteerMouse.app)


Can someone please explain the difference between sound frequency and, say, beats per second?

Question: I'm sure this is a monumentally stupid question buy I'm just stumped.  I'm not sure how sound frequency is different than beats per sec from a physics perspective.  Humans can hear down to 20HZ which is 20 compression waves per second isnt it? But when I tap something at 20 beats per second I'm also creating 20 compression waves per second.  Clearly I can hear 20 beats per second and it only becomes more distinguishable as I go lower, so I'm clearly wrong on my interpretation, I'm just not sure how. I know I could tap a 440 Hz tuning fork, allow it to ring for 500ms, do that 20 times per second, and I'd have 20 cycles per sec samples of a 440 cycles per second sound, but if they're both compression waves, what's going on?
Comment: P.S., Any periodic signal can be mathematically _decomposed_ into a sum of sinusoids of different frequencies. Your ears are equipped to actually do that--they contain thousands tiny receptors, each of which resonates with a different frequency. If a sound continuously stimulates some combination of those receptors, then you perceive it as a continuous combination of tones. If the sound contains frequencies lower than any that your ears are equipped to perceive as distinct tones, then you perceive that as the sound changing over time.
Comment: Re, "I'm not sure how sound frequency is different than beats per sec from a physics perspective." Why do you think it _is_ different? The Earth's atmosphere is capable of transmitting so-called "infrasound" signals, where the frequency is expressed in seconds per cycle instead of the other way around, over distances of many miles. Just because your ears are not equipped to perceive infrasound does not mean that the physical principles that underlie it are any different from the physical principles that underlie the sounds that you are _able_ to hear.
Answer: You are exactly right in your thinking. The reason you are confused is that you know humans can't hear below 20Hz but if you are tapping something at 5hz you can definitely hear it. How is this possible? It's because when you tap an object (say the desk with your fingernail) you are creating many frequencies at once. You could download a fft waterfall app for your phone and test this for yourself. The reason it contains many frequencies is that the sound wave resembles an impulse function (a sharp spike). When people say humans can't hear below 20hz they mean that they can't hear a pure sine wave below 20hz.
If you have a good subwoofer you could have it output a 10hz sine wave that you couldn't hear, but you could feel. In real life you can actually hear the 10hz from a subwoofer if it is loud enough because other things in the car will start to vibrate and emit sounds at higher frequencies. But if the subwoofer is made well it will not distort the 10hz sine wave (by rattling or emitting sound at other frequencies) and will therefore be silent. You can also make a 10hz sound by tapping on something, but it will have a ton of other frequency content higher than 10hz that makes it possible to easily hear.
Beats per second and frequency are exactly the same thing. If you tap a 440hz tuning fork 20 times per second you will get a mixture of 20hz and 440hz sound coming from it. The reason for this lies in the mathematics of the fourier transforms. This math tells us that any arbitrary waveform (like the impulse from tapping your desk) can be broken down into a sum of sine waves (like your tuning fork).
Comment: Thanks, I think i get it and what remains of my confusion lies in how the brain processes sound.  Off to study that now.  Thanks.


can a document set welcome page instance have a custom webpart that is specific just to that instance?

Question: i wanted to have a content viewer webpart in my document set welcome page that people could set when their document set was created. i found out that unfortuntely when it is set for one, it applies to ALL of the document set instances. any way around this limitation?
Answer: Using the CEWP, no.
You could, however, approach this a bit differently.  For instance, one way you could accomplish this is to create a custom Visual Studio web part.  In this web part you could do the following: 1) allow the users to enter and save text, 2) this text gets saved as a hidden field on the document set, 3) the web part displays what that field contains when displaying it.  This would allow you to add the web part to each document set instance (like you are currently doing), but it would only interact with the content of the field of the current set.
Comment: let's pretend i have VS 2012 installed, i'm the sharepoint admin and can do whatever i want to the box, and yet i've never (ahem...) created a custom webpart before. where would i find explicit instructions on doing so - your opinion on the best/easiest path?
Comment: Here is a pretty basic overview of how to create a web part (that is wrapping an ASP.NET ASCX user control): http://www.learningsharepoint.com/2012/12/24/how-to-create-a-custom-webpart-in-sharepoint-2013/


iOS 7: modal view controller status bar is wrong color but normal view controllers are correct

Question: I have an issue in iOS7 where a normal UINavigationController pushed view controller has the correct status bar text color for the UINavigationController navbar color (which is a light gray, almost white so the status bar text is black).   However, when a "modal" view controller is presented using -presentViewController:animated:completion:, the status bar text color is changed to white and is very hard to see given the color of the navbar.  Navbar color is always the same across the whole app and does not change for each view controller. This happens on every -presentViewController call.
"View controller-based status bar appearance" is set to YES.
I am not sure what to look at to try and solve this.
Comment: Surely the real issue to solve is the changing background colour on modal popup? Changing the status bar text colour doesn't address the root problem
Comment: This discusses some solutions, but they are a bit hackish: http://blog.ijasoneverett.com/2013/09/ios-7-bugs-the-status-bar-and-modal-view-controllers/
Answer: set YourModalViewControler.modalPresentationCapturesStatusBarAppearance to YES and keep "View controller-based status bar appearance" to YES.
- (void)viewDidLoad {
    [super viewDidLoad];
    self.modalPresentationCapturesStatusBarAppearance = YES;
    ....
}

then overwrite preferredStatusBarStyle
- (UIStatusBarStyle)preferredStatusBarStyle {
    return TheStyleYouWant;
}

Comment: Thank you! Somehow the `modalPresentationCapturesStatusBarAppearance` property had completely passed me by, and until I tried this I had no clue why I couldn't get my modal's status bar showing correctly.
Comment: Worked for me but setting `modalPresentationCapturesStatusBarAppearance = true` before presenting the viewController
Answer: The navigation controller decides whether to have a light or dark content based on its navigation bar's barStyle property. The default, UIBarStyleDefault, means the navigation bar has a light color and the status bar will have dark content. Changing this property to UIBarStyleBlack doesn't actually make the navigation bar black (the color of the navigation bar is still set using barTintColor), but it tells it that it has a dark color. The navigation controller then decides that, since the navigation bar is dark, it should set the status bar content to light.
It appears that on your main navigation controller (on which you push things) the barStyle is indeed set to UIBarStyleBlack somewhere. You have to do the same thing to the modally presented navigation controller, like so:
UINavigationController *newViewController = [[UINavigationController alloc] initWithRootViewController:modalViewController];
newViewController.navigationBar.barStyle = self.navigationController.navigationBar.barStyle;
[self presentViewController:newViewController animated:YES completion:nil];

Comment: Thanks! Works perfect.
Answer: You can redefine the preferredStatusBarStyle method in your navigation controller class
- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
// or UIStatusBarStyleBlackOpaque, UIStatusBarStyleBlackTranslucent, or UIStatusBarStyleDefault

}

and you can also define a "view did load method" to set custom colors you want
- (void) viewDidLoad
{
    UIColor *barColor = [UIColor whitecolor];

    UIView *colorView = [[UIView alloc] initWithFrame:CGRectMake(0.f, -20.f, 320.f, 64.f)];
    colorView.opaque = NO;
    colorView.alpha = .5f;
    colorView.backgroundColor = barColor;

    self.navigationBar.barTintColor = barColor;
    self.navigationBar.tintColor = [UIColor whiteColor];
    [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];

    /*self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
     self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
     [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
     self.navigationController.navigationBar.translucent = NO;*/

    [self.navigationBar.layer insertSublayer:colorView.layer atIndex:0];

}

Comment: I'll have to try it again as it has been a few days, but the preferredStatusBarStyle call was not changing the result for modal presented viewControllers when I had tried that.  I'll try again to make sure.  Thanks!
Comment: Did you try UIStatusBarStyleDefault for yours? I think it's one or the other UIStatusBarStyleLightContent
Comment: This does not fix the problem as described. As long as the app is using VC controlled status bar appearance, the preferredStatusBarStyle method will never be called for modally displayed screens but works great otherwise. This is still happening in iOS 7.1.
Answer: This works.  But I'm not happy with it because it a bit hacky.  I think it's a bug that preferredStatusBarStyle is not called for modal view.  Will ask Apple.
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    [self setNeedsStatusBarAppearanceUpdate];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
    [self setNeedsStatusBarAppearanceUpdate];
}

Comment: @Banana Add `[self setNeedsStatusBarAppearanceUpdate]`.
Answer: I just figured out how to do that. I had the exact same problem and it seems that it works like a charm!
The first thing you need to do is to change an attribute in you .plist file of your project to NO. The attribute is: "View controller-based status bar appearance". If the attribute doesn't exist, don't hesitate to add a new one exactly as I just written to you (without quotes).
The second thing is to add to each view controller's viewDidLoad method
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

if you want your status bar's text to be white or
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];

if you want your status bar's text to be black.
That's all!
Answer: Set UIViewControllerBasedStatusBarAppearance to NO in your info.plist
Answer: I was having the same problem as you were having. The info.plist was correct and everywhere else preferredStatusBarStyle was called correctly. But not in my modal view. That is because preferredStatusBarStyle was sent to the navigation controller. So I made a subclass of UINavigationController that passed on preferredStatusBarStyle to the view controller it was presenting, and voila, all was behaving as it should again
Answer: Having reviewed all the answers provided here and in other answers, I have found that the only solution that worked for me was to create a vacuous navigation bar for the view controller I am presenting modally.
This may not work for you, but it works for me for the following reasons:

My modal dialog has a navigation bar anyways (although it is not used for navigation; it is simply used to either save or dismiss the results.
The status bar color has already been defined application-wide in applicationDidFinishLaunching as discussed above, and it has a custom colour.

It's somewhat annoying from an engineering perspective to have a navigation controller that effectively does nothing, but without one I was unable to get past this problem.
Answer: My solution:
newViewController.modalPresentationStyle = .fullScreen

By default, UINavigationController decides the status bar style and overrides all sub view controllers styles. However, when a modal view controller is fullscreen, its method preferredStatusBarStyle is called.


How to solve cron problem in Wordpress?

Question: I am working with associations using the paid membership Pro plugin but I noticed that the subscriptions are not expiring, I thought that at the beginning it was a plugin problem but I realized that even disabling plugins and themes my posts with scheduling data are not published. Could someone help me how I could do this, I did the test passed in the wp-config function - define ('ALTERNATE_WP_CRON', true); everything seems to work but I see that my url is being changed causing an impact on my SEO for being an unfriendly url. Could someone help me on how can I adjust this cron problem on my wordpress?
Comment: Can you edit your question slightly to help others understand what the actual problem is? You said "my posts with scheduling data are not published" and "my url is being changed causing an impact on my SEO for being an unfriendly url" - maybe you could expand on those problems, with examples of the behavior of a specific post. It is difficult to understand what is being asked.
Answer: If your site is using HTTP Authentication (you know, the dialog/prompt that pops up and asks for your username and password), WP Cron will not work. This is because WP Cron does not present the proper login credentials when making the request. To help with this, there is a free plugin that enables WP Cron when HTTP auth is enabled. Check it out at the WP Plugin Directory: "WP Cron HTTP Auth".
Hope this will solve the problem.

How to solve cron problem in Wordpress?


When can changing a theme damage a website?

Question: My supervisor thinks that changing the theme of an existing website is as easy as clicking a button.
To my way of thinking, depending on the change of theme, areas for posts or pages (or other things) might be added, eliminated, or the layout may stay the same (only the colors or background images may be different, for example). In the case that things get eliminated, if that can happen, is the WordPress developer alerted at all that something bad may be happening, or could the changes eliminate existing work?
In the case the changes eliminate existing work, how would one be able to know (besides scrutinizing the entire web site) how things would be affected. Is it possible to do this before hand?
Comment: ...To answer the title of this post - When you don't have a staging environment to test your theme updates on.
Answer: In short yes. The best way to achieve this is by setting up a staging environment. This will have a carbon-copy of the latest version of your WordPress site. From there, you can update the theme and  verify that everything works as planned.
Once everything checks out, you can apply those changes to your live environment. See this article for more details.
Answer: This is about trust level in the developer.
Full paranoia mode - you don't trust at all and you not only read the change log but also inspect the code. This is the only way to go when any down time means a noticeable loss of money.
Full trust - the themes are from a reputable source you trust, and they claim that things are compatible enough to change the themes. In this case you just go and change the theme. (note, reputable here means they understand user expectations, and have a proper QA, not that they never have bugs)
The (very) wide in between - it is all about risk calculation, how much money/time will you loss if you do the upgrade and it will fail so badly you will have to restore the site from backup. For some sites the cost of setting proper testing environment might be higher.
But as you imply the kind of content you have on the site have a huge impact on the ability to switch themes. In general if you want to be able to change themes easily you should avoid using any of a theme's specific widgets, shortcodes, post meta data, and CPTs. Themes should be used only for front end design, any content related settings should be done in plugins.
If you follow this path when setting up a site, a themes switch should be almost painless with the main risk is incompatible sidebar and menu area names which might require some small effort to re-attach things to where they should be.
Answer: To change the theme name you need to changed it in the style.css file also the folder name but that's not it if you have given static path somewhere in the files it can cause issue. What you can do is just copy paste a theme and change it's name and try to activate that new theme if everything goes well you can take that backup of older one and remove it. hope it's help.


In CrPc (India) can a court discharge or dismiss a complaint against the accused even if a prima facie case is made out against them?

Question: Or is it generally impossible for this to occur and can grounds for not proceeding against an accused be based on anything other than evidence? How do magistrates prevent First Information Reports that are in bad faith?
CrPc = code of criminal procedure
Comment: Your pattern of questions suggest that this is not just of casual interest. If you have been charged with a crime, you need a lawyer, not a group of random Bozos on the internet.
Comment: What do yu mean when you say a prima facie case made out against someone? Is this only in the charging document or is it established with evidence in affidavits and/or a preliminary hearing? What if there are affirmative defenses that are established in pretrial proceesings (e.g. it might be clear that a statute of limitations was established or that the person alleged to be murdered is not dead)?
Comment: oh don't worry. I can assure you it's nothing like that (I do however have a lot of hypthetical law and politics questions with specific topics because those are usually not answered well in text books) @DaleM
Answer: First Information Reports that are "in bad faith" will be (should be) tested in court by the production of witnesses and evidence.
Opportunities to discharge depend on the mode of trial i.e. whether it is a "summons" or "warrant" trial.
For a Warrant's Trial the court can discharge (in addition to the prima facie provisions at CrPc 227 referred to by this related answer) under:

CrPc 239:

If, upon considering the police report and the documents sent with it under section 173 and making such examination, if any, of the accused as the Magistrate thinks necessary and after giving the prosecution and the accused an opportunity of being heard, the Magistrate considers the charge against the accused to be groundless, he shall discharge the accused, and record his reasons for so doing.

Or under:

CrPc 245:

(1) If, upon taking all the evidence referred to in section 244, the Magistrate considers, for reasons to be recorded, that no case against the accused has been made out which, if unrebutted, would warrant his conviction, the Magistrate shall discharge him.
(2) Nothing in this section shall be deemed to prevent a Magistrate from discharging the accused at any previous stage of the case if, for reasons to be recorded by such Magistrate, he considers the charge to be groundless.
[with a West Bengal ammendment]

But there are no provisions to discharge in a Summons' Trial see this detailed article (by Anirban Bhattacharya and Bharat Chugh)

The recent order of the Supreme Court in Amit Sibal, appears to be the much needed course correction and seems to suggest that the trial court has no power to drop proceedings / discharge in a Summons Trial. This also appears to be in sync with the settled judicial view and also the scheme of CrPC, wherein separate and distinct procedures have been laid down for Warrants, as opposed to Summons Cases (or those cases triable summarily for that matter).


Voltage signal from a Geiger-Muller counter

Question: In a Geiger-Muller counter which is the signal produced?
If we imagine the tube as a capacitor, we intially have a certain voltage between the plates (the cilinder and the filament). But when the electrons arrive at the anode and they are collected by it, the voltage falls? And slowly the positive ions will reach the cathode, so they invert the voltage?
Which is the correct behaviour of the signal produced?
Answer: When the gas in the tube becomes conducting the usual method of detection is to have a resistor connected between the cathode and the negative end of the power supply.
This converts the current pulse into a voltage pulse which can then be detected and counted.
This method of detection of a current pulse at the cathode is preferred to the detection of a pulse in the anode part of the circuit.
One reason is that the stray capacitance of the detecting circuitry will have less effect on the characteristics of the tube when connected to the much larger cathode as compared with the relatively small anode.
On hitting the cathode the slower moving positive ions are neutralised but at the same time can emit secondary electrons.
On gaining electrons the ions can become excited atoms (some of the electrons are above the ground state configuration) and emit photons which could start the avalanche process again as can the secondary electrons.
So as well as argon gas in the GM-tube there is a small amount of quenching agent present (bromine or chlorine) and the atoms of the quenching are more easily ionised than argon because of their lower ionising potential.
The argon ions can take electrons from quenching agent atoms and when they hit the cathode there is less chance of the emission of secondary electrons.
There is also the possibility of the emission of photons by an argon ion after it becomes an excited argon atom.  These photons could also trigger further avalanches (pulses).  The photons emitted by the excited quenching agent atoms are of smaller energy and thus less likely to produce further avalanches.


Why is benzoic acid a stronger acid than 3-aminobenzoic acid?

Question: Why is benzoic acid a stronger acid than 3-aminobenzoic acid? Obviously at meta position, only negative inductive effect will operate. But, how does that make it a weaker acid than benzoic acid?
Answer: The $\mathrm{p}K_\mathrm{a}$ of benzoic acid is $4.2$. The $\mathrm{p}K_\mathrm{a}$ of aniline (aniline's conjugate acid really) is $4.8$.
The two macroscopic $\mathrm{p}K_\mathrm{a}$s of 3-aminobenzoic acid (aniline-3-carboxylic acid) are $3.1$ and $4.8$.
When the microscopic $\mathrm{p}K_\mathrm{a}$s of two groups in a molecule are similar, the macroscopic $\mathrm{p}K_\mathrm{a}$s are not reflective of one particular group protonating/deprotonating. The neutral form will include both a zwitterionic and an non-zwitterionic form in the case of 3-aminobenzoic acid.
When the groups are close in space within the molecule, there will be electrostatic interaction. If the amino group is protonated, it facilitates deprotonation of the carboxylic acid group. If the carboxylic acid group is deprotonated, it facilitates protonation of the amino group.
Addition: There is a very relavent article: Carbon-13 NMR determination of acid-base tautomerization equilibriums J. Org. Chem., 1984, 49 (4), pp 691–696.  It reports that the neutral species is 59% zwitterion and 41% molecular (non-zwitterion).
Answer: 3-Aminobenzoic acid exists as a zwitterion in solution (just like aminoacids, which the given compound is, just not natural) thus instead of existing as  $\ce{C6H4(COOH)(NH2)}$ it exists as  $\ce{C6H4(COO^-)(NH3+)}$,  thus instead of $\ce{-COOH}$ acting as the acid group, $\ce{-NH_3+}$ acts as the proton donor, and as we know that $\ce{NH_3+}$ is a weaker proton donor than $\ce{COOH}$, we can say that $\ce{C6H4(COOH)(NH2)}$ (3-aminobenzoicacid) is a weaker acid than $\ce{C6H5-(COOH)}$ (Benzoic acid).
Comment: Please don't post the same answer twice. Also for future reference, check the help pages (site guide) and [guides to formatting chemical equations](https://chemistry.meta.stackexchange.com/questions/86/faq-how-can-i-format-math-chemistry-expressions-on-chemistry-stack-exchange).


Ideal Gas Vs Real gas

Question: If ideal gas equation is formulated using ideal gas concept then why is the same equation used for real gases os they are not the ideal gases
Comment: The ideal gas law is an excellent approximation to the behavior of real gases at low pressures and high specific volumes.
Answer: For real gases there are some contradictions in the assumptions made while defining real gases.
Therefore some corrections were needed in the equation which were given by van der waals in his real gas equation
The van der Waals equation corrects for the volume of, and attractive forces between, gas molecules:
(P+a(n/v)^2)(V-nb) = nRT
There are two corrective factors in van der Waals equation. The first,   , alters the pressure in the ideal gas equation. It accounts for the intermolecular attractive forces between gas molecules. The magnitude of a is indicative of the strength of the intermolecular attractive force.
The factor - nb accounts for the volume occupied by the gas molecules. b has units of L/mol. Since b corresponds to the total volume per mole occupied by gas molecules, it closely corresponds to the volume per mole of the liquid state, whose molecules are closely layered. b is generally much smaller in magnitude than a . The values of a and b generally increase with the size and complexity of the molecule.
Comment: The van der Waals equation does somewhat correct for real gas behavior, but it isn't a particularly good correction. There are other corrections that do a better job.
Comment: For starters... https://en.wikipedia.org/wiki/Real_gas

Ideal Gas Vs Real gas


Why can´t i select the image frame?

Question:
So I am trying to select the frame in order to zoom out a little as
I normaly do, but somehow i can´t select it. I tried it in other files and it worked there. I recognized that there is normaly a clear black outline at the frame but in this case it´s somehow missing. What am I doing wrong?
Comment: That frame is the camera view. It can only be selected in Object mode. If you click on the edge is should make the camera the active object. If you can't activate it by touching it could be that the camera selection has been disabled in the outliner (the arrow between the eye and camera icons). An alternative way to navigate would be to select the camera and  use [Lock Camera to view](https://blender.stackexchange.com/a/45116/1853).
Answer: I have the answer. I noticed that there was no camera in the layers I wanted to render. I simply had to additionaly select the original layer where the camera was placed in order to manipulate the camera view.

Why can´t i select the image frame?


Sql Server Management Studio does not have access to a .bak file on a remote server

Question: I'm trying to restore a database backup that is on a server. This server is on a remote machine and runs in a docker container. The container OS is Ubuntu 20.04.
I can access the database, make queries on the master, etc. But when restoring the database, the .bak file is not visible to Sql Server Management Studio.
How do I solve this problem?
Comment: If you type `*.*` in the `Nome do arquivo` (`File Name`) textbox and hit enter, do you see any files listed after that?
Comment: I can list the files when I select the "All Files" option in the checkbox next to it. But the .bak file still doesn't appear.
Comment: And you do see the same files as your command window (other than the .bak file)?...e.g. `Entropy.bin`?
Answer: The restore wizard is not using your permission for local or remote folders but it uses the SQL Server account permissions.
You need to give SQL Server Engine service account proper rights to reach that network location.


How to make platforms spawn without touching other platforms

Question: So I am making a doodle jump like game where there are platforms scrolling by but right now how I have platforms spawning is completely random. I would like the platforms to be spread apart so they weren't touching but don't have much of an idea to implement it. I was thinking of using the distance formula to check to make sure that they were apart but I was thinking that as I was creating those object I would have to check with all the previous objects before to see if they weren't colliding. Does anyone have any ideas on how to make this work efficiently?
Answer: You could keep it simple.
Methods:

Randomly generate platforms, if a newly generated platform's position is overlapping, simply don't use it and randomize another position. It will work unless the platforms are very dense which they should not be.
Another way to do it is to use slots across the Y-axis and never use the same Y slot. For instance if the height of the screen is 100 units and a platform's height is 5 units, divide the screen into 20 discrete logical slots and pick one at random  and never pick the same one twice. This could be accomplished by storing the empty slots in a pool.

In general arrays are not very fast O(N) when you need to remove a random item. To be able to quickly remove items from an array, you may want to shuffle the array and only pick items from the end. In your specific case the size of the array should be < 1000 so it will likely have no noticeable effect.
You may also simply want to shuffle the array and then iterate on the array in order, never reusing items your previously picked.
Comment: I like the second option but was wondering how would I accomplish that? Would I store those positions in an array and have each platform choose one position in the array and then remove that position from the array once it has been used?
Comment: tl;dr Yes. You can use an array and erase an item after you use it.


How do I delete unpushed git commits?

Question: I accidentally committed to the wrong branch.
How do I delete that commit?
Answer: Delete the most recent commit, keeping the work you've done:
git reset --soft HEAD~1

Delete the most recent commit, destroying the work you've done:
git reset --hard HEAD~1

Comment: And make sure HEAD~1 is the commit... You could also do `git reset --hard origin`
Comment: make sure HEAD is pointing at the branch.. (check it out first)
Comment: Thought `git remote` lists origin for me, `git reset --hard origin` says `fatal: ambiguous argument 'origin': unknown revision or path not in the working tree.`. Why?
Comment: `git reset HEAD~1` will also keep all your changes but will leave you with an empty index rather than keep everything (as the `--soft` option would).
Comment: Why was this upvoted? It's completely wrong and doesn't answer OP's question. Running `git log HEAD@{1} -1` will still show you the commit you supposedly "destroyed".
Comment: The `--hard` option just blew up _all_ of my unpushed commits, instead of just the most recent one. No thanks...
Comment: @MikhailT. I'm sure it wont help you anymore, but lost commits can be found doing `git reflog`
Comment: @trss if you get the "ambiguous origin" error, you need to specify the branch like- `git reset --hard origin/feature/my-cool-stuff`
Comment: Just as additional info, you can use HEAD^ instead of HEAD~1. The result will be the same as soon as the HEAD is pointing at the right palce ;-)
Comment: For first commit: `git reset origin/master`
Comment: NOTE: That actually modifies your folder locally. If you want to just remove commit but not make any changes to your work use: git reset HEAD~1 --soft
Comment: Another option is the one I use.  "git rebase -i", delete the commit(s), and add "noop" as the only action.  Without the noop rebase makes no changes.  I like this way, because I see exactly what I'm removing.
Comment: This actually removed the work for me (with `--soft)` --'
Comment: worked for me, `git reset --soft HEAD~2` (2 insted 1) then `git pull` and all ok ! thank you !
Comment: beware, `git bisect reset` seems to do the same thing. I lost commits I had not yet pushed to the remote repo.
Answer: I wonder why the best answer that I've found is only in the comments! (by Daenyth with 86 up votes)
git reset --hard origin

This command will sync the local repository with the remote repository getting rid of every change you have made on your local.
You can also do the following to fetch the exact branch that you have in the origin as Cleary suggested in the comments.
git reset --hard origin/<branch>

Comment: Thanks for this, expanding the explanation slightly: for a specific branch: `git reset --hard origin/`
Comment: Or `git reset --soft origin/`, if you want to get rid of the commit but keep the local work.
Comment: Brilliant! This actually works, unlike the "accepted" answer which just detaches the head and leaves you hanging.
Comment: i get `fatal: ambiguous argument 'origin': unknown revision or path not in the working tree.`, you need to specify the branch like: `git reset --hard origin/feature/my-cool-stuff`
Comment: How do you link to a comment?
Answer: Don't delete it: for just one commit git cherry-pick is enough.
But if you had several commits on the wrong branch, that is where git rebase --onto shines:
Suppose you have this:
 x--x--x--x <-- master
           \
            -y--y--m--m <- y branch, with commits which should have been on master

, then you can mark master and move it where you would want to be:
 git checkout master
 git branch tmp
 git checkout y
 git branch -f master

 x--x--x--x <-- tmp
           \
            -y--y--m--m <- y branch, master branch

, reset y branch where it should have been:
 git checkout y
 git reset --hard HEAD~2 # ~1 in your case,
                         # or ~n, n = number of commits to cancel

 x--x--x--x <-- tmp
           \
            -y--y--m--m <- master branch
                ^
                |
                -- y branch

, and finally move your commits (reapply them, making actually new commits)
 git rebase --onto tmp y master
 git branch -D tmp

 x--x--x--x--m'--m' <-- master
           \
            -y--y <- y branch

Comment: @KatariaA That is a valid alternative to deleting the commit done on the wrong branch and will help others in the same situation (good commit done on wrong branch).
Comment: unfortunately, that was not the question.
Answer: Do a git rebase -i FAR_ENOUGH_BACK and drop the line for the commit you don't want.
Comment: If you end up removing all the commits, you can add "noop" as the action, or rebase takes no action.  This is my preferred version, because it's very clear what you are changing.
Answer: If you want to move that commit to another branch, get the SHA of the commit in question
git rev-parse HEAD

Then switch the current branch
git checkout other-branch

And cherry-pick the commit to other-branch
git cherry-pick <sha-of-the-commit>

Comment: From my experience, this does not undo the commit from the original branch, thus necessitating the `git reset --hard HEAD~1` afterwards.  I think using `reset --soft` then switching branches and committing again would have saved extra work.  Then again I was using SourceTree to do most of my basic stuff, only command line-ing it with this after my error.
Answer: Following command worked for me, all the local committed changes are dropped & local is reset to the same as remote origin/master branch.

git reset --hard origin
Comment: This is a copy of https://stackoverflow.com/a/54323316/3714940
Comment: I did not notice that response, I tried that command & it worked for me, I posted response accordingly.
Answer: For your reference, I believe you can "hard cut" commits out of your current branch not only with git reset --hard, but also with the following command:
git checkout -B <branch-name> <SHA>

In fact, if you don't care about checking out, you can set the branch to whatever you want with:
git branch -f <branch-name> <SHA>

This would be a programmatic way to remove commits from a branch, for instance, in order to copy new commits to it (using rebase).
Suppose you have a branch that is disconnected from master because you have taken sources from some other location and dumped it into the branch.
You now have a branch in which you have applied changes, let's call it "topic".
You will now create a duplicate of your topic branch and then rebase it onto the source code dump that is sitting in branch "dump":
git branch topic_duplicate topic
git rebase --onto dump master topic_duplicate

Now your changes are reapplied in branch topic_duplicate based on the starting point of "dump" but only the commits that have happened since "master". So your changes since master are now reapplied on top of "dump" but the result ends up in "topic_duplicate".
You could then replace "dump" with "topic_duplicate" by doing:
git branch -f dump topic_duplicate
git branch -D topic_duplicate

Or with
git branch -M topic_duplicate dump

Or just by discarding the dump
git branch -D dump

Perhaps you could also just cherry-pick after clearing the current "topic_duplicate".
What I am trying to say is that if you want to update the current "duplicate" branch based off of a different ancestor you must first delete the previously "cherrypicked" commits by doing a git reset --hard <last-commit-to-retain> or git branch -f topic_duplicate <last-commit-to-retain> and then copying the other commits over (from the main topic branch) by either rebasing or cherry-picking.
Rebasing only works on a branch that already has the commits, so you need to duplicate your topic branch each time you want to do that.
Cherrypicking is much easier:
git cherry-pick master..topic

So the entire sequence will come down to:
git reset --hard <latest-commit-to-keep>
git cherry-pick master..topic

When your topic-duplicate branch has been checked out. That would remove previously-cherry-picked commits from the current duplicate, and just re-apply all of the changes happening in "topic" on top of your current "dump" (different ancestor). It seems a reasonably convenient way to base your development on the "real" upstream master while using a different "downstream" master to check whether your local changes also still apply to that. Alternatively you could just generate a diff and then apply it outside of any Git source tree. But in this way you can keep an up-to-date modified (patched) version that is based on your distribution's version while your actual development is against the real upstream master.
So just to demonstrate:

reset will make your branch point to a different commit (--hard also checks out the previous commit, --soft keeps added files in the index (that would be committed if you commit again) and the default (--mixed) will not check out the previous commit (wiping your local changes) but it will clear the index (nothing has been added for commit yet)
you can just force a branch to point to a different commit
you can do so while immediately checking out that commit as well
rebasing works on commits present in your current branch
cherry-picking means to copy over from a different branch

Hope this helps someone. I was meaning to rewrite this, but I cannot manage now. Regards.

How do I delete unpushed git commits?


How do I reinstall Bonjour

Question: Should I reinstall Bonjour after I got an message : File Problem: M DNSResponse.exe
How do I go about doing this?
Answer: This might be more relevant on superuser.com but here's the steps

Go to the Control Panel and click on Add or Remove Programs.
Select Bonjour from the list.
Click Change/Remove.
Choose Remove, then follow the onscreen instructions.
Reinstall Bonjour for Windows from the Apple website, or the media on which it was supplied to you.

How do I reinstall Bonjour


Load Testing Vaadin 6.3.4

Question: I need to load test a Vaadin application.
I found this link explaining how to use JMeter with Vaadin however I can't get it to work. I suspect the problem are my MenuItems since Vaadin 6.4 ChangeLog mentions that some change was made to MenuItems in order to make Vaadin MenuItems HTTP-Level tester friendly. However upgrading the Vaadin 6.4 and 6.5 yielded no better results.
Here is my problem, I need to load test my Vaadin application to prove it will work with at least 50 concurrent users. However the async nature of Vaadin means that most tools have no idea when a response has taken place or whether it is correct. How can I script a test and emulate 50 users? Any help will be much appreciated I've tried a lot with Selenium and other tools but their scripts never execute reliably. Has anyone load test a vaadin app? If so how?
Answer: Selenium does not work out of the box with Vaadin apps, that partially is why TestBench exists.
The easiest solution to your problem is to add a sleep to each request in jMeter. It's ugly and needs some experimenting to get the sleep times good enough. And it's not completely fool-proof. It might however be enough for you to prove that 50 concurrent users works.
Another thing is to add some kind of client-side rendering and use JS to check if there is still an existing connection from client to server. TestBench uses something like this for implementing a waitForVaadin() function that checks if the request is complete. Here's some discussion: http://vaadin.com/forum/-/message_boards/message/236584#_19_message_236823
Comment: We actually ended up writing our own vaadin test suite. Thanks for you help though, but this doesn't answer my problem as Vaadin 6.3.2 seems to have plenty of components like MenuItems which simply tools like selinium is not picking up.
Answer: Vaadin uses many technical ids for the components, so in order to automate a realistic navigation you need to correlate those ids.
You can read this blog which illustrates the use of a commercial plugin for Open source Apache JMeter that does auto correlation for you.
You just record and you can replay, all correlation is done by plugin.
Disclaimer : We are provider of this solution

Load Testing Vaadin 6.3.4


Is it known whether Kaori Miyazono is half-Japanese?

Question: Her dad had a pretty big nose, if we want to go there. Nothing is said on the Wikia. And this question doesn't really matter... but I'm sure people want to know! Was Miyazono half-Japanese? What indications are there that she was?
Comment: @Mindwin your phrasing... that better be intentional.
Comment: This question is not primarily opinion-based; a factual answer exists and is one of "yes, she is"; "no, she isn't"; or "there is no evidence for or against her being half-Japanese". If you think the question is bad, please cast downvotes instead of voting to close it.
Comment: I don't even see why this question gets upvotes. This is as good as asking if character X is half japanese because his/her parent/s has Y feature. Completely speculative and unsubstantiated to even begin as a question.
Comment: Apparently her father has a Japanese name. For all I care, he doesn't look overtly foreign either, so I'm assuming Kaori probably isn't, particularly since it seems like the sort of detail that would be disclosed _somewhere_.
Comment: We can't even be sure she is blonde, she might be dyeing.
Comment: @Mindwin: In the OVA, which shows the characters as children, Kaori already has blonde hair, but I don't think this is actually indicative of much. (Takeshi is also already blond as a kid, and Tsubaki already has her brown hair. I find it difficult to imagine small children dyeing their hair, and well, hair colour in anime these days doesn't seem too consistently realistic anyway.)
Comment: @Maroon so she wasn't dyeing. one less "e", then.
Answer: There is no evidence to suggest that Kaori is half-Japanese. I discuss my reasons for this assertion below.

The fan wiki for Your Lie in April makes no such assertions about the ethnicity of Kaori. Were there an indication or (obvious) suggestion that Kaori is half-Japanese in official material, I would expect someone to have noted it.
Kaori's parentage is straightforward, and her parents have Japanese names and do not look overtly foreign.
We cannot extrapolate any information about ethnicity from the characters' hair colours. While Kaori had blonde hair even as a child (as seen in the OVA), so did Takeshi. Tsubaki already had brown hair (rather than black) as a child. Takeshi's sister, Nagi, is also blonde. It is difficult to imagine primary school students dyeing their hair, but it is also difficult to imagine that all of these characters have significant non-Japanese heritage. It is best to chalk this up to a lack of realism in anime hair colours.

As far as I am concerned, I would thus err (at the time of writing) on the side of assuming that Kaori is not half-Japanese. Were Kaori half-Japanese, it would seem to be such a large character detail that it would have to be disclosed somewhere.
Comment: Two other possible pieces of evidence stem from (1) Kaori's grandparents (which are mentioned in the wiki, but whom I don't recall seeing) and (2) the live-action film, which I have not watched (although it's not uncommon for films to misrepresent "canon" ethnicity).
Answer: There is no direct answer to this question, but the fact that she has blue eyes is what would leave me to believe she could be at least only half Japanese. This trait is almost never found in people of Asian decent specifically Japanese. Often times I have also noticed that in many other Animes they make the foreigners (western/European) also have blonde hair and blue eyes. (oc she could be dying her hair.)


Communication between hardware components

Question: We know that each component has different frequencies, but what happens when a fast component directly comunicates with a slow one?
Comment: (I remember the term *connected components* from graph theory, not hardware.)
Comment: I couldn't find a tag so I didn't had much choice (I edited now)
Comment: Did you have a specific architecture or type of hardware in mind? For example mixing RAM speeds means you may need to manually over click one or have them running at the slowest of the speeds. Can you add some more specifics about the problem to the question?
Comment: Just generally speaking about any component, just what happens when a fast comunicates with a slower one.(Directly)
Comment: @ C8H10N4O2 What do you mean by over click? Select them manually?
Answer: I think what you're asking is how two machines or components, which run at different clock speeds/phases, can communicate. The short answer is that the receiver synchronises to the sender.
In low-speed communication channels (e.g. I²C), this can be achieved with an explicit clock line. Essentially, the sender has a separate wire that is the transmission clock. This is also generally the way that things work with parallel busses (e.g. where you send 8 bits over 8 wires plus a clock).
This doesn't work as well at high speed, because a small difference in the lengths of two wires can cause signals to arrive at different times. It also doesn't work over channels where there you don't or can't have more than one "wire", such as radio.
If you only have one "signal" (be it a single pair of wires, single radio frequency, or what have you), you are in the domain of line coding.
In that case, the receiver can synchronise by looking for edges in the source signal. There is an agreed-upon clock rate, which neither end can reproduce perfectly. But if the sender sends the message 00101001, for example, every time the bit flips from 0 to 1 or 1 to 0, that is something that the receiver can synchronise to.
Exactly how to synchronise clocks is a question for electronics engineers, who can explain techniques like phase-locked loops to you better than I can. It's a little subtle because the receiver can detect edges, but ideally wants to take its sample from the half-way point between the leading edge and the trailing edge, so there has to be some kind of delay involved.
But what if there are no edges? If the transmitter wants to send a whole bunch of zeroes, how does the receiver synchronise then?
The way around this is to design a code which does have transitions. RS-232, for example, specifies that each byte begins with a start bit, and ends with one or more stop bits, and there is a zero between the two frames, so every byte effectively has the bits "101" between bytes.
Medium-speed channels where retransmission is not an option (e.g. digital broadcast, satellite/spacecraft communication, or recording media such as optical disks) will often use error-correcting codes to achieve the same effect. Not only do you get error correction, the extra redundancy gives plenty of opportunity for clock synchronisation.
And then, you get into physical problems to do with the fact that you're communicating over physical wires or physical radio signals.
Over wires, for example, it's desirable to design a code with approximately the same number of 0 bits and 1 bits, a property known as DC balance. Real pairs of wires will act like a capacitor at high speed, and so if you have (say) more 1's than 0's, they will retain a charge and hence resist sending 1's. An example of a code designed for this is 8b/10b, which is used in a lot of modern high-speed serial communications such as HDMI, SATA, Gigabit Ethernet, and USB 3.0.
See this question from electronics.SE for further details.
Radio communication (e.g. Wi-Fi and cellular telephony) has its own problems that I can't really cover here, even if I understood it all. You have to protect against the Doppler effect, destructive interference caused by reflections, and so on.
Answer:
what happens when a fast component directly comunicates with a slow one?

They must both be able to communicate and the same speed, regardless if it an async or sync type channel.
Consider the channel capacity as the block rate on average or burst mode.  In any event each side must either acknowledge ready or not (eg DTR DSR) or (ACK NAK) unless it is something of lower value then it may not and just stream it and hope the recipient can keep up without errors E.g. streaming Video, UDP.
I have a 1Gbps ethernet connection to router, but only 100 /5 Mbps modem so the channel capacity is limited by the thruput limitations of the weakest channel and host which is often somewhere on the web.
A slow firestick might be able to stream HDMI video at a Gbps video speed yet never be able to process video internally at that speed.
Buffers
To enhance byte thruput, the  penalty is latency but the benefit is slack time to load each word. E.g. DS1 digital audio might have 1 byte buffer for low fixed latency per repeater even if MUX'd from 1.544 Mbps to OC96. Whereas a UART usually has 16 byte buffer for Rx to handle interrupts without buffer over-run flag being set.


Preview Microsoft Word in Greyscale?

Question: If I have a Microsoft Word document with colour images, but I have a monochrome printer, how can I preview the document in greyscale to verify what the printed document will look like?
Answer: This is a late reply, but I wanted to share the method that I use for future reference. I found it useful to instead of changing the document's color scheme, just change the display to greyscale.
I use an nVidia graphics card, in order to do this go to desktop, right click -> nVidia Control panel -> adjust desktop color settings (left tab) -> set "Digital Vibrance" at 0.
This is a little cumbersome, but is better than changing the entire document by hand.
Comment: This is not a direct answer to previewing in Microsoft Word, but it's a great workaround, and definitely the best answer in almost two years! A more general solution that should be compatible with most video cards (mine is Intel) is to set "Saturation" on the video card to 0; that has the effect of setting all colours to greyscale. This lets me preview the document (or anything else on my screen) in greyscale and then change back the settings when I'm done.
Answer: Using Word 2013 I cannot get the print preview to show in grayscale.
One thing I was able to do is save it as a PDF file via CutePDF and then use Acrobat Reader's print dialogue to preview the document in grayscale.
I know it's a somewhat lengthy workaround but it's better than nothing :-)
Answer: I was unable to get the print preview to show in grayscale.
However, I have another suggestion on top of the one provided by MonkeyZeus.
This may not be an efficient way to do this depending on how many pictures you have in your document.  If you only have a few, you can change the color of each photo to 'greyscale' by double clicking the picture, which brings up the Picture Tools.  Click on the color button and choose greyscale.
That should give you a good idea of what it will look like when printed.
Hope this helps!
Answer: I've found another solution that works. Right click on start menu, hit settings, ease of access -> colour filters, then turn on colour filters and set the filter to be grayscale.
Comment: Is that in Word or do you mean the Windows settings?
Comment: I'm talking about the Windows setting here. I'm not sure if there's an equivalent for Mac/Linux, I suspect there should be.
Comment: This solved it for me. Although at the time of writing, for Windows 10 you don't need to go through ease of access - you just need to go Settings -> type in 'Colour filters' to get there.
Answer: If you want to verify specific pictures, you can select the picture then:

Right click->Format picture
Go to the tab with the image icon.
Expand the "Colour tone" area.
Then you can set the saturation for the picture to 0.

When you are done, there is a preset to reset it to 100 in the icon that looks like a coat-hanger.

Preview Microsoft Word in Greyscale?


To lease or buy when I have the cash in my RSP

Question: I am retired, collecting a pension, CPP & OAS. I also have money in my RSP, which becomes taxable when I withdraw it. I purchased, for cash & a trade-in, a 2014 BMW SUV. Sale price was $39000. This vehicle is now coming up to the 4 year warranty & full servicing anniversary, which means it will no longer covered. I believe it is probably worth $25000 as a trade-in on a purchase price of approximately $50000 or so. I would now like to replace it with a newer model BMW SUV which will again be covered for servicing & warranty. My dilemma is - do I withdraw funds from my RSP & have my OAS clawed back or do I lease the new purchase?
Comment: consider buying a normal used car for say $3,000.  you will save an incredible amount of money, particularly on insurance, repairs, upkeep.
Comment: I remember years ago reading J Paul Getty's book "Being Rich" where he noted that you should buy things that appreciate in value and rent things that depreciate, adding that most people do the opposite, they buy their cars but rent their houses.
Comment: Are you sure that you've provided all the necessary information?  I don't know Canadian law, but I would expect your income to matter to this determination.
Comment: Not familiar with Canadian tax laws, but if "_money in [your] RSP is taxable when [you] withdraw it_", then presumably it will _always_ be taxable when withdrawn, and in effect you should simply view the "RSP pot" as being that much smaller. That's not to say you shouldn't think carefully about whether to _use_ this pot or not (as opposed, say, to paying servicing bills) **but** you shouldn't let "_having to pay tax on the withdrawal_" be a determining factor.
Comment: Are you planning on keeping this vehicle for four years before trading it in?
Answer: Any OAS clawback you might incur by withdrawing additional RRSP amounts, would certainly wipe out any ownership cost-benefit analysis comparing buying vs leasing. Further, you quite possibly would be drawing additional income at higher tax bracket than you normally would, so it isn't true to say that drawing RRSP's today is the same as drawing tomorrow - you want to use up your bottom tax brackets as much as you can, without going into new brackets.
A more complete answer would require knowing your full income amounts and any other tax impacts, but I would find it almost impossible that buying through use of RRSP-drawn funds is preferential to simply leasing and making payments over time.
Of course you could buy the car and finance, and still take out only small amounts to pay the loan over time. There would be little difference in your case vs the regular lease vs finance case. If you are anti-debt, consider that leasing is just another form of debt, and either way you end up paying interest for the use of someone else's funds.
All in all - just don't buy it in cash.
Answer: Presumably if you are retired you will be drawing down from your RRSP at some point, so the issue of whether to do it now or later becomes a cost benefit analysis. Assuming your income is unlikely to change in the future most of the variables cancel out and it becomes a question of whether you are likely to pay more on a lease over that period of time compared to the growth of whatever investments you are holding in your RRSP.
So the calculation should be (Additional cost of leasing a vehicle) - ($25000 * whatever rate your RRSP has been growing by historically).
*Note: this answer ignores the effects of reduced taxes on capital gains from dividends your investments may be paying out as the effect should be marginal.
Comment: This answer is incomplete as is it really sidesteps the specific Canadian tax impacts in play.


Kernels for Categorical or Mixed Data

Question: It appears that when data sets have a combination of categorical and continuous attributes, the common way to apply kernel algorithms to such data sets is to use a one hot encoding scheme for each categorical variable - this requires replacing a categorical variable with K levels with K dummy indicator variables. I am interested in unsupervised applications of kernel methods. I tried the above idea (performing PCA) on a data set with mixed attributes using an RBF  kernel but the eigenvalues I got did not have the desirable scree plot look. I am aware of Multiple Correspondence Analysis, I am just curious if there is a way to do this using kernel methods - perhaps a better encoding scheme or better choice of kernel etc. I'd appreciate any insights in solving this problem with kernels.
Answer: I'm not an expert on mixed data but there are indeed some kernels that combine continuous and categorical attributes, such as the clinical kernel. In the paper where the clinical kernel was proposed you will most likely find other approaches and proposals in the references. There are also some follow up papers using that kernel with good results.
Comment: Thank you. I apologize for the late reply - but I just saw this.

Kernels for Categorical or Mixed Data


Non-Assembly DLL in bin

Question: We are trying to use WebSupergoo's ABCpdf .NET v10.  And it works great if we use their installer.  But v8 is already installed on the server with other projects using it, so we do not want to run the installer at this time. (Hopefully in the near future we can test the install on a different machine and/or upgrade those projects, but this project cannot wait on that.)
The "Manual Install" instructions from WebSupergoo (http://www.websupergoo.com/helppdfnet/default.htm?page=source%2F3-concepts%2F6-installation.htm) indicate to place the 3 main DLLs (ABCpdf.dll, ABCpdf10-32.dll, and ABCpdf10-64.dll) into the bin folder and add a reference to ABCpdf.dll.
We don't really want them in the bin folder, because Source Control is set to not add anything from that folder.  However, to get it working (for now) they were placed in that folder.  Then when I attempt to run the project, I get the following error (folder names changed for security):
<code> System.BadImageFormatException was unhandled by user code
  HResult=-2146234344
  Message=Could not load file or assembly 'file:///D:\\Projects\Solution\WebProject\bin\ABCpdf10-32.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
  Source=mscorlib
  FileName=file:///D:\Projects\Solution\WebProject\bin\ABCpdf10-32.dll
  FusionLog==== Pre-bind state information ===
LOG: Where-ref bind. Location = D:\Projects\Solution\WebProject\bin\ABCpdf10-32.dll
LOG: Appbase = file:///D:/Projects/Solution/WebProject/
LOG: Initial PrivatePath = D:\Projects\Solution\WebProject\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: D:\\Projects\Solution\WebProject\web.config
LOG: Using host configuration file: D:\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Attempting download of new URL file:///D:/Projects/Solution/WebProject/bin/ABCpdf10-32.dll.
ERR: Failed to complete setup of assembly (hr = 0x80131018). Probing terminated.

  StackTrace:
       at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
       at System.Reflection.Assembly.LoadFrom(String assemblyFile)
       at WebActivator.PreApplicationStartCode.Start() in D:\Code\Bitbucket\WebActivator\WebActivator\PreApplicationStartCode.cs:line 11
  InnerException:
</code>
Our prefered method would be to have them in a "lib" folder (currently at the Solution level).  So, I put the 3 DLLs in that folder and added the reference.  The project compiles and runs, but when we attempt to create the PDF we get the following error:
<code>Unable to load DLL 'ABCpdf10-32.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
</code>
WebSupergoo support says: "ABCpdf10-32.dll is not an assembly so of course it does not contain an assembly manifest".
I tried taking ABCpdf10-32.dll out of the bin folder, and I get the same error with ABCpdf10-64.dll.
I tried setting "Copy Local" on reference to False. No change.
Copy Local: https://msdn.microsoft.com/en-us/library/t1zz5y8c(v=vs.90).aspx
I tried using the "Probing" technique. I tried it in both the web.config & app.config file for the Project (there doesn't appear to be one for the Solution).  I also tried moving the lib folder to within the project itself. No change.
Probing: https://msdn.microsoft.com/en-us/library/823z9h8w(v=vs.110).aspx
I'm not sure what else to try at this point.  Any help would be greatly appreciated!
Answer: System.BadImageFormatException its a general exception, that use to occur when you are using a 32 bits DLL on a 64 bit enviroment, or viceversa.
Web apps: they use to load all the dlls on the folder, used or not (WebActivator.PreApplicationStartCode.Start()).
Check the IIS pool, it's 64 bit? Then delete all the 32 dll on the folder or subfolders.
Are you forcing it to 32? Then delete all the 64 dll on the folder or subfolders.

Non-Assembly DLL in bin


Obese guy first time flying

Question: i'm flying from Frankfurt to Seattle(condor airlines - Boeing 767-300 economy class) in few weeks for the first time, and the seat width in the plane is 17 inches,while my width is around 19 inches, will there be any problems ?
Comment: Well of course from the measurements you quote there will be problems. You can purchase two seats for comfort or hope you get an empty seat adjacent to you. People have been known to get into arguments even fights with seatmates over such _inconveniences_
Comment: @KeithLoughnane I've always (within in the United States) raised the armrest the first thing I do before I even take my seat when traveling with my wife and I've never heard an announcement about armrests needing to be lowered for takeoff/landing..

Qr14: 2" inches should be no problem, especially with a raised armrest.  An aisle seat might be a bit more wiggle room but then you face bumps from passengers and drink carts.
Comment: @MarkStewart It may be that US internal flights are lax about safety procedures. For international flights though, they will *always* insist on armrests being up.
Comment: @MarkStewart a window seat might also provide more room, though on smaller planes the curvature sometimes means that there is less room for the feet or head.  At least there is no bumping from the aisle traffic.  It's occasionally possible to lift the outer armrest on a window seat by finding the secret switch under the armrest.  I've actually managed this only once.  A sympathetic flight attendant might help with this, though I suspect that the switch is hidden because of some regulation or another.
Comment: As a note, depending on your airline premium economy might be cheaper than buying two seats and a better experience on a very long flight.
Comment: Thanks for your answer. I'll try to lose those 2 inches in few weeks, but i'm also traveling with someone, could that help? I've seen that you can lift the arm rest, somewhere on google..
Comment: Where is your width 19 inches? Does that include your arms?
Comment: @phoog upper part of my legs(im not sure if you call it like that) and my buttocks is 19, arms are around 20 inches
Comment: You can't lift the armwrest during takeoff and landing. If you can squeeze in and you have for instance a window seat while your friend has the center seat it could be ok but be warned planes and tight places even for most people.
Comment: It's probably too late now but it might have been good to take a shorter flight first e.g. Paris.  I expect that you will survive but it might not be very pleasant.  Even without this challenge, I find such a long flight in economy quite a tough experience.  You need to balance how much you want to do the trip, how much you can afford, and what discomfort you can bear.  My personal choice is to bear the discomfort of economy so that more of my budget is available to spend at the destination.
Comment: @KateGregory I've just read that and it looks like "i wont have problems" because of 1 inch.. Also the passenger next to me is way smaller, so the armrest will also help me a lot.. Thanks everyone for helping me out, i feel way better right now, i also might lose that inch or more in 2-3 weeks. Thanks again, have a nice day.
Answer: As the 767 has 2-3-2 seating and you are travelling with a companion, if you are able to select seats, you can:

book 2 seats on one of the sides, and use the window seat for yourself. There's usually a little bit of extra room on that side, at chest/arm level (there's of course plenty of extra room at chest/arm level if you are in an aisle seat, but then you get bumped into constantly).
book 2 aisle seats on the same row in the central portion, which an empty seat between you. There's evidently no guarantee that it will remain empty, but such seats are always the last to go, so if the flight isn't completely full, you may have an empty seat next to you. If there's someone in the end, they will probably gladly switch their middle seat for an aisle seat. The further back in the plane you select the higher the chances the seat will remain empty, usually.

Note: do NOT book seats on the first row of any section (like row 22 for instance, and 23 on some versions). You may have extra legroom, but the TV screen and/or tray table are often in the armrest, so the armrest can't move and is usually thicker than on other seats, reducing width even more.
Comment: Excellent point about the front row seats.  Some people quite like being in the front row, though I (at 6'5" or 195 cm) generally do not, because even though my knees and shins are happier in the front row, I usually cannot stretch my feet enough.  If OP ends up in the front row, though, it should not be too difficult to find someone willing to switch, since most people view these seats as more desirable.
Comment: Traveler can try to select a seat based on information from https://www.seatguru.com/
Answer: Many airlines do have rules around this (primary for safety reasons). Typical are

If the seat belt doesn't close, they will give a seat belt extender
If one extender isn't enough either, you may be prohibited from flying since they think you can't be kept safely in the seat during severe turbulence (which is rare, but happens)
Both armrest need to be able to come down. If you the arm rest won't go down, you need to buy an extra seat. Some airlines have an extra category for this type of seat

I couldn't find the specific rules for Condor so I recommend to contact the airline directly and ask.
EDIT
It looks like Condor flies a 767 with a 2-3-2 configuration on this route. If you buy an extra seat and you and your companion get a 3 seat row in the middle, you'd be quite comfortable. It's a lot of extra money, but it's also an 11 hour flight.
Answer: You can purchase an extra seat or make sure there is an empty set next to you. Some people get annoyed when people take up to much room. You can push the armrest up if you want.
Comment: If you want and your neighbour agrees (unlikely) or you don't have one, of course.
Comment: You can only push the armrest up after takeoff. During takeoff and landing, the armrest between you and your neighbour needs to be down. No exceptions.
Answer: Since you're flying on an aircraft with a 2-3-2 configuration and mention that you're flying with someone who is much smaller, I'd recommend picking one of the groups of two seats on the side. Assuming the person you're flying with is ok with it, you can raise the armrest between you. The armrest on the aisle generally must be kept down during takeoff and landing, but you can usually raise the one between seats if it is movable.
You should avoid picking the bulkhead seats (the first row in a given cabin,) as these often (including on some of Condor's 767 configurations) have the tray table stored in the arm rest. This significantly reduces seat width at the hip area and also makes the arm rest immovable (so you can't raise the arm rest between you and the person you're traveling with.)
Of course, another option would be to pay to upgrade to business class. These seats are 19" wide. They also fold out into a bed, which makes sleeping on a long-haul flight much easier than in economy, though, in Condor's case, the beds are angled downward somewhat rather than being fully flat, as on most of the major airlines' modern business-class products.
Condor currently operates 3 different seating configurations on their 767s, but all of them are 2-3-2 in economy and 2-2-2 with angle-flat seats in business. You can find the current configurations on Seat Guru's page for Condor.
Answer: Flying with assigned seats, I request the aisle seat, as a broad broad.  I unapologetically request a seat belt extender from the attendant first thing.  Sometimes, if there is not much of a crowd around, I request one as I pass upon entry.  I smile and am polite.  I do not attempt to fasten my seatbelt until I obtain the extender.  I pull the armrest up before being seated.
When I get the extender, I fasten it, but only after all passengers have been seated in my row.
If I am flying Southwest where seats are not officially assigned except A, B or C, I am careful to log in early as possible before leaving for the airport in order to register for Group A which enables me to be seated during the first group.  I choose an aisle seat, and like above, I request an extender, waiting to fasten my seatbelt until everyone has been seated in my row.  While I am waiting for Groups B and C to be seated, I make myself appear as fat and unhappy as possible.  I frown.  That's all.  I make eye contact with every person who walks down that aisle, and, using my very best "Resting "bit*&face" expression, magically, no one chooses to sit next to me.  Easy peasy.
Never apologize for your size.  I don't like have half my thigh flopping over into the next seat, but I am wider than a 140 lb person.  So what?  The airlines choose to make their seats 17 inches (barely) and no one is "comfortable" during a flight.  You have a right to be there just like the tiniest person does. Some people talk incessantly, some have horrible breath that knocks you out from 10 feet away, some drink heavily, crunch chips or nuts in your ear, some people need a bath or don't use deoderant.  Others fart.  We are each different.  There are a number of things that make me physically or mentally uncomfortable when I fly.  My extra girth is the thing that makes others uncomfortable with me.  I am aware of it.  I wonder if they are equally as self-aware of their own idiosyncrasies.
Happy traveling!
Answer: You will be fine.  Everybody fills up the seats on planes these days no matter how large or small, not to worry.
My dad worked for an airline and the 17" measurement is not always accurate.  They have to list the smallest seat that might be on a plane and not all seats are that size.  He also used to point out that the seat measurement is for the butt pad (for lack of a better word) and does not include the area that the arm rests flare out.  Hope that helps, have a good flight!
Answer: I'm a pretty broad person, and fly regularly. I buy one seat, generally on one of the edges (in 3-3 configurations). If you can get into the exit row, you'll have more leg room. Personally, I found flying to be uncomfortable even before I gained weight. It's uncomfortable, and it sucks. If you can get an edge seat, with your companion beside you, you could be more happy about being in such close quarters.
The idea that you should be required to purchase an additional seat because people are made uncomfortable by sitting next to a fat person is valid if you want to, but by no means necessary. I am made uncomfortable by sitting next to strangers who talk to me during flights, but I recognize that there are things I can do to mitigate that.
If you are still nervous, I would encourage you to look up resources by fat people regarding flying while fat-- there's a lot of them. But I wouldn't bother buying an extra seat. It's a huge amount of money. Flying on its own is stressful enough, don't add the stress about your body onto it. Everyone is uncomfortable and cramped on an airplane. That's just
Comment: It's not "made uncomfortable" like not knowing which gender pronoun to use. It's "made *actually* uncomfortable" due to physical dimensions remaining.  The indignity of someone else intruding upon ones own space that one *paid good money for*, and the concomitant disrespect for the concept of ownership,  is secondary.
Comment: It is by all means necessary to purchase a second seat or a ticket in a higher cabin class with wider seats according to the contracts of cartridge of many airlines.
Comment: Buying a comfort seat isn't necessarily expensive - you won't pay the taxes or surcharges, just the fare, which in economy may only be a modest proportion of the cost of a second ticket. However it'll depend on the airline's policies and unfortunately I'm not familiar with this carrier.
Comment: I'm not familiar with Condor, but some airlines will actually refund the price of the second seat to you if the aircraft is not sold-out. For example, I seem to recall reading that this is Southwest's policy.

Obese guy first time flying