How do I debug OpenGL apps written in python?

Question: How do I debug OpenGL apps written in python? I tried but I was unable to use standard tools like nvidia nsight or glsl-debugger or renderDoc on python code.
Answer: It's hard to tell without knowing more about the python code you are trying to debug and with what library. All the tools you listed will be able to capture OpenGL calls in python the same way it would in C++, C#, rust etc.
They work by intercepting the underlying library calls to the library (.dll, .so, etc) which happen no matter what language you are using.
Some common issues on RenderDoc you can avoid are:

Bad executable path: The executable you enter has to be the interpreter python. It cannot be the script, this has to go in the command-line arguments section:

Executable path: /usr/bin/python
Command-line Arguments: /tmp/hello_world.py

Your script could be quitting due to some error during runtime. Check the log in this case.
The library you are using could be rendering in a forked process. Check "Capture Child Process" in RenderDoc or the equivalent option in NSight or glsl-debugger. Make sure you try capturing all the child processes.
If your application is a static image, it's possible that you cannot capture because that image was submitted to OpenGL only once. For example, pyglet will only draw once unless it is given an update function with pyglet.clock.schedule. If that's the case, you tell RenderDoc to capture the first frame with Actions: Queue Capture Frame 0.
Finally, make sure your library is using a compatible OpenGL profile. RenderDoc will warn you if a profile is too old. If that's the case, either find a way to use at least 3.2 profile or you can use apitrace.

For example, here are the safest options you can have in RenderDoc. Capture Child Process is enabled in case it forks, Queue Capture is enabled in case only one frame is submitted and python is set as the executable.

And this is the code
import pyglet

window = pyglet.window.Window()
label = pyglet.text.Label('Hello, world!',
                          font_name='Arial',
                          font_size=36,
                          x=window.width // 2,
                          y=window.height // 2,
                          anchor_x='center',
                          anchor_y='center')

@window.event
def on_draw():
    window.clear()
    label.draw()

def update(dt):
    pass

# Update function to make sure pyglet re-draws periodically
pyglet.clock.schedule(update)
pyglet.app.run()


QoS configuration for a medium ISP

Question: What is the best Linux-based QoS platform to implement a configuration where all 256Kbps DSL clients (all belong to the same IP range) get a guaranteed speed of 200Kbps with single QoS rule?
Answer: The standard linux QoS/traffic control system is called <code>[tc][1]</code> (traffic control).
You will need to initialize a chain, set it's properties, then add your IP's to it, something like this:
<code>#!/bin/bash
DEV=eth0
PATH=$PATH:/sbin
tc qdisc del dev $DEV root
tc qdisc add dev $DEV root handle 1: htb default 20
tc class add dev $DEV parent 1:1 classid 1:10 htb rate 2000kbps ceil 2000kbps burst 500kb quantum 1500
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32 match ip dst 10.10.10.1/24 flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32 match ip src 10.10.10.1/24 flowid 1:10
</code>
Comment: Can you explain the code a bit, because you used two qdisc's : HTB and SFQ. And will the mentioned configuration assign each IP in the range the required speed without having to have a separate rule for each individual IP?
Answer:
And will the mentioned configuration assign each IP in the range the required speed without having to have a separate rule for each individual IP?

No, it won't. The way HTB works, you just can assign rates for the entire bucket, not individual IPs. What Caleb tried to do, was to evenly distribute the available bandwidth of 2000 Kbps via the SFQ qdisc among your 10 customers. However, this will not work as expected - SFQ calculates the scheduling per connection, not per IP - if any of your customers has more bandwidth-hungry connections open than the others, he will get more bandwidth in total.
There is another scheduler called ESFQ which extends SFQ to be able to schedule per-ip, but even then you only would schedule currently active traffic without capping any given user at 200 kbps. I do not know if there is any readily available qdisc which would allow you do do that, but given the sheer amount of different qdisc projects, I'd assume so.
Another problem is that tc only schedules outgoing traffic on an interface, inbound traffic is never taken into account. The Intermediate Queuing Device (IMQ) helps working around this limitation.
Answer: For guarantees and fair division, HFSC scheduler (ported from BSD's altq to linux) is a great thing. (at least it's not as clumsy and buckety as HTB.) Regrettably, setting up any traffic shaping in Linux is a painful process with a brutal learning curve, and because tc interface is simply just unfriendly, I'd suggest using MasterShaper or some similar frontend.
(PS. if you decide to manage tc by your own, use IFB kernel feature for upload shaping - it's like IMQ suggested here earlier, but works on newer kernels and fits the whole framework a little better)
Answer: Mikrotik RouterBoards ;) Best platform you can have. Their OS (RouterOS) is Linux based, but being an applicance you dont have access to a real shell or the file system.
They are a small ISP platform, though, so youay really like them.
Answer: Perhaps, my previous answers related to Linux/QoS may help you as well:

Can TC limit bandwidth by the Qos field of IP header
Why This TC Script Not Working
What do these two QOS script statements mean

QoS configuration for a medium ISP


How to flip 2d skinned quadruped character?

Question: just would like to know is flipping 2d skinned character with one of scale axis good way for left or right movement(flipping direction and animation)?
Normal direction would change.(UPDATED)
for example i have a 2d skinned dog, and i wanna dog move left when i press left with same animation as right direction.
or is there any better way?
Thanks.
Answer: When drawing the character, you can scale it to -1 along the x axis to perform a flip. Additionally, the sprite object has a flip function that will allow you to flip the sprite along the x or y axis.
It's a quick way to do left/right movement without redrawing everything. There are other ways to get this result (like creating new animations for the opposite direction), but if they're better or not is something only you can answer.
Comment: Thank you for answer, I also noticed on Rayman Legends, when character flipping, a simple transition animation helps for more realistic flip.


C++ Builder: Cannot bind, address already in use

Question: I have an application running on Android, it uses Bluetooth in some tabs (using sockets, after I include it on my project, I get the warning), and when I run (only) debugging it shows me a warning: Cannot bind, address already in use.
The situation is:

If I run not debugging, it shows no warning.
If I include a parameter on Project/Options/Debugger/Parameters (e.g: -debugport=54321) and I run using debug, it execute with no warnings.

