Date display in Solaris 11

Question: # date +"%b %d %H:$(( $(date +'%M')-5))"
Nov 20 12:45

date +"%b %d %H:$(( $(date +'%M')-55))"
Nov 20 12:-5

Why I am getting -5 here? How to correct? Pls help.
Answer: Probably because you ran it at 12:50, where date +%M gives you 50 which becomes 45 when you subtract 5 and -5 if you subtract 55.
At 12:00, you would have gotten -5 with the first one as well.
At 12:07, you would have gotten 12:2 instead of 12:02 and at 12:09, some shells would complain that 09 is not a valid octal number. You can't just subtract 5 to the minutes field to get the time 5 minutes earlier. Consider that for instance at Jan  1 00:00, it should give you Dec 31 23:55.
For date calculation on Solaris, you can use perl or zsh though the latter is not always installed by default. To get the time it was 5 minutes ago:
perl -MPOSIX -le 'print strftime("%b %d %R", localtime(time - 5*60))'

or:
zsh -c 'zmodload zsh/datetime; strftime "%b %d %R" $((EPOCHSECONDS - 5*60))'

Actually since version 11 of Solaris, /bin/sh and /bin/ksh are actually ksh93, so you could also use ksh there (better not sh as while sh is currently implemented by ksh93, that could change in the future and the standard sh language doesn't have those features):
ksh -c 'printf "%(%b %d %R)T\n" "5 minutes ago"'

As indicated by @glennjackman in comments, if you have bash installed, you could also do:
bash -c 'printf -v t "%(%s)T" -1 && printf "%(%b %d %R)T\n" "$((t - 5*60))"'

(support for %s and a recent enough version of bash was added in release 11 of Solaris as well).
And while we're at piling more languages, if you have a TCL interpreter, such as expect:
expect -c 'puts [clock format [
  clock add [clock seconds] -5 minute] -format "%b %d %R"]'

Or python3:
python3 -c 'import time; print(time.strftime("%b %d %R", time.localtime(time.time() - 5*60)))'

Comment: @glennjackman, from the [man page](https://docs.oracle.com/cd/E88353_01/html/E37843/strftime-3c.html#scrolltoc), looks like `%s` was added in Solaris 11 (*The conversion specifications for `%+`, `%P`, `%s`, `%OB`, and `%OV` and also optional flag characters and optional field width were added in the Solaris 11 and OpenSolaris releases for a better compatibility with other operating systems*). And it looks like Solaris 11 [now comes with bash-4.4 (optional package like for zsh)](https://docs.oracle.com/cd/E88353_01/html/E37839/bash-1.html#scrolltoc)
Comment: and starting in bash 4.2, you can write `printf '%(%b %d %H:%M)T\n' $(( $(printf '%(%s)T' -1) - 300 ))` -- what version of bash ships with Solaris 11, if any?
Comment: @glennjackman, (only if `$IFS` doesn't contain digits as you forgot the quotes). Are you sure `%s` is supported on Solaris (as that's not a standard `strftime()` directive)?
Comment: I don't have access to a Solaris machine to verify.

Date display in Solaris 11


List of all Object's fields which are not refer anywhere in System

Question: We have a requirement where we need to clear each fields which are just lying in the system and not used any where to make environments more cleaner, Is there any way to do this. I used eclipse earlier for reverse process where we chose any field and can find its reference.
Comment: What have you tried so far? Where are you stuck? If you try deleting an individual object it will tell you all the references.
Comment: I have only used eclipse so far, but i have to go each and every field and put that in search bar to find its reference. Second way i tried is try deleting them if that is refer anywhere salesforce don't allow to delete. But this is very long way. I am looking for any alternate way anyone has tried.
Answer: This might not be exactly what you're looking for, but Salesforce does offer an "Optimizer" feature, which examines your org, and reports possible improvements in a few areas. One of those areas is field usage, allowing you to see fields which have not been populated in about 6 months.
A few categories reported by a Optimizer report generated a few months ago:

Field Limits per Object
Field Usage per Object
Field Usage per Page Layout

Offical Documentation.


Cyberroam Firewall

Question: In my University, the network is protected by Cyberroam Firewall and we are provided a login page through which we access internet and the login page isn't secured.It sends out the userid and password unencrypted in the network. From past few days, someone has been changing my passwords.
And I think someone is performing MITM and stealing credentials. How do I figure out if this is the case and protect it ?
Comment: 'You' don't. You report it to your university's IT services. If you are correct they will take action.
Comment: There is nothing you can do. Even if you could replicate the problem to prove that someone could do this, you *still* need to engage the IT team to do anything about it.
Comment: They are dumb and the IT services in the university is outsourced. No access to students.
Answer:
You do not need to concern it is Cyberroam Firewall or other brands of firewall. Different firewall products always have the similar functionality. What you should know is the configuration & functionality of firewall.
Functionality: Actually, you should understand the original objective of firewall. Pure firewall is only used to filter different network activities (e.g. IP addresses, port numbers, transmission direction, payload applications, etc.). User ID and password encryption is not the mission of pure firewall, but protected by secure channel methods (e.g. VPN). The truth is: many modern products have combine firewall, IDS/IPS, VPN, anti-virus,etc. functions together into a single product. You buy different packages with different prices. Hence, first, you should know whether your Cyberroam firewall has the channel encryption function.
Configuration: if your firewall has the channel encryption function, you need to know how it is configured. In your case, userid and password are sent in plaintext. Hence, this firewall may not include channel encryption function or not configure/activate encryption. In addition, only network-level integrated firewall has the capability to do such encryption.

What you should do to prevent this - Report to your network administration.
(one solution is encrypt information before sending. However, you use the common login page. Encryption on your own is not feasible.)

Cyberroam Firewall


Breaker lets more Amps then its max

Question: The last few day's I had the main breaker triped a few times, I checked the amps with a multimeter and when the central air conditioner turns on it draws 150! amps for 1 second and then goes down to 20, its breaker is a double 50A breaker and the main is 125A. So is this the cause or its normal that when turning on it should go up so high and maybe the breaker is designed so?
Comment: The motor might need a new start capacitor.
Comment: Can you tell us what model of breakers you have, or provide a photo for that matter?
Comment: I first have to know if this is a problem at all. Also my concern now is about the breaker itself.
Comment: The breaker rating is for steady currents. It will allow several times that current (depends on breaker type) before tripping, but only for a short time.
Comment: @aofkj there is a problem.  It's likely the start capacitor on the AC motor.  Normally there is inrush current, but yours has changed and gotten too high.  Breakers also weaken slightly each time they trip.  Start by getting the AC serviced.
Comment: A reading for 1s on a multimeter probably isn't very accurate, but most handheld meters I've seen are more likely to underread than overread on spikes.
Answer: If a breaker is tripping regularly, that's a serious problem you should look at.   That is not normal or acceptable.  It means something is wrong with your overcurrent protection, or a defective device actually drawing too much current.
It is normal for circuit breakers to allow overcurrent for a short amount of time.  This is needed by motors to start, incandescent bulbs to light, and many electronic power supplies to initially start up.  The term is called "inrush current".
Ultimately the purpose of breakers is to protect wiring and receptacles.  Overcurrent makes them excessively warm, but small overcurrent makes them warm slowly.  The breaker is designed to trip before this heat would endanger the wires.
Many breakers also have an instantaneous trip, where they will trip immediately for very high current (i.e. a dead short).  This is many times the nameplate rating of the breaker.
There is a chart for your breaker of how much overcurrent it will permit for how long.   Here is one example, there should be a vaguely similar chart for your breaker.   I'd get and see if it explains your breaker's tripping behavior.  If it doesn't, then either your measuring method is not precise enough, or you have a bad breaker.  I would be surprised at a breaker instantaneously tripping at 125% of rating.
Comment: So is 150 on a 50A acceptable? And if yes then how could I troubleshoot why the main breaker keeps on triping?
Comment: @aofkj  I would be surprised if 3x resulted in an instantaneous trip, and certainly 1.25x should not.  The data sheet for the tripping breaker would say for sure.  Otherwise it's either a bad breaker, or a larger current spike that's too brief for your meter to see.
Answer: Breakers do not trip right away. Whether they trip depends on how far over their rated capacity the current is and how long the current has been going for.
This behavior is documented in a circuit breaker trip curve for your specific breakers, which gives a range of times for a specific current amount. E.g. in that example, a current of 3x the rated current should take between 10 and 35 seconds to trip. At 100x the rated current (e.g. a short circuit) it should trip in less than 1 cycle (1/60 second).
Answer: Motor starting loads (its the compressor motor in your A/C drawing all the current) can be very high and it is normal for them to briefly exceed the continuous rating of their circuit including the breaker. If breakers were designed to open with more sensitively, with that kind of load they would nuisance trip all the time.

Breaker lets more Amps then its max


Convert distance from meters to EPSG 3857

Question: I need to convert distance from meters to units of EPSG 3857 in PostGIS. This is important for me to calculate a radius for ST_DWITHIN as I'm dealing with geometries. How can I do this?
Comment: 3857 is in metres already
Comment: Yes, but meters in EPSG:3857 are badly distorted meters. Konrad, do you want to convert a circle with a radius in real world meters into an ellipse in EPSG:3857?
Answer: As an approximation suitable for medium-small radii, use the cos() of the latitude to scale up the true distance to a "distance" that makes sense for your latitude in web mercator, as described here.
SELECT *
FROM mytable
WHERE ST_DWithin(
    ST_Transform(ST_SetSRID(ST_MakePoint(%lon, %lat), 4326), 3857),
    the_geom_webmercator,
    %radius / cos(%lat * pi()/180)
);

You only want to do this for small/medium radii because the scaling only makes sense at one latitude. The further you get from your reference latitude, the more wrong your radius gets. If you want a "perfect" result, you could pair this approach with a test on ST_DistanceSpheroid() to pare the results down to items exactly within the radius.


Excel Chart with data points not in chronological order

Question: Say you have total monthly spend for 36 months and you want to display it in a bar graph to show all the spend for the 3 Januarys, then all the spend for the 3 Februarys, etc.  When I sort my data that way, and then put it in a chart, it automatically displays it in chronological order, no matter how I have it sorted.  I want a view of month-over-month to identify seasonal trends, so seeing the spend with the same month of each year grouped together would be ideal.  I can't get that to display.
Comment: Welcome to Super User. We need a little more information about how your data is laid out and how are your dates formatted. What version of Excel are you using?
Comment: I am using Excel 10, version 14.0.6129.5000 (32-bit).  My data is very basic.  I have the year in one column as 10-2012 and a dollar amount in the next column as $5,000, for example.  I did try using the Month function, @Riet.  It did returnt he correct numerical month but I need a bar chart, not a scatter graph.
Comment: I think if figured it out.  I put the months of the year across Row 1 from B1 to M1 with no year reference, and the Years in Column A, then populate the dollar amounts for each month/year in B2 to M4, it works.  Separating the month and year into different cells seems to be the key.
Comment: Glad to hear. You can answer your own question. Just use the area below to describe how you resolved it.
Answer: You might try excel's month() formula. Putting this in a column as the x axis and then scatter plotting it should work.
For example, if the dates are a1:a12, then I would put =month(a1) in column b, with the data in column c.
Comment: `="m" & text(DateColumn,"MMYY")`


What is certificate pinning?

Question: I'm superficially familiar with SSL and what certs do. Recently I saw some discussion on cert pinning but there wasn't a definition. A DDG search didn't turn up anything useful. What is certificate pinning?
Comment: I'm a co-author of the HTTP-Based Public Key Pinning RFC. The answers here are inaccurate in some ways (for example, PKP is separate from STS). Check out my blog post on the topic, https://noncombatant.org/2015/05/01/about-http-public-key-pinning/, or read the RFC itself, https://tools.ietf.org/html/rfc7469.
Comment: There's a reasonably succinct description of [certificate pinning](https://en.wikipedia.org/wiki/Certificate_pinning#Certificate_pinning) in Wikipedia. For a more detailed description see the IETF Web Security (websec) Working Group's [Public Key Pinning Extension for HTTP](http://tools.ietf.org/html/draft-ietf-websec-key-pinning) specification (currently an Internet Draft but probably soon to be become an RFC).
Comment: FYI: This question linked from http://www.theregister.co.uk/2015/03/24/google_ssl_cnnic/
Answer: Typically certificates are validated by checking the signature hierarchy; MyCert is signed by IntermediateCert which is signed by RootCert, and RootCert is listed in my computer's "certificates to trust" store.
Certificate Pinning was where you ignore that whole thing, and say trust this certificate only or perhaps trust only certificates signed by this certificate, ignoring all the other root CAs that could otherwise be trust anchors. It was frequently also known as Key Pinning, since it was actually the public key hash that got saved.
But in practice, Key Pinning turned out to cause more problems than it solved. It was frequently misconfigured by site owners, plus in the event of a site compromise, attackers could maliciously pin a cert that the site owner didn't control. Key Pinning was deprecated in 2017, and was removed entirely from Chrome and Firefox in Nov. 2019. It was never supported to begin with by IE and Safari.
The recommended replacement is to use the Expect-CT header to tell browsers to require that the cert show up in Certificate Transparency logs.
Comment: Good answer, but it also depends on the browser; Google's Chrome browser pins the certificates for Google sites, so in your example, a Chrome browser would only trust specific google.com certificates known to be the correct ones (or the ones signed by the Google Internet Authority).
Comment: @JoshvonSchaumburg When the offending certificate is locally installed (not chained to a root store certificate) then Chrome doesn't do it's pinning checks. This is intentional. The idea is that if you are the owner of the local machine, then your decision should be final and Chrome shouldn't try to circumvent your actions. I think there's been some chatter in the past about giving some visual indication that the certificate is locally-trusted rather than globally-trusted, nothing has been implemented so far.
Comment: Your post confuses HSTS for HPKP. HSTS only ensures HTTPS is used; certificate pinning is [HPKP](https://en.wikipedia.org/wiki/HTTP_Public_Key_Pinning)'s job.
Comment: @KeithS the principle is browser-independent. Google pins certificates it knows using a slightly different mechanism (public key hashes instead of certificate hashes), but it's still close enough that calling it "pinning" is still correct.
Comment: So how is it done? Certificate Pinning, I mean
Comment: @user93353 the certificate details are stored client-side and compared against those sent over the network.
Comment: What I still don't understand about certificate pinning is - why am I still able to access Google apps through a corporate MITM? I know that I have the root cert for my corporation installed on my PC, but shouldn't Google throw an error when its sites are signed by a cert (my corporation's cert) that does not match one of the pinned certs? Maybe I'm misunderstanding how pinning works.
Comment: Fuller details of how it's done (or how it might be done when draft proposals are standardised):
https://www.owasp.org/index.php/Certificate_and_Public_Key_Pinning
https://tools.ietf.org/html/draft-ietf-websec-key-pinning
http://tack.io/index.html
https://www.imperialviolet.org/2011/05/04/pinning.html
Comment: "**Hongkong Post Office**" should make you think
Comment: @user2428118 No. The way you access hpkp configuration (at least when this was written) was as an option in your hsts setup.
Comment: @tylerl: ehhh... no? HPKP uses Public-Key-Pins header, while HSTS uses the Strict-Transport-Security header. They're totally unrelated.
Comment: @tylerl based on [your comment](https://security.stackexchange.com/questions/29988/what-is-certificate-pinning/84425#comment146160_29990) are you saying if an iOS app implements certificate pinning then even that case its network requests would be revealed to something like Charles Proxy, because "if you are the owner of the local machine, then your decision should be final". If that's the case then wouldn't API keys be easily phished from network calls?
Comment: My post referenced the HSTS header rather than HPKP because at the time, the HPKP header hadn't yet been defined, and Chrome overloaded the HSTS header to pin keys. That's not what they do today; in fact, today nobody uses key pinning at all since the feature has been removed.
Comment: `Expect-CT` now seems to be deprecated to :( Unfortunately, this answer need updating again.
`Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. `
Answer: It's ambiguous, but it refers to solutions for an issue in SSL certificate chain verification. Essentially, trust in SSL boils down to root certificates, the certificates your system trusts in to be genuine. Those either come with your OS or with your browser.
If one of those is compromised, all certificates signed by this and transitively signed certificates are to be treated as compromised.

TACK or Public Key Pinning Extension (referred to as cert pinning by chrome, apparently) allows the admin of a server to "pin" a certificate authority's (CA) public key signature to a certificate, which is verified by the client (delivered via SSL extension). If the CA certificate's key is different upon retrieval of the certificate chain, the CA certificate is likely to be compromised.
Source
Cert pinning can also refer to importing a host's certificate in your trust store, rather than trusting CA certificates. This mitigates the risk of a CA cert being compromised but forces you to update certificates if they expire manually.
Source
Answer: SSL server certificates come from the X.509 world. The client verifies the validity of the server's certificate by validating a lot of cryptographic signatures from Certification Authorities. The beauty of the scheme is that it is stateless: a given server could change its certificate every five minutes, and it would still work with clients.
It has been argued that while supporting fast-revolving certificates is awesome but useless, because in practice a given server changes its certificate once per year; indeed, an early certificate switch is indicative of some ongoing fishy business. Certificate pinning is a way for a server to state that this should not happen under normal conditions, and that the client should raise a metaphorical eyebrow should an unexpected certificate switch occur. This is a protocol extension, suggested but not widely supported yet. Actually there seems to be several relatively similar, competing proposals.
See also Convergence, yet another protocol extension which can be thought of as "certificate pinning by trusted third parties". Convergence and the certificate pinning proposals all dance around the same core idea, which is to have some state in the client (or somewhere, at least), and trigger security warnings when certificates change too often or too early. Whether any of these proposals will ever reach wide acceptance (i.e. will be implemented in a compatible way by IE, Firefox, Chrome and Safari, and will be used by most SSL server sysadmins) is anyone's guess.
Comment: I'd claim that Convergence (or Perspectives) are not protocol extensions but a side channel for verifying that the host is using the same certificate when viewed from different locations around the globe and that this situation has around for a while. The core difference to other measures is that the host cannot affect this verification, unlike other cert pinning methods.
Comment: I know this is not the selected answer but for me this was the explanation I could understand. Thanks Tom.
Comment: Seconding Sizons, expressive and concise explanation by Tom. Here's [MDN docs for the implementation of pinning that appears to be the standard today (HPKP)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning).
Comment: "Certificate pinning is a way for a server to state..." Certificate pinning is something that happens on the client side and server does not influence it. More precisely we could say that "Certificate pinning is a way for the developer of the distributed system to state...".
Answer: Generally what happens in a HTTPS connections is that client asks for SSL certificate from the SSL compliant server it is communicating with over https. Server will provide a certificate from its key store. After client receives this certificate it validates its credentials depending on whether

hostname is same as requested
has a verifiable chain of trust back to a trusted (root) certificate [from clients trust store]

Now if connections are proxied and you can get the device to trust your (rogue) root CA certificate then you can intercept the secure connections. This is essentially  man-in-the-middle attack. Now here is what happens in SSL pinning which potentially adds an extra security layer from man-in-the-middle attacks-
App will bundle the known server certificates with itself. When app tries to make a secure connection with the server, it validates the certificate received by the server with the ones it has bundled with. So even if OS validates the received certificate chain against a (potentially rogue) root CA, the app will reject the connection displaying network error.
Note: I have tried to answer this question from a perspective of SSL pinning in Android Apps. SSL pinning is easily possible in such Apps because the app already knows the server (hostname) it is going to connect to. Same may be difficult to implement in browsers though. I think chrome browser already implements this.
I have also wrote a sample code demonstrating cert pinning in Android. You can find it on github. You can also find the same app on playstore.
More information :

http://nickfishman.com/post/50557873036/reverse-engineering-native-apps-by-intercepting-network
http://blog.lumberlabs.com/2012/04/why-app-developers-should-care-about.html
Comment: FWIW there's an issue with certificate pinning: 1. It makes debugging difficult. Because you can't connect it to Charles — unless you disable it during debugging 2. Your certs will eventually expire.
Answer: Certificate pinning allows to bypass standard certificate authority chains to mitigate the risk of an valid certificate be issued to a criminal.
Motivation for a new solution...
SSL/TLS certificates are signed by other certificates. Browsers normally recognize a certificate as valid when in some point of this signature chain a trusted entity is found. The signatures of the trusted entities comes in the basic installation of the operating system and browsers. It is an embedded list of about 100 entities.
If one of the trusted certificate authority are compromised or if the certificate authority is victim of a fraud they can issue an valid certificate to a criminal. The criminal will have a perfect SSL/TLS certificate in your name. The criminal will be able to make successful and believable "man in the middle" attacks. The user will see a valid certificate info to your website.
Also, is not difficult to convince the user to install a new trusted certificate authority. For instance, in Brazil, the official certificate authority is not recognized by the main browsers and everyone has to install an additional certificate authority. Browsers got very good at this: only click in a link and answer yes. To reach this level of usability I believe this is a common task worldwide.
The certificate authorities can not be fully trusted. The process to get a certificate is by no means secure. I already bought one in a company and did not much more than pay for it. Of course is way better than nothing. But needs improvement.
What is pinning?
On the first access to the website secure.example.com, the website send a hidden message to the client browser that loosely translates as:
"in the next N days the secure.example.com website will use the certificate CECECECE. In that period do not accept another certificate, even if the certificate authority claims it is valid for this website. If it happens notify me at http://188.8.131.52/callbacks/warn_pinning.php".
Pinning solves the problem?
It does not solve the weakness of the certificate authorities certificate signing process. But minimize the window of opportunity of a criminal to get by with a man in the middle attack. The attack will only work if gets the user in his or hers first access to the website.
It is similar to the SSH security. On first access the signature of the key of the server is saved. If in future access the identification does not match the system generates an warning. The warning is taken seriously because only happens when you make real changes.
The best thing for a big company is to get notified through clients complaints that someone has issued a real TLS/SSL certificate in their name to a criminal. As I understand the pinning mechanism was proposed by Google
Application Level Pinning
Pinning can also be made outside the browser, by compile the real certificate fingerprint in a app.
Comment: I suppose in the case of DNS poisoning and similar where the IP for the domain name is changed by an attacker, certificate pinning would also help (assuming you visited the site earlier).
Comment: Good question. On encrypted connections it will. But I do not know if pinning a site will prevent unencrypted connections to work. If does not, the attacker will still be able to make a believable attack using unencrypted connections. If does not is only question of time. Make no sense at all to allow unencrypted connections for a pinned site.
Comment: I'd thought cert-pinning is an additional mechanism rather than a replacement of a normal validation. If this validation is by-passed completely (assuming the certificate is not self-signed), then how the certificate (signature) is validated/checked in the first place?
Answer: I think it is just a HSTS implementation to retain SSL certificates of browser clients when a MITM sslstrip attack is made against the web user
Comment: Certificate pinning is different.  At present HSTS doesn't provide any way to pin to a single certificate; instead, HSTS is a boolean that lets a site say "SSL only please" (but doesn't let the site restrict to a single certificate).  Certificate pinning is an extension/different mechanism.

What is certificate pinning?


SSIS Import with IF / THEN Expression (Or an T-SQL Script)

Question: I am currently working on a project and I need to create a temporary solution (for about 6 month) until our consultation group is finished with another project and impliments the needed code fix on the back-end system.
Here is what I am trying to accomplish.
I have a Text file that is dropped into an FTP site. I want to grab the Text file, import it into a folder then run an SSIS process to correct a column.
I need to have the SSIS process look at the column labeled [jobkeyid], if the [jobkeyid] is 65000100 or 65000101 then I want to temporarily capture the [userid], Then I want to look in the [managerid] column, if the temporarily captured [userid] is found then I need to swap it with the [approverid].
once this is done then I will replace this file in the FTP so that a separate system can parse the data for a permissions approval table in an online training system we are launching.
Here is a view of the txt file (put into Excel to make it easier to understand).

I would like to do this in SSIS but if there is a clean T-SQL script that I could implement that would also be good as this is just a temporary solution.
Comment: In SSIS you can implement this with Derived Column and Look-up task. But Look-up Task AFIAK only supports RDBMS sources.
Comment: yeah, you can import the entire file into SQL Server and then process the file.
Comment: This really sounds like a task better accomplished with Powershell.  Is that an option here?
Comment: So I would need to make a table that had all of the people I would want to switch, then set the look-up to point to that. Instead of creating a temporary table that just went away after every pull?
Comment: Powershell is not an option as I have never used that. It's on my list of items to learn though.
Answer: Ah the good old "temporary solution" - if I had a dollar for every ...
You can use an upstream Data Flow Task to load the managerid and approverid into a Lookup Cache.  By default it will ignore duplicates and use the first row for each key (managerid).
Then in the main Data Flow Task, I would use a conditional split to separate the jobkeyid 65000100 or 65000101, then add a Lookup (using the cache loaded above) to get the new userid.  Then I would add a Derived Column transform to overwrite the userid.
Then a Union transformation would pull all the rows back together before delivering them to the output file.
For the FTP tasks I would call WinSCP - this is more reliable and has more functionality than the generic SSIS FTP task.


Oracle used by a Smart Contract no longer available

Question: Ethereum relies on Oracles to provide information about the outside world used by SmartContracts. Also, when a node syncs (in slow mode) it has to go  over all transactions (including SmartContract transactions) to validate the entire transaction history. Well, what if by the time a new node is syncing, the oracle is no longer available?
Answer: I think the important thing to understand is a contract can't consult an oracle for the exact reason the OP describes in the question. Oracles sign transactions with input for contracts, so the fact of that input is part of the chain regardless of the future availability and consistency of the Oracle.
A callback-like pattern can make it seem like the contract calls an Oracle.
Roughly:
Step 1: The Client (contract) sends a request to the Oracle contract.
Step 2: The Oracle's off-chain components observe the request, e.g. watching events.
Step 3: The Oracle's off-chain components sign a transaction to the Client's callback.
Step 4: The Client (contract) has the Oracle's input and can continue with the next step of its process.
In such a sequence, both the sender's transaction that kicked off Step 1 and the Oracle's response, Step 4, are immutable transactions that other nodes will use to compute the Client contract's state. It's not important that the Oracle remains available. What it said, once, is recorded and that's what the Client acted on.
Hope it helps.
Comment: Thanks, that makes a lot of sense!
Answer: The blockchain is isolated from any external interaction and you have all data required to validate blocks and transactions at any time.
Some transactions may include statements from an oracle but they are at a higher abstraction level so regular network client cannot validate them.
An oracle protocol has to provide ways to validate such statements. A typical solution is to provide a voting period if a majority is reached the statement is confirmed. All votes are recorded in the blockchain and you can validate them.


Applying to masters program to further explore my interests, should I mention specific areas of interest in statement of purpose?

Question: I am currently revising my statement of purpose for several applied math master program. I wounder if I should mention some specific area of interests or specific name of faculty? The problem with me is that my undergraduate is rather "theoretical" , that I haven't taken many applied math courses and the purpose of my master is to further explore my interests. But the lack of specific interest on SOP seems a little bit odd for me.
Answer: Short answer: be honest and concrete.
It's not typically expected that you have very specific, highly focused interests for masters programs in mathematics.  For a masters, you won't get too specialized anyway (at least assuming you're not doing a thesis).  Read the application directions carefully to see if the schools are looking for anything in particular, but what I look for in SOPs is a sense of the applicant's goals, background, motivation, seriousness and maturity.  (And maybe other things in special cases.)
You should try to explain your goals as clearly as you can, but be honest about it.  So you don't need to say something specific like you want to do KAM theory for Hamiltonian PDEs, but if you can give specific examples of things that made you want to study applied math, that would be good.  If you can list specific topics in applied math that you would like to learn about, also good.  It's also not a bad idea to get an feeling for the strengths of the departments you're applying to and say why you're interested in them (e.g., strong in xxx, but you don't need to mention specific faculty, unless you're honestly really interested in workin with them).
See also here and here for other points of view.


how to make softlink to bunch of files in one shell comand

Question: I'm under linux and use bash as my login shell . I need to make softlink to a bunch of files.
Thoes files are listed in a text file , let's say file_list.txt . Every line in file_list.txt is just a full path of one target file need to be linked . Although I don't know exactly how to, I do believe there is way to combine "cat " "| " and "ln -s " together to make the job done whithin one shell command . So need your help .
Answer: Consider something like (untested):
for targ in $(cat file_list);
do
   tfile=$(basename $targ)
   ln -s $targ $tfile
done

Note that the basename will strip any file extention like naming (i.e. ".exe" or whatever). This can be fixed but it is a pain. You can have base name strip any single given filename extension if you so desire (use the -s  flag).
You can compress this into a single line like:
$ for targ in $(cat file_list); do tfile=$(basename $targ); ln -s $targ $tfile; done

Comment: `basename` doesn't strip extensions unless you tell it to.
Comment: @Dennis: For some reason I had that behavior reverse in my head. Thanks.
Comment: BSD and OS X (BSD based) `basename` has `-s`, others (Linux, HPUX, AIX, etc.) don't. For the ones that do, you can still do the extension stripping without `-s` for portability.
Answer: You don't say what you want to link to.
Use a while loop without cat. If there are spaces in the filenames this method will handle that.
while read -r line; do ln -s "$line" target; done < file_list.txt

You will have to supply the way to derive the name of the target since you didn't specify it in your question.
Answer: If you want the names in the current directory (or any one directory), and if the names in the file are all absolute names, or are relative names correct relative to the target directory, then:
ln -s $(<file_list.txt) .

If you prefer to use 'cat', then:
ln -s $(cat file_list.txt) .

Clearly, I'm using the current directory as the target.


How do I keep the rear LCD on longer on a Nikon D200?

Question: The LCD on the back of my Nikon D200 has a fairly short screensaver timeout that turns it off if I am not doing anything. This is fine, but sometimes I want to look at something carefully for a while. How can I lock the display on temporarily so that it does not go dark?
Answer: The D200 has menu C5 where the Monitor Off delay can be adjusted from 10 seconds to 10 minutes.  This LCD duration will affect your battery life, but lightly tapping the shutter release button will turn it off.
Conversely, with a short delay, retapping the preview button will turn it back on.


When should I raise risk with stakeholder

Question: Should I raise risks immediately when I see one or should I try to resolve the risk first and then raise it. How long should I try before raising one.
Comment: This question needs to be expanded with additional detail and context. As written, it is too vague, and calls for an opinion on an abstract topic.
Comment: "Should I raise risks immediately when I see one or should I try to
resolve the risk first and then raise it. How long should I try before
raising one." Not enough information. Do you have a risk management process? Search 'NASA risk management' or search for 'risk' at [pmi.org](http://www.pmi.org) for further reading.
Answer: Communication and transparency are key principles in managing a project so stakeholders know what is going on and you maintain trust with them.  So early and often communication messages to stakeholders should be a critical success factor for you.
That said, there is a very real psychological component when it comes to risks that you need to manage.  What people want to hear and what they need to hear are often times--too often--not the same thing.  Intellectually, stakeholders know they need to know and understand the threats jeopardizing their project for which they are spending money.  Emotionally, they want to hear that everything is running perfectly, success is a guarantee, issues are few and uneventful, and risks don't exist.  In a very real way, we all thrive in this illusion.  We reward our employees who maintain that illusion for us, by calling them 'can-do', positive employees and discriminating them against the alwaysnegativeboatrockingtroublemakers.
As the PM, you likely want the same thing when you're dealing with your team, and your team wants to come across like optimistic, can-do people so they will naturally hide their threats.  So your challenge is to break through your own desires of wanting that illusion with your team and then communicating that to your stakeholders while you desperately want to hide those threats.  And then you need to manage their adverse reaction of bringing up what they need to but don't want to hear.
However, their reaction is very real and can materially affect how they engage in your project in a negative way.  Raising your risks--the right thing to do--can cause you more trouble, exacerbating your impacts, more than the risk itself.  Therefore, there are benefits, real benefits, in choosing not to disclose and mitigating under the radar.  That choice is not free of costs and risks so it becomes a trade-off analysis you need to do but you need to do it and it will result in some of those risks being treated stealthily.  Perhaps it's an 80/20 rule, where only 20% going hidden.  I don't really know.  That's for you to decide.
Answer: One thing you should know is that, as a project manager, one of your main goals is to raise, mitigate or resolve risks. But you must definitely differentiate between the risks that concern your board (thus you should not keep it for yourself nor deal with them alone), and the risks that concern you (kind of risks that only need your position and abilities). So make the balance, and if you believe that the risk is of the first type, don't hesitate and raise it.


Can the simplicity of abelian varieities be implied by the reduction

Question: A is an abelian variety over number field K, with simple good reduction at a finite field $\kappa$, can we deduce that $A$ itself is simple?
Comment: Yes. Let $\mathcal{A}$ denote the Neron model over the dvr local ring at the chosen good place. The natural map ${\rm{End}}(\mathcal{A}) \rightarrow {\rm{End}}(A)$ is an equality and the natural specialization map ${\rm{End}}(\mathcal{A}) \rightarrow {\rm{End}}(\mathcal{A}_{\kappa})$ is injective (using $\ell$-adic Tate modules for $\ell \ne {\rm{char}}(\kappa)$), so we get an injective map ${\rm{End}}^0(A) \hookrightarrow {\rm{End}}^0(\mathcal{A}_{\kappa})$. The target here is a division algebra, so the source is too (as everything finite-dim'l over $\mathbf{Q}$).
Comment: Just want to make sure I understand the way to prove the injectivity correctly: Do I need to first go to endomorphism of $A[l^n]$ over formal scheme $Spf(R)$, then use formal GAGA and lifting property of etale scheme $A[l^n]$ over $R$?
Comment: Formal GAGA is not needed; it is simpler. Each $\mathcal{A}[\ell^n]$ is a finite etale $R$-scheme ($R$ is base dvr), and any map between finite etale $R$-schemes is determined by its effect on a single geometric fiber. (This is true way more generally over any connected scheme, but let's not get into that.) Indeed, can assume by faithfully flat scalar extension to completion, then maximal unramified extension, then completion again, that $R$ is complete with sep. closed residue field. Then by Hensel every finite etale algebra is a product of copies of $R$. So it is "physically obvious".
Answer: Here is a slightly different proof. We have the following facts:

(1) If $B, C$ are abelian varieties over $K$, then the Néron model of $B\times C$ is the product of the Néron models (this is a simple onsequence of the universal property of Néron models). In particular, if $B\times C$ has good reduction, then $B, C$ also have good reduction, and the reduction of $B\times C$ is the product of the reductions of $B$ and $C$.

(2) If $A$ and $B$ are isogeneous abelian varieties over $K$ and if $A$ has good reduction, then $B$ has good reduction and any isogeny $A\to B$ induces an isogeny on the reductions.

Proof of (2): if $A\to B$ is an isogeny of degree $n$, then there exists an isogeny $B\to A$ such that the composition $A\to B\to A$ is the multiplication-by-$n$ map $[n]_A: A\to A$ on $A$. On the reductions we have the maps $A_k \to B_k^0 \to A_k$ whose composition is $[n]_{A_k}$. Consider a positive integer $\ell$ prime to $n$ and to $\mathrm{char}(k)$. As the restriction of $[n]_{A_k}$ to $A_k[\ell]$ is an isomorphism, $A_k[\ell]\to B^0_k[\ell]$ is injective, so $B^0_k[\ell]$ contains $(\mathbb Z/\ell \mathbb Z)^{2\dim B}$. Therefore $B_k^0$ is an abelian variety and $B$ has good reduction. Finally $A_k\to B_k=B_k^0$ is an isogeny because its kernel is contained in $A_k[n]$.
This is a special case of Néron-Ogg-Shafarevich criterion (Serre-Tate: Good reduction of abelian varieties, §1).
Now to answer the original quesiton, if $A$ was not simple, then it is isogeneous to a product of abelian varieties $B\times C$. Then $B\times C$, $B, C$ have good reduction by (2) and (1), and $A_k$ is isogeneous to $B_k\times C_k$. So $A_k$ would not be simple.


Multiple Column Sorting With dgrid

Question: How can I change the default behavior of grid.js::_setSort() in order to correctly display the sort criteria (up/down arrow) in the header of all the columns involved in a sort? Currently, _setSort() only deals with the first column of the array passed to grid.set("sort"). For example, after setting the sort criteria with the following command, only the header of col1 will contain an arrow (up arrow in this case).
grid.set("sort", [{attribute: col1, descending: false}, {attribute: col2, descending: true}]);

I could override _setSort() but the underscore tells me it's a private function...
Answer: The underscore just means that the function should be treated as private, but that doesn't mean you can't override it. I would go forth and prosper with your override approach. :)

Multiple Column Sorting With dgrid


Power analysis for circular data

Question: Imagine I have a sample distribution for a circular data set with a mean group direction and known variation. I would like to do a power analysis for a known effect size (e.g. to determine what sample size I need to be able to determine a certain angular difference) but on the circle. Do I have to convert circular data to linear and then apply the known power analysis or is there any other approach? Many thanks. Dmitry
Answer: Converting the data to linear is a step that would need to be factored into the power analysis. Therefore, that approach will not give you the correct answer for the required sample size.
There are no standard tools available for power analysis of circular tests (that I'm aware of). Therefore, the only solution that I see is to repeatedly simulate data similar to yours, and calculate the power based on this small simulation study.

Power analysis for circular data


Idioms that mean watch your back

Question: I am looking for an idiom or phrase that means to make sure your back is covered or to limit your exposure from behind. Something that connotes the idea of sitting in the corner of the room like Wild Bill Hitchcock always did. Would be nice if it also had a sort of cryptic connotation as well but this is not necessary.
Comment: "Check your six" (a metaphor from clock dials) springs to mind but fairly reeks of cordite. And I believe "Wild Bill" wrote his surname Hickok, or sometimes Haycock.
Comment: What kind of "cryptic connotation" do you mean? Something linked to secret messages or cryptocurrency, or something that most people wouldn't understand or is otherwise subtle or hidden.
Comment: In the US, the acronym _CYA_ (pronounced /siwayei/) is very common for all sorts of bureaucratic and political horseshit, especially where extra steps have to be taken for security and success (where it is possible). Though, usually, one doesn't have to worry about violence. **CYA**, of course, means "Cover Your Ass".
Comment: What's wrong with "watch your back"?
Answer: "Keep your head on a swivel" is another idiomatic phrase from the armed forces which describes hyper-alertness or maintaining awareness of possible danger from all directions.

Idioms that mean watch your back


Ctrl+TAB is not working in vim with gnome-terminal

Question: I have a serious problem.
Usually, the editor I use is vim, though I can't map ctrl+tab action.
I wanna switch tabs with ctrl+tab (ctrl + shift + tab).
In xterm, this mapping is enabled, and the action will be used.
But, in gnome-terminal, tab is escape sequence have just appeared.
Please tell me how to switch tabs in vim with gnome-terminal.
Answer: Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today, even in GVIM. Some key combinations, like Ctrl + non-alphabetic cannot be mapped, and Ctrl + letter vs. Ctrl + Shift + letter cannot be distinguished. (Unless your terminal sends a distinct termcap code for it, which most don't.) In insert or command-line mode, try typing the key combination. If nothing happens / is inserted, you cannot use that key combination. This also applies to <Tab> / <C-I>, <CR> / <C-M> / <Esc> / <C-[> etc. (Only exception is <BS> / <C-H>.) This is a known pain point, and the subject of various discussions on vim_dev and the #vim IRC channel.
Some people (foremost Paul LeoNerd Evans) want to fix that (even for console Vim in terminals that support this), and have floated various proposals, cp. http://groups.google.com/group/vim_dev/browse_thread/thread/626e83fa4588b32a/bfbcb22f37a8a1f8
But as of today, no patches or volunteers have yet come forward, though many have expressed a desire to have this in a future Vim 8 major release.
Answer: The problem is that in a terminal, a Tab character is ^I (Control-I).  This means that pressing control while pressing tab is not something the terminal even bothers to pass through to Vim.[1] It just sends a regular tab character.
GVim can support this because it doesn't have to rely on the terminal to tell it what keys are being pressed in what combination--it has more direct access to keyboard events, so it has no trouble seeing modified special keys.
I suggest you find a different key to map so you can have consistency.
[1] It is my understanding that with "modern" terminal emulators this is no longer true, but it was true for so long that there is a huge legacy hurdle to overcome because the terminal library that Vim uses (Ncurses) doesn't even handle this event, so even though the terminal technically may support it, Vim can't because the library API it relies on can't.  Roughly once a year there's been serious discussion in the Vim Developers' list about fixing this problem by various means, including switching to a more capable API, but nothing ever comes of it.
Comment: It's still true with most terminal emulators – neither xterm, gnome-terminal (vte), nor urxvt handle Ctrl+Tab any differently from Tab.
Answer: The closest answer I have for this is to create Leader + Tab and Leader + Shift + Tab
map <leader><Tab> :bnext<cr>
map <leader><S-Tab> :bprevious<cr>

I have mapped my Leader to , (comma), so it's typing , + Tab
However they don't work very well. You can't keep Leader held down and keep hitting Tab to scroll through the tabs. This is also not in the MRU (most recently used) behaviour either.
For clarification I'm using 'buffers' instead of 'tab pages' as I find these map much better to the concept of what other editors use tabs for.
Instead of this, you can try the following:
map <leader><Tab> :b<Space>

This opens up the ex command, and then you can press Tab to start scrolling through the buffers. You can also then use ← and → to go back and forth.
With this approach you can also start typing the part of an open buffer and pressing Tab will then cycle through the filtered list of open buffers.
Personally though I just map Leader + Tab to give me the basic MRU behaviour:
map <leader><Tab> :b#<cr>


Android BLE Advertisement not able to exceed 20 bytes

Question: I'm trying to send a series of BLE advertisements from my Android app. Is there a way to use more of the 31-byte maximum for BLE advertisement packets for actual data? Currently, I can only use a maximum of 20 bytes for actual data. Here is my code for building the advertise data.
AdvertiseData advertiseData = new AdvertiseData.Builder()
                        .addServiceData(uuid,adv_packet)
                        .addServiceUuid(uuid)
                        .setIncludeTxPowerLevel(false)
                        .setIncludeDeviceName(false)
                        .build();
                adv.startAdvertising(advertiseSettings, advertiseData, advertiseCallback);

Where adv_packet can currently be a maximum of 20 bytes.
Is there a way I can increase this maximum?
Answer: The advertising packet is fixed at 31 octets and will contain a number of AD structures. Each AD structure shall have a Length field of one octet, which contains the Length value, and a Data field of Length octets. For service data that means about 20 octets of actual data.
Some common workarounds are:

compress/encode the data that is sent
Have a number of advertisements each with different data
Use scan response

And of course, looking to the future, there will be Bluetooth 5 Extended Advertisements


Display tabs conditionally in record page

Question: In the custom record page for an object, can I show or hide tabs based on record type? For example, I want to show a tab "Incident Details" if record is an Incident and "Service Request Details" if record is a Service Request
Comment: You can create multiple lightning pages and bind them to the record types when they become activated.
Answer: If you have a small number of combinations of tabs, for each combination:

Create a Formula Checkbox that is true only when you have this combination
On the Record Lightning Page, create a Tabs Component and include tabs appropiate for this combination.  Then add a Filter for this combination's Tabs under Set Component Visability using the Formula Checkbox from above.

I'm researching if there is a better way since my implementation has a large number of combinations: 9!
Answer: Please vote for this idea (Lightning tabs - tab visibility filters) to add visibility filters for individual tabs in lightning tabs.
When I need to provide functionality for a specific subset of people it's not practical to provide a whole separate tab set for each possible combination of features. It'd be great to be able to toggle visibility of individual tabs.
Comment: This idea has been merged into this one: https://ideas.salesforce.com/s/idea/a0B8W00000H6VzyUAF/allow-conditional-tabs-for-lightning-app-builder-tab-component
Answer: Another solution could be if you add two set up tab components in record page and give them different visibility condition.


Restoring .bak file SQL Server 2005 in SQL Server 2008

Question: I don't have enough knowledge in SQL Server back and restore. I just want to know is it possible to restore an SQL Server 2005 .bak file in SQL Server 2008? If yes, how can I do it?
Answer: All restore operations in SQL Server are backward compatible. You can restore a 2005 backup on a 2008 instance just like you would restore a 2008 backup on that same instance.
There are some limitations to older SQL Server versions, but a backup that was taken on a 2005 or newer instance can currently be restored on any supported SQL Server version.
However, the backups themselves are not backwards compatible. So on a 2005 instance you cannot restore a backup that was taken on a 2008 instance.
Answer: Yes, it is quite possible to restore a SQL Server 2005 backup to SQL Server 2008.
The restore command is the same as of restoring to SQL Server 2005.  E.g.
RESTORE DATABASE [Xyzzy]
  FROM  DISK = N'\\Server\Share\Path\Xyzzy_FULL_20130915.bak' WITH  FILE = 1,
  MOVE N'Xyzzy_Data' TO N'D:\Data\Xyzzy_Data.MDF',
  MOVE N'Xyzzy_Log' TO N'F:\Data\Xyzzy_log.LDF',  RECOVERY,  NOUNLOAD,  STATS = 10

The restore will be followed by some upgrade steps to bring the SQL Server 2005 database format up to the SQL Server 2008 database format.
(Note: You will not be able to restore the 2008 database back to 2005.)
There are limits to how early a version of SQL Server can be restored to 2008, but 2005 should work fine.  Here is a link to the supported upgrade paths to SQL Server 2008:
http://technet.microsoft.com/en-us/library/ms143393(v=sql.100).aspx
Comment: Thanks for the replay. I took .bak file from another server, now I want to restore my system. Is it possible ?
Comment: While restoring the .bak from GUI, its showing error like Restore failed for SERVER 'my server name' . What can I do ?
Comment: What error messages are you getting?
Comment: sorry, I forgot inform you. Somehow its worked. Thank you.
Answer: Yes you can do it
As you want to restore the database of SQL server 2005 to  SQL server 2008 I will say it as a "Migration" of Database.
How you can do it?

You Can follow this steps.
1. Perform a full and a transactional log backup of the user database
2. Copy the database backup files to the new server
3. Restore the full backup followed by the transactional log backup of the user database
4. Change the Database Compatibility Level
5. Verify Logical and Physical Integrity of the Database
Note: if the database is in SIMPLE recovery mode then you only need to perform a full backup and a full restore.
*Perform a Full and a Transactional Log Backup of the User Database Using T-SQL Commands*

Connect to SQL Server 2005 Instance using SQL Server Management Studio.
Execute the below mentioned T-SQL code to backup the Adventure Works database.

BACKUP DATABASE AdventureWorks
TO DISK = 'D:\Backups\AdventureWorks.BAK'
GO
BACKUP LOG AdventureWorks
TO DISK = 'D:\Backups\AdventureWorks.TRN'
GO
Restoring the User Database from the Database Backups

Copy the backup files that were created above and place them on the server with SQL 2008.
Connect to SQL Server 2008 instance using SQL Server Management Studio.
Execute the below mentioned T-SQL code to restore the Adventure Works database on a SQL Server 2008 Instance. Note: make any adjustments that may be needed to the below code.

RESTORE FILELISTONLY
FROM DISK ='D:\Backups\AdventureWorks.BAK'
RESTORE DATABASE AdventureWorks
FROM DISK ='D:\Backups\AdventureWorks.BAK'
WITH
MOVE 'AdventureWorks_Data' TO 'D:\MSSQL\DATA\AdventureWorks_Data.MDF',
MOVE 'AdventureWorks_Log' TO 'D:\MSSQL\DATA\AdventureWorks_Log.LDF',
NORECOVERY
RESTORE LOG AdventureWorks
FROM DISK ='D:\Backups\AdventureWorks.TRN'
WITH RECOVERY .
Change Compatibility Level
Once the database is upgraded to SQL Server 2008, execute the below T-SQL code to change the database compatibility to 100 (SQL 2008). You may need to check that your application works without issue after changing the compatibility level.
USE [master]
GO ALTER DATABASE [AdventureWorks] SET COMPATIBILITY_LEVEL = 100
GO
Verify Logical and Physical Integrity of Database
DBCC CHECKDB ('AdventureWorks')
GO
Note :--When you restore a SQL Server 2005 backup file in SQL Server 2008, the operation takes much longer than when you restore the same backup file in SQL Server 2005. Hot fix is available at
http://support.microsoft.com/kb/967178.
Thank you,
Sam
Comment: ...and while you are at it UPDATE STATISTICS with FULL SCAN and DBCC UPDATEUSAGE after upgrade to a newer version of SQL Server.
Comment: If you really want to check consistency of database, check it before restore. That would have advantage.


Could not initialize class com.google.gdata.client.youtube.YouTubeService

Question: I am using grails and google youtube api( https://developers.google.com/youtube/2.0/developers_guide_java#AuthSub_for_Web_Applications) to fetch details about videos uploaded by users. But as soon as I try to initialize YouTubeService class as :
String emailID="email@example.com"//this is the id with which i registered for developer key
String DeveloperKey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" //developer key given by google
YouTubeService service=new YouTubeService(emailID,DeveloperKey)
//I am done using appName,clientId(given by google) as the first parameter to the
YouTubeService but nothing helped

It gives me the following error:
Class java.lang.ClassNotFoundException
Message com.google.gdata.data.media.MediaMultipart
//I can see this MediaMultipart file in the said destination in one of the included jars.
Originally it was complaining about com.google.collections.common.Maps but then i
added google.collections.1-rc.jar. I also tried adding guava.jar as read from various
forums but that could not solve my problem

If I reload the page, the error changes to
Class java.lang.NoClassDefFoundError
Message Could not initialize class com.google.gdata.client.youtube.YouTubeService

I have included all the required jars( http://code.google.com/p/gdata-java-client/downloads/list) but this problem is not getting solved. Please help.
Answer: Try adding javax.mail and com.google.guava dependencies that are required by gdata-java-client.


Could not find a navbar background that fits with my logo

Question: I recently changed the logo for my company but now it does not fit anymore on the navbar. The color of the logo are  #3331a1 and #a8b0c6. I don't really want to have a white navbar but seems to be the only option. I am also willing to modify a bit the color of the "HR". Do you have any suggestions for the navbar color?
Answer: Logos should generally have multiple approved configurations for various use cases..... 1 color, reversed, greyscale, processes color, spot color.
In this instance I would merely change the logo to a one-color version. And in white for this use.


Magic Transit or Magical Transit, Poxy Everything or Proxy Anything

Question: Cloudflare uses 'Magic Transit' and 'Proxy Anything' and I want to know why.
Comment: This is really a marketing decision,  not a matter of everyday usage.
Answer: "Proxy Anything" refers to the fact that whatever a user wants to proxy, they can proxy. Everything is proxiable by the user, but only some things actually are proxied by the user. "Everything" describes the potential things proxied, but "anything" describes what's actually proxied.
Answer: The marketing people thought that it sounded better like that.
Perhaps "Magic Transit" sounds like it is "Magic"= really good, wonderful, rather than "magical" = supernatural.
And "anything" can proxy, but not "everything" at once.
But these are not examples of normal grammatical English.


How can I remove the cylinder from a Bernzomatic QuickFire propane torch?

Question: This torch was discontinued by the manufacturer and the division that made it is no longer a part of the company, so current tech support has no knowledge of it. It takes a proprietary propane cylinder about the size of a coffee mug, which twists up into the base.  I cannot remove the cylinder after turning it CCW and pulling fairly hard on it.  Anyone know how to get it out?
Comment: Going to have to try harder to unscrew.
Comment: pipe wrench? maybe a squirt of penetrating oil onto the threads overnight?
Answer: This torch was discontinued, and finding replacement cylinders will be a chore. I read that the company did have an exchange program at one time, but that was several years ago so that may no longer be an option. You could try calling the Bernzomatic customer service line to see if they still will allow you to return it for credit towards a replacement torch.
The canister may be seized onto the torch, and I would not try to use force to remove it. The contents are under pressure, and may cause an explosion if excessive force is applied. My advice would be to light it and burn off all of the gas in the cylinder, and then safely dispose of it. They sell other torches just like this that accept full size cylinders that have all of the same features. I have had mine for many years and never had any issues.
Answer: You could try a small oil filter wrench, I have one for a motorcycle that fits over a propane cylinder , it would probably fit between the bottle and the housing and that would provide more force to unscrew.


What is the name of this chord? (Csus2+4)

Question: The chord, is a Csus2+4 combination without the perfect fifth. The inversions are Dm7 (without fifth) and F5 (with major sixth). WhatI want to know is the name of this chord?
Comment: Why do you think there is "the" correct name, one single correct name, and all others must be incorrect? And once you know what the correct name is, this knowledge enables you to do ... what? Google the chord's name and the search gives you songs where this chord has been used? Or do you want to write the chord symbol somewhere and not be ridiculed by others for using an incorrect name?
Comment: @TechnicGoblin5R, I answered with what it could be. But, really, you aren't asking for the correct name?!? The point of this exchange is to _explain music theory_ not side step it. Why won't you explain what comes next, or if you aren't playing any other chords?
Comment: I'm not necessarily asking a "correct name", just what names could be used. The post will be edited (again!) to reflect this.
Answer: Insufficient information to give it a definite name.  We need more notes, or some context (a chord is often best described by what it DOES, not merely what it IS.)
You say 'the root is C'.  All you really know is that the lowest note is C.  Not at all the same thing.
It could be the bare bones of a Dm7. But we really don't know.
What does 'bound' mean?  Tied up with ropes, a fence, a jump...?  See what I mean?  No context, no definite meaning.
Comment: I rewritten my post. But i don't know what this cord does, and i cant attach sound files to demonstrate it.
Comment: That's fine.  But you must therefore accept that there is insufficient information to give it a definite name.  (And you still can't know that the lowest note is the root.  Chord inversions exist!)
Comment: I think _everything_ is better described by what it does. Using "is" sentences either rely on people having the same assumptions and understanding, or try to impose the assumptions upon others. "What _is_ this chord" without specifying a behavioral context just means, "I don't know what I'm talking about and/or I don't know how human communication works". :)
Comment: Related to chord inversions, i think that this appears to be an inversion (not sure if first or second) of a f5(add6) chord but i'm still not sure...
Comment: @TechnicGoblin5R, we don't need an audio file. If you give the chord before, and especially the chord after, that should be enough context. If you are just experimenting with combinations of notes and want to know how to name the "chord", Larry's point is you need to move to another chord to really define things. You could make it act like a `Csus` chord or you could make it act like a `D` minor seventh chord. Give us some more background info.
Comment: Rewritten again with more info.
Comment: You've destroyed the question in your latest re-write!  Yes, you have quoted three possible names.
Answer: I think you are missing the point from commentators. We don't need details about C D F in isolation we need to know the other tones around that.
Below are three examples putting C D F into a harmonic context. I've highlighted with two colors to make clear that the mere group of notes C D F - which are in the red boxes - are not necessarily the proper chord. In the green boxes are the proper chords. Notice that those "proper" chords can span several rhythmic events...

The first treats C D F so that the C is just a neighbor note movement within a B diminished chord. Again, notice that everything in the green box can be properly considered the B diminished chord. Or, you could consider the chord G7 with the root omitted. Either way the chord is root position.
The second treats C D F as a D minor seventh chord in third inversion moving to a G dominant seventh chord. Here the red and greeen boxes overlap.
The third treats C D F as a suspension within a C chord in first inversion. In this case the green box groups C D F with the C chord.
So... that's three different ways to identify C D F depending on what you do with the other chords.
In order to name the chord in a harmonically meaningful way you must name it within the harmonic context.
If the green boxes seem confusing, if they look like they contain 3, 1, and 2 chords, keep in mind this is a more conceptual understanding of harmony and chords involving the treatment of non-chord tones.
Answer: I think what you call it should depend on how and where you use it.
There's Csus4 flavor in it, but my first idea when hearing it was F6omit3/C. Or Dm7(omit5)/C. Fm6omit3/C? Do you want to use it as a suspension? What other notes do you imagine that could be coming soon? If there's a melody that this chord is backing, what scale might the melody use? Where's the tonic? It could be anywhere.
If you think that this C+D+F chord is a sample that you trigger, it could fit a great variety of musical situations, and if you had to write a name for the harmony, the chord's name would depend on the context.
Answer: this is a C (sus 2) (sus 4) (no 5)
Comment: What if the D and F are held into the next chord?


When I would use a specific similarity coefficient over another?

Question: Like using Jaccards over Dice.
I want real examples, of when I would prefer to use Jaccards, Dice, Cosine or any other similarity coefficient.
Answer:
Jaccard - measures similarity of assymetric, binary attributes. For example, if you have insurance claims with binary attributes ("poor driving record", "premium paid in cash") you can compare claims with those attributes.
Cosine - measures similarity between vectors, like feature vectors. Could be used in a recommender system where a user asks to see items similar to some selected item.
Dice - equivalent to F1-score. Often used in image segmentation, comparing a model's output with reference masks.


How do I find CMRR?

Question:
How do I find the common-mode rejection ratio, CMRR for this circuit? I know I have to find differential gain and common-mode gain as 'differential mode gain/commonmode gain' but with current mirrors in, I'm having trouble finding it..
Could not find though I saw other questions posted here
Thank you
Comment: Start by asking yourself what CMRR means. If this amplifier was was given to you on a PCB and you had a lab with a lot of equipment available, how would you measure the CMRR? Then do the same in the simulator. If you want to determine the CMRR analytically, then draw the small signal equivalent circuit and analyse that. Do you know how to determine the CMRR of a differential pair? Realize that if you have to ask how to determine XYZ for each existing circuit, that's not going to work. You have to understand the **method** so that your knowledge can be applied to **ANY** circuit.
Comment: Hi Jessie! Can you tell us where exactly you're stuck? We can help you with problems, but we need you to narrow down for us what you need help with. Like you're currently asking, we'd need to write a complete introduction to electonic circuits, or just do your homework for you, and we'll do neither in an answer.
Answer: CMRR = 20 * log (|Gd| / |Gcm|)
Gd = differential mode gain
Gcm = common mode gain

Let's calculate Gcm:
Add two identical voltage sources Vs1(t) to the circuit: the first on VINP and second on VINN.
We have a common mode signal applied to the circuit.
Superposition now:
Turn off (short VINN to GND) the second and calculate:
G1p(t) = VTIA'(t) / Vs1(t)   or   G1p(s) = VTIA'(s) / Vs1(s)

Now turn off (short VINP to GND) the first and calculate:
G1n(t) = VTIA''(t) / Vs1(t)   or   G1n(s) = VTIA''(s) / Vs1(s)

Now calculate Gcm:
Gcm(s) = G1n(s) + G1p(s)

or
Gcm(t) = Gn(t) + Gp(t)

Let's calculate Gd:
Add two identical voltage sources Vs2(t) to the circuit: the first on VINP and second on VINN.
This time though flip vertically Vs2(t) on VIN in order to have a differential signal applied to the circuit.
Superposition now:
Turn off (short VINN to GND) the second and calculate:
G3p(t) = VTIA'(t) / Vs2(t)   or   G2p(s) = VTIA'(s) / Vs2(s)

Turn off (short VINP to GND) the first and calculate:
Gn2(t) = VTIA''(t) / Vs2(t)   or   Gn2(s) = VTIA''(s) / Vs2(s)

Now calculate Gcm:
Gcm(s) = G2n(s) + G2p(s)

or
Gcm(t) = G2n(t) + G2p(t)

Finally calculate:
CMRR = 20 * log (|Gd| / |Gcm|)
Comment: *short VINN to GND* That's not how you determine CMRR. Common mode means that both the \$V_{INP}\$ and \$V_{INN}\$ are exited by the same signal meaning \$V_{INP}\$ and \$V_{INN}\$ should be shorted and a signal should be applied to them. It is good that you provide answers but giving wrong answers is only confusing to OP.
Comment: You are right. I corrected my answer.

How do I find CMRR?


How to send push notification in android using php?

Question: I want to send android push notification from php. I have created admin in php & mysql when admin approve anything from admin than send notification to user.
Comment: This is a question about php, not about WP (even if it maybe is incorporated in some plugin)
Answer: Android Push Notification requires you to have GCM Keys and Project ID which needs to be registered on Google Developer console.
I am assuming you are able to get your users registration IDs and stored in a table.
To send Android Push Notification create a function somewhere in your functions file
<code>function AndroidPushNotification($registration_ids, $message) {

$url = 'https://android.googleapis.com/gcm/send';
$fields = array(
    'registration_ids' => $registration_ids,
    'data' => $message,
);

define('GOOGLE_API_KEY', 'YOUR-API-KEYS');

$headers = array(
    'Authorization:key=' . GOOGLE_API_KEY,
    'Content-Type: application/json'
);
echo json_encode($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));

$result = curl_exec($ch);
if($result === false)
    die('Curl failed ' . curl_error());

curl_close($ch);
return $result;
</code>
}
Fetch all registration IDS from your database and call this function. Break registration IDs into group of 999. Sometimes, if your array has more than 1000 registration IDs, the notifications aren't delivered.
If you subscribers list if very big, you can also look for multi-curl option which will be faster.


Grails: How to remove any and all HTML tags from a String

Question: What is a simple, fast and reliable way to remove any and all HTML tags from a text string in Grails?
Answer: This first removes any comments (which might contain tags) and then any tags:
text = text.replaceAll(//, '').replaceAll(/<.*?>/, '')

(via http://grails.1312388.n4.nabble.com/Strip-html-tags-tp1316579p1316580.html)
Answer: The best way is to use library Jsoup. Add to dependency:
compile 'org.jsoup:jsoup:1.8.1'

And then use it wherever you want. Simply delete all tags, of course, you can configure parsing. The simplest way to delete is:
Jsoup.parse(html).text()

Answer: I generally do this by regular expression. If tags are missing below just add them:
def stripHTMLTags { content ->
  def regex = /<\/?(?i:script|embed|object|frameset|frame|iframe|meta|link|style|a|img|br|p|span|div|hr)(.|\n)*?>/
  content.replaceAll(regex, '')
}

Source: http://grails.1312388.n4.nabble.com/Strip-html-tags-td1316579.html#a1316586
Comment: I'm rather looking for a solution to remove ALL HTML tags. Since the standard surely will be expanded by further tags in the future, having to list them all is not an option as that will need manual amendment.


Is is possible to apply separate formatting to multiple different Excel table columns?

Question: I have some calculated columns in an Excel (2007) table. I'd like to distinguish them visually from the user-input columns in some way, but without losing the nifty automatic row banding. It looks like I can create a "table style", but only the first and last columns can get separate formatting. Is there any way to format arbitrary columns (or at least the last n columns instead of just the last one)?
Answer: You can format columns to unlock cells which are user-input, and then set conditional formatting for columns in your table specifying the formula condition =CELL("protect", ) as condition. Or you can set the following udf:
<code>Function IsFormula(cell)
  IsFormula = cell.HasFormula
End Function
</code>
and then set an analogous conditional formatting.
Comment: Thanks for the answer. Wouldn't conditional formatting lose me the rest of the table formatting though? Specifically the row banding?
Comment: Yes, conditional formatting overwrites other formatting properties. It could not be different. You have to think a conditional formatting that is compatible with row banding. For example, a row banding with slight different colors than the other ones, or with different colors for text. About conditional formatting for row banding you can see http://www.google.com/search?q=row+banding+conditional+formatting+excel
Comment: Try to  set the color of cells in the columns using the conditional formatting. I tried it and you don't use the banding.


Syncing epub reader

Question: What epub readers will sync between my Android phone and rooted Nook Simple Touch? (I mean my place in a book, not the books themselves.)

I tried PageTurner - and, while it works, it's ugly as sin. Text looks awful, margins are bad.

Ideally I'd use Google Books, but it won't run on my Nook. I tried version 1.6 (I think) and it opens, shows covers, then crashes.

Thanks!
Answer: Moon+ Reader can sync between devices, via Dropbox or Google Drive.
It, too, has an ugly UI... but not, I seem to recall, as poor as PageTurner.

Syncing epub reader


How do I remove the white line in Chrome Trusted Web Activity?

Question: I'm using the SVGOMG-TWA Trusted Web Activity example from the Google Labs example (https://github.com/GoogleChromeLabs/svgomg-twa). How do I remove this white bar above the navigation bar? In this example, in styles.xml is configured only for the parameters of the splash screen that appears before loading the site view itself. The site itself is dark, as well as the colors of all the panels in the app. During the display of the splash screen, this band is missing, so I came to the conclusion that this is either part of the "site browsing activity" itself, or it does not fill the entire height of the screen and there is a free space, which is painted white. All colors in @color are dark.
Here is the styles styles.xml:
<resources>
<!— Theme to create a blank screen while the TWA is opening —>

</resources>

And this is a part of the AndroidManifest AndroidManifest.xml:
<meta-data android:name= "android.support.customtabs.trusted.STATUS_BAR_COLOR"
android:resource="@color/colorPrimary" />

Thus, the example sets the color of the status bar for the site viewing itself after the splash screen is displayed, but if you set the background color in the same way, nothing changes and the white bar still remains.
I attached a screenshot of the app with the opened site and this white line:
https://i.stack.imgur.com/0OhZH.png
I also tried to look for other examples of TWA implementation, but they also had this band and they themselves were not functional. If you know of other ways to implement a PWA application without using Chrome and standard WebView, then I would be very happy to learn about them.
If the device has a battery charge of less than 10%, the page itself reloads and this white bar is removed. The color of the Status Bar also changes to light gray, although the color is specified for it. Maybe it's connected in some way.
I would be very grateful for any help!
Answer: This is not currently possible. There's a feature request for this to be implemented here: http://crbug.com/1021436


Skyrim - Companions attacked me for no reason?

Question: So, I was using Eorland Gray-Manes forge without causing any harm and all of a sudden I see loads of red dots on my map and it was the Companions and then even Eorland started attacking me. The Guards didn't do anything but cheered: "A Fight!" I even saw Vignar Gray-Mane attack me too. I have a bounty but it wasn't in Whiterun.
Comment: Were you by any chance a Vampire/contracted sanguine vampiiris?
Comment: It sounds like a weird bug, I've had something similar happen to me before in Whiterun.  Strange.
Comment: If the guards say "A Fight!", then it must mean it's a brawl.
Comment: My answer here might help: [Help! I'm being attacked on sight in Dragonsreach!](http://gaming.stackexchange.com/a/267598)
Answer: In general, most factions will not be hostile towards their own members.  Adding yourself to the offending faction is often a solution to this kind of problem (e.g. Missing In Action, I've personally experienced that bug).  The Companions have a faction ID of 00048362, so running this command should stop them attacking:
player.addtofaction 48362 0

This may break the quest Take Up Arms, and possibly the entire Companions questline with it.  You should be able to resolve this by using setstage C00 <stage number> to partially or entirely skip the quest.  It may be safer to skip one stage at a time instead of trying to skip the whole quest at once.  It's also possible the quest will "just work" (or that it will work once you've advanced it to stage 10), so you should try to complete it normally first.
This does leave you a member of the Companions, which you may not have wanted, but you are not obligated to continue the questline, and membership in the Companions is rather useful in the early game, IMO.  At a minimum, it gives you some free items, a place to sleep, and an endless supply of simple radiant quests.
Answer: I had a similar problem before. It was beacuse i had killed someone part/related to the companions. or it could be a mod bug. To fix i would say to either create a new save, check your mods for bugs [if you have any] or to completly avoid the companions
Answer: I think my experience with the companions attacking me was more deliberate on the games part. See I was walking around the country side near markarth ( the reach I think it's called) after completing the mission where you break yourself out of silver blood mine with the foresworn. I had collected a rather large bounty in markarth killing guards and such so out of nowhere farkus, the dark elf, (forgot his name)and Trevor came charging at me already hostile. I defended myself, but after that I had to avoid all contact with the companions even though I had no prior contact with them before the attack.
So maybe it has something to do with excessive bounty?
Comment: This seems more like speculation than a concrete answer. If you have anything to back this up, it would be a good idea to edit this into the answer.
Answer: I had the same issue. I tried the console command paycrimegold 0 0 on vilkas and it fixed the issue.
Answer: If you are married to a companion and you sell/destroy the ring they will attack.
Answer: I was returning from a side quest Vilkas had given me and before I could approach him Ria and Najda Stonearm drew their swords and attacked me.
My follower, Alea, and a couple guards stood back and watched. The Jarl came to my defense and soon went to his knee to yield.
That's when I ended the attack by killing both Najda and Ria.
There was no further aggression even though I was sure Alea would retaliate.
I'm playing esV on a ps3.
I'm going back to a previous save to see if it happens again.
In my opinion this problem is a random glitch that won't occur again.
(I loaded a previous quest save then went back to Vilkas and asked for work again.
After completing that quest I went back to Vilkas but didn't get attacked.
So I can say my idea worked.)
Comment: This does not provide an answer to the question. Once you have sufficient [reputation](https://gaming.stackexchange.com/help/whats-reputation) you will be able to [comment on any post](https://gaming.stackexchange.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/318376)
Comment: As it's currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Comment: I loaded a previous quest save then went to Vilkis and asked for work.
Comment: I followed the 3 steps for answering questions.


InDesign: 'search for missing links in this folder' not working

Question: I have a huge document and ALL the links are broken. I have one folder with ALL the links in it, but when I relink one or two and tick 'Search for missing links in this folder', it still doesn't relink any. I really don't want to spend the next 5 hours relinking every single link. Am I doing something wrong? I copied all the links in a new folder, and tried that way - also doesn't work.
Comment: Any special character in the linked files names?
Answer: InDesign will normally look for links in a folder which should actually be called 'Links'. Rename this folder you have so the new name is 'Links' and make sure the source file is just outside this folder.
If this doesn't work then some files are either truly missing or have been renamed (which is something InDesign will not autodetect).
Comment: @magerber Hence why Lucian said to rename it to _Links_ and make sure it's in the same folder. It doesn't matter whether the file has been packaged or not: when a document is opened, InDesign **always** checks if there is a _Links_ folder in the same folder and then looks for missing links if there is.
Comment: This is only true if the InDesign file has been packaged.  Otherwise the links could point to whatever location the original images were in.  The OP's "one folder with all of the links" might be called anything.
Answer: Make sure that the file extension specified in the "match same filename but this extension:" dialogue box does not have a period in front of it.
The image below shows the  box with "jpg" typed in. This worked for me.
Typing in ".jpg" with the dot, did not work for me.
Hopefully this helps someone.
Answer: I realize this is an old thread, but I'm leaving this one here in the event anyone else has this problem.
I had a doc with nearly 700 links & even though I checked the 'search for missing links in this folder' option checked, it just wasn't happening. I closed the InDesign doc, placed it in the same folder as all the linked images, opened it & all links updated. I then did a 'save as' to the folder that the InDesign doc was originally in & all is well.
Hope that helps somebody!
Answer: Also had this problem today. What did the trick for me was deleting some .indd file that was in the link folder. I received this files from other professional and didn't realized they were there.
Comment: Welcome to GD.SE!


Garageband—how to change volume of a region (not whole track)?

Question: In garageband I have one audio track with many regions. I'd like to adjust the volume for each region. Is there an easy way to do that, or do I have to make a new track each time, and adjust the tracks volume?
Answer: Finally found the answer, not very intuitive but cool once you know.
There's a button to toggle 'automation'. Once that's on you can select from a dropdown whether you want to change volume, echo, reverb, etc. Then you click on the actual waves on the track and a coloured line will appear. Clicking along the line creates break points, and you can move either points or the line segments between points to shift the volume. It's not based on regions—you can adjust it anywhere.
For more information:
https://www.howtogeek.com/238649/how-to-use-automation-in-garageband/
Comment: Its interesting that the GarageBand iOS have something like Logic Pro called Clip Gain, but the MacOS version doesn't have.
Answer: Under "Mix," choose Show Automation. You didn't have to do this before. Now you do.
Comment: how do you use it to amplify beyond the range of automation?
Comment: I also first had to add a software instrument before the menu item becaome enabled! After that, I could delete the software instrument track again, and automation stayed available.


How can I compare classes from clusterings performed on two different data sets?

Question: I have two data sets defined by real valued vectors, and I have performed clustering on both of them. Now I want to compare the classes to see how they map to each other. If I put the data sets together into a single, bigger data set, and cluster that, I see that most of, say, class 1 of the first data set and class 2 of the second (numbers are arbitrary) fall into the same class of the total clustering, which makes sense, meaning they're probably equivalent. What would be a good rigorous way of performing this kind of analysis and giving a quantitative measure of this overlap? Thanks.
Answer: I suggest using Kullback–Leibler divergence (KLD) to compare the classes. The procedure is as follows:
1- Find the mean vector and covariance matrix of each class of each dataset.
2- Calculate the KLD between each class of the first dataset and all classes of the second dataset. So, for example if you have two dataset and each of them has 5 classes, you should calculate KLD, 25 times.
3- For each class of the first dataset, find the class from the second dataset with the lowest KLD between them. Doing this, you will find the most similar classes of the two datasets.
Note that KLD measures the similarity between two probability distributions and by calculating the mean vector and covariance matrix of each class, you are fitting a normal distribution to it. To find the formula for calculation of KLD between two multivariate normal distribution, refer to here:
https://en.m.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence
Comment: Thanks! I actually just realised I have a problem with this currently - my clusters are defined through a distance matrix, not just points. I can make it the other way around though with some work. I expected a method that would just use class assignments.
Comment: @Okarin You're welcom. I see what you mean. I suggested this method because you requested a quantitative measure. If you want to compare the classes visually, you can use t-sne method, too. Sorrily, by just using class assignment, it is not possible to compare the classes.
Comment: not even if I have both the individual classes, and the joint dataset classes?
Comment: @Okarin No, I don't think so.
Answer: The usual cluster evaluation measures can be used, and this will be easiest to convey to reviewers and clustering experts.
You simply restrict the full labels to only one part of the data, then compare established measures such as the adjusted Rand index (ARI) or normalized mutual information (NMI) on the two results (these measures are symmetric, so it does not matter which labels are from the full data clustering, and which are from the subset clustering.


MIP binary decision value under a condition if else

Question: In MIP, I have a constraint that is validated only if the demand $d_i\leq Q$:
C1 : $d_i \leq x_i \leq Q$ where $x_i \geq 0$. I tried to introduce big M with binary variables as follows:
$My \leq x_i \leq Q - d_i$ Where $M=|Q-\min{(d_i)}|$
The problem where $d_i > Q$ then $x_i$ is equal to zero but if $d_i \leq Q$, $x_i$ should be between $d_i$ and $Q$. Any help please to how formulate this constraint.
Thank you
Answer: I'm going to drop the subscript $i$ to save a little typing, and I will assume that both $d$ and $Q$ are nonnegative (which was not actually stated). I will also assume that $Q$ is a constant. $d$ can be either a constant or a variable. Given a valid upper bound $M$ (presumably $\ge Q)$ for $d,$ we introduce a binary variable $y$ together with the constraints
$$d \le Qy + M(1-y)\quad (1)$$
$$d \ge Q(1-y)\quad (2)$$
$$0 \le x \le Qy \quad (3)$$
and
$$x \ge d-M(1-y). \quad (4)$$
If $y=1,$ then (1) and (2) imply $0 \le d \le Q$ and (3) and (4) imply $d \le x \le Q.$ If $y=0,$ then (1) and (2) imply $Q \le d \le M$ and (3) and (4) imply $x = 0.$
Note that $d = Q$ can occur with either value of $y,$ meaning $d=Q$ and $x=0$ is feasible (with $y=0$). Depending on the objective function and the rest of the model, this many not be a problem. If it is, your best recourse is to change (2) to $$d \ge (Q+\epsilon)(1-y)\quad (2')$$for some small positive value of $\epsilon.$ This will ensure that $y=0$ (and thus $x=0)$ occurs only when $d$ is strictly greater than $Q.$ Unfortunately, it will also make any solution with $Q < d < Q+\epsilon$ infeasible.
Comment: Thank you so much for theses explanations. I finnaly understand how it works.


Installing scikit-learn python package for QGIS on Win

Question: I want to install scikit-learn package to be executed in Python-QGIS. I've tried to use OSGeo4W Shell to install with pip. But I got this error.
I've tried to run osgeo4w-setup-x86_64.exe and install all Python packages but it doesn't work.
Comment: Have you tried `python -m pip install -U pip` before?
Answer: It's an SSL certificate error, I think resulting from the python.org host not taking HTTP url requests (or possibly your firewall blocking it).  You can try the following line, which may or may not immediately solve the problem:
pip install --trusted-host pypi.python.org scikit-learn

Or, the approach I've taken with the OSGeo4W Python installs that are sectioned off, is to download the module as a Wheel Package sourced from https://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn.  Ensure you grab the correct wheel based on your system (32 or 64 bit) and Python version (2.7, 3.6 etc).  With my OSGeo4W default Python, it would be:
pip install scikit_learn‑0.19.1‑cp27‑cp27m‑win_amd64.whl

Answer: After downloading the .whl file, this works in the OSgeo shell for me:
python -m pip install scikit_learn-0.19.1-cp27-cp27m-win_amd64.whl

I read from this.


Tax ID for an international student investing in U.S stocks

Question: I am an international student studying at Villanova University in Philadelphia, PA. I am very interested in trying my luck at the U.S stock market. However, I do not work on campus and so do not have a Social Security Number. Is there any way around this using which I can trade stocks using an online account?
Comment: Before starting to set up accounts etc, you should take a look at how much money you have available to invest in the stock market. It is harder to make money by buying "odd lots" of shares of any particular stock because the commissions you pay your broker are higher than if you are trading in multiples of 100 shares, and, except for home-run kings, it is generally hard to make money by investing in just a few companies; diversity of investments protects you against the occasional bad investment. As a rule of thumb, _students_ tend not  to have enough money to invest successfully.
Answer: You need an ITIN. Follow the instructions on the IRS page to apply. You might be better off getting an on-campus employment authorization and getting an SSN, though, as the ITIN process is not really convenient.


Front brake won't respond until fully engaged

Question: A bit new to cycling so please pardon my ignorance. All was fine on my bike up until the other day when I engaged the front brake and nothing happened. I had to fully squeeze the brake until it was touching the handlebar before the pads would close. This had never happened before, and the rear brake only needs a small squeeze for the pads to engage. I did squeeze hard on the brake as I was about to miss my turn, but nothing broke or snapped as far as I can see. Please see pictures for the front and rear brakes engaged. Any idea on what has happened?
Comment: Show us a photo of the caliper - I wonder if the quick release has been opened, which normally facilitates installation of a wheel with a tyre that is wider than the gap between brake pads.
Comment: Maybe the cable slip from the nut ?
Comment: Do you mean the pads don't move until you have the lever all the way down, or that they don't contact the rim until then? Also, please post a picture of the brake calipers.
Comment: Thanks for the reply. Sorry I meant the pads don't move until the lever is all the way down. I will add the calipers to the question
Comment: Also, do remember to do a brief safety check before you set of on your ride.  Brakes is absolutely something that should work first time, so check them as you're getting on your bike.
Answer: Work the lever and check that that the caliper is moving - that will tell you that the cable is attached and has not broken.
Make sure the little lever on the caliper that spreads the pads to let the wheel come out of the bike isn't engaged
Inspect the cable run from lever to caliper, make sure the housing is properly inserted into the lever and all frame stops.
If that all checks out the cable may have slipped through the pinch bolt on the caliper. Undo the pinch bolt to free the cable, verify the lever is pulling cable by pulling on the cable and and working the lever, reattach the cable. You can refer to this Park Tool video for installing and adjusting calipers.
Comment: OK thanks, I will give those checks a go


Execute shell script without password

Question: I have a shell script with a bunch of commands, one of them needs root. I want to execute the script without entering passwords at all: neither before script nor in the middle of execution. How can I make it?
Comment: Is sudo involved?
Comment: You can register the script with `sudo`. See `man sudoers`
Comment: @Jeff Schaller Yes
Answer: sudo is a common practice , to give privileges to some user .
a simple example with multiple command :
   i want  the user nagios to use a specific command to dump informations.
nagios ALL=(root) NOPASSWD: /usr/bin/dmidecode, /bin/netstat -ntp

Another example , you manage multiple servers , you want to  deploy the same  sudoers file on each . and the rule will be valid only on one server .
nagios srvpeug1208 =(root) NOPASSWD: /usr/bin/dmidecode, /bin/netstat -ntp

this will allow nagios on srvpeu1208 to execute some commands .
Comment: "you can deploy only one sudoers file" This is not entirely accurate. Some *NIX distributions include the /etc/sudoers.d/ directory, which you may configure sudo to read and parse file from, which can contain additional sudo rules.
Comment: @0xSheepdog i rewrote my statement
Answer: As others have touched on, the key thing that your script needs is to run the command that requires root permissions as root without requiring a password prompt.
This is a common problem in *nix when a user needs to run a particular command that would normally require root permissions but we don't want to give that user root permissions in general.
Unix has a general solution for this: the setuid bit.  When the setuid bit is set/enabled on a binary, that binary will always run as the file owner (so if the owner of the executable file is root, it will execute as root).
To set this, make sure that the binary that requires root permission is owned by root, and then set its permissions to include the setuid bit:
sudo chown root /path-to-binary
sudo chmod 4755 /path-to-binary

That binary will now execute as root, without requiring a password from the calling user.  Note that if you have a shell script instead of a binary you'll need to use the workaround described at Why does setuid not work?
This will work regardless of the user who accesses the file, so be careful.  If you want to restrict this ability to only one particular user, then you can instead modify the sudoers configuration as others have suggested.
Answer: Some options:

read man sudoers, and register the script with sudo as not needing a password to run by you. Be careful to read the bit on visudo (and how not to get your self locked out). If you don't you will be back here asking how to edit the file, when sudo is not working.
re-write it in golang and use setuid bit.

Execute shell script without password