Change old external ultegra brake cables to under the tape brakes

Question: Is it possible to change my old external ultegra brakes to integrated brakes ?
Comment: In case it's not obvious from the answers, those are the shift cables not the brake cables that are externally routed. Your brake cables are already under your bar tape
Comment: What do you mean exactly? Change the STI brake levers/shifters for ones with the shifting cable routed under the bar tape? Possible, but why? Route the brake and shifting cables internally through the frame? Impossible if the frame hasn't been designed for it.
Comment: yeah under the bar tape.. Why ? just because of curiosity i guess x)
Comment: A sideways option - you can try binding the gear cable loops with cable ties or heatshrink, but that tends to kink oddly when you turn.  Not recommended.
Answer: Yes you can change your STI brake levers/shifters for ones with cable routing under the bar tape. There is nothing special required.
However I see very little advantage in routing under the bar tape. It looks slightly better (subjectively) and improves aerodynamics slightly. Personally I upgraded from 105 5600 (good old "washing lines") to 105 5700 due to a broken shifter. I have the impression that the 5700 with cable under the bar tape shifts slightly worse, which wouldn't be surprising considering the sharp bent required.
I assume these are Ultegra 6600 STIs? They are 10 speed. Unfortunately the only compatible 10 speed shifters with routing under the bar tape are the 105 5700. Ultegra 6700, Ultegra 8000 and 105 5800 are all 11 speed. You'd have to upgrade your rear derailleur, cassette and chain as well.
Edit: Oh, Ultegra 6700 is 10 speed and has routing under the bar tape. Thanks to JoeK for pointing that out. So you could go for either 105 5700 or Ultegra 6700.
The 10 speed Tiagra shifters are incompatible with other 10 speed rear derailleurs.
Comment: Ultegra 6700 is 10sp. 6800 was the first 11sp group at this level.
Comment: Current (4700) 10sp Tiagra is compatible with 10 speed GRX. There's also the old 10 speed Tiagra (4600) which uses the legacy 10 speed road cable pull
Comment: *the sharp bent required*  And that sharp bend is usually where the cable frays.  So not only is shifting worse, cable life is dramatically shorter.  And when it does need to be changed, the under-the-tape routing makes replacing the cable that much harder.
Answer: Yes, with some qualifications. I'm guessing you've got Ultegra 6500 shifters, for a 9-sprocket cassette. Current Ultegra shifters are designed for use with an 11-sprocket cassette, and Shimano differentiates its road groups, in part, by the number of sprockets they work with; the group that works with 9-sprocket cassettes currently is Sora. Here are the three options I can think of.

If you replaced your levers with Sora levers, that should work with no further modifications.
If you wanted to stick with Ultegra to maintain a consistent level of "fanciness" throughout your bike, things get more complicated. 11-speed cassettes require a different freehub body (the part of the hub that the cassette slides onto) with a tiny bit more width for the cassette; freehub bodies often can be replaced, but it's obviously more of a to-do. So that would require you to change cassette, freehub body, levers, chain (chain widths are different, and it's generally a good idea to replace your chain when you replace your cassette), and rear derailleur (Shimano 11-speed derailleurs have a different cable-pull ratio).
Your current freehub body will work with a 10-speed cassette; the 10-speed generation of Ultegra levers (6700) did route the shift cables under the bar tape. So for this, you'd need new levers, cassette, and chain. You would have to buy these levers used or find someone selling them as new old stock.

Compatibility can be complicated and there are some weird edge cases; I'd read this set of articles before spending any money.
Answer: The levers in the picture are from the generation where the shifter cables were 'non-aero' (Shimano designated them that way) meaning that they ran out of the top of the brake-levers to an anchoring point on the downtube. It was only later types where the routing of the cables turned by 90° backwards to the handlebar which enabled the housing to follow the same route as the brake cable housing and to disappear under the bartape.
Unfortunately you cannot switch the routing in the way you intend. The inner workings of the levers are totally different.


"Let me say this on the outset …"

Question: Is "let me say this on the outset" formal English in business-speak? What does it really mean?
Answer: "Let me say this at the outset"
It's reasonable in a speech, but probably wouldn't be used in written English.
It means "let me make this clear at the start". Outset = setting out (as in a journey) = start.
Answer: It's a strange phrasing; I would expect "Let me say this at the outset".  It's a bit bombastic and only really appropriate to spoken English, but it's certainly formal enough for business use, if that's what you're after.  It normally means that the speaker is calling attention to something that he or she believes should in some way be kept in mind as an important factor in whatever process is presently beginning.
Answer: Let me say this at the outset is an odd construction. It is an informal way of expressing someone wishes to make a point clear before other points are made.
There are several alternatives that are equally colloquial and probably more common:

Let me make this clear. (Assertive, possibly confrontational in some contexts.)
Let's address this now. (Cooperative, objective.)
Allow me to be upfront about this. (Candid, frank.)
I should mention now that... (More informal, objective.)
Answer: It's a bit like saying "Let me be frank."  It's not terribly formal, and it's also an expression that you wouldn't understand unless you had already been explained what it meant, which is in general bad when you're goal is to be clear in business talks.

“Let me say this on the outset …”


Sources for supporting a married couple

Question: The way I understand, it has become common in recent times for the parents of the girl, to offer a monthly stipend for a period of time after marriage. Is there a source for doing this?
Comment: @LazerA - Can you perhaps record these sources?
Comment: @LazerA Are these sources about supporting one-who-learns in general, or specifically a child for a certain number of years after marriage? And GershonGold, if it is the general one, is that what you want in this question?
Comment: If you're talking about just supporting a young married couple when the husband is not learning, I doubt there are any sources for such a practice (though people may have done it for any number of reasons). However, if you're talking about supporting a couple so that the husband can devote himself to Torah study then there are numerous sources that speak of this as a praiseworthy practice.
Comment: So, you are confirming that the question is the latter? If so, b"n, I will try to collect a few sources when I have time.
Comment: @DoubleAA If my memory serves me correctly, there are a number of sources that specifically speak of the merit of supporting one's sons and/or sons-in-law so that they can study Torah. I don't recall any of the sources setting a time limit.
Comment: _Mohar_ is mentioned as early as _sefer B'reshis_.
Comment: @msh210 Is this _mohar_?
Comment: @DoubleAA, dunno. Sounds like it.
Comment: @msh210 I think you have it backwards. Mohar is from groom to bride. Nedunya is from bride to groom. Either way, if this were nedunya, then the bride should get back the value of the stipend if she is divorced or widowed. That's the whole point of nedunya.
Comment: @DoubleAA, yes, I meant _n'dunya_ (or _nadn_).
Answer: This practice, or at least the idea broadly, is endorsed by Rambam who writes the following in Hil. Matnot Aniyim (10:15):

הנותן מזונות לבניו ולבנותיו הגדולים שאינו חייב במזונותן, כדי ללמד הזכרים תורה, ולהנהיג הבנות בדרך ישרה ולא יהיו מבוזות, וכן הנותן מזונות לאביו ולאימו--הרי זה בכלל הצדקה; וצדקה גדולה היא, שהקרוב קודם
One who provides sustenance to his grown sons and daughters whom he is not required to support so that the males learn Torah, and so to lead the daughters in the proper path and that they not be disgraced, as so too one who gives sustenance to his father and his mother--this is included in charity. And it is a significant [example of] charity; for relatives take precedence. (translation my own).

Significantly, his wording ולהנהיג הבנות בדרך ישרה ולא יהיו מבוזות definitely seems to include cases besides for supporting the husband learning, and apparently cases besides for supporting the wife learning. Furthermore, his natural transition to speaking of supporting one's mother and father, making no mention of doing this to facilitate their study, strongly implies that besides for support to facilitate study, Rambam endorses all support for grown family members who could use it. Today, many people's primary financial concerns begin after marriage, and it is then that Rambam's statement would be most applicable.
Indeed, Rambam writes explicitly in Hilkhot Matnot Aniyim (7:13) that supporting one's family takes precedence over charity to others:

עני שהוא קרובו, קודם לכל אדם

Note: Rambam does not limit his statement to support after marriage. It seems probable that continuing to feed and house one's unmarried children would qualify as well. However, he certainly includes cases after marriage.
Comment: this seems to me with a father giving his son money to learn or his daughter money not to be embarrassed. This does not indicate that one should support his son in law.
Comment: @GershonGold a) I suspect that the plural term הזכרים refers to all the male household members. Including the SIL. || b) assuming the interconnected financial statuses of one's daughter and son-in-law, support for one's daughter, **is** for all intents and purposes, support for one's SIL. || c) the juxtaposition of this statement with support of parents indicates that, as he states explicitly, this is not a particular **din azza** pertaining to this person, or that, but rather a general philosophy of prioritizing one's kin. This certainly applies to one's SIL.

Sources for supporting a married couple


Firefox no sound (v57.0.2) in Windows 10 rs_prerelease 17063

Question: Firefox 57.0.2 is unable to play sound after switching to this Windows release.
Also affects Nightly and Developers edition
eg youtube video plays on chrome/edge not on firefox.
Answer: Logged and confirmed as a known issue by Microsoft.
Microsoft response
Windows has several audio volume APIs - IAudioEndpointVolume, IChannelAudioVolume, ISimpleAudioVolume, and IAudioEndpointVolume. These APIs can be used to change the volume and/or mute state of the stream, app, or audio device.
In build 17063 a change was made to these APIs to have them return S_FALSE (1) if the requested change was a no-op.
This broke apps (like Firefox) which request changes (that may be no-ops) and then explicitly check the return value against S_OK (0).
Answer: It was determined to be a Firefox bug. The problem has been fixed in Nightly, and should make its way to 58 beta, 57 release and 52 ESR as soon as possible


Nonnormal covering space of Klein bottle by Torus

Question: I've been trying to construct a non-normal covering space for a Klein bottle $K$ by some torus $T$.
I've found some non-normal subgroups of  $\pi_{1}(K)= \langle a,b \mid a b a b^{-1}=e \rangle$ that should correspond to Torus covering spaces, e.g: $<a^{3},a^{2}b^{2}>$, but I'm not sure how to describe the covering map $p \colon T \to K$, especially how do I set a partition of the fundamental polygon of $T$ into the squares representing $K$.
Comment: I gave an example [here](https://math.stackexchange.com/a/251234/265452).
Comment: Why didn't you accept your own answer?
Answer: Ok, I got it.
Let $a$, $b$ span a lattice $\mathbb{Z}^{2}$ in $\mathbb{R}^{2}$. If we are considering the covering space corresponding to $\langle a^{i}b^{j},a^{k}b^{l} \rangle \le \pi_{1}(K)$, we can choose the parallelogram $P$ made by vectors $ia+jb$ and $ka+lb$, then cut it into squares along the lattice. An edge of $P$ within each square can be mapped homotopically onto the boundary of the square, and the composition of these boundaries should give back $a^{i}b^{j}$ or $a^{k}b^{l}$ that corresponds to the edge.
Take the case $\langle a^{3},a^{2}b^{2} \rangle$ as an example:

In the parallelogram, the edge $c_{1}$, $c_{2}$ are homotopic to $ab$, $a^{-1}b$, so the edge $c_{1}c_{2}$ is presented by $aba^{-1}b=a^{2}b^{2}$.


Sharepoint 2010 - Infopath, should we be using it?

Question: The company I am working for is just starting out on Sharepoint. None of us have experience using it.
The on-line training courses do not seem to tell the whole story. My Google search on Infopath shows that it is not popular, but most of the comments I have found have been on the 2007 version.
What about the 2010 version? Is Infopath a good choice in that it is quick and easy? Is it a good choice for mobile devices? You can use the application rather than the web form so you do not have to be concerned about broweser compliance?
Comment: I'd suggest to flip a coin. The InfoPath story looks very similar to the SilverLight story. Your concern should not be just your current version, but also what will happen in the next 2-3 years.
Answer: It depends on your organization, I am SharePoint administrator for a government agency and in the US government there is a big push to go completely paperless. In that aspect InfoPath is good at generating forms and being able to submit those forms straight into SharePoint making things nice and easy. On the other hand when you start creating a lot of InfoPath forms there can be a lot of overhead in the management of those forms ie. updating, editing, legal... Just think of a situation that your organization uses a form on a daily basis and create it in InfoPath and see if it works for you. When you implement digital signatures into the forms you start to see how your organization can go completely paperless.
Hope that helps.
Answer: Practically InfoPath enables easy creation of Forms using ways familiar for Office users. Behind the scenes actually the forms are stored as XML which enable advanced customizations & development scenarios that could allow for further manipulation. At the same time InfoPath enables IT-Pro audiences to embed advanced business rules & logic, connect to other data sources (e.g. Web services, other SharePoint lists, etc.), used by example in building cascaded lists scenarios, etc.
For business users (IT-PRO) there are essentially 2 types of Forms:

Edit forms for SharePoint Lists - enabling fast customizations of how
new/edit/display forms are looking & behaving
Forms libraries - create templates with advanced grouping & repeatable sections, which can than be submitted and stored as an Xml file directly in a library (a file). Publishing the form also can be combined with something known as "promoting fields" which practically translates in automatic storage of data during submission of the InfoPath. SharePoint collects data from InfoPath and stores it in fields just as with regular forms.

There is much more to say about the InfoPath, such as Administrator published forms, or publishing to Content Types, etc. but I hope this gives you an idea.


iOS Prefix.pch best practices

Question: I have seen many developers that add various convenience macros to the Prefix.pch of their iOS projects.
What do (or don't) you recommend adding to the iOS Prefix.pch file? What does your Prefix.pch look like?
Comment: Simply put your macros into a header file, for example `Macros.h`, and then import this file into your `prefix.pch`.
Comment: A detailed blog post on the subject: http://www.cimgf.com/2010/05/02/my-current-prefix-pch-file/
Comment: I'm also facing same issue... how to resolve in Xcode 6.1
Answer: Ewww… don't put macros in a .pch file! A .pch file is, by definition, a project specific precompiled header. It really shouldn't be used beyond the context of the project and it really shouldn't contain anything but #includes and #imports.
If you have some macros and such that you want to share between headers, then stick 'em in a header file of their own — Common.h or whatever — and #include that at the beginning of the .pch.
Comment: Nothing;  I'd only put the various #defines, etc... in it.
Comment: What would you include in that Common.h?
Answer: For modern iOS and OS X, people should be using Modules. This is enabled by default for new projects, and importing/inclusion is accomplished using @import.
Modules allow the compiler to create an intermediate representation of the contents of a module (e.g. a framework's headers). Much like a PCH, this intermediate representation may be shared across multiple translations. But modules take this one step further because a module is not necessarily target specific, and their declarations need not be localized (to a *.pch). This representation can save you a ton redundant compiler work.
Using modules, you do not need a PCH, and you probably should just do away with them entirely -- in favor of using @import local to the dependency. In that case, a PCH is only saving you from typing inclusions local to dependencies (which IMO you should be doing anyway).
Now, if we look back to the original question: You should avoid filling your PCH with all sorts of random things; Macros, constants, #defines, and all sorts of little libraries. Generally, you should omit what really is unnecessary to the majority of your source files. Putting all sorts of stuff in your PCH is just adding a bunch of weight and dependency. I see people put everything they link and more to in the PCH. In reality, auxiliary frameworks typically only need to be visible to a few translations in most cases. E.g. "Here is our StoreKit stuff - let's import StoreKit only where it must be visible. Specifically, these 3 translations". This keeps your build times down, and helps you keep track of your dependencies, so that you may reuse code more easily. So in an ObjC project, you would usually stop at Foundation. If there is a lot of UI, then you might consider adding UIKit or AppKit to your PCH. This is all assuming you want to optimize build times. One of the problems with large PCHs that include (nearly) everything is that removing unnecessary dependencies is very time consuming. Once your project's dependencies grow and your build times go up, you need to fight back by eliminating unnecessary dependencies in order to reduce your build times. Also, anything that changes often should generally be kept out of your PCH. A change requires a full rebuild. There are some options to share PCHs. If you use PCHs, do aim to support sharing.
As far as what I put in my PCH: I stopped using them for the vast majority of targets years ago. There just usually is not enough in common to qualify. Bear in mind, I write C++, ObjC, ObjC++ and C - the compiler emits one for each lang in your target. So enabling them often resulted in slower compile times and higher I/O. Ultimately, increasing dependency is not a good way to fight dependency in complex projects. Working with multiple languages/dialects, there are is much variation in the dependencies required for a given target. No, I would not advise that as optimal for every project, but that does give some perspective to dependency management in larger projects.

References

http://clang.llvm.org/docs/Modules.html
http://clang.llvm.org/docs/PCHInternals.html

Notes

This question was originally asked a few years before Modules' introduction.
Presently (Xcode 5.0), modules work for C and ObjC, but not C++.
Comment: @MadNik Suppose your app's PCH includes a master header of a library/framework which you are actively developing. For example: `#import "MyLib/MyLib.h"`. Anytime a file included by `MyLib.h` changes, every source file in the app must be recompiled. If you use MyLib in just one source file, then only that file must be recompiled when MyLib changes. Believe it or not, I'm not using any PCH files these days.
Comment: What does it mean by complete rebuild for a module enabled project. You know this new -Swift.h bridging header is definitely not a right candidate for a .pch. But I have seen people do that. So as you can see if someone do that. We have a always changing header in .pch. So it rebuild everything in the .pch file every time the -Swift.h regenerated. Do you agree with this? You have more inputs?
Answer: I agree with bbum. My take on the PCH file is that it should contain pretty much only #include or #import statements. So if you have a bunch of helpful, high-level macros, define them in something like Common.h and #import that file, as bbum suggested.
I usually go a step further and use the PCH file to #import a file called XXCategories.h (where XX is the class naming prefix convention you use) that contains #imports for all my UIKit and Foundation class categories: NSString+XXAdditions.h, UIColor+XXAdditons.h, etc.
Comment: The difference is re-usability. The PCH is project specific. The Common.h would be common to many projects. It's akin to asking why you don't just put all your util classes into your project instead of creating a sub project that you can reuse. Albeit a contrived example, because it's only a simple copy paste... but copy paste is naughty.
Comment: I'm just curious. In the .PCH file ,what's the difference between importing a Common.h which has various `#import` and just importing those `#import` directly? Wouldn't those be the same?, or does it affect any performance?
Comment: To my knowledge, there's no *real* difference. It's more of a best practice, I guess. Rather than shoving a bunch of macros and other things into your PCH file, it should only be for `#import` and `#include`.
Answer: create an header file "macros.h"
import this header into Prefix.pch
In this macros.h put all the frameworks and other important things.
If you are worried about performance, don't worry, look what apple says:
Headers and Performance

If you are worried that including a master header file may cause your
  program to bloat, don't worry. Because OS X interfaces are implemented
  using frameworks, the code for those interfaces resides in a dynamic
  shared library and not in your executable. In addition, only the code
  used by your program is ever loaded into memory at runtime, so your
  in-memory footprint similarly stays small.
        As for including a large number of header files during compilation, once again, don't worry. Xcode provides a precompiled
  header facility to speed up compile times. By compiling all the
  framework headers at once, there is no need to recompile the headers
  unless you add a new framework. In the meantime, you can use any
  interface from the included frameworks with little or no performance
  penalty.

also in my macros.h I put a lot of constants like:
// delegate
#define UIAppDelegate (AppDelegate *)[[UIApplication sharedApplication] delegate]
#define APPDELEGATE   ((AppDelegate *)[[UIApplication sharedApplication] delegate])

// system
#define IS_IPHONE_4INCH (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height==568)
#define IS_IPAD                     (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

// screen size
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_4 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 480.0)
#define IS_IPHONE_5 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0)
#define IS_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0)
#define IS_IPHONE_6PLUS (IS_IPHONE && [[UIScreen mainScreen] nativeScale] == 3.0f)
#define IS_IPHONE_6_PLUS (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 736.0)
#define IS_RETINA ([[UIScreen mainScreen] scale] == 2.0)
#define IS_RETINA_DISPLAY ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)] && ([UIScreen mainScreen].scale == 2.0))
#define IS_PORTRAIT                 UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])
#define IS_LANDSCAPE                UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])

//system version
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)

// math
#define DEGREES_TO_RADIANS(angle) ((angle) / 180.0 * M_PI)
#define RADIANS_TO_DEGREES(radians) ((radians) * (180.0 / M_PI))

// cores
#define RGB(r,g,b)    [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1]
#define RGBA(r,g,b,a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]
#define MAKECOLOR(R, G, B, A) [UIColor colorWithRed:((float)R/255.0f) green:((float)G/255.0f) blue:((float)B/255.0f) alpha:A]
#define MAKECOLORFROMHEX(hexValue) [UIColor colorWithRed: ((float)((hexValue & 0xFF0000) >> 16))/255.0 green:((float)((hexValue & 0xFF00) >> 8))/255.0 blue:((float)(hexValue & 0xFF))/255.0 alpha:1.0]

//customizations
#define SHOW_STATUS_BAR               [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
#define HIDE_STATUS_BAR               [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];

#define SHOW_NAVIGATION_BAR           [self.navigationController setNavigationBarHidden:FALSE];
#define HIDE_NAVIGATION_BAR           [self.navigationController setNavigationBarHidden:TRUE];

#define VC_OBJ(x) [[x alloc] init]
#define VC_OBJ_WITH_NIB(x) [[x alloc] initWithNibName : (NSString *)CFSTR(#x) bundle : nil]

#define RESIGN_KEYBOARD [[[UIApplication sharedApplication] keyWindow] endEditing:YES];

#define CLEAR_NOTIFICATION_BADGE                       [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
#define REGISTER_APPLICATION_FOR_NOTIFICATION_SERVICE  [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)]

#define HIDE_NETWORK_ACTIVITY_INDICATOR                 [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
#define SHOW_NETWORK_ACTIVITY_INDICATOR                 [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];

Comment: Another useful here: `#define async(...) dispatch_async(dispatch_get_main_queue(), __VA_ARGS__ )` ... to run blocks on the main thread: `async(^{ self.someLabel.text = @":D"; });`

iOS Prefix.pch best practices


Stabilizing a lightweight (empty) ship

Question: Is it possible to stabilize an empty ship on high ocean waves with weights on long structures free to open up like wings by rotation on two vertical axis attached to the body of the ship simmilar to a man walking on a rope with a long bar which is more massive at the ends,ofcourse not that long in proportion to make problems to other ships and only in use on not crawded parts of the ocean?Is it already in use in some cases?
Comment: floats work better, they're called outriggers
Comment: Outriggers would not be suitable for ocean-going ships. The stress on the arms would break them off in heavy seas. If you retract them when the seas are rough that  defeats the purpose of having them because that's when they're needed most. Much better to use the weight as ballast to lower the COM of the ship.
Answer: Ocean-going ships that are empty of cargo are stabilized by filling the holds partially with water; weight added in this manner is referred to as ballast.

Stabilizing a lightweight (empty) ship


Jmeter Testing Backend behaviour

Question: I am new to jmeter load testing. I am doing tests for a web based application. Will the load testing actions can be seen from the DB BE? for ex: If I am doing load testing for ordering items from amazon for 100 threads, can I see the load from Back end like 100 people ordered from amazon is recorded in DB?
Answer: JMeter is a tool to manage interactions with services, e.g. manage HTTP requests. It does not affect how your services will deal with the interactions.
So, to answer if your interactions will change the state of a DB, then: Not necessarily.
It will depend on what service you are hitting.
You may have a service that is running locally configured to use a stubbed DB, returning always some specific value. You may have a repository in the file system. You may... because databases are details.

So, if you want to see the results of your interactions in a DB, you have to hit a service that will change the DB state based on the interactions you are doing.
Answer: Yes you can, JMeter provides the following test elements for working with databases:

JDBC Connection Configuration - where you can put your database URL, credentials, etc.
JDBC Request sampler - where you can place your SQL queries to verify presence of certain entities in the database

See How to Retrieve Database Data for API Testing with JMeter for example JMeter configuration for database communication.
Remember that you'll need to download the appropriate JDBC driver for your database and put it into JMeter Classpath as JMeter is not shipped with any database driver libraries

Jmeter Testing Backend behaviour


Turn off network Discovery: Still able to browse network

Question: In Control Panel\All Control Panel Items\Network and Sharing Center\Advanced sharing settings, I have checked the box for "Turn off Network Discovery".
Yet I am still able to login to servers on the network.  I would have thought that I would no longer be able to do that.  Did I misunderstand something?
Also in the network adapter settings, what does disabling "File and Printer Sharing for Microsoft Networks" do?  Is this separate from the Advanced sharing settings?
Thanks...
Answer: To explain Your Scenario :
What is network discovery ?
Network discovery is a network setting that affects whether your computer can see (find) other computers and devices on the network and whether other computers on the network can see your computer.
So now i turned off the network discovery now what will happen :
It will prevents your computer from seeing other network computers and devices and prevents people on other network computers from seeing your computer.
What Happens when you turn on network discovery :
From Technet
When enabled, the Network Discovery method gathers information about devices on your network, like the other discovery methods that are available in SMS do. However, the Network Discovery method is unique because, besides computers, it also finds network devices such as printers, routers, and bridges. Basically, the Network Discovery method finds any device on the network that has an IP address.
Now why i able to view other computers :
Network Discovery uses SNMP to discover routers and subsets. SMS(system mange server) Network Trace uses this data to provide information about the health of network links between SMS site systems.When you select the topology discovery type, Network Discovery discovers subnets and creates DDRs for network devices that have an SNMP agent. DDRs contain information about each identified resource.
With the topology discovery type, Network Discovery first connects to the local router (default gateway) to collect IP addresses from its ipRouteNextHop routing table. Network Discovery uses this information to find other network devices that are connected to the router.
Network Discovery attempts to query the specified DHCP servers to retrieve the active leases and defined subnet lists that are configured on that server. Network Discovery then attempts to resolve the IP address to a name for each network device and subnet that it discovers.
With the topology discovery type, Network Discovery first connects to the local router (default gateway) to collect IP addresses from its ipRouteNextHop routing table. Network Discovery uses this information to find other network devices that are connected to the router.
Note that you turned off network discovery in your computer so that your computers cant access your computer,But other network computers are not turned off discovery,so you will be able to view other computers.
Comment: It's worth noting that the TechNet article referenced in this answer is for the SMS/SCCM product's Network Discovery, which is not the same thing as Windows Network Discovery in the OP, although they can interact with each other.   Here's a link to the Windows Network Discovery article:
https://technet.microsoft.com/en-us/library/cc181373.aspx
Comment: @GuitarPicker nice article buddy,kindly feel free to edit my answer cheers!:)


Climbing a ladder attached to an extended object while in Earth Orbit

Question: If a ladder attached to the International Space Station were oriented "vertically", that is, perpendicular to the Earth's surface, how much force would an astronaut with a mass of 100 kg climbing the ladder have to exert to take each step upward?
Answer: If the ladder is mounted to the top of the station: None, he actually needs force to climb down!
The center of gravity of the station is in free fall around the Earth. At this point, centrifugal force and gravity cancel out precisely. Any other point of the station experiences a small residual force (hence the term "microgravity").
A point above the center of mass is in an orbit with the same angular velocity, but further away from Earth. An orbit at this height would have a angular velocity that is slightly lower, so he is too fast and feels and outwards force.
We can assume that gravity is constant on this small scale and centrifugal force scales as $F = m \omega^2 r$. ISS is in an orbit with about $r=6800km$ while the astronaut is in an orbit $r'=6800km + x$. The difference in centrifugal force is now just the relative difference of these radii. If the ladder is e.g. 68m long, the astronaut feels about 1/100000 of his natural weight pushing him outwards, about 1/10 N.
Comment: Another way to look at this force (or another force?) is as [tidal force](https://en.wikipedia.org/wiki/Tidal_force): the gravity pull on the astronaut is slightly weaker than on the center of ISS because the astronaut is slightly farther away from Earth. In a less handwavy form:
$$
F_\text{tidal} \approx 2\Delta r G M m / R^3 \approx 2 \Delta r m g / R
$$
, which differs from your calculation by a factor of two. Any ideas about the physical meaning of this difference? Do the two expressions describe the same effect, or are they different things that should be added together or something?
Comment: This is exactly the same thing. The factor of two comes from the definition of the tidal force formula: It describes the difference in force between two parts of the object on opposite sides of the object, not between one side and the center of gravity.
Comment: I believe $\Delta r$ is the distance from the center of mass, not the opposite end. The formula with the factor of two is easily derived from the $F=GMm/R^2$ with assumption that $\Delta r$ is measured from center of mass. Am I doing it wrong? (It does seem intuitive to me that the tidal and centrifugal force should be exactly the same thing, but I'm still failing to explain the factor of two.)
Comment: Sorry, I have to correct myself: The two forces are not the same. Essentially we are looking at (a) the derivative of the centrifugal force with respect to r and (b) the derivative of the gravitational pull with respect to r. As gravity scales with $r^{-2}$ and centrifugal force scales with r, we get a factor of 2 into the game. The different exponents on r don't matter as this is just a constant in our calculation. In the center of the station both forces are equal, and so the residual forces just differ by the factor of 2 from differentiation. We have to add up both forces to get the total.


Cost functions penalizing certain types of misclassification more heavily in tensorflow

Question: I have 2 classes of data A and C.   I want to create a NN with 3 output nodes, classifying data as either A, B, or C.   Classifying an A or C correctly should have zero cost (very good).  Classifying an A as a C or vice versa should have high cost (very bad).  However, for samples that are "blurry", I'd like to classify them as B, which would have relatively low cost (better than a misclassification, but still not ideal).   I am new to tensorflow, and am not comfortable with the different ways to define cost functions.   Can anyone point me in the right direction on this one?  Thanks in advance
Answer: You are talking about having different missclassification costs.
Classification consists of outputing a continuous score which is then thresholded to decide the discrete classification. The threshold (ex. probability>0.5 leads to C) is chosen to satisfy your apetite on sensitivty/specificity.
The training algorithm only cares about your continuous score. This means that you can make it easy for yourself by doing simple binary classification (typically with softmax_cross_entropy_with_logits-loss) and create your vague class B after training is done by thresholding say [0,0.4) is A, [0.4,0.6] is B and (0.6,1] is C.
To achieve exactly what you're saying, penalizing certain errors more, then you want to use the weighted_cross_entropy_with_logits. This throws out the interpretation of your outputted score as a probability, and you will need to work more to get a reasonable threshold afterwards so this is not recommended as a first step as it will probably add more complexity than results.
I also recommend reading the wikipedia article on roc analysis


ArcObjects: Equivalent/Similar object to old Avenue ObjectTag from ArcView 3.x?

Question: I have annotation where a single annotation feature consists of one or more TextElements and RectangleElements grouped together in a GroupElement and then stored in the annotation feature.  To edit the contents of the annotation feature later, it would be nice to be able to know which elements are related to each other.  The elements have natural groupings, but those groups cannot be grouped together and then grouped into the final GroupElement for storage.  Due to a bug, the ESRI optimized map service cannot handle nested groups in annotation.  (See this posting.)  So all elements just have to be thrown in together.  An identifier object, holding, say, a group name string, attached to each element would make identification of elements belonging to each subgroup much easier to identify.  The Avenue ObjectTag object in old ArcView GIS 3.x (I guess it was a property) used to be great for such things.  You could stick a tag on just about any object in the whole model, including dialog controls.  Really handy.  I haven't thought about this -- until recently -- since the old Avenue days, but it has now come to my consciousness again.  I haven't been able to find anything like the old ObjectTag in ArcObjects.  Any ideas?
Comment: Did you try using [IElementProperties.Name](http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/IElementProperties_Interface/001200000463000000/) for this purpose?
Comment: @blah238 - No I didn't. Darn.  How did I miss that one?  Duh.  You save me once again.  Thanks.  (Hanging head in shame)
Answer: I guess the most direct equivalent in ArcObjects would be IElementProperties.CustomProperty:

CustomProperty is a place for developers to attach custom objects to
  an element. Previous versions of the software required that the
  specified variant be of type VT_UNKNOWN, i.e. a reference to an
  object, but that requirement has since been removed. Now, the
  CustomProperty can also be a simple type like an integer, double,
  boolean (VARIANT_BOOL) or a string (BSTR).
When this property is an object reference, the object must implement a
  persistence interface, so if you write a custom object it must
  implement IPersistStream or IPersistVariant. As an alternative to
  writing a custom object, you can use a PropertySet or XMLPropertySet,
  since they both already implement IPersistStream.
CustomProperty is never used by the core ArcObjects for its own
  elements, but the core software will expect to find an IPersistStream
  or IPersistVariant interface when the this property is an object
  reference, and it is part of an element being retrieved from or stored
  in an .mxd file.
Comment: Thanks again.  This is just what I had in mind ... and more.  I am prototyping in Python/comtypes/ArcObjects at the moment, so the Name populated with a string will do fine for now; however, all of this is going into .NET eventually, and we may want to do something more sophisticated.


How to Track Queries on a Linq-to-sql DataContext

Question: In the herding code podcast 14 someone mentions that stackoverflow displayed the queries that were executed during a request at the bottom of the page.
It sounds like an excellent idea to me. Every time a page loads I want to know what sql statements are executed and also a count of the total number of DB round trips.
Does anyone have a neat solution to this problem?
What do you think is an acceptable number of queries? I was thinking that during development I might have my application throw an exception if more than 30 queries are required to render a page.
EDIT: I think I must not have explained my question clearly. During a HTTP request a web application might execute a dozen or more sql statements. I want to have those statements appended to the bottom of the page, along with a count of the number of statements.
HERE IS MY SOLUTION:
I created a TextWriter class that the DataContext can write to:
public class Logger : StreamWriter
    {
        public string Buffer { get; private set; }
        public int QueryCounter { get; private set; }

        public Logger() : base(new MemoryStream())
        {}

        public override void Write(string value)
        {
            Buffer += value + "

";
            if (!value.StartsWith("--")) QueryCounter++;
        }

        public override void WriteLine(string value)
        {
            Buffer += value + "

";
            if (!value.StartsWith("--")) QueryCounter++;
        }
    }

In the DataContext's constructor I setup the logger:
public HeraldDBDataContext()
        : base(ConfigurationManager.ConnectionStrings["Herald"].ConnectionString, mappingSource)
    {
        Log = new Logger();
    }

Finally, I use the Application_OnEndRequest event to add the results to the bottom of the page:
protected void Application_OnEndRequest(Object sender, EventArgs e)
    {
        Logger logger = DataContextFactory.Context.Log as Logger;
        Response.Write("Query count : " + logger.QueryCounter);
        Response.Write("

");
        Response.Write(logger.Buffer);
    }

Answer: If you put .ToString() to a var query variable you get the sql.  You can laso use this in Debug en VS2008. Debug Visualizer
ex:
var query = from p in db.Table
            select p;

MessageBox.SHow(query.ToString());

Answer: System.IO.StreamWriter httpResponseStreamWriter =
new StreamWriter(HttpContext.Current.Response.OutputStream);

dataContext.Log = httpResponseStreamWriter;

Stick that in your page and you'll get the SQL dumped out on the page. Obviously, I'd wrap that in a little method that you can enable/disable.
Comment: Helped me to get: Db.Log = Console.Out;
Answer: I have a post on my blog that covers sending to log files, memory, the debug window or multiple writers.
Answer: From Linq in Action

Microsoft has a Query Visualizer tool that can be downloaded separetly from VS 2008.  it is at http://weblogs.asp.net/scottgu/archive/2007/07/31/linq-to-sql-debug-visualizer.aspx


Is it a good idea to reduce resistance with each set?

Question: My workout is mostly tension-focused with two sets per exercise. I can't perform as well in my second sets so I'm kind of incentivised to cheat, not to do quality reps to the same extent as I do in my first sets. I started to unload weight plates from the dumbells after first sets so that I don't have that excuse to cheat anymore. My suspicion was that my strength gains may be compromised by my inability to keep my performance up to scratch, quality-wise, throughout all sets. Besides, it adds a metabolic component to your training, I guess, which is beneficial if you want endurance gains too. Is it a good idea to reduce resistance with each set?
Answer: Everyone is different.
I think it is really important that you log and keep track of your lifts and your progress so that you finds what works for you.
Here are some key metrics:
1 RM
One rep max, the max amount of weight you can lift for one rep.
Can be calculated from a lift of n repetitions using a 1 RM calculator.
NL/week
Number of lifts per week measured in 1 RM.
For instance if your 1 RM benchpress is 100 kg and you lift 80 kg for a total of 25 reps one week your NL/week is 0.8x25 = 20
RIR
Reps in Reserve.
If you can lift 80 kg for 10 reps but instead only do 7 reps you have 3 RIR. Can be looked up from your 1RM using the table in the 1 RM calculator linked to above.
AWOL
Average weight of lift.
Say your 1RM is 100 kg and you lift 60 kg for 30 reps and 80 kg for 20 reps one week. AWOL = (60 * 30+80 * 20)/(50 * 100) = 68%
Up until some months ago I would train lat pulldowns like this 2x a week:

Set 1: 68kg: 6 (RIR:0)
Set 2: 68kg: 5 (RIR:0)
Set 3: 68kg: 4 (RIR:0)

1 RM = 79 kg,
AWOL = 86 %,
NL/week = 25.8
I had very slow progress with this approach.
What I do now 2x a week:

Set 1: 50 kg: 10 (RIR: > 10)
Set 2: 59 kg: 8 (RIR: 6)
Set 3: 68 kg: 6 (RIR: 3)
Set 4: 77 kg: 6 (RIR: 0)

1 RM = 89 kg,
AWOL = 69 %,
NL/week: 41.
So a 60 % increase in volume compared to my previous approach, but a reduction in intensity and only going to failure in last set.
For me this seems to work better.
"Volume is the most critical factor for overall gains in strength and size. The most reliable way to get stronger is to do more."(1)
"For most of your training, most of the time, 70-80% of your 1rm is a good intensity
range to stay in because it's sufficient intensity to still have a strong effect on strength, but it's not so heavy that you compromise the amount of volume you can handle."(1)
Here is a week of the popular 5/3/1 program (Boring But Big):
Monday

Set 1: 65% x 5 (RIR:11)
Set 2: 75% x 5 (RIR:5)
Set 3: 85% x 5+(RIR:0)

Thursday
5 sets x 10 reps @ 60 % (RIR:10)
From my calculations:
AWOL = 60%,
NL/week = 38.8
So this is quite similar to what I am myself doing but the AWOL is a bit lower.
For me as in the 5/3/1 program the key seems to be to use some submaximal ("easy", high RIR) sets as a mean to accumulate volume without a lot of fatigue. This principle seems to be taken even further in Sheiko programs. This is a good description of the logic behind Sheiko programs from which some of the metrics above are taken.
BTW a similar principle seems to apply to running. Many of the fastest runners spend a lot of time running slow: "run slow to get fast".
(1) The Art of Lifting
Comment: Sorry, but I'm not familiar with this initialism, "1RM". What does it mean?
Comment: One Rep Max (1 RM), the max amount of weight you can lift for 1 rep.


Accelerate convergence of sequence

Question: Is it always possible to extract a subsequence from my generic sequence $(q_n)$, such that the convergence of the subsequence to the same limit $r$ is faster then the original?
Answer: The answer is yes.
Pick any rate of convergence $r_n$ you want. Then, for each $n$ there exists some $M_n$ such that for all $m >M_n$ we have
$$|a_n-l|<r_n$$
Pick inductively
$$k_n > \max \{ k_1,k_2,..., k_{n-1}, M_n \}$$
Then $a_{k_n}$ is a subsequence and since $k_n >M_n$ we have
$$|a_{k_n} -l| <r_n$$
Comment: @TheTurtleHermit For each $n$ you set $\epsilon$ to be the rate of convergence at that $n$ and pick one element which satisfies that inequality, yes.
Comment: So we are basically choosing the natural number $M_n$ so that we make $\epsilon$ small enough (what you called $r_n$) to convergence, at every step, at the rate I want?

Accelerate convergence of sequence


Islam and homosexuality

Question: I am a Muslim. I believe in Almighty Allah, the Most Beneficent and Merciful. But I am a lesbian. I've known this since the age of 8. I don't want to go to hell. Will I go to Jahannam? I'm scared. This is who I am. I'm also Non-binary. Help.
Comment: This is neither a clear nor a focused question. All it's doing is attracting opinions and critiques on homosexuality, which is not particularly helpful or productive.
Answer: "A person is not to be blamed for his nature. Rather, he is to be blamed if he acts according to his nature." -Al-Junayd in 'Hilyat al-Awliya"
THis is from this question: Why is homosexuality a sin if Allah made me this way?
It basically says that you are not going to Hell for the way you are but for the things you would do.
Answer: Asslam o Allaikum.
First of all, As another user Yakoub Ali also referred to this:

"A person is not to be blamed for his nature. Rather, he is to be blamed if he acts according to his nature." - Al-Junayd in Hilyat
al-Awliya.

This clearly means that although you may seem attracted to the same gender but if you control that feeling of yours and not do anything unlawful / haram then obviously you won't go to Jahannam for this matter.
In other words: One who has homosexual desires is not irresponsible for that but committing unlawful things does make him/her sinful.
Answer: If you're a homosexual Muslim with urges to engage in homosexual behavior, then you should simply abstain from it and remain celibate. This is just your test. Just like how if you're a straight Muslim with urges to commit adultery, you shouldn't, and should wait till marriage.

Islam and homosexuality


Indesign small subheading graphic library option?

Question: Is there a way to design a subheading (fancy font, lines and small icons) that I could reuse again and again? Sort of like a clipart/small template library?
(I'm brand new to using InDesign. I figure there's gotta be a way people stick to a certain look.)
Answer: Found it under Library and dragging my items into it and pulling them back out as needed.


How do I set a time zone for a crontab?

Question: I would like to use UTC for the scheduling times in a crontab for a single user, regardless of the current time zone of the server. How do I do this on Debian Etch?
Comment: http://unix.stackexchange.com/questions/195818/change-the-time-zone-of-a-cronjob
Answer: you can set the variable TZ in /etc/default/cron. but this is the timezone for all crontabs.
another alternative is using fcron. the documentation shows an option to set the timezone in each crontab.
Answer: Some cron installations use CRON_TZ to set the per-user interpretation of the crontab times.
Here's part of man 5 crontab on Centos 7:
The CRON_TZ variable specifies the time zone specific for the cron table.  The user should enter a time according to the specified time zone into the table.  The time used for writing into a log file is taken from the local time zone, where the daemon is running.
Default Debian uses a patched vixiecron, (per https://wiki.debian.org/cron)  and does not support per-user time zone functionality.  If you set a variable in the crontab, it passes to the child jobs, but does not affect the TZ of the parent cron job.  Debian has a 'cronie' package in experimental that supports the CRON_TZ functionality.
Comment: Haha. I love how Debian puts cronie in "experimental" when the rest of the Linux world has been using it for 10 years or more.

How do I set a time zone for a crontab?


I live in a city and I walk my dog on community college campus they come out say that it is policy not to have dogs on campus

Question: The retort I had is that this is not posted anywhere, and even if it was what legal enforcement does the campus have against me. They can't find out who I am, They can't detain me. They can't hold me until police arrive. So how would they enforce that policy. After it escalated to that level what penalty for trespassing would there be, and can I even trespass on public property.
Answer: You were trespassing
The community college is a public institution but they can decide what part of their land you can walk on and in what circumstances. Just like the military is a public institution but they don't let you walk across their shooting ranges.
To be clear, in the absence of clear "no dogs allowed" signage, you were not trespassing until you were told about the policy. At that point, you were legally obliged to remove yourself (or more precisely, your dog) from the campus as soon as possible. When you refused to do so, you became a trespasser.
It's trivially easy to find out who you are. One photograph, one reverse image search they'll know everything about you right down to your shoe size. Even if you don't use social media, I'm sure some of your family and friends do.
In most US states, trespass is a misdemeanour and also in most states members of the public can arrest someone who is committing a misdemeanour in their presence. They can use reasonable force to do so and can hold the arrestee until they can transfer them to the custody of a law enforcement officer. Admittedly, this seems unlikely but it is possible.
If you have caused damage, you can be sued. It seems that your discussion with the college staff was somewhat protected so the loss of productivity of those staff members is a loss that the college suffered and that they could sue you for. Again, not likely but possible.
Alternatively, they could just report you to the police who may or may not bring charges.
Note: this assumes the dog is a pet. If it's a disability assistance animal, it can't be excluded.
See:

Are sidewalks on a university public or private property?
Can a local government charge a fee to enter a public downtown area during an event?
Trespassing or Public Property?
Is a mall considered a "public place" for copyright purposes?
Comment: @user6726 I do not understand why Dale M emphasized that.  I do not think it is important.  It is obvious that the community college (rightly or wrongly) thinks you are a nuisance.  They know who you are - you are the jerk that walks his dog on their campus.  If you persist, they can sic the police on you.  The police have ways of identifying you (e.g., put you in a cell until you are willing to identify yourself).  I would suggest you stay off their campus.  After they book you for trespassing you are in their system and you can no longer remain anonymous.
Comment: Does 'walking the 'dog' actually mean 'taking the dog somewhere to do a dump", as it often does here in England? because if so, the college may have good reason to get antsy. Also they may have risk of liability if someone gets bitten.
Comment: FYI I just searched a picture of me and they couldn't even find another picture of me.
Comment: "To be clear, in the absence of clear "no dogs allowed" signage, you were not trespassing until you were told about the policy" A person asserting that a policy exists is not the same as constructive knowledge.
Comment: @MichaelHarvey Yes
Answer: It depends on who they are, and where you are. A property owner or "person with authority" can order you to leave their property. If you don't leave, you are trespassing, which is at least a misdemeanor, and a person who witnesses you to committing a misdemeanor usually can make a citizen's arrest (which means detain and remand to the police). But it depends on what the law is in your location. And it depends on who "they" are. Campus police would have authority to order you to leave, an accounting TA would not. It doesn't matter if this restriction is posted or not. You say that this is a "community college" which suggests that it it an arm of the government to some extent, so the rules can't be completely capricious (when on private property, you can be told to leave because they don't like you). Government operations are expected to operate in a more rule-like fashion, but the lack of any posting does not mean there is no rule. For example, dogs are prohibited in university buildings in Washington state, but this isn't posted at the U. Washington -- because that law is published, you are expected to know and comply with the law.
You'd have to name the institution, if you want a pointer to the relevant laws.
Comment: Campus police might not be authorized to enforce the trespass ordinance. Most colleges would have a memo on file, probably a policy of the board of trustees, listing the people or offices that are so authorized. You can ask for a copy of the memo. It is a public document.
Comment: "Campus police would have authority to order you to leave" Not unless there are specific facts giving them the authority. Police can't just arbitrarily order you to leave.


Change file to read-only mode in Python

Question: I am writing a data processing code, in which I create a new file, write processed data in to this file and close. But the file has to be closed in read-only mode, so that it would not be accidentally modified. Can this be done in Python?
Answer: For this you use os.chmod
import os
from stat import S_IREAD, S_IRGRP, S_IROTH

filename = "path/to/file"
os.chmod(filename, S_IREAD|S_IRGRP|S_IROTH)

Note that this assumes you have appropriate permissions, and that you want more than just the owner to be able to read the file. Remove S_IROTH and S_IRGRP as appropriate if that's not the case.
UPDATE
If you need to make the file writable again, simply call os.chmod as so:
from stat import S_IWUSR # Need to add this import to the ones above

os.chmod(filename, S_IWUSR|S_IREAD) # This makes the file read/write for the owner

Simply call this before you open the file for writing, then call the first form to make it read-only again after you're done.
Comment: Ah, you didn't specify that in the original question. I'll update
Comment: And how do I change it to write when I run the program. I want to change it to write when the program runs and when it exits it should be changed to read-only mode.
Comment: Does not work on Windows. Even if this article says it should
https://docs.python.org/2/library/os.html#os.chmod
Answer: This solution preserves previous permission of the file, acting like command chmod -w FILE
import os
import stat

filename = "path/to/file"
mode = os.stat(filename).st_mode
ro_mask = 0o777 ^ (stat.S_IWRITE | stat.S_IWGRP | stat.S_IWOTH)
os.chmod(filename, mode & ro_mask)

Answer: Using pathlib.Path, for modern python3, use path.chmod(mode: int)
The octal mode could be specified like 0o444 (read only). See this for more chmod mode options.
Note, if it is to apply to the symlink itself, see path.lchmod.
For path.chmod, after 3.10, there's now a follow_symlinks = True parameter as well.
On windows, this may not be sufficient for anything but twiddling the read-only flag. See other SO posts [1].
Answer: For Windows OS maybe to try something like this:
import os

filename = open("file_name.txt", "w")
filename.write("my text")
filename.close()
os.system("attrib +r file_name.txt")

Comment: Not recommended because it is not operating system independent, and because it fails if file_name has a space in it.
Comment: This seems to be the same as @dgsleeps answer that was posted 3 years earlier
Answer: I guess you could use os module after writing on your file to change the file permissions like this:
import os
filename=open("file_name","w")
filename.write("my text")
filename.close()
os.system("chmod 444 file_name")

Comment: calling chmod via `os.system` isn't portable, it won't work on windows. Better to use the `os.chmod` method directly.

Change file to read-only mode in Python


In what situation could a fish tape potentially touch live wires?

Question: I want to invest in a high-quality fish tape and I'm doing some research on them. One of the biggest selling points of many fiberglass fish tapes is that they are non-conductive, for safety. But when would a fish tape bump into a bare live wire?
Answer: When fishing into an electrical panel
In most cases, there will be live terminals (at a minimum, the service connections on the main breaker) in a panel you are fishing wires into.  While new panels have what are known as IP20 terminal shields that make the service terminals finger-safe (i.e the live parts are no longer poke-able with a finger), these shields are not complete protection, and are only found on very recent panels anyway.  In addition, many times when you are fishing into a panel, branch circuits not proximate to the rest of the work are left live, for obvious nuisance reasons.
Comment: Another reason I would go for the fiberglass is their excellent flexibility and drag coefficient through the conduit.
Comment: Yet another reason I like my intermediate junction boxes a foot from the panel.  Fish to the intermediate box after deenergizing all the circuits in it, then just poke the wires through the last foot carefully.
Answer: Commercial buildings regularly have shared conduits with live circuits. Many old circuits that have yet to be replaced with new cables. A string should always be left behind, but that doesn't always happen. Some of those conduit penetrations are not always penetrations you want to, or are allowed to, recreate.
Metal tape is still metal, as "smooth" as it can be, and rubbing against just insulated wiring can cut into it. Among the fact there could be already exposed wiring from some sort of existing damage you could run into. Coated tape could cause a little more friction and burn cables, but that's completely controllable by speed. Both of which are heavily alleviated by using dielectric grease, they sell large bottles of the stuff for fishing. Technically it should insulate the metal tape from shorting a little, but I still wouldn't rely on it for that.
This especially applies more to Ethernet/LV applications. Fish tape is regularly used in live conduits. And nowadays communications is generally considered critical infrastructure so even more so have to be very careful of damage. Among the fact it can now carry substantial amounts of wattage and voltage through PoE++. Being class 2 it, and you, are pretty protected against a truly dangerous short, but it's again not something to play around with and can still damage some very expensive equipment doing so.
There's also some frankly cool types of the coated tapes that allow you to pull it all the way through the reel and out, so it becomes effectively a massive push rod. So you can just attach a string/head to the back and pull straight through in one go, without needing to first back-feed a string and then pulling the cable. Which for structured Ethernet/communications, some paths don't give you a choice which end to really start at. And junctions for communications are very improper and to be generally avoided. Among the need to locate the end of conduits in the first place, which you could also then pull through in one go with such a thing.
Answer: If you are fishing through stud/joist bays in an old home there is the possibility of contacting live knob-and-tube wiring where insulation or connectors are damaged or missing.
There is always the possibility of contacting a live wire that was incorrectly left in a wall with just some tape or a wire nut and no junction box.  Fish tape can find its way into these incorrect splices and caps and become energized.
Answer: The one important point left out in the other answers is:
you need a non conductive tape when pulling a new wire in with live wires.
metal tapes square edges (although rounded some) can cut through the insulation and create a short to ground if metallic conduit, or cut through multiple wires insulation and create a short that way.
The live terminals in a panel are obviously an important place to use caution.
I have had a metal tape find a Nick in the wire insulation at a point the pipe was not properly reamed instantly welding the tape to the pipe.
The damaged insulation from the original work allowed the metal tape to become a conductor but I have heard of electricians pulling and have the metal tape slice the insulation and cause the same problem.
I have had a few 100% non conductive tapes break and become brittle over time, I now purchase nylon coated metal, it holds up better for the heavy use I put them through,
For really heavy work we only use the fish tape as a guide to pull a string/rope through when a mouse cannot be "blown through".
Comment: @Tim Wires in the pipe that are live it is very common in the electrical world to use a pipe for multiple circuits. You don't get to turn off circuits that are in use to pull new ones in commercial work.
Comment: Why would you (or anyone) be pulling through live wires? Seems a recipe for problems, no matter what you're pulling/pushing with.


Prims and Bellman-Ford Algorithms in Directed Graphs

Question: Please suggest resources to learn how to find a minimal spanning tree in a directed graph using Prim's algorithm, as well as Bellman-Ford algorithm to calculate the shortest path in a directed graph.
Answer: Finding an MST from a directed graph is a different problem, for which you cannot simply adapt Prim's. You should instead use Edmond's algorithm.
Bellman Ford already works on directed graphs. No need to alter anything.
The links provided should get you started. Google for additional resources if necessary.
Answer: If you'd like some actual code for the algorithms, I recently coded both of these algorithms up.

Prim's algorithm
Bellman-Ford algorithm

The comments at the top of these files contains an analysis of the two algorithms both from a correctness and runtime perspective, and I hope they can shed some light on how they work.
Answer: The alsuwaiyel textbook on Google Books is very good and has most of the book available.


Can witches leave a spell slot open for later use in the day?

Question: Wizards, clerics, and other full casters can leave a spell slot open, and later in the day study or pray or something similar for an suitable length of time, and fill the open slot with a spell.
Do witches have the same ability?
Answer: Yes, they can. Just like wizards.
This has been answered in a FAQ:

Preparing Spells in Open Slots: The Magic chapter says a wizard can leave spell slots open and prepare spells in them later. Can any other class do this?
That text was written when wizard was the only class that prepares arcane spells. This option is also available to magus and witch characters (both of which are classes that prepare arcane spells).

This extends to other prepared casters that were released in the last few years. Assume that the text in the core rules say prepared arcane casters instead of wizards.
Comment: "This extends to other prepared casters" Note that it applies to prepared _arcane_ casters. The FAQ or magic rules don't mention prepared divine casters.
Comment: Good point. Divine casters already had a blank statement that applied to all of them.
Answer: I believe they do, but nothing states that clearly.

Preparing Wizard Spells
When preparing spells for the day, a wizard can leave some of these spell slots open. Later during that day, he can repeat the preparation process as often as he likes, time and circumstances permitting. During these extra sessions of preparation, the wizard can fill these unused spell slots.

The same can be said about clerics, druids, rangers and paladins. They named all the classes that prepare spells at Core Rulebook, but they never mentioned anything about that for the Witch (Advanced Player's Guide) or the Magus (Ultimate Magic).
But why am I talking about the Magus? Because the Magus prepare his spells as the same way a Wizard does, being able to prepare from a Wizard spellbook and even so, never states clearly that he prepare his spells as the same as the Wizard. However, the Magus is an Arcane spellcaster and his text explanation refer to the Arcane Spells part in the Core Rulebook that only speaks of the Wizard, Bard and Sorcerer (but the last two don't prepare spells).
If the Arcane Spells explanation of the Wizard way of preparing spells is applicable for the Magus as an arcane spellcaster that prepares spells, I believe the same is valid for the Witch that belongs to the same category. The main difference would be spending your time studying your spellbook or communing with your familiar.


Can I put documents onto the Windows 8 Metro Start Menu?

Question: You can search for a document and click to open it, but is there a way to put a document you are working with on the Start Menu (Metro UI) for quick selection?
Comment: @Rich Melton: That brings up a good point. While consumption of online feeds seems to be the rage on the MetroUI, I wonder where local documents fits into this picture.  Before, I could create libraries of each project I was working on, which weeded me away from the hierarchical filesystem. Now, I'm not so sure where Libraries fit in. . .
Comment: @surfasb - That's something I was thinking also. Homegroups too? As this is technical preview, and not a feature complete release, I'm curious to see what the Beta shows up with.
Comment: @Rich Melton: Yeah, that reminds me. I have to test the homegroups. It would be a shame if Library support dropped to the waist side. . .
Comment: @surfasb - Yup, I have a corporate customer who I've been persuading to use the feature to help mitigate some IT department issues with backing up data. We'll see.
Comment: @surfasb - Homegroups is in the metro control panel. When you search for documents, pictures, etc... you do get a title that looks like it should be able to be pinned, but it doesn't stay. Given the nature of the developer preview's focus on app development and Sinofsky's comments about the amount of missing features (eg: Paragon), I'm speculating that the beta will clear this issue up.
Answer: Here is an article that explains how to add a shutdown tile to the Metro UI, you could possibly add documents to the same location.

Move this shortcut into C:\ProgramData\Microsoft\Windows\Start Menu\Programs (the location of the start menu).  Anything in here can be pinned to the Start Screen.
Comment: Good idea, but that doesn't seem to do it.
Comment: Maybe it has to be a shortcut to a document?
Comment: The Metro UI internally follows the shortcut and confirms it is an application, to prevent non-application tiles.
Comment: Moab, because `shutdown.exe` is, perhaps unsurprisingly, an application, not a document. I'd be a little scared it a document could shut down my computer, too.
Answer: Drop a bath file that starts your document in C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
This is a hack that may not work later. There are a lot of complains about Windows 8 adding ALL shortcuts installed by programs to the metro start screen, including uninstall shortcuts. Microsoft may do something about that.
Comment: Yea, that's been tried see the existing answer. While watching the build conference sessions, I've been looking at what is on other's start menus. There's def a feature disparity between this build and what is installed on the Microsoft machines at the conference.
Answer: This worked for me. Create a shortcut to the application in quotes followed by the location of the document in quotes.  Put the shortcut in the location identified above.
Answer: You could use a third-party application such as Pin to 8

In the screenshot below, I've added an SQL dump file as an example.
Answer: You can't put anything in the Windows 8 Start Menu, maybe in the future build updates you can once it's been implemented but all you can really do now is just go to the Desktop and pin it to your Taskbar and select it from there.
Comment: I can add applications. Since Applications, Settings, and Files all show up under search, I thought there should be a way. I don't know though.
Comment: This won't be implemented, you can't *start* documents or files.
Comment: But you *can* start documents.  From the command line, I can type "start C:\Users\dschilling\Documents\my-spreadsheet.xlsx", and Excel opens, displaying the spreadsheet I specified.
Answer: You need an application to create secondary tiles for documents and folders.
There are already a lot of other ways to open them:

Find them on your desktop.
Find them using WIN+F.
Open them from your library.
Open them through your application.
Open them through the jump list of your application.
...

Also, it's quite a shift from the intended paradigm, that's why Microsoft will not implement this...
Comment: Do you have documentation that states that I must have 'secondary tiles' for documents, I haven't seen it or heard it mentioned? The rest of the post is subjective.
Comment: @RitchMelton: They [explicitly discourage](http://msdn.microsoft.com/en-us/library/windows/apps/hh465398%28v=VS.85%29.aspx) it for that reason. Note how their [guidelines on tiles](http://msdn.microsoft.com/en-us/library/windows/apps/hh465403%28v=VS.85%29.aspx) are all referring to applications. Nothing I said is subjective, but rather the way things are designed and is the intention of Microsoft if you have followed the various presentations available through the Build application, for your ease of access. Perhaps one could write a Metro application that shows recent files and folders?
Comment: [Tiles & Notifications - Slide 6 says that the Customer goal is: "**Start is my space for the apps I love.**"](http://video.ch9.ms/build/2011/slides/APP-396T_Olson.pptx)
Answer: Use OblyTile to pin any file to Start.
Answer: Just press Windows+Q -> Search documents -> right click -> Pin to start.
Comment: Not what the OP is asking.


Why java has "String" type and not "string"?

Question: Wrapper class are just fine and their purpose is also well understood. But why do we omit the primitive type ?
Comment: I've edited my answer with some more info.
Answer: It depends what you mean by "primitive"
"Primitive" in Java is usually taken to mean "value type". However, C# has a string keyword, which acts exactly the same as Java's String, it's just highlighted differently by the editor. They are aliases for the classes System.String or java.lang.String. String is not a value type in either language, so in this way it's not a primitive.
If by "primitive" you mean built into the language, then String is a primitive. It just uses a capital letter. String literals (those things in quotes) are automatically converted to System.String and + is used for concatenation. So by this token, they (and Arrays) are as primitive as ints, longs, etc.
First, what is a String?
String is not a wrapper. String is a reference type, while primitive types are value types. The means that if you have:
int x = 5;
int y = x;

The memory of x and y both contain "5". But with:
String x = "a";
String y = x;

The memory of x and y both contain a pointer to the character "a" (and a length, an offset, a ClassInfo pointer, and a monitor). Strings behave like a primitive because they're immutable, so it's usually not an issue, however if you, say, used reflection to change the contents of the string (don't do this!), both x and y would see the change. In fact if you have:
char[] x = "a".toCharArray();
char[] y = x;
x[0] = 'b';
System.out.println(y[0] == 'b'); // prints "true"

So don't just use char[] (unless this is the behavior you want, or you're really trying to reduce memory usage).
Every Object is a reference type -- that means all classes you write, every class in the framework, and even arrays. The only things that are value types are the simple numeric types (int, long, short, byte, float, double, char, bool, etc.)
Why isn't String mutable like char[]?
There are a couple reasons for this, but it mostly comes down to psychology and implementation details:

Imagine the chaos you'd have if you passed a string into another function and that function changed it somehow. Or what if it saved it somewhere and changed it in the future? With most reference types, you accept this as part of the type, but the Java developers decided that, at least for strings, they didn't want users to have to worry about that.
Strings can't be dealt with atomically, meaning multithreading/synchronization would become an issue.
String literals (the things you put in your code in quotes) might be immutable at the computer's level1 (for security reasons). This could be gotten around by copying them all into another part of memory when the program starts up or using copy-on-write, but that's slow.

Why don't we have a value-type version of a string?
Basically, performance and implementation details, as well as the complexity of having 2 different string types. Other value types have a fixed memory footprint. An int is always 32 bits, a long is always 64 bits, a bool is always 1 bit, etc.2 Among other things, this means that they can be stored on the stack, so that all parameters to a function live in one place. Also, making gigantic copies of strings all over the place would kill performance.
See also: In C#, why is String a reference type that behaves like a value type?. Refers to .NET, but this is just as applicable in Java.
1 - In C/C++ and other natively-compiled languages, this is true because they are placed in the code segment of the process, which the OS usually stops you from editing. In Java, this is actually usually untrue, since the JVM loads the class files onto the heap, so you could edit a string there. However, there's no reason a Java program couldn't be compiled natively (there are tools which do this), and some architectures (notably some versions of ARM) do directly execute Java bytecode.
2 - In practice, some of these types are a different size at the machine level. E.x. bools are stored as WORD-size on the stack (32 bits on x86, 64 bits on x64). In classes/arrays they may be treated differently. This is all an implementation detail that's left up to the JVM -- the spec says bools are either true or false and the machine can figure out how to do it.
Comment: @Ravi - All objects are reference types (that is to say ALL classes). The only Java value types are the ones that have keywords (int, char, double, etc.)
Comment: not sure how this answers the question..or am i misunderstanding the question? i thought the question asks, why java does not have a primitive type for string
Comment: What are other reference types in java ?
Comment: Every class you create and use that isn't one of the primitive types
Comment: It answers my doubt for confusing wrapper with String. But yes, the other part "why we don't have string in java" is still left out.
Comment: In .net, if `String` had been a value type with a single field of type `char[]`, and there were no special CLR handling for it, it could behave largely like `String` does not except (1) the default value could behave like an empty string, and (2) conversion of `String` to `Object` would require boxing of the wrapper (though not duplication of the character data).  Things could be slightly improved if (IMHO the optimal design) there were a `HeapString` type which behaves largely as `String` does now, and a `String` value type which encapsulated a `HeapString` type.  Actually, Java could have...
Comment: ...benefited from such a design as well, since if `string` were a compiler-recognized type it could have had an `==` operator based upon character-sequence equality (if two strings were cast to `Object`, however, the `==` operator would test reference equality).
Answer: The primitive type for String is char[].
This is true for many languages (C, Java, C#, C++ and many more...).
Comment: Oded: Strings are not arrays of char. The String class may be implemented with an array of char as internal storage (and mostly is), but that is not required by the language or API specification.
Comment: `char` is as primitive as it comes, and the array construct is part of the language. Strings _are_ arrays of `char`.
Comment: char[] is not primitive as far as i know
Comment: Yup, and String is not just a wrapper for a char[]
Comment: So it implies that int[], char[] and all arrays of primitive qualify as primitive type ?
Comment: @Ravi - NO! A char[] is actually an Array class that has some special syntax. Arrays are passed by reference and are only "primitive" in the sense that they have special support in the language (but so do Strings).
Answer: strings could be of arbitrary length. the fathers of java did not want to have a primitive type for which they could not assign a concrete memory size. this is one of the chief reasons string is not a primitive in java.
Comment: hmm..but this sounds more of impementation issue rather than specification one.
Comment: well..depends on how you perceive it..i wouldnt classify it as a total implementation issue..its just one of the considerations that went into the decision.
Answer: String is sort of a special case. All the real primitive types (int, long, etc) are pass-by-value, and implemented directly in the JVM. String is a reference type, and so dealt with like any other class (capital letter, pass-by-reference...), except the compiler has special hooks to deal with it like a built-in type (+ for string concatentation, for example).
As it is already a reference type, it does not need a wrapper class like Integer to be able to use it as a class (in collections, for example)
Comment: Reference types aren't pass by reference. They're pass reference by value.
Comment: I guess nothing in java is pass by reference irrespective of the type.
Answer: Primitive?
If Java there's no primitive for strings. The primitives are int, float, double, boolean, etc... and char.
So for using strings they've used an object. You instance it, it lives in the heap, you have a reference to it, etc.
How did they implement it? Saving the value it represents in a char array.
Inmutability
But they ensured inmutability. When you have a reference to a String object you know you can pass it freely to other objects knowing the value pointed by that reference will not change. All methods that modifies strings returns other instance of the string so it doesn't change the value represented by other references to String.
Can it be other way (like in .Net)
Yes. They could have defined a reserved word string and the compiler do the transformation.
But they didn't...
Answer: a String is an array of char. As it is an array, it cannot be a primitive ! :-)
Comment: No it's not - it's an array, plus an offset, plus a length. I agree it's not just a primitive, but there's more to it than a char[].
Comment: @Jon: And a monitor and a ClassInfo. Can't forget the 'ol syncronized() statement :-).
Comment: As Mr. Anderson of SO pointed out char[] stands out from String in many ways.
Comment: @Robert: not sure what you meant by ClassInfo, but a char[] also has a Monitor (can be used for a synchronized block) and a Class, it's superclass is Object: `char[].class.getSuperclass() == Object.class`


Group data with checkboxes and drag/drop functionality in C#/ASP.NET

Question: I have a table of data that I want to display as groups in an asp.net web page. The sql database table has columns for items and item_product. I'd like to show a list of items that belong to each item_product. Each item in the group needs a checkbox to enable selection and all items in the group can also be selected/unselected with a "check all" checkbox. I would also like to be able to expand/collapse each group. It would also be great if I could drop and drop all the items so I could re-order them easily.
I've already googled this to death and I just don't see a suitable solution that fits my needs. I don't mind what data control is used or if jquery or whatever is used, as long as the end result does what I want.
I know I'm being awkward but if you think have a solution, could you please post the entire code please? I'm just starting on ASP.NET and C# and would love to have this working before the end of the year.
Comment: OK, maybe I was asking for too much. If I could see code to display my data in groups, I think I could figure out the rest myself. As I said, I don't mind what data control I use.
Answer: for acheiving the desired functionality you need to purchase third party gridview control. the options are devexpress,telerik and jqgrid
i personally use devexpress


P2TR: Is pub key hashed in address?

Question: Are the new Taproot addresses (SegWit v1) also a hash of the (potentially tweaked) public key, or is the public key directly encoded into the address, without hashing it?
Answer: Public keys are not hashed in Taproot (SegWit v1). The Taproot (Merkle) tree in the script path uses hashes but the Merkle root of this tree tweaks the unhashed public key (internal key) and the resulting tweaked public key is not hashed either. For more details on why see the reference 2 in BIP 341.
Comment: Right, not quite 2^256 possible points on secp256k1 curve but pretty close https://bitcoin.stackexchange.com/questions/114135/how-does-ecdsa-work-when-generating-the-public-key/
Comment: Does that mean that there are roughly 2^256 possible Taproot addresses (eg pubkeys)?

P2TR: Is pub key hashed in address?


pKa and pKb in solvents other than water

Question: I know that when you have aqueous solutions, then the pKa and the pKb are linked to each other (pKa + pKb = 14). Is there an equivalent relationship between pKa and pKb in non aqueous environments? I'm currently looking at a paper where they have measured pKb values in glacial acetic acid (https://pubs.acs.org/doi/epdf/10.1021/ic50084a055), but I'm interested in finding the pKa values for a different set of compounds in glacial acetic acid. Thank you.
Comment: Closely related, possibly duplicate:  https://chemistry.stackexchange.com/q/28022/35806
Answer: Bruckenstein and Kolthoff give some values in the abstract, which is available in the free preview. Notable among acids: perchloric acid, $pK_a=4.87$; hydrogen chloride, $pK_a=8.55$.
Also given is an autodissociation constant, whose base-10 logarithm is $-14.45$. Thus whereas we render $pK_a+pK_b=14$ in water under ambient conditions, the corresponding constant in glacial acetic acid would be $14.45$. As an example, citing the hydrogen chloride acid dissociation constant given above, we can compute the $pK_b$ of the conjugate base chloride ion as $14.45-8.55=5.90$ (significant zero).
Reference

S. Bruckenstein and I. M. Kolthoff (1956). "Acid-Base Equilibria in Glacial Acetic Acid. III. Acidity Scale. Potentiometric Determination of Dissociation Constants of Acids, Bases and Salts". J. Am. Chem. Soc. 78, 13, 2974–2979.
https://doi.org/10.1021/ja01594a014
Comment: Wow, that is unexpected. I have been assuming perchloric acid is still strong in acetic acid, considering it is used for titration of weak bases there. But I admit I have zero experience in the area.
Comment: This is brilliant! Thank you for the reference. I'm wanting to use perchloric acid for the non-aqueous titration, so this is also a really useful resource for that value.
Comment: From the autodissociation constant aso given in the abstract, we calculate that the neutral "pH" in acetic acid is about 7.2. Perchloric acid with $pK_a$ between two and three units less can reach that condition with most bases; hydrogen chloride can't (unless you go far beyond the equivalence point) and sulfuric acid is marginal at best.


Is there a way to store matrices in an FPGA?

Question: I just finished a Coursera course on hardware design (nand2tetris) and I want to take the next step and implement the design in an FPGA. Being fairly new to the hardware aspect of computing in general, I needed to clear a few questions regarding memory. In particular, I want to implement a memory design that is organized into square arrays of 16 bit wide registers. The data would be accessed by specifying an array and then either a row or column (with the goal of expediting matrix multiplication). However, I am unsure if such a design will fit into an FPGA (I believe I can afford at most a Cyclone V or something equivalent). Since GPUs can be implemented on FPGAs, there must be a more efficient way of doing this that does not require using the D flip flops in each logic element to store a bit from an individual register. If there is not, how do people handle arrays of data in parallel on FPGAs?
Any information would be really helpful and since this is all a purely pedagogical exercise, pointers to learning materials on the subject are appreciated.
Comment: 1/ How big are your matrices? 2/ Matrix multiplication does not requires row AND column access for each matrix. For one you need rows for the other you need columns.
Comment: Ideally I would try to fit about 100×100 matrices. I was considering both column and row access because at some point I might have to left multiply a matrix and at another I might have to right multiply it, so having the flexibility to do it without having to transpose it would be nice.
Answer: Your 'most limited resource' is likely going to be the number of multipliers on the FPGA.
Your matrix multiplication logic will then consists of a stream of numbers read from a source, fed into a bundle of multipliers and the result stored again.
Two-dimensional access is easiest implemented using register albeit it also uses a lot of logic to select the outputs. I have implemented a two-dimensional memory using standard (one dimensional) memory chips but that was patented. I think you will just need to spend some cycle 'rotating' the matrix. Or be clever how you write the result. You might even consider storing each matrix twice.
I am more concerned about precision.
I have no idea what your numbers are, but I do recollect colleges at Delft University about the problems with maintaining precision when repeatedly using floating point numbers. In your case it will be worse because the multiplier in an FPGA has only a limited number of integer bits. Unless you want to implement massive parallel floating point multiplication.
Comment: Yes, you can implement it on an FPGA, but I think your focus is wrong. I suggest you start with normal matrix multiplication and with the experience of that re-assess how to make it more efficient.
Comment: Does this memory design have a name that I can look up? Where can I find out more?
Comment: No, it does not have a name. I can't tell  you more. (non-disclosure etc.)
Comment: You did not mention what FPGA you used. Is it possible to implement what I described in a chip like the Cyclone V?
Comment: It was in an ASIC, not an FPGA (Look at my profile :-)
Comment: Sorry about that. But do you think it is feasible on an FPGA?


How do mobile phones produce signals?

Question: Normally it would require alternating currents to product electromagnetic waves. Yet as mobile phone is powered by batteries which only produces direct current, what type of mechanism/structure allows them to generate the electromagnetic waves,i.e. the signals to communicate?
Comment: Read up on *oscillator*; devices which produce oscillating voltages when supplied DC power.
Comment: an AC power supply would not produce the necessary frequencies either ... why are you singling out cell phones? ... what about garage door opener remote control and RF toy remote control? ... use google to discover how a transistor AM transmitter works
Comment: If you redirect DC in different directions through something, it becomes AC through that thing.
Answer: Your cell phone contains an oscillator. This is a circuit which when fed direct current converts it into ultrahigh frequency sine waves, which are then modulated by an encoded version of the audio signal from the phone's mic unit.

How do mobile phones produce signals?


Power calculation for logistic regression in G*Power

Question: I am performing a sample size calculation in G*Power for a logistic regression with continuous predictor. I am requested to estimate a value for Pr(Y=1 | X=1) H0, i.e. the probability that my binary outcome (group) =1, when my main predictor is at its mean, and to estimate a value for Pr(Y=1 | X=1)H1, i.e. the probability that my binary outcome (group) =1, when my main predictor is one SD unit above its mean.
The paper I am extracting the estimates from reports means and SDs of the two groups (which are my predicted variable).
How can I estimate the probability values requested by G*Power?
Answer: Under $H_0$, $P(Y=1|X=x)$ does not change for any value of $x$ d/t no association. If $X$ is standardized, the mean response is $X=0$. So $P(Y=1|X=0)$ under $H_1$ or $H_0$ would be the proportion of the sample with the response. For ease, let's just call this $p$.
Hopefully table 1 gives you the SD for the predictor $X$. Call this $S_x$. If not, you can't do this.
If you get the odds ratio from the logistic output in the paper you reference, call this $OR$. Then you can find the predicted proportion with response for a one-SD higher group of $X$ by first calculating this
$$ Odds_{1SD}  = p/(1-p) * OR^{S_x}$$
Odds-1SD is the odds of response at one SD higher value from the "center". Convert back to probability with:
$$P(Y=1 |X = S_x) = Odds_{1SD} / (1+ Odds_{1SD})$$


Update error 80050007 windows defender updates 8.1

Question: I've read several posts offering solutions but none seem to help. I have Comodo installed - defender I think gets disabled by this. Tried running update as administrator and a script. Made sure logged in as administrator. Disabled my firewall. I get the error code at the end of trying to install, following download.
Answer: I found an answer to my own problem. Solution was remove third party anti virus security and firewall. In this case comodo suite. Then windows defender becomes accessible again ( buttons wouldn't respond) turn off app by unchecking box - first though run windows update which should now complete . Now when try to access get message box pops up to disabled and won't launch. Now run the install Comodo. Restart windows. Sorted. Seems a conflict. Should have been properly disable. Software tries to do this i think
Comment: You cannot have 2 antivirus softwares operating at the same time, they butt heads as you have found out.


How can I get a cell in Excel to automatically adjust its height to fit the wrapped text contents?

Question: I have a cell with wrapped text content in Excel and I want to format the cell so that its height will adjust to fit the content which can span over several lines. How can I achieve this behavior?
Comment: not sure about excel 2007, but I am using excel 2003 and there that goes automatically, when I input multi-line data in a cell, the line height gets fixed when I press enter.
Answer: From http://support.microsoft.com/kb/149663
To adjust the height of the row to fit all the text in a cell, follow these steps:
Select the row.

In Microsoft Office Excel 2003 and in earlier versions of Excel, point
  to Row on the Format menu, and then click AutoFit.
In Microsoft Office Excel 2007, click the Home tab, click Format in
  the Cells group, and then click AutoFit Row Height.

Also Works when all the rows are selected
Answer: Try

Select the column -> right-click
  column -> Format Cells -> Alignment
  tab -> Wrap text
Comment: I'm not sure if you can make this happen as the contents of the cell change, but once your finished double clicking on the border between the row number and the one below auto sizes it to fit the contents.
Comment: The cell already has this formatting and I want the cell to also adjust its height. I want the height of the cell's row to adjust so that the whole wrapped content of the cell is visible.
Comment: +1: This is not a bad answer. If you toggle `Wrap Text` off and on again, Excel will resize the row height to fit the tallest row. Not suitable if the height of rows is changing dynamically but if you're dealing with static text it should be OK.
Comment: It worked for me on Excel 2019.
Answer: Note that autofit doesn't work on merged cells.  You have to do it manually.
See this Microsoft answer:
You cannot use the AutoFit feature for rows or columns that contain merged cells in Excel
Answer: If it doesn't automatically do it, then place your cursor over the small line between row numbers (ex: between 1 and 2) and double click, this will resize the row (directly above the small line, in the example: 1) so that everything is visible (from a vertical aspect).
Comment: That's something you can do when you have little of this to do but the more complex the more you'll have to deal with that and that means waste of time and energy, getting focus and momentum broken because of such tasks. The solution given by Bertieb works like a charm on Excel 2019.
Answer: Do you know macro? Put the following code in

Application.ActiveCell.WrapText = True

inside your Worksheet_SelectionChange subroutine.
Answer: A VBA solution is to use the following:
<code> Call Application.ActiveCell.AutoFit
</code>
Answer: The only way I can get it to work as expected is to highlight the whole sheet with CTRL-A, unclick the "Wrap Text" button in the toolbar, then re-select it. No other settings change, but each row is now the "proper" height for its contents.
Answer: I created the following VB code to resize the header row when a cell within a range (B2:B1500) because date values above 12/28/2014 would cause the header to show a warning that these dates, in a timesheet, would go into Week1 of 2015:
<code>Private Sub Worksheet_Change(ByVal Target As Range)
    Dim KeyCells As Range

    ' The variable KeyCells contains the cells that will
    ' cause an Action when they are changed.
    Set KeyCells = Range("B2:B1500")

    If Not Application.Intersect(KeyCells, Range(Target.Address)) _
           Is Nothing Then

        ' Change the height of the header row when one of the defined cdlls is changed
        Rows("1:1").EntireRow.AutoFit

    End If
End Sub
</code>