It seems to be the port that I'm using to debug is busy, but I can't find a way to "set another port" or "if port n is busy, go to another", because I don't want to put parameters (the debugport) on my settings.
Maybe some code to modify the state of the ports of IDE, or even in adb.exe
EDIT: My program is running normally, I just want to hide this warning (not forever, but a solution to this occasion).
EDIT 2: When I run for the first time (restarting PC and Android phone) I get no errors (in this case it will be the first time that it's using this port), I don't know if some function/method to free the port that the application was using will resolve the problem.
For some code to have in mind of my project: The whole process of sockets and connection is based in the sample that Embarcadero offers, I'm using "Classic Bluetooth Basic app" (it includes FSocket->Free(); and    FServerSocket->Free(); that seems to free the socket and resolve problem, but no).
How can I deal with it?
Answer: You need to reconnect your usb chord from your device. It will work!!!


Is there any difference between the two handbrake options?

Question: I notice that, on Xbox at least, both RB and A are assigned to handbrake. I had a look at the controls and noticed that A is also used for answering the phone in the vehicle, so my question: is there any difference between the two handbrakes? I know on a bike there is additional braking controls (different buttons for front and back brakes) but presumably this is not the case in a car.
Answer: According to the manual, there is no difference.
A and RB buttons are both mapped to the handbrake, so it's just for convenience.
Personally, I alternate between the two based on what I am doing.
Example:
When I want to change weapons, X, and make an immediate sharp turn, I would use A.
Otherwise, I would use RB (especially if I had to answer the phone).
Hope this helps!
Answer: i think that rb is for making weaker powerslide like drifts making a lil turn or something while the a handbrake is slicker and stronger turning making good powerslides and pulling off the drifts
Comment: Hi Dee!  Would you have any other information that would help pad out your theory?


If we get a timber-framed single-storey extension, can we later (in a few years) add another storey on top?

Question: We probably can't afford to get 2 storeys built at the moment but don't want to close off that option for future years (when we may want an extra bedroom). We are thinking of a timber-framed extension for environmental reasons: trying to avoid too much concrete. Thanks.
Comment: If you remember Senator Ted Stevens, he got into trouble because of who paid for it, but his solution was to raise his home and build a story under it then lower it down and make it one home.  The place is beautiful.  Have you considered doing that instead?
Answer: Can you - yes - with the application of sufficient money, anything is possible.
Will it be cost-effective - probably not. Building, and then destroying a roof is a very expensive proposition. Removing roof framing and replacing it with an additional floor, likewise.
If you wanted to do this in a way that might make fiscal sense, have the frame designed as a two-story frame, but leave the 2nd floor out at first. It will cost somewhat more than a single-story, but it can actually be built out later without costing an absurd amount of money.


Free hosting of public files

Question: What applications will allow me to freely host and share a variety of files or documents? What are the limitations?
Comment: Is this really a duplicate? The other question deals with backing up files, this one deals with sharing files
Answer: All you need is Dropbox. You can easily share big files with your friends and there is also an option for public shares. One folder that whatever you're putting there has a public link to it, so you can share it.
The only limitation is the 2GB for free accounts, but you can go up to 10GB if you'll invite people with a special link. Both you and who ever is registering via this link are getting +250MB for free.
Answer: If you don't want to install anything you can use Google docs where you have 1024 MB of free storage. Files can be converted to Google docs. OCR is supported as well. You can set sharing settings (public, accessible to anyone with the link, accessible to people you specify) for each file or for a bunch of files in one folder.
Check this help page for the details.
Comment: You don't have to install anything if you don't want to to use Dropbox as well...! :D But in both cases it's going to be hard to upload big files.. if the connection is lost then you have to start over.

Free hosting of public files


Cracks in Basement Floor

Question: We are in the process of buying a home and most of the homes we see have cracks on the floors in the unfinished part of the basements. We are worried about buying a home that is not structurally sound and one that will cost us thousands to fix down the road. We have also went under contract with one house and there was a foundation issue found on a wall. We backed out of the contract, but we paid the inspector $500. We don't want to keep paying $500 only to find out that the foundation is bad. It will take away from our down payment and every penny counts for us. I was told by the realtor that most basement cracks are not a problem but only the inspector can tell us for sure. Can anyone tell me by this one picture if this crack is an issue? I am planning on looking at the home again tomorrow and can take more pictures if needed. We really like this home but we're scared to make an offer. In case needed, we are in the Denver metro area. Thank you for any help you can offer.
Michelle
Comment: I don't see a reason to think this is structural, all concrete cracks it may be 1 year or 50 but it will happen! The slab is not structural, I would have more concerns about the dark marks on the wall under the window. I don't see any high water marks but if the basement is dry I am sure I can find you a inspector that will say it is fine and another that says look there is a crack the sky is falling,,, oops wrong story the house will fall down but there is only evidence of a crack that has been filled in the past not properly but refer to my statement ALL concrete cracks. This is not unusual.
Comment: I'm not a structural engineer - we have some on this site who are. However, based on this one pic and my experience it looks as if this is typical cracking that you get with a concrete basement floor. What you want to watch for are vertical heaves and severe wall cracking. The crack going off to the right looks like it gets more severe as it goes. More pics might help. I also live in Colorado and many areas have bentonite which is vertically expansive when it comes in contact with moisture. If you see that type of heaving around the foundation it pays to investigate further.
Comment: Cracks in floor, usually not big structural problem, could be place where moisture/water comes up.  Cracks in walls usually can be more of a concern, especially if they continue onto the floor.
Comment: Also, is that moisture below the window where the wall and floor meet?
Comment: Almost any large concrete slab will crack in an irregular fashion as your picture shows, especially if it is not reinforced with rebar, steel mesh or both.  One way to reduce the chance of that occurring is to separate the large slab into smaller sections with an expansion strip between the sections.  Of course this has to be done when the slab is poured.  Another technique that I think is used uses a v-shaped trowel to put a shallow groove into the surface of the concrete.  This is usually done before the concrete cures completely.  This causes the stress cracks to follow the grove cut.
Comment: These are settlement/structural cracks (long, wide cracks diagonally extend from the columns or corners of walls), if you putting a long level across one of the cracks, the level will tilt up.  Concrete does crack due to drying and shrinkage, but usually is quite fine (hairline crack) and short. I wouldn't take the chance for $500, which might cost you $5000 or more to fix it.
Answer: I can't see the entire crack pattern but it does appear to be one of the "back-of-an-envelope"-patterns that strongly indicate a structural issue. This in itself does not have to be much of a problem, but it means there is a real risk that it will continue to grow. And if you try to repair it by injecting mortar or epoxy, it may very well reappear.
To estimate how much of a problem a crack is, the first thing to look at is the crack width. Some rough guidelines since I can't really tell the width from the photo:

0.3 mm or so is no problem. This is the kind of crack that merits a comment like "all concrete cracks".

0.5 mm is not a major problem, but repair is needed. Otherwise the concrete will eventually break apart and the rebars rust away. This is a process that takes years if not decades, so usually not exactly an urgent problem, but it will often be the cheapest solution to fix the crack sooner rather than later.

1.0 mm is a problem. Not particularly dangerous for a typical basement floor, but definitely means it is coming apart.

I note that parts of the crack appear wet, indicating that water seeps through. This in itself doesn't have to be a big problem, as while it will eventually break down the concrete and the rebars, it will do so quite slowly. It does however indicate that the cracks go all the way through the slab, and therefore radon is likely entering the building as well. I don't know how much of a problem, radon is in your area, but globally it is one of the leading causes of lung cancer.
Along a part of the crack, there is something orange. If this is rust (and not just the result of sloppy cleaning), that means the rebars in the slab are in the process of rusting away, and the days of the slab are counted. Trying to repair the crack by injecting mortar or epoxy will likely be no help, and there is no realistic alternative to breaking it apart and casting a new slab. It doesn't have to be today or tomorrow, though.
Answer: I live in Denver metro and I have some training as an engineer although I am not a practicing structural engineer. Personally, I am very sensitive to potential foundation problems in my own home so I will offer the following comments.

Basement floors are rarely structural and most often unreinforced. In Colorado, they will crack.

The crack in the floor here is caused by either soil expanding or contracting underneath the floor. That is very likely due to moisture fluctuations. It wasn't cracked like that when it was poor.

Cracks in the walls are much more concerning than cracks in the floor.

it appears that one side of your crack is offset from the other— that is not good.

The precense of moisture related defects in the floor means there is a related increased likelihood of similar defects in the walls. No certainty however.

I would not close on this house without having a structural engineer examine the crack— it's likely under 500 dollars to hire a PE. You want to hire an experienced, licensed PE, that has no affiliation with your real estate agent.

I occasionally find it useful to bound the worst case repair for a given defect. In the case of a floor crack, you could actually cut out the crack and repair concrete in the cavity. No guarantee it won't crack. Repairs to walls are more challenging and expensive.

My opinion is that the greatest risk you face is that whatever caused the floor to crack has also compromised the footer underneath the basement walls.

If this house has a drain tile or sump pump, that is encouraging.

Cracks in Basement Floor


Does Android OS impose an SMS sending limit?

Question: Is there an SMS sending limit? I have sent SMSs totaling >30,000 characters within 24 hours and am no longer able to send any SMSs (though I can receive them). Is my SMSC blocking me, or is the Android OS limiting how many SMSs I can send? If the latter is the case, how do I reset or increasing the SMS sending limit using adb (service call?)?
Comment: Related: [Pop up message when sending large amounts of SMS messages](https://android.stackexchange.com/q/38461/44325)
Answer: Yes, there is. From

Lynch, Doug. "How to Change the SMS Limit on Android Without Root." XDA Developers, August 27, 2017:

by default, Android will check to make sure you haven't sent more than 30 SMS messages to anyone within a span of 30 minutes.

How to Change Android's SMS Limit

Set up ADB as outlined in this previous tutorial.

Enter an ADB shell by sending the following command in the command prompt or terminal window: adb shell

Then run the following command in the ADB shell to change the max SMS limit option: settings put global sms_outgoing_check_max_count 5

So in this example, I am actually reducing the number so Android warns me if I have sent more than 5 SMS messages within 30 minutes.
Change "5" to whatever number you want.

Next, you can run the following command to also change the time frame: settings put global sms_outgoing_check_interval_ms 9000000

And with this command I am reducing the time frame for this check from 30 minutes, to 15 minutes (this value is in milliseconds). You
can choose any integer value here for the time frame, just make sure
it's something sensible.


Battery operated trike

Question: I am building a battery powered trike. My battery is 72v. I have a three position key switch ( off, on, accessory) I have purchased a 72v contactor coil to operate my dc controller, the controller is rated for 0v to 100v. My confusion is in the switch, the switch is rated at 28vdc. My question is:Can I use a voltage divider to drop to 12 volts, and then go through my key switch using the 12 volts to turn on the contactor to supply the 72 volts to my controller? My knowledge is limited on the types of components needed to achieve this and I did not want to burn up the switch with 72 volts. I also failed to mention that my battery does go through a  30 amp breaker on my positive line, before the contactor. Any help would be appreciated.
Comment: I actually looked at that exact one this morning!  I ended up going cheap and got this https://www.ebay.com/itm/72V-to-12V-DC-DC-Golf-Carts-Intelligent-Voltage-Reducer-Converter-for-/222939954165  So... do I need something between the 12volts from the key switch to the coil of the contactor ?
Answer: Voltage Divider is not a good option as it will HUGELY consume current and most probably cause Fire Hazards. You can use a voltage regulator and choose one that supports 12 Volts. Try to choose one where the voltage conversion is in the low power range of the voltage regulator.
Another option is to use a DC/DC buck converters and there are options in the market ready for the specific voltage 72 Volts to Volts 12.
For example: https://www.powerstream.com/dc-72v-12v-5a-extreme.htm
Comment: This is pretty close to what I have.    https://www.mcmaster.com/7278k18
Answer: The easiest way would probably be to just upgrade the switch to a 125V type. These are common for industrial controls, so should be easy to find / order from the usual places like Mouser or Digi-key.
Also, search for '72V key switch' and a lot of e-bike stuff comes up.
I would also recommend a kill switch / deadman's switch for your setup that will open your contactor. Fail in wide-open is a thing, as my friend the motorcycle mechanic can attest (a Zero got away from him and launched him at a tractor-trailer.)
Comment: I would change to a 125v switch if I had to do it all over, But The original key switch is in a tight location, so I cant put a larger switch in its place. The key switch I have is mounted in a 19mm hole.

Battery operated trike


how can i find Spectral Acceleration (Sa(T1; 5%))?

Question: I want to do incremental dynamic analysis (IDA) for my project and for hunt and fill algorithm i need the 5% damped Spectral Acceleration at the structure's first-mode period (Sa(T1; 5%)) . Can i find it by using Seismosignal software directly ? if not how can i calculate Sa(T1; 5%) ?
Answer: ASCE 7-16  Section 11.4.5 provides the equations for the 5 percent damped spectral response acceleration, Sa, relative
to period, T, in the following range.
0 ≤ T < T0, T0 ≤ T ≤ TS, TS < T ≤ TL, and TL < T
here is a link to a detailed solved example. look at Example 2, how to create design spectra with 5% damping. Except that the link, they have for the USDS application is dead use this link instead, find USDS data from addressto read Ss and S1 and other dates then
use them to plug in this ASCE 7-16 example 2.
use example 2. open first


Can Pumpking drop his Trophy before Wave 15?

Question: I've challenged the Pumpkin Moon about 20 times now. Each time I get to Wave 10 and I have never once gotten Morning Wood or Pumpking trophies. So, can they only drop them during Wave 15?
Answer: You just got unlucky.
There is a 10 % chance for a boss mob to drop a trophy , until the 15th wave of the Pumpkin Moon Event. If it is the 15th wave, if you successfully kill Pumpking, or Mourning Wood you will have a 100 % chance of obtaining the trophy.
Tips:

1. Since your going for the trophies, try focusing on hitting the Pumpking and Mourning Wood during the later waves. Don't waste your time anywhere else.
2. If your still dying at wave 15, upgrade your gear and try to get the best load-out for your class. Make sure your health is at 500, you have all the required class accessories, and your weapons are the best you can get.

A list of class setups can be found here.
Comment: AWESOME, +1 for giving class setups
Answer: The wiki mentions that the drop is 100% at wave 15, however it has a 10% chance to drop at other times.  So it is quite uncommon, but it can drop before wave 15. Here is the reference.


Do my parents need to purchase long-term care insurance?

Question: I've been hearing about long-term care from my parents since my sister moved out two years ago. They'll have to let me finish college before buying it, however. What is the purpose of long-term care insurance? Do my parents need to buy it?
Comment: The answers to [this question](http://money.stackexchange.com/q/3046/7590) may give you enough information. Basically, it depends on their asset levels, their current age/health, how much they intend to pass on as their legacy, etc. [This question](http://money.stackexchange.com/q/705/7590) also covers some of the basics of long-term care insurance.
Comment: Are you asking if it's advisable for your *parents* to purchase long-term care insurance, or for you to purchase it now? Also, where are you located geographically? The answer may vary from country to country.
Comment: Advisable for _them_ to purchase. I am currently out and about in Asia studying but my parents are in USA. Oklahoma to be specific
Answer: Yes. My parents bought it quite a while ago; my father ended up in Alzheimer's care, and my mother needed full-time care for a couple of years. The long-term care insurance paid a significant amount of money; for my mother, it was something around $60K.
Answer: The purpose of long term care insurance is to pay for your long term care while protecting your assets. This is highly recommended to people who have high risk factors or family history. People who will most likely receive care should purchase this as early as possible in order to avoid the soaring cost of coverage and care. Another reason why people should buy this is is because of the much longer life expectancy today. Statistics would show that about 70% of people who are 65 years old will need long term care. This is obviously high and alarming. For me, this is enough to encourage people to prepare for their future and buy insurance for long term care.
Comment: I agree with C. Ross here. More people will need long term care today because of the longer life expectancy and the most efficient way to pay for this is through long term care insurance. According to http://www.ltcoptions.com/, this insurance product will cost you between $1,000-$8,000 year which is still a lot cheaper compared to paying out-of-the-pocket. Since your parents will be left alone, they'll greatly benefit from this once they need home health care or they need to move to a facility.


How to tell VIM to store the viminfo file somewhere else?

Question: Is it possible to tell vim to save its viminfo file somewhere else,
such as in the .vim folder?
Answer: Try adding set viminfo+=n~/.vim/viminfo to your ~/.vimrc file. From :help 'viminfo':
    n       Name of the viminfo file.  The name must immediately follow
            the 'n'.  Must be the last one!  If the "-i" argument was
            given when starting Vim, that file name overrides the one
            given here with 'viminfo'.  Environment variables are expanded
            when opening the file, not when setting the option.

Comment: @BeyondSora, @sarnold Reread help that is quoted here: «the name must *immediately* follow the 'n'». Purge semicolon out of the answer.
Comment: @ZyX, many thanks! I had just tested with a directory without write access, and was happy to get _an_ error when it didn't work. Sigh. Lesson learned. :)
Comment: Which doesn't work? The option or the specific value I suggested? Feel free to give it any reasonable path that makes sense for your platform.
Comment: it doesnt work as in, after I added that into my vimrc file, viminfo still gets saved directory under my home folder... Unless I set it manually everytime I open vim, that would work, but not if I have it in vimrc
Answer: set viminfo='1000,nc:\\users\\abcdef\\_viminfo

This works for me in Windows 7.
Comment: What does the 1000 do?
Comment: Yes, I tried `set viminfo+='1000,n~/.vim/viminfo` instead and it worked.
Comment: Worked for me on Windows 10 with Vim 8.0.x. It even works with a variable, e.g.: `set viminfo='1000,n$VIM/viminfo`.
Answer: I had a similar problem but had no write permission to my home folder (thus could not create the ~/.vimrc).
I solved it by modifying (through the Administrator) the _vimrc in C:\Program Files\VIM to include the line:
let $HOME = $USERPROFILE

I placed it at the beginning of the file and it worked well. Just in case someone comes across this question and this answer didn't work.
Answer: I know its quite a while now, but I am just mentioning this for future readers.
I was facing the same issue while trying to change the location for viminfo file in vimrc. At last setting the value of viminfofile option worked for me.
Added the following to my vimrc:
set viminfofile=D:\vim\viminfo

It works for me on windows with vim 8.2
Answer: TL;DR
This seems to be a bug in vim where set nocompatible is not idempotent and doesn't follow the principle of least astonishment.
As a workaround, either:

Ensure that you set nocompatible (or the equivalent set nocp) only once, and at the top of your vimrc.
Don't set it again if it's already set:
if &compatible | set nocompatible | endif " Avoid side effects if `nocp` already set

Explanation and bug illustration
From :help compatible (empahsis mine):

This is a special kind of option, because when it's set or reset,
  other options are also changed as a side effect.  CAREFUL: Setting or
  resetting this option can have a lot of unexpected effects: Mappings
  are interpreted in another way, undo behaves differently, etc.  If you
  set this option in your vimrc file, you should probably put it at the
  very start.

Note that &viminfo is not listed in the side-effects, however the following lines clearly show the side effect upon &viminfo:
set nocompatible
set viminfo+=nWatch-my-viminfo-file-location-be-ignored
echom &viminfo
set nocompatible " do side effects even though nocomptible is already set
echom 'After 2nd "set nocompatible":'
echom &viminfo

Output:

'100,<50,s10,h,nWatch-my-viminfo-file-location-be-ignored
After 2nd "set nocompatible":
'100,<50,s10,h

vim --version | head -1

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 05 2016 16:48:20)

Resolution
I have raised two GitHub issues regarding this:

Undocumented "set nocompatible" side effect upon &viminfo
set nocompatible not idempotent - setting produces side effects when already set

See also Vi StackExchange's question: Can't move viminfo file - &viminfo reverts upon loading vim which I raised before seeing this one.
Answer: The ordering of settings in the .vimrc affects the use of :set viminfo. The setting of viminfo should be after the setting of nocompatible. After reordering my .vimrc, the above solution to have the viminfo file be located in the .vim directory worked for me.
Answer: In gvim8.2 on Windows10, following option works to change path of viminfo :

set viminfofile=$VIM/.viminfo

Write this in .vimrc .
It could to change viminfo file path to under the $VIM.


Does the purchaseToken remain the same when a subscription is renewed with Android In-App Billing V3?

Question: Does the purchase token remain the same when a subscription is renewed with Android IAB V3?
Would it be a bad idea to rely on the purchase token as the user's ID on a backend server? (Assume throwing away their data when the subscription expired isn't a big deal)
Answer: According to this answer this answer,
it remains the same.
So should be fine to rely on it, keeping in mind that it will be different if the user cancels and then purchases the subscription again.
Comment: If orderId and purchase token remains same, whats the identifier for the renewal?
Answer: Yes, the token remains the same whenever a subscription is renewed.
In the case of downgrade or upgrade, Purchase Token and order_id is newly generated, but in case of renewal, Purchase Token remains the same.


Freeze at Startup & Shutdown

Question: my Ubuntu 19.04 has been acting weirdly at startup and shutdown. At startup, boot is very slow (on SSD) and sometimes freeze on desktop screen. I can't use my mouse & keyboard, with those folder and Trash shortcuts that won't appear and the drive LED indicator always active. Sometimes I can press the power button so it can bring restart/shutdown/cancel dialog and if I press 'cancel' button it solves the problem. But in other times it won't help, I have to press and hold power button to restart it.
Also, shutdown is also very buggy. It won't power off my PC and stuck in blank screen, with drive LED also always active. I have to press and hold power button again.
It's important to note that it doesn't happen on both 18.04 and 18.10. I also have changed Grub file and add acpi=force like I read from other site, removing quite splash so it probably can show log about it (but nothing works, only blank screen) and also modified some BIOS settings like fast startup and secure boot, but it seems it only worked the next time I use my PC, after that, the problems always come back.
I use 1 SSD (Ubuntu partition) with 3 WDC Blue HDD as media storage, I use this PC solely for Ubuntu (no dual boot w/ Windows or other Linux distro).
Please help, thanks.
Answer: Never mind, turns out one of the HDD has 8 bad sectors. I've swapped with new HDD and the problem is solved

Freeze at Startup & Shutdown


How to open this locked door

Question: Accidentally locked the door and am panicking because I am house sitting. Would really appreciate the help
Comment: Was the doorknob not present to begin with?
Comment: put the doorknob back into the door
Comment: I have to ask; How did and why did this happen?
Comment: Are you trapped? It doesn't look like a house that's even worth house sitting.
Answer: That type of latch rotates (there is a half-cam inside)
That square hole you see is engaged by the shaft on the missing knob, and rotates that piece.
You can use anything to turn that either way. A screwdriver with a bit too big to fit straight, but will fit in 'diagonally' will do the trick...
a quarter turn should open it fully.
This is provided it is the same as the kind I am trying to describe, from what I can see in the picture.
Also, after you get in, when you try to put the pieces back together, make sure the key works BEFORE you close-up and lock yourself out.  It is often possible to get the inside knob and outside knob together wrong by 90º, and then you will probably not be able to rotate the key one direction, and/or be able to turn the lock-tab inside both ways.  Check the knobs and keys and lock tab function, with the door open, for proper operation BEFORE you close the door...
Comment: I can't see well in that pic, and don't have one in front of me. See Jasen's solution below too, He has a good answer! He says it can be slid to the 'right'. Either way if you have a situation like this, you can either rotate it; or you can pull/push it to the side (in direction away from the latch). one or the other should work, depending on the brand.
Answer: If you have the doorknob - look at the back of it and see how it actuates.
I'd suspect theres a vertical bar that rotates, and pushes on the top or bottom black bit, making it move to the right in the photo.
You can probably duplicate that action with a screwdriver, put the tip where the letter A is, and push the tip to the right.
Answer:
Hook into the metal bit (red in my picture) and push it to the right.
The red piece is the end of the latch bolt. pull on it an the bolt retracts. the cam that normally pulls on it is missing
Comment: I believe that is incorrect. This is an older fixed-backset latch (Weiser?). The red piece is captive and rotates only, you won't be ble to 'move it to the right'. If you note the smaller hole on the left, and the half-hole to the right; those are for the knob screw posts and screws; they don't move. The slider that moves the door latch is a rail inside the outer piece, it is barely visible in the pic, hard to push because the housing only gives you a fraction before you hit the housing, and need an angle or hooked tool to do it that way moreso when it's in the door. Not positive, hard to see.
Comment: the red piece is the end of the latch bolt.  pull on it an the bolt retracts.  the cam that normally pulls on it is missing.
Comment: I gotcha. It is so hard to see depth in a photo like this. I wish I could find that box of old locks I have somewhere, but his post was urgently needing suggestions! I thought I was seeing the bar hiding at the right peeking out in the cam hole. Thanks for clarifying, hope I didn't offend. I see you help a lot here! -wish he would tell us if he got in... (and what he found to do it)
Comment: I interpreted that curve as the back of the plastic body

How to open this locked door


Meteor : Iterate through array of Objects inside an Object

Question: I'm currently trying to iterate through an array of Objects inside an Object.
I have my Collection "Proposals", and this is the corresponding Schema :
Schemas.ProposalsSchema = new SimpleSchema({
  'content': {
    type: String,
    max: 140
  },
  'parties': {
    type: [Object],
    autoform : {
      type: "select-multiple"
    }
  },
  'parties.$._id': {
    type: Object,
    optional: true
  },
  'parties.$._id._str': {
    type: String
  },
  'parties.$.name': {
    type: String
  }
});

I would like to iterate through the array of parties inside one of my template. I tried this :
{{#each proposals}}

{{content}}

{{#each parties}} {{this.name}} {{/each}}

{{/each}}

The content is displayed, but not the name of the different parties. Here's my template helper :
Template.proposalsIndex.helpers({
  proposals: () => Proposals.find().fetch()
});

Do you know what do i do wrong?
Thank you in advance.
Comment: does not work either
Comment: look in the client console if your data is getting passed from server or not.
Answer: The code you posted looks ok.
Things you need to check are:

Is the "parties" field populated in a database? (you can run Proposals.find().fetch() in a meteor shell to check it).
If not, find out why it is not populated.

Is the "parties" field published to client? (you can run Proposals.find().fetch() in a browser console and see the results).
If not, check your publication.


Metrics for one-class classification

Question: How do you calculate precision and recall in one class classification?
In other words in one class classification, we just have TP(True Positive) and FN(False Negative). Which metrics we should use for these type of classification?
Comment: During the training or the testing?
Answer: Though it's a late reply, I'd like to point of implicit assumptions by previous answers that likely don't hold.

for one-class classification, we don't know the real ratio of positive and negative data. So we cannot any development set has similar distribution to the real data.
A standard setting for one-class classification is we have positive and unlabeled dataset. We can't assume we have the label for "negative" data even in the development set. Also, we can't assume all the unlabelled data are "negative".

An alternative evaluation is proposed in the following paper (section 4):
Lee, Wee Sun, and Bing Liu. "Learning with positive and unlabelled examples using weighted logistic regression." ICML. Vol. 3. 2003.
They uses
$$ \frac{r^2}{\Pr(Y=1)} $$
P.S.: Prof. Lee, Prof Liu and Dr. Cheng are the people that coined one-class classification. We can take their evaluation as somewhat "official".
Comment: Could you explain what $r^2$ is in here?
Comment: Sorry for the late reply. _r_ is just the recall. More specifically, _r = Pr[f(x)=1|y=1]_. This is based on section 4 of the reference paper above.
Comment: I think the formula is $^2/Pr(f(X)=1)$.
Answer: We use one-class classification is used when we have only "positive" labels (although some argue for using it when the quality of the data about the labels is poor) for outlier, or anomaly, detection.
With such data you cannot assess accuracy of the predictions. Technically you can check if it properly labeled all your data as "positive", but then you would conclude that the useless model that always returns "positive" label no matter of data, has perfect fit.
To judge performance of such classifier you would need to have data with "negative" labels. One thing you could do is to simulate data with artificially introduced anomalies (this is often done, e.g. in image classification where you add noise to the data, or transform the images), or simulate such data that you know that should be classified as anomaly, and use such data for testing.
The story is different if you have data about "positive" and "negative" classes, since then you can use exactly the same tools for evaluating your model as for classification in general, but then, why would you use one-class classification algorithms?
Answer: @user3791422 has the right answer. In addition, I would like to point out:
If you have the notion of True Positive and False Negative, it means you have a notion of the ground truth and you have predicted responses. Therefore, by definition, False Positive and True Negative should exist.
Logically, what the OP didn't consider is, if we know some examples belong in the class we know the remaining examples (rest of the world population for which we don't actually need training examples) belong outside the class. Therefore, FP and TN can be calculated when we observe them during testing.
Answer: When you do one class classification, besides TP and FN, you should also have FP (false positive) and TN (true negative). FP are the instances that you have classified as positives when they were actually negative and TN are the instances that you have correctly classified as negatives. Then you can calculate precision and recall:
precision = TP/(TP + FP)
recall = TP/(TP + FN)
The wikipedia page https://en.wikipedia.org/wiki/Precision_and_recall explains it very well.
However, when you do one class classification, some other common metrics are  the false positive rate (FPR) and the f1-score.
FPR = FP/(FP+TN)
F1-SCORE = 2TP/(2TP+FP+FN)
I hope that helped.
Regards!
Comment: In one-class classification you typically don't have negatives, hence its name. What you describe is standard supervised learning.
Comment: As far as I understand it, one-class classification means that you classify the new records according to they are part of the class X or not. So, if we consider a positive as not being from the class, a negative would be being from the class. Supervised vs unsupervised is a different thing than one-class or not. This has to do with having labelled data in the training phase or not. For the one-class algorithm you do not normally have labelled data to train. But, when you want to calculate some metrics I believe that you need some ground truth to be able to calculate the metric.

Metrics for one-class classification


OWASP Consider regenerating a new session upon successful authentication or privilege level change

Question: On the OWASP web site one of their top ten items states that we should consider regenerating a new session upon successful authentication or privilege level change.
What would be the correct way of doing this?
One thing a co-worker has told me but I haven't tested is that when a user uses browser tabs each tab does not get it's own session, so I think that would negate the whole exercise.
Thanks,
Paul Speranza
Answer: Depending on the language you are using, you would simply call something like session.invalidate() and then redirect which would create a new session.


A chrome extension that lets you edit the source code of a page (doesn't have to save)

Question: I often see a demo for some library or other, and I want to try to make a small change. So I have to download the entire page with all dependencies and then make the change there. I'd like to be able to make the change when I view the source code in the browser.
Comment: The built-in developer tools allow you to modify things, can I post that as an answer? If it is not a good solution, please edit your question to explain why, thanks :-)
Answer: Try tampermonkey. This extension changes the HTML code of the page with Javascript, when the page loads. This is called DOM manipulation.
Tampermonkey is not really a High-Level HTML editor, though.
For instance this script:
https://greasyfork.org/en/scripts/536-imdb-standard-deviation/code
changes this:
Arithmetic mean = 7.5   Median = 8
to this:     Arithmetic mean = 7.5   Median = 8   Standard Deviation = 2.02
on the IMDB Ratings page of 'Black Mirror' movie


Mesh changes on multiple objects while keeping other properties

Question: Let's say I'm modeling a chair. The object is placed in different locations on my scenes, with different modifiers, transform data, and materials. Now I want to make changes to the chair's mesh using the sculpting tools. Is there a way to only apply the mesh changes to all chairs while keeping all the individual properties of each chair, such as materials, transforms, etc. Thanks!
Comment: if you've used instances of the same mesh, the sculpt will change the mesh and each object should keep its transforms, modifiers and materials
Answer: Dynamic links + library overrides work best for me when using the same object multiple times within a scene. In this way, I can assign different materials, modifiers, constraints, and transforms to each individual copy of the object (which I think is impossible with instances). When I want to manipulate the mesh itself, I can do this and update all objects in the scene simultaneously.
This is how I built up the scene:
Object
In file A I created the object (e.g., chair), which I want to use with different materials, modifiers, and transforms on different locations in a scene.
Scene
I created file B to set up the scene (e.g., bar) and imported the object as a dynamic link.
(File/linked/...)
In the outliner, I can define that new materials, modifiers, etc., can be assigned to the object.
(Right-click/ID Data/Make Library Override)
The object can now be duplicated and manipulated with individual materials, modifiers, constraints, and transforms for each individual copy.


Remove Pop!_OS login password

Question: I know this has been asked before, but I couldnt find a solution that fits my needs.
I am the only user on my PC (running Pop!_OS 20.10). Nobody has access to my computer because I live alone. This is why I want to remove my login password.
How can I achieve the following things:

No password required to log in
No "Unlock Login Keyring" popup after login without password
A password for sudo is still required
When the computer goes to sleep because I haven't used it for a while and then wake it up again I don't want to have to enter a password

So far I have tried to enable "Automatic Login" in Settings>Users>Authentication & Login. But this only solves problem 1 and 3. After booting up, I am always asked for a password for "Unlock Login Keyring". And after waking up my unused computer, I also need a password.
I also have tried removing the Password from my user. But after that I couldnt execute sudo commands anymore because I had no password.
Answer: No authentication after lock screen on pop os :
Settings >  Privacy > Screen
Then uncheck 'Automatic screen lock' && 'Lock screen on suspend'

Remove Pop!_OS login password


Why are n public keys needed for reconstitution of an x of n multisig?

Question: Trying to conceptually understand why I must store the public keys of the n hardware wallets in an x of n multisig set up? Only x of the seed phrases/private keys are needed to reconstitute/recover the multisig wallet, but why do I need all n public keys?
My understanding is that to send btc I only need x private keys (aka the x wallets on hand), to receive I just need the resultant multisig public key stored, but to recover I need x private keys and n public keys? Why is this?
Answer: The conditions for spending a coin (UTxO) are expressed using a small script. In order to be able to recover your coins, you need to back up both:

The script template
The private key(s) corresponding to the public key(s) used in the script

You need the script template because the script expressing the spending conditions is part of the coin itself. And the wallet needs to be able to locate which coins you own from the set of all existing ones (the "UTxO set").
This is true for any type of script (single-sigs, multisigs, or even more complex constructions). But it is often implicitly assumed backups with no corresponding script template are for a single-sig. The wallet would therefore reconstruct a single-sig script template from your private key.
It is however not possible to reconstruct any other script than a single-sig only from a private key. Hence the recommendation to back up other public keys involved in the multisig along with your own private key. This is simply a manner of backing up the script template to be able to locate your coins. (It's however a very incomplete manner.)
Backing up the public keys as a way to reconstruct the script template is suboptimal because it's leaving out a lot of information:

What's the script type? Is it using a bare script, a P2SH, a P2WSH, a P2TR?
What's the construction used? Is it using CHECKMULTISIG, a list of CHECKSIGs? A list of CHECKSIGADDs?
If using Taproot, in what leaf is the multisig? Is it spanning multiple leaves?

Modern Bitcoin wallets nowadays use Output Script Descriptors as a way of describing all the information needed to reconstruct a script template. I recommend using it to backup your multisig (or anything else) instead of relying on implicit information for something so critical.
Comment: 1. It's part of the descriptor. 2. Yes. It looks something like `multi(2,xpub1/*,xpub2/*,xpub3/*)` (not technically correct but simplified so you get the gist).
Comment: I don't fully follow. 1. Would the Output Script Descriptor contain the derivation paths or would it be kept separate? 2. In the case of a multisig from 2 hardware wallets & 1 seed signer would there be a single OSD for the multisg wallet? Or 3 individual OSDs, one for each multisig constituent?
Comment: And how would this be generated? If I self create the multisig via sparrow, is there an automated mechanism to generate this OSD?
Comment: You would generate one (or your wallet would) before receiving funds, and derive addresses from it. I'm not sure but i think you can access your descriptor from within Sparrow.
Answer: The common practice in Bitcoin is to use "pay-to-script-hash" for multisig. In fact that is the only way to receive money in a standard "address" for your multisig wallet (there are variants in non-SegWit world, SegWit v0 and Taproot).
Pay-to-script-hash means the sender doesn't know where the money is being sent to. All it knows is that it is sending it to a "hash" of the actual script that specifies the spending conditions -- in this case a multisig script that looks like 2 <key1> <key2> <key3> 3 OP_CHECKMULTISIG.
To spend any pay-to-script-hash UTXO you have to provide the actual script first -- which the Bitcoin verification process will hash and check. And then (in the same transaction) you provide the signatures that will fulfill the script.
For example, this transaction is sending 1631068 satoshis to a 2-of-3 multisig address, but you can't know that just by looking at it. All you can see is that it is paying to the hash a64224765fa40b1bb04a4e8f82d29ca580e2022e20750078b5c3bd610b9015c9.
However, since it was spent in this transaction you can see the script that it used. It is the last element in the witness stack -- 522102b4608d0bba8f2f5665648462819d4a0fe97a8012d386d88ebb4e1ddc93fba5af2102db19c6f47c04ac128a8d9015a75dc350e5291849f999d267598d019dcdf5cbae21030994d7f93c0fb81eeeae14cabe0dbc8a547a9770aca304f4633eaab743fbc06a53ae, which translates (using bitcoin-cli decodescript or hal script decode) into:
OP_PUSHNUM_2
OP_PUSHBYTES_33 02b4608d0bba8f2f5665648462819d4a0fe97a8012d386d88ebb4e1ddc93fba5af
OP_PUSHBYTES_33 02db19c6f47c04ac128a8d9015a75dc350e5291849f999d267598d019dcdf5cbae
OP_PUSHBYTES_33 030994d7f93c0fb81eeeae14cabe0dbc8a547a9770aca304f4633eaab743fbc06a
OP_PUSHNUM_3
OP_CHECKMULTISIG

Finally, if you check the sha256 hash of the (byte-encoded) script above you'll see that it matches the script hash from the previous transaction.
>>> b = bytes.fromhex('522102b4608d0bba8f2f5665648462819d4a0fe97a8012d386d88ebb4e1ddc93fba5af2102db19c6f47c04ac128a8d9015a75dc350e5291849f999d267598d019dcdf5cbae21030994d7f93c0fb81eeeae14cabe0dbc8a547a9770aca304f4633eaab743fbc06a53ae')
>>> hashlib.sha256(b).hexdigest()
'a64224765fa40b1bb04a4e8f82d29ca580e2022e20750078b5c3bd610b9015c9'

Comment: You could perhaps explicitly answer the question of the asker by mentioning that you can only provide the actual script if you know all public keys. E.g. you could append "If you don't know all public keys, you cannot reconstitute the actual script." to the third paragraph.


Learning Try-Catch

Question: I'm a Java beginner so please bear with me
static int load = 100;
static int greet;

public void loadDeduct(int cLoad, int c){
    int balance;
    balance = cLoad - 7;
    System.out.println("Your balance: " + balance);
}

public void loadDeduct(int tLoad){
    int balance;
    balance = tLoad - 1;
    System.out.println("Your balance is: " + balance);
}

public static void main (String [] args){
    int choice;
    Scanner scan = new Scanner(System.in);

    System.out.println("I'm a cellphone, what do you want to do?");
    System.out.println("Press 1 to send SMS / Press 2 to Call");

    choice = scan.nextInt();

    CellphoneLoad N95 = new CellphoneLoad();

    if (choice == 1){
        N95.loadDeduct(load);
    }else if (choice == 2){
        N95.loadDeduct(load, greet);
    }else{
        System.out.println("Invalid Option!!!");
    }

How do I implement the exception handling with this program?
I'm not quite sure how to use the catch block as we weren't taught yet about the whole exceptions thing. It was just an exercise we were asked to do.  I want to replace the if else statements with a try-catch blocks... is that possible?
Comment: Thanks for all your help!
I'm going to try it all out.

We weren't taught yet about the whole exceptions thing.
It was just an exercise we were asked to do.
Thanks!
Answer: One important principle to consider with exceptions in Java is that there are two types:
1. Runtime
2. Typed/explicit (for lack of a better word)
Runtime exceptions should be thrown when there is a programming error and generally they should not be caught unless you are catching at the top level to report an error.
Typed/Explicit exceptions are decorated on method calls and should be there so the caller can take some action on them.
In the case of the code above, there isn't really a place that feels like it should use exception handling.
And as Patrick pointed out, you don't generally want to use exceptions for flow control.
Answer: It is not ideal to use Exceptions for flow control. From your code it  is not clear what Exceptions might be thrown. Maybe you can elaborate a bit more.
Answer: The only part of your code that might possibly throw an exception is the call to:
scan.nextInt();

According to the JavaDocs, this can throw the following possible exceptions:

InputMismatchException (if the next
token does not match the Integer
regular expression, or is out of
range)
NoSuchElementException (if
input is exhausted)
IllegalStateException (if this
scanner is closed)

So if you wanted your code to account for the possibilities of these exceptions being thrown, you should re-write it like so:
try {
    choice = scan.nextInt();
}
catch (InputMismatchException e) {
  System.out.println(e.getMessage());
}
catch (NoSuchElementException e) {
  System.out.println(e.getMessage());
}
catch (IllegalStateException e) {
  System.out.println(e.getMessage());
}

Generally, you want your "catch" blocks to start out specific or very likely to happen to less likely / more general in nature.
You can additionally "throw" the exceptions so that whatever method the exception occurs in doesn't handle it-- the method which called that exception-causing method would have to handle it (or throw it again, etc, until it gets to the Java runtime).
In the event it's the "if" statement you wish to replace, I'd recommend the "switch" statement:
switch (choice) {
    case 1:  N95.loadDeduct(load);
             break;
    case 2:  N95.loadDeduct(load, greet);
             break;
    default: System.out.println("Invalid Option!!!");
}

Answer: The Scanner.nextInt() method can throw a few exceptions. The linked page of the API Specifications lists out the three exceptions which can be thrown.
For example, if a non-integer value is entered, such as "one" instead of 1, an InputMismatchException can be thrown.
In general, a try-catch is used to catch exceptions, as illustrated in the following code:
try
{
    Integer.parseInt("one");      // Statement that can cause an exception.
}
catch (NumberFormatException e)   // Specify which exception to catch.
{
    // Code to handle the NumberFormatException.
}

More information about exceptions can be found in Lessons: Exceptions of The Java Tutorials. In particular, the Catching and Handling Exceptions section may be useful.
Answer: Adding exceptions in this piece of code does not add much value.
What I can think of is something like this:
public static void main (String [] args){

.....

try{
 handleUserChoice(choice);//new method
}
catch(InvalidChoiceException e){
 System.out.println("Invalid Option!!!");
}
}

Answer: It's really pretty simple.  First identify where you want an exceptioon.  There can be exceptinos thrown by library code or you can throw your own.  Then use a try .. catch to handle it.  Here's a simple "hello, world" ish example:
public class TryTry {

    public void doIt() throws Exception {
       System.err.println("In the doIt method.");
       throw new Exception("Hello there!");
    }

    public static void main(String[] argv){
       TryTry t = new TryTry();
       // here we'll catch it.
       try {
           System.err.println("About to call doIt().");
          t.doIt();
       } catch (Exception e) {  // e now has your exception object
          System.err.println("In the exception handler.");
          System.err.println("Exception says: "+ e);
       }
    }
}

The effect of throw is to construct that exception object and send it up the stack until it's caught.  To catch it, you surround the code that might throw it with tr { ... }, and handle the exception with catch.
Here's the results:

javac TryTry.java && java TryTry
About to call doIt().
In the doIt method.
In the exception handler.
Exception says: java.lang.Exception: Hello there!
Answer: I don't see any reason to use exceptions instead of the if-else block. you could try using a switch statement, it'd look better.
you should use exceptions to handle errors that might occur inside the methods loadDeduct. then you would surround the lines calling N95.loadDeduct with a try-catch block, to write what would happen if loadDeduct went wrong.

Learning Try-Catch


Connection lost. Saving has been disabled... (Updating Posts/Pages)

Question: I've been developing for Wordpress for a few years now without any trouble on an old XP/WAMP development server (v1.7.4) but recently have been getting the error "Connection lost. Saving has been disabled until you're reconnected" whenever I try to update either Wordpress Posts or Pages.  The majority of what I've turned up on the subject points to plugins as the source of the problem,  Sadly,  I find that even in a clean install of wordpress 3.8.1, in a new DB, without any plugins the problem persists.  Next logical culprit then is the server. I check the logs, and find nothing. In the process of migrating my workflow to a newer Windows 7 platform (WAMP v2.2.22) I created a new install there, and the problem is gone. I've run the php.ini's from both servers through a difference engine hoping to suss out the cause, but I'm afraid it's a bit beyond me where the issue might be, nor how to share the results of the comparison here, either as a flat file, or CSV.
Any thoughts?
Comment: I have the same problem, it's only just started to happen on 3.8.1 and have gone through the same processes as you. There doesn't seem to be any fixes for it!
Comment: Yes, I am facing the same trouble and the WP version is 3.8.1.
Comment: Maybe read this, I had similar issue and finally resolved them, hope it helps https://wordpress.org/support/topic/connection-lost-saving-has-been-disabled-6?replies=4
Answer: That message is a result of your server throwing a 503 error and the WordPress Heartbeat API catching that error. See https://core.trac.wordpress.org/ticket/25660 for the background on the fix that WordPress introduced to save offline edits.
Things to check on your computer are if WAMP is actually running when you're getting this message (check the status icon in the system tray). You should also check to make sure no other programs are trying to take over the port WAMP uses. Reports of Skype and TeamViewer taking control of ports 80 & 443 abound, as well as fixes for each of them.
If you haven't checked out the WAMP forums, here's a page that outlines the debugging steps for the 503 server error, and fixes for Skype and TeamViewer: http://forum.wampserver.com/read.php?2,115474,115576.
Comment: @moganestes Thanks for playing, but sadly... no... none of the above. My error logs are clean, nothing running on this machine but WAMP, FF, Chrome, AVAST, and Notepad++. I do however think the first link you provided is telling.  I have hated WP's forays into Auto-Draft et.al. from the beginning, and it appears -- reading between the lines int the link provided -- that the Heartbeat API remains suspect, and not yet ready for prime time.  I'm betting the answer lies there somewhere.
Answer: Try the following:

Disabled all plugins, removed plugins folder entirely - problem still persists.
Removed the .htaccess file - problem still persists.
Tried a fresh install - problem still persists.
Cleared browser cache.
Checked the server for any auto updates - there haven't been any.
Changed the autosave to various times define( 'AUTOSAVE_INTERVAL', 160 );

More info
Answer: So here you go I downloaded and installed manually onto my admin plugins page on both of my domains and the problem seems to have stopped. I first stumpled upon the php compatibility checker which had a few of its own issues and having to enable the WP-cron plugin which i had to download and install as well or the checker would stall out.
https://wordpress.org/plugins/php-compatibility-checker/
https://wordpress.org/plugins/wp-crontrol/
And even after all this i was still having the issue at hand i came across plugin detective plugin.
https://wordpress.org/plugins/plugin-detective/
after running all 3 plugins on both of my pages everything seems to have been fixed or the problem removed at least. I hope this helps you


Registering a static menu?

Question: I have a website with a very large sidebar menu that uses an accordion plugin to keep everything compact and organized. Unfortunately, my menu has grown so big that I am unable to save any new entries; my research shows that this is a known problem. Is there any way that I can create a static menu and register it so that it is recognized as a WordPress custom menu? I've been digging though codex, but haven't found what I'm looking for.
Answer: You could create a custom widget that contained just your menu and then hardcode the menu in HTML...it's not a good solution, but it would work.
Comment: Thanks for the input. I was trying to avoid this since the plugin I was using has worked very well the purposes of my the website it is being used on. Seems like this might be my only solution though.
Comment: Try contacting your hosting and see if they can tell you what resource is holding you back on the default menu page and then see if they can give you a larger allocation of that. IMO the issue with large menus is a significant issue with wordpress that should have been addressed long ago...hopefully 3.4 will get it!
Comment: Well I'm using an unmanaged dedicated server, so they won't really help me in that regard. I've looked at resource usage during menu saves, and nothing peaks or looks out of the ordinary. Unfortunately the page just hands while trying to save and eventually throws Internal Error 500.

Before this, I was getting php timeouts, but altering the max_execution_time fixed that. A few new menu items later and I'm stuck with this issue. Hopefully they do address is soon!
Comment: Have you increased your memory limit?
Comment: I just tried raising that up from 64 MB to 512 MB, but that didn't make any difference unfortunately. I really appreciate your suggestions, so if you have any other suspicions please let me know!

Registering a static menu?


How do I place leading zeros for numbers less than 10 without affecting those 10+?

Question: Probably a newb question, but...
I have a table with a VARCHAR field containing numbers 1 through 300. I need to place a leading zero in front of any numbers less than 10 while retaining the original number if it is 10 or greater (i.e. 1=01, 10=10 and 300=300).
SELECT DISTINCT RIGHT('0'+CONVERT(VARCHAR,[FacilityCode]),3) FROM...

This returns 1=01, 10=010 and 300=300 (using the same examples as above)
EDIT: I'm trying to do this within a query so that I can do lookups without altering either table.
Can someone lend a brother a hand here? My brain just ain't working.
Comment: Any particular reason you don't want `1` to be `001` ?
Comment: RolandoMySQLDBA - The related table has varchar values which follow the example above.

Mark, I'm using MSSQL 2008 r2.

All... I'm trying to do this through a query in order to select items in a related table which formats the numbers (which are actually varchars) in the manner illustrated above.
Answer: The safest way is probably to only add zeroes when the length of the column is 1 character:
UPDATE
   Table
SET
   MyCol = '0' + MyCol
WHERE
   LEN(MyCol) = 1;

This will cover all numbers under 10 and also ignore any that already have a leading 0.
EDIT
To just select the data try:
SELECT
   MyColPadded = CASE WHEN LEN(MyCol) = 1 THEN '0' + MyCol ELSE MyCol END
FROM
   MyTable;

Answer: If you wanted a 3 digit number try this.
SELECT DISTINCT
RIGHT('000'+CAST(ISNULL([FacilityCode],0) AS VARCHAR),3)
FROM...

Result: 1=001, 10=010 and 300=300
An 8 digit number would be:
SELECT DISTINCT
RIGHT('00000000'+CAST(ISNULL([FacilityCode],0) AS VARCHAR),8)
FROM...

Result: 1=00000001, 10=00000010 and 300=00000300
This has the advantage of working with subqueries:
SELECT t_lac.FORCE_OVERWRITE
            , ISNULL(lay.ID,0) AS lacIDLayout
            --, t_lac.lacName
            , CASE WHEN t_lac.lacIDControlType = 18
                THEN 'PAN' + RIGHT('000' + CAST(ISNULL((SELECT ID FROM Layout l WHERE l.layName = t_lac.lacName),0) AS VARCHAR),3) + '_' + t_lac.lacName
                ELSE t_lac.lacName
                END AS lacName
            , t_lac.lacIDControlType
            , t_lac.lacStyle
            FROM @T_LayoutControl t_lac
            LEFT JOIN Layout lay ON lay.layName = t_lac.layName

Answer: (it looks from your example code that you are using MS SQL Server, but you should add an appropriate tag (and/or body text) to your question to indicate this if so, or if not which DBMS you are actually using)
Any of the options above should work fine, I would generally use the "prefix 0s then use RIGHT() option as you have but the others are perfectly valid), but a word of warning if you expect new rows (or updates to existing rows) to contain low numbers - if that is possible then you will end up with unpadded values creeping back in. To avoid this you could use either an AFTER or INSTEAD OF trigger to force values into the right format as they are inserted/updated to stop the problem coming back (without needing to change all code points that save to that table). Be careful to verify performance though: triggers can be very powerful but it is also easy to create a performance nightmare with them.
Answer: You can use a case statement for this, if it must be formatted in the database and you can't persist it.
Select case when len(facilityCode) = 1 then
          '0' else '' end + facilityCode as facilityCode
From YourTable

It sounds like you are doing this as a FK, if so you can't have a FK constraint on a calculation.  To make doing the join easier, you might consider a calculated column.
 ALTER TABLE yourTable
    ADD cFacilityCode AS (
      case when len(facilityCode) = 1 then '0' else '' end + facilityCode);

Answer: UPDATE MyTable
SET MyColumn = '0' + Mycolumn
WHERE MyColumn < '10'
AND MyColumn NOT LIKE '0%';

Comment: The logic behind the answer is sane but the answer is not correct for a very different reason than the above comments. `MyColumn` is a varchar, so the condition `MyColumn < '10'` will not result in `TRUE` when the value in the column is `'2'` or `'3'` or ... `'9'`. For char values `'9' < '10'` is false.
Comment: Agree with @ypercube. You could change the first comparison to `MyColumn < 10` but that might break as we don't know if `MyColumn` is *guaranteed* to ever contain only numbers.
Comment: The OP stated that the minimum value is 1, but in general, if you want at least two digits, and you have zero, you do want to add another zero, so I would use `LEN` (as in JNK's answer) rather than `LIKE`.
Answer: declare @num varchar(50) = '7'
select case when @num<100
            then RIGHT('00'+ CONVERT(VARCHAR(50),@num),2)
            else CONVERT(varchar(50),@num) end

Comment: welcome to the site. Along with code try to write down some statement for better understanding.
Comment: Also - why use 100 as a cut-off, when 10 would be a better one - only values from 0 through 9 should have an extra zero added.


How to set up the following newsletter

Question: My nodes are broken down by taxonomy, each taxonomy term comes with a different icon, I need to set up a newsletter that sends out a title, teaser and the right icon for each node. What is the easiest way to achieve this? Simplenews? ePublish? Do either of these modules easily integrate with Views so I can output the right fields?
Answer: Newsletter can do what you need. The description on the project page:
Multiple newsletters lists configurable on existing terms
Plain text or HTML out of the box.
Multiple schedules Each newsletter can have more than one schedule, e.g. Daily, Monthly, Weekly, manually or even custom, eg after 10 new posts for this term.
Centralized administration and configuration on a single page.
Users can customize the terms in the list they subscribe to.
Custom template per list.
Statistics (CTR and Open-Rate).
Drupal 7 only.
I'm using it on my site and it works like you've mentioned.

How to set up the following newsletter


Does the Create 2 have the roomba room mapping software?

Question: My understanding is that the Roomba has a sophisticated room mapping capability. Does the create 2 include that capability and is it usable by the hobbyist?
Answer: No, Create2 does not have room mapping capabilities.  The Create2 is based on the Roomba 600 series chassis.  Only the Roomba s series, i series, and 900 series robots have mapping capabilities.
Disclaimer: I am an iRobot employee, but the postings on this site are my own and don't necessarily represent iRobot's positions, strategies, or opinions.


Serial.print() is slower than it should be

Question: I'm trying to use Arduino as a DAQ but the Serial.print() is not working as fast as I expected. How many bits are sent if you are using a int, because if I use a uint8_t, it's taking the same amount of time? How I could improve the speed of the Serial.print()? I'm already working at 115200 baud.
Comment: What does it mean "slow" how many ms?
Comment: Its take about 204 us and  its supposed to go less than that but know I know it's sending ASCII so it's sending more bits than I thought.
Comment: How many channels are you acquiring? See my modified answer for more comments
Comment: I'm already taking samples at  50 kHz and the resolution is enough and Im acquiring data from all 6 analog pins. And what version of "timerone.h" is better?
Comment: Please see https://github.com/mikaelpatel/Cosa/blob/master/examples/Benchmarks/CosaBenchmarkDataLogger/CosaBenchmarkDataLogger.ino this might give some hints on how to boost the performance.
Comment: What Arduino board are you using? 50 kHz sample rate is much higher than AVR based Arduino boards can achieve. Typical peak performance is 9 K samples per second (10 bit).
Comment: if the outbound serial buffer is already full, `serial.print` and `serial.write` will wait for there to be space. Does it run faster if you call `Serial.flush()` beforehand?
Answer:
I need a sample rate of 6 kHz

OK, so that means you need to sample and send every 1/6000 seconds (167 µs).
I have a lengthy discussion about the ADC hardware. Amongst other things is a table of conversion times for the different ADC prescalers, assuming a 16 MHz clock:
Prescaler
    2    * 13 * 1/16E6  = 0.000001625 (  1.625 µs)
    4    * 13 * 1/16E6  = 0.00000325  (  3.25  µs)
    8    * 13 * 1/16E6  = 0.0000065   (  6.5   µs)
   16    * 13 * 1/16E6  = 0.000013    ( 13     µs)
   32    * 13 * 1/16E6  = 0.000026    ( 26     µs)
   64    * 13 * 1/16E6  = 0.000052    ( 52     µs)
  128    * 13 * 1/16E6  = 0.000104    (104     µs)

If you go for maximum resolution (10 bits) you need a prescaler of 128, which takes 104 µs. The number of conversions you can do a second (taking the inverse of the above) is:
Prescaler  Conversions/sec
  2           615,385
  4           307,692
  8           153,846
 16            76,923
 32            38,462
 64            19,231
128             9,615

You also need to take into account the transmission time. At 115200 baud you can transmit one byte every 1/11520 seconds (86.8 µs) so therefore two bytes (16 bits) would take 173.6 µs.
If you sample then transmit you will therefore take, per sample:
104 + 174 = 278 µs

This is too slow if you want to achieve it inside 167 µs.

You can sample asynchronously (in the background) so you transmit one sample while taking the next one, but you are still limited by the transmission speed of serial, so it would still take 174 µs per sample.
In fact, fiddling with the prescaler isn't really the issue here because the serial transmission time is the limiting factor.
Forget about the ADC and how it works for the moment. At 115200 baud you can't transmit 2 x 6000 bytes per second. That is simply because the maximum is 11520 bytes per second.
Comment: Actually, the serial library (of course I'm speaking about the hardware one) sends the data asynchronously, in the serial ISR. So serial transmission and main loop (with the ADC acquisition) can be considered as two "parallel" tasks. So the sample time will be `max(104,174)`, so 174us. Of course there is a bit of overhead (go to ISR, exit from ISR, perform ISR) but as a first approximation the sample rate here is not the sum of the two, but the highest
Comment: You are quite right, of course! (*What was I thinking when I wrote that?*) - still we are both in agreement that the limiting factor is the baud rate. The Arduino hardware is capable of faster baud rates, I'm not sure about the receiving side.
Answer: By not using Serial.print?
Serial.print will format the number as a string of ASCII characters. The number of characters depends on the size of the number. Yes, that is very wasteful.
If you are sending values between 0 and 255 (uint8_t) you can just send the raw value as a single ASCII character, since there are 256 of those.
Serial.write(myVal);

For anything greater than 255, i.e., you want to send an int or uint16_t then you will have to come up with some better way. You can't send one byte for the full value, so you would have to send it as two bytes:
Serial.write((myVal >> 8) & 0xFF);
Serial.write(myVal & 0xFF);

HOWEVER... how do you know which byte coming in is which? It's very very easy to get out of sync and not get the right values when you read the data in.  So you need some way of "packetizing" the data so that you know "This is a correct set of values".  Just how you do that is entirely up to you - do you just wrap each pair of bytes in a special set of other bytes? Nah - that becomes as wasteful as Serial.print. Instead it's better to buffer up a batch of values and send them as a block with just a few extra bytes to define the packet.
One example of doing that is my ICSC library. Take a look at it and you can see how you can craft a packet to send lots of data as one stream of data.
Comment: The 10th bit is usually just quatisation noise, so you only have 9 bits of real information. So you would in fact only be losing 1 bit of information by going from 10 to 8 bits.
Comment: In fact, I'm using 10 bits in the analogread() but I can't give up that resolution in orde to get more speed.
Answer: Serial.print sends the ASCII representation of the data. So:
uint8_t data8 = 102;
uint32_t data32 = 102;
char datastring[] = "102";
Serial.print(each_of_the_previous_data);

each of these are sent exactly in the same way, i.e. three bytes ('1', '0', '2', so 0x31 0x30 0x32).
This, as you noticed, is highly inefficient. What I suggest you is to send them in binary mode, so
uint8_t *convertToByteArrayLittleEndian(uint8_t *buffer, int32_t val)
{
    uint8_t i;
    for (i = 0; i < 4; i++)
    {
        buffer[i] = val & 0xFF;
        val = val >> 8;
    }
    return buffer;
}
uint8_t *convertToByteArrayBigEndian(uint8_t *buffer, int32_t val)
{
    uint8_t i;
    for (i = 0; i < 4; i++)
    {
        buffer[3-i] = val & 0xFF;
        val = val >> 8;
    }
    return buffer;
}

uint8_t supportArray[4];
uint8_t data8 = 102;
uint32_t data32 = 102;
char datastring[] = "102";
Serial.write(data8); // Sends 0x64 = 100
Serial.print(convertToByteArrayLittleEndian(supportArray,data32),4); // Sends 0x64 0x00 0x00 0x00
Serial.print(convertToByteArrayBigEndian(supportArray,data32),4); // Sends 0x00 0x00 0x00 0x64
Serial.print(datastring); // Sends 0x31 0x30 0x32

I had to use an helper function to convert from int to byte array, since Serial.write does not support directly an int. You can choose if you want to send the data in big endian or little endian format.
As you can see, in binary mode the amount of data exchanged varies.
Just three more things.
1) you probably can go higher in frequency (maybe 1Mbit/s) with the serial. Just try it out
2) If you decide to use binary mode, maybe you will need some synchronization (i.e. a start byte) to ensure you are not listening a stream from a "middle" point. There are various techniques (prevent use of some bits in the stream, use some forbidden values and escape it)...
3) If you want to go faster, I suggest you to switch peripheral. For instance use SPI (of course you won't be able to use a common USB-UART interface, but you can create a native USB dongle with an SPI interface to get the connection)
EDIT:
According to other info from the OP:
The data is 10 bits. Let's split it into two 5bits data, so we can use the upper 3 bits for sending sync info (to understand which byte comes first). The required rate is 6kHz.
I made some calculations, and it looks like that you can use this code:
#include "TimerOne.h"

bool timerHasBeenTriggered = false;

void setup()
{
    Timer1.initialize(167);         // initialize timer1, and set a 6kHz frequency
    Timer1.attachInterrupt(callback);
    Serial.begin(#HIGHER_THAN_115200#);
}

void callback()
{
    timerHasBeenTriggered = true;
}

void loop()
{
    int16_t val = analogRead(ANALOG_PIN); // takes 104us
    Serial.write((val & 0x1F) | 0xA0); // Send lower 5 bits, upper 3 set to 101
    Serial.write((val >> 5) & 0x1F); // Send lower 5 bits, upper 3 set to 000
    while (!timerHasBeenTriggered);
    timerHasBeenTriggered = false;
}

Here the loop has an execution time of around 104us (serial calls just store the values in a queue). The vast majority of the time is spent acquiring from a channel.
I used a timer to trigger the next acquisition so it can be more precise (and the millis() function is useless, since you want to trigger it 6 times per millisecond).
From the PC you will receive two bytes. The first one is in the form 0b101XXXXX, the second 0b000YYYYY. You will only have to

wait for a byte starting with 101
save the other 5 bits (XXXXX)
get the next byte and check it starts with 000
the data will be just the concatenation of the two 5-bits chunks: YYYYYXXXXX

Note that the limiting factor of the timing is the analogRead function. If you want to go faster (or to acquire from multiple channels) you will need to change the ADC clock prescaler. This, however, will make your ADC frequency higher than 200kHz, which is not recommended (you will get less precise data).
Comment: But if I do all of that it should be done for each sample? I need a sample rate of 6 kHz and I'm not really sure if is that posible.
Comment: 6 kHz only, or 6 kHz times 6 pins?
Comment: What do you mean by "each sample"? you will be able to acquire from just ONE analog channel, since EACH analog reading takes about 100us. Moreover serial baud rate needs to be higher than 115200, since with 115200 you will be able to send two chars in 174us, which means 5.7kHz. It doesn't matter how much faster, since sending and reading are performed in parallel..
Answer: If your signal of interest is of short-enough duration, you might get by by collecting the data into memory, then dumping it at whatever speed you can. If you're using an Uno or other AtMega328 based Arduino, the RAM size, and therefore, your buffer, will be quite limited. Storing the first value as int and subsequent values as one-byte differences can help.
An on-board memory device, like an FRAM, could buffer 8K or 32K bytes (or half as many ints).
Or the same differences technique can be used to send one-byte binary differences and improve your sample transmission rate. It's easy to get out of sync, though. This won't be too reliable for continuous or long data streams.
Otherwise, you're just baud-bound. How fast can you drive the serial output and the receiver still be able to keep up? You're pushing the edges of what the device can do. It's an interesting problem and possibly fun to solve, but I'm reminded of the old adage about alligators and needing to drain the swamp! :)
Answer: Some benchmarking of Serial.print() and comparing to clib functions (itoa/ltoa) might give some insight. First, printing int and long int with DEC base using Arduino core Print functions (Arduino IDE 1.6.7, Arduino Mega2560).
Serial.print(12345, DEC): 240 us
Serial.print(12345678L, DEC): 388 us

Second, use HEX base.
Serial.print(0x1234, HEX): 204 us
Serial.print(0x12345678L, HEX): 384 us

Third, use the AVR clib functions to convert number to a string and then print the string. 10 and 16 base.
Serial.print(itoa(12345, buf, 10)): 104 us
Serial.print(ltoa(12345678L, buf, 10)): 240 us

Serial.print(itoa(0x1234, buf, 16)): 80 us
Serial.print(ltoa(0x12345678L, buf, 16)): 240 us

Cheers!

Below is the test sketch:
void setup()
{
  uint32_t start, stop, us;
  char buf[16];
  Serial.begin(9600);

  start = micros();
  Serial.print(12345, DEC);
  stop = micros();
  us = stop - start;
  Serial.println();
  Serial.print(F("Serial.print(12345, DEC): "));
  Serial.print(us);
  Serial.println(F(" us"));
  Serial.flush();

  start = micros();
  Serial.print(12345678L, DEC);
  stop = micros();
  us = stop - start;
  Serial.println();
  Serial.print(F("Serial.print(12345678L, DEC): "));
  Serial.print(us);
  Serial.println(F(" us"));
  Serial.flush();

  start = micros();
  Serial.print(0x1234, HEX);
  stop = micros();
  us = stop - start;
  Serial.println();
  Serial.print(F("Serial.print(0x1234, HEX): "));
  Serial.print(us);
  Serial.println(F(" us"));
  Serial.flush();

  start = micros();
  Serial.print(0x12345678L, HEX);
  stop = micros();
  us = stop - start;
  Serial.println();
  Serial.print(F("Serial.print(0x12345678L, HEX): "));
  Serial.print(us);
  Serial.println(F(" us"));
  Serial.flush();

  start = micros();
  Serial.print(itoa(12345, buf, 10));
  stop = micros();
  us = stop - start;
  Serial.println();
  Serial.print(F("Serial.print(itoa(12345, buf, 10)): "));
  Serial.print(us);
  Serial.println(F(" us"));
  Serial.flush();

  start = micros();
  Serial.print(ltoa(12345678L, buf, 10));
  stop = micros();
  us = stop - start;
  Serial.println();
  Serial.print(F("Serial.print(ltoa(12345678L, buf, 10)): "));
  Serial.print(us);
  Serial.println(F(" us"));
  Serial.flush();

  start = micros();
  Serial.print(itoa(0x1234, buf, 16));
  stop = micros();
  us = stop - start;
  Serial.println();
  Serial.print(F("Serial.print(itoa(0x1234, buf, 16)): "));
  Serial.print(us);
  Serial.println(F(" us"));
  Serial.flush();

  start = micros();
  Serial.print(ltoa(0x12345678L, buf, 16));
  stop = micros();
  us = stop - start;
  Serial.println();
  Serial.print(F("Serial.print(ltoa(0x12345678L, buf, 16)): "));
  Serial.print(us);
  Serial.println(F(" us"));
  Serial.flush();

}

void loop()
{
}

The clib itoa/ltoa are regarded to be relative slow and there are proposals to improve performance. Please see, for instance, this bug report.
Comment: The bug report is interesting, but it looks to me like a speed/size trade-off: bigger code and faster execution. It is quite common on AVRs to optimize for size instead.


Verification of a contract

Question: A university has a contract with the government. Does a university need to confirm the existence  of a contract when the third party asks?
Comment: Public or private university? Which country?
Comment: Some US government contracts are "classified" and the fact they were awarded to a specific company may also be classified, as necessary for national security.
Comment: Why does the third party want to know? If it is a potential subcontractor wanting to know that the prime contract exists before committing to the subcontract that might be legit, if it is an auditor wanting to know that might be legit, a random person off the street might not have that right.
Answer: If this is a government university in the US, the matter would be controlled by that state's public records law. An example is 42.56 RCW Public Records Act. Generally, you have to make available any public record. In the definitions, that

includes any writing containing information relating to the conduct of
  government or the performance of any governmental or proprietary
  function prepared, owned, used, or retained by any state or local
  agency regardless of physical form or characteristics.

which a contract would be an example of.
The obligation to make accessible is in 42.56.070, which requires that

(1) Each agency, in accordance with published rules, shall make
  available for public inspection and copying all public records, unless
  the record falls within the specific exemptions of subsection (8) of
  this section, this chapter, or other statute which exempts or
  prohibits disclosure of specific information or records.

Thus there are some exceptions to what must be made available. One partial exception is, as that subsection continues that

To the extent required to prevent an unreasonable invasion of personal
  privacy interests protected by this chapter, an agency shall delete
  identifying details in a manner consistent with this chapter when it
  makes available or publishes any public record; however, in each case,
  the justification for the deletion shall be explained fully in
  writing.

hence you can't make a public records request to obtain my address, phone number, SS number and so on. Also as mentioned above, subsection (8) instructs that

This chapter shall not be construed as giving authority to any
  agency...to give, sell or provide access to lists of individuals
  requested for commercial purposes, and agencies... shall not do so
  unless specifically authorized or directed by law

And there is a sub-exception therein that

lists of applicants for professional licenses and of professional
  licensees shall be made available to those professional associations
  or educational organizations recognized by their professional
  licensing or examination board, upon payment of a reasonable charge
  therefor

On the front of personal information, the law indicates more or less what personal information is excluded, in 42.56.050:

(1) Would be highly offensive to a reasonable person, and (2) is not
  of legitimate concern to the public

There are quite a number of other exceptions:

Records in the medical marijuana authorization database established in
  RCW 69.51A.230 containing names and other personally identifiable
  information of qualifying patients and designated providers are exempt
  from disclosure
Actual enumeration data collected under RCW 35.13.260, 35A.14.700,
  36.13.030, and chapter 43.62 RCW shall be used and retained only by the office of financial management and only for the purposes of RCW
  35.13.260, 35A.14.700, 36.13.030, and chapter 43.62 RCW. The enumeration data collected is confidential, is exempt from public
  inspection and copying under this chapter, and in accordance with RCW
  43.41.435, must be destroyed after it is used.
The following investigative, law enforcement, and crime victim
  information is exempt from public inspection and copying under this
  chapter: (1) Specific intelligence information and specific
  investigative records compiled by investigative, law enforcement, and
  penology agencies, and state agencies vested with the responsibility
  to discipline members of any profession, the nondisclosure of which is
  essential to effective law enforcement or for the protection of any
  person's right to privacy;

and especially pertaining to security:

The following information relating to security is exempt from
  disclosure under this chapter:
(1) Those portions of records assembled, prepared, or maintained to
  prevent, mitigate, or respond to criminal terrorist acts, which are
  acts that significantly disrupt the conduct of government or of the
  general civilian population of the state or the United States and that
  manifest an extreme indifference to human life, the public disclosure
  of which would have a substantial likelihood of threatening public
  safety, consisting of...

(and a lot more).
So in Washington (and many similar states), if University of X has a contract with W, that fact is a public record and subject to some degree of disclosure. The actual content might be heavily redacted, pursuant to the numerous exceptions that exist, but the existence of a contract is not subject to suppression. Also, there is no requirement to disclose records for the purpose of commercial exploitation.
Federal law might be relevant, if the university were a federal university, but there are none. There are federal military academies, which are not termed "universities", but with an expanded understanding of "university", military academies would be subject to federal law, the Freedom of Information Act. Federal agencies are subject to an analogous obligation to disclose, with exemptions (for example:

This section does not apply to matters that are— (1) (A) specifically
  authorized under criteria established by an Executive order to be kept
  secret in the interest of national defense or foreign policy and (B)
  are in fact properly classified pursuant to such Executive order;

If any party to the contract is a government agency (state or federal), one can pursue a records request. Consequently, the only university contracts which are entirely exempt from disclosure are those between a private university and a non-governmental party.
Comment: There are at least five federal universities: US Military Academies for Army, Navy, Air Force and Coast Guard, and Gallaudet U for the deaf.

Verification of a contract


Classical analog of state vector

Question: I can't believe I don't know the answer to this question. What is the classical analog of the state vector of quantum mechanics?
Answer: The state vector represents a complete (as complete as quantum theory allows) specification of the system's physical state. So the classical analog of the state vector would be a point in phase space, or any other type of data that suffices to specify a unique solution of the classical equations of motion.
By the way, classical physics can be regarded as a special case of quantum physics in which all observables commute with each other and in which the state is always an eigenstate of all of the observables. In this sense, states in classical physics are always orthogonal to each other (cf What makes a theory "Quantum"?).$^\dagger$
$^\dagger$ Minor technicality: In quantum physics, we normally require that the Hilbert space be separable, which means that it must admit a countable basis of mutually orthogonal state vectors. An obstacle to treating classical physics as a special case of quantum physics is that the Hilbert space (state space) of classical physics would typically be non-separable. The significance of this is emphasized, in a different context, in the paper String quantization: Fock vs. LQG Representations.

Classical analog of state vector


VB Script for Windows Servers

Question: I require a VB script which when run gives me the details about the latest Windows patch that was updated on the servers along with the date & time.
Comment: Have you considered using [WSUS](http://technet.microsoft.com/en-us/wsus/default) instead of doing this manually?
Comment: Anu- I hope that you're not asking anyone on this site to write one for you, or search Google for you? You haven't told us what you've tried so far and what did or didn't work.
Answer: You can do this with the following command:
<code>wmic /node:"<servername>" qfe get description,fixComments,hotfixid,installedby,installedon,servicepackineffect
</code>
Where  is the hostname of your server.
You might want to take a look at WSUS.
Answer: I have no idea but you could try something like this
http://forums.eeye.com/index.php?/topic/1883-windows-patch-installation-date/
Answer: Here you go: http://technet.microsoft.com/library/ee176545.aspx
Answer: Please use powershell for new / future scripting on windows platform.  it is the modern oo based shell environment and should meet your needs.  VBS is a pre 2000 (over 10 years old) scripting solution that should be on the retirement technology list.
This blog post has lots of interesting info regarding your need:
http://blogs.technet.com/b/heyscriptingguy/archive/2011/08/13/use-powershell-to-audit-and-install-windows-patches.aspx
There are several sites that contain pre-built powershell scripts you can bing / google for.
Adding: Agree with other commentors that WSUS is a good solution for this as well.

VB Script for Windows Servers


To find no of (count) unique accounts from the campaign member related list

Question: How to display no of (count) unique accounts from the campaign member related list on the campaign detail page. [P.S: If two campaign members belongs to the same account it should count the no of accounts as 1, unique no of accounts is what we are looking for]
Comment: Where this count needs to be stored? Campaign? On update of campaign(trigger) or on specific time(batch)
Comment: The idea is to use this field in reports, hence we require this on campaign detail page
Answer: There is no configuration through which this can be achieved easily. This can be done via a trigger.

Create a trigger on CampaignMember for after insert, after update, after delete and after undelete.
Get the unique campaign Ids from Campaign Members
Create a aggregate query and group by Campaign Id and Account Id.

The aggregate query should be able to give you the unique count which you can update on Account. You might also require triggers on Contact and Account for handling situations such as Account update on Contact, Contact deletion, Account deletion.


I'm looking to save an irregular-shaped image - what is/are most popular formats supporting irregular images?

Question: I have an irregular shaped picture I'd like to save, in a format which allows the irregular shape to be preserved. Which image formats should I look at, which will support the irregular shape so I don't have to do any manual processing when editing the image?
Comment: What software created the image?
Comment: A custom tool I'm working on.
Comment: Would a vector format such as SVG be suitable then?
Answer: If you mean an image with a transparent background then the most useful format would be png. This has lossless compression and can support an alpha channel.
Most (if not all) image editing programs support reading and writing png format files.
Comment: I'm looking to preserve image editing information - I want to be able to manipulate the irregular polygon in the image without having to re-define it when I import into editing software
Answer: No matter the format, your image will always be rectangular, that is, the usual width X height format.
As above answer, I am assuming you want to preserve transparency, and for that you would need either gif or png format. Png has better quality than .gif and is supported in most if not all mainstream browsers and  image applications.