Movement in RPG

Question: I want to make an RPG game in which I move tile by tile. So when I hit up, the tile row that I am on decreases by one for example. Also, it's supposed to be a slow movement so that I can see the change in tile, i.e. I can see my sprite move from tile to tile. Currently, with the code I have, when I hit a direction on my keyboard, I move several blocks within seconds and by the time I release the button I have already gotten a nullPointerException error because I have left the map. How can I slow down the movement?
Answer: This sounds like an input problem. You need to check your inputs to see if you've already processed a key press. Keep the state of the keyboard from the last frame and check it when you're on your new frame. Only move if the key was not being pressed in the previous frame. Similar to responding to the event of pressing the key instead of the key being down.
For example:
currentKeys.fillFromKeyboard();

if(currentKeys.isDown(Key.UP) && !previousKeys.isDown(Key.Up))
    character.moveUp();

...

previousKeys.fill(currentKeys);

That will apply one move to each key press. If you wanted to have a held key repeat movements you can do something like:
int repeatDelay = 500; //time in MS that we'll delay before repeating a key

if(currentKeys.isDown(Key.UP) && (getCurrentGameTime() - timeMoved) >= repeatDelay) {
    character.moveUp();
    timeMoved = getCurrentGameTime();
}

Additionally, you should probably be checking bounds when moving. So check that your character's position + movement amount is withing world bounds, before moving.
Comment: moveUp would also have to be changed to be aware of if the character is currently moving, otherwise tapping up a few times would still move the character upwards several blocks.
Comment: @CiscoIPPhone Good point. The move up command can either queue up movements if the character is currently moving or additional moves can be ignored. I think expected behavior would be to ignore the additional input, but that's something you'll have to play test.
Answer: This is the code I used.
// These numbers represent the different directions in movement.
private final int STILL = 0, LEFT = 1, UP = 2, RIGHT = 3, DOWN = 4,
        STOP = 5;
// The current direction of movement of the player.
public int movement = 0;

// The move method, like any other player class.
private void move() {
// The keyboard input class works like this:
// If the up keyboard button is pressed, player.movement = player.UP,
// if right is pressed, player.movement = player.RIGHT, etc.
// and if no key is pressed, player.movement = player.STILL;

    if (movement == UP) {
        moveUp();
    }
    if (movement == LEFT) {
        moveLeft();
    }
    ....
    if (movement == STILL) {
        setDx(0);
        setDy(0);
    }
}

private void moveLeft() {
// Because this intends to work on a tile grid, this method checks if
// the tile to the left of the player is occupied.
    if (!tileIsOccupied(LEFT)) {
// The player can press a key every 200 ms. Sets the time moved to this
// point in time. If a player attempts to move before those 200 ms are
// over, no movement will occur.
        setTimeMoved(getCurrentTime());
// This tile is essential the tile to the left of the player.
        Tile tile = getGrid().getTiles()[getTileRow() - 1][getTileColumn()];
// If the xpos of the player is greater than the xpos of the tile, keep moving
// left.
        if (getXpos() > tile.getXpos()) {
            setDx(-1);
            setXpos(getXpos() + getDx());
        }
// If the xpos of the player is less than or equal to that of the tile,
// set the player's position equal to the tiles. In other words, when
// the player has moved to the tile.
// Set this current tile to equal the player's tile, and movement is reset to
// still.
        if (getXpos() <= tile.getXpos()) {
            setTileColumn(tile.getTileColumn());
            setTileRow(tile.getTileRow());
            setXpos(tile.getXpos());
            setMovement(STILL);
        }
    } else
        movement = STILL;
}

// It's essential that the update function be called on a loop. Otherwise, the
// player will not move.
public void update() {
    move();
}

Comment: -1 Answers that are just code are poor. Generally it doesn't explain things as nicely as some text, and in this case, it makes the answer too localized to this question, making it less useful to  future visitors. It's not even commented code.
Comment: I added comments. Hopefully this will be more useful to future visitors.
Comment: That's better, it explains the code, but it doesn't explain how you solved the problem.
Answer: Just a note on structure - you are calling repaint(); in your update(); function, but it would probably be better if you didn't chain the calls like that, but rather have those in your main game loop, ie.:
while(true) {
   update();
   render();  // if you use double-buffering, which you probably should
   repaint();
}

Movement in RPG


How much is Google investing in the Go language?

Question: I have read quite a bit about the Go language, and it seems promising. The last important bit of information I am missing before I decide on spending more effort on the language is: How much money/man power does Google or other companies invest in the development effort? If this information cannot be provided, do you have any other information showing the commitment of Google to the project. Is it being used as the primary language for a new investment or similar (my guess is that it is too early for this, but I do not know)?
Comment: Recently Google invested another bit in Go and now [Go runs on AppEngine](http://blog.golang.org/2011/05/go-and-google-app-engine.html). Another sign that Go is alive and kicking.
Comment: @9000 Please provide that comment as an answer, so we can upvote anand comment on it.
Comment: I'm voting to close this question because this question is about investment strategy and product management, of really about software engineering
Answer: I have been using go for about a year now, and the language has continually improved since then. Things are changing, improving, (somewhat) stabilizing, and generally amazing me in their innovations (e.g. gofix). It is most certainly not dying, and they seem to be putting quite a bit of effort into it.
The Google code page shows 17 people contributing to the project. From the looks of it, all but three of them are likely Google employees: http://code.google.com/p/go/people/list.
Worth noting is that the go project has notable programmers such as Rob Pike and Ken Thompson working for it, fathers of UNIX. If Google didn't care about the future of the go language, it is unlikely they would assign such high-profile programmers to its development.
Google is using go internally: http://golang.org/doc/go_faq.html#Is_Google_using_go_internally
The oracle saga won't happen with go: See the licence file and the irrevocable patent grant. Even if Google were to stop developing go (which is unlikely, given my points above), someone else would likely pick it up.
In addition to all of the above points, Google go is pretty much ideal for Google's internal use, due to it's built-in parallelization, native library support for the http protocol, and speed. For this reason alone, you can be pretty confident that go will be supported by Google for a while to come.
Comment: Brad Fitzpatrick of memcached and other projects fame is also part of the Go team, he has been fixing bugs and implementing features all over the standard library like crazy.
Comment: also that lock free guy from 1024cores blog  is working on Go. So although im not a fan IMHO Go isnt Going under.
Answer: Recently Google invested another bit in Go and now Go runs on AppEngine. Another sign that Go is alive and kicking.
Upgraded from a comment by popular demand :)
Comment: Go on AppEngine looks awesome. Too much easier than Java and clear&fast than python.
Comment: And it's just [got ready](http://blog.golang.org/2011/07/go-for-app-engine-is-now-generally.html) now.
Answer: I don't know the number of developers, but there's an intensive continuous development of Go. The team releases their improvements often (almost every weekly), maintains the documentation and the dashboard (http://godashboard.appspot.com/) and participates at the Google I/O and other conferences.
The community grows as well as the number of projects. So after a first hype and the trough of disillusionment Go now slowly gets up to a productive language.
Comment: Who needs Google Answers when you got Stack Exchange?
Comment: You never can be sure. But for me Go has the potential to let Google be more independent from Java (which is now owned by Oracle), e.g. on Android phones. Additionally Go is a good combination of many C, C++ and Python features, all intensively used at Google.
Comment: I am just worried about Google suddenly cutting on exactly the services I have began to love and depend on. One of them being Google Answers.
Comment: Google is cutting services that didn't caught on. Just like any other successful company. I guess it is called learning from mistakes.
Comment: @Job With Google Answers I could ask people to do a lot more work than on Stack Exchange. Here there is always the risk that nobody will be motivated to do the work needed to answer a question.
Comment: Google has always said they develop almost anything, throw them at the wall and keep the ones that stick. Google answers obviously slowly slid down to the gutter.
Answer: How much is Google investing in Go language? I don't think any one could answer except Google itself.
Google has the habit of releasing projects and see how people react to them, if there is a lot of buzz around it, invest into it and if not, drop it.
Examples:
Chrome OS, Google Buzz, GMail, Reader, Android ...
Comment: It is worth noting that even if Google stops investing in Go, the language isn't necessarily going to die. It is open source and free, and other companies are using it seriously. There are three compilers that I'm aware of. So unlike, say, Answers or Wave, if Google decides to stop supporting it, it won't be devastated.
Comment: Also quite a few companies have started to build their infrastructure using Go, see: http://go-lang.cat-v.org/organizations-using-go


When playing Phase 10 with 2 or more players, how do we conclude the hand?

Question: Why keep score for the points if on phase 10 there will be only one winner? I assume as soon as one person lays the phase 10 and goes out first he or she will be the winner regardless of the previous scores? No one can lay out phase 10 at the same time, right? How will there be a tie? In what situation?
Answer: Score is used when more than 1 player completes Phase 10 in the same hand. Completing a phase doesn't end the hand immediately; a player must go out by getting rid of all his or her cards. So a second player can complete Phase 10 after the first player has done so. Once a player goes out by getting rid of all of his or her cards; then if multiple players have completed Phase 10; score is used to determine winner.

GOING OUT: The player who gets rid of the last card in hand, by discarding or hitting, is said to go out. This player wins the hand. The winner of the hand, and any other players who also complete their Phase, will advance to the next Phase for the next hand.

and

If two or more players complete Phase 10 in the same hand, then the player with the fewest total points is the winner.

http://www.natlassoc.org/fun/games/phase10/phase10r.htm
Note that the terminology is a little confusing, because the rules say that whoever goes out "wins the hand", but "winning" the hand doesn't really mean anything other than getting 0 points for that hand. Anyone who completed the Phase moves on; and "winning" Phase 10 doesn't mean that you will win the game.


Microsoft Asp.Net & IIS & server limits

Question: How can I test my asp.net web application limits. User connections etc. And does my application is limited to server & IIS performance or what are the other factors?
How can I host an application which will be used by millions of people?
Comment: check this(Application pool settings) : http://www.codeproject.com/KB/aspnet/IIS7ASPNet.aspx  http://www.codeproject.com/KB/aspnet/ExploringIIS.aspx
Answer: This is a complicated question indeed.  I will try my best to answer it as best I can, so bear with me if the explanation seems contrived.
In terms of testing your application, Visual Studio comes with several plugins that can do load testing and performance analysis on your application.  I don't know what version of VS you need to have in order to gain access to these features, however I believe they are available starting in the Professional edition.  In the absence of Visual Studio, there are lots of programs available to run these tests, just search Google for ASP.Net load testing.  One application that works with Apache also works with IIS is available here.
In terms of hosting your application, it really depends on how many users you're expecting.  Many people get excited and say "millions of users", but in reality, for most people, it's a small fraction of that.  If you are honestly interested in scaling so large, there are a couple of options:

Host in the cloud - Amazon Web Services and Microsoft Azure are two options that are both scalable to nearly infinity, and support ASP.Net virtually out of the box with zero configuration.  Be aware, however, that these options can get very expensive, especially if you start using lots of CPU time and bandwidth.  The upside, is, however, that you won't lose performance or throughput if your site has 1 thousand visitors or 1 million.
Throw hardware at it - The tried-and-true method of throwing hardware at the problem is probably less expensive, but won't scale as quickly.  Start out by finding a good hosting provider and take a look at their offerings.  Dedicated servers are a good start and fully-managed, but at some point you will have to build your own servers and co-locate them.  Load balancing and redundancy become very important at the higher levels.

Regardless of what you decide to do, both options can be expensive.  Hosting in the cloud costs little up-front but can become very pricey as it grows; dedicated servers or co-location typically has a large up-front cost (for setup fees and/or additional hardware) but is less expensive overall and in the long run.
My suggestion would be to start small and go from there.  Shared hosting, while not scalable, gives you a great avenue to beta-test your site for pennies.  If there's interest and you start making some cash, upgrading to a dedicated server should be painless.
Good luck!
Answer: The first limits that you going to face, is yours.
What I mean by that. The main problem is when more than one users at the same time ask for a page.
Now if you have only one worked pool for your application then every user waits for the previous to finist its call.
If your pages delay more than  500 milliseconds to render, and takes more than 3-10 seconds to send them, and 2 or more users ask for the same think at the same time, your second user gets more lag. Also there is a problem that one user ask for a long wait query and stop the rest of them for get anything until this one finish.
The first solution is to user more worked pools (web garden) When you do that you need to make good synchronize of your data, because now 2 users can change the same think at the same time.
So my point is:Make a good design of your pages, and when you get the millions of users the only think that you need is money to get more computers and make a web farm (upgrade from web garden).
The iis limits is set on configuration of iis pool limits. If you actual have too many users what they see is the delay to get a page. If this is happens on one only pool then maybe a user crash it and stop them all to get anything. If you have many pools you maybe have less problems. More pools means more free memory, fast hard disk, fast computer, good synchronize of your data.
Sites with too many users maybe some times sites with nice videos, or photos, or shared stuff. In this case you can also place this media to a different server and split out the load.
Hope this help.

Microsoft Asp.Net & IIS & server limits


How can I get signet coins?

Question: We had several requests for signet coins in the past week. This question is meant as a lightning rod to answer how to go about and where to direct a request for signet coins instead of asking for signet coins here on Bitcoin Stack Exchange.
Answer: Get Signet coins
Since Signet is centrally controlled, you only option is to get it from a faucet or ask for coins in the bitcoin-signet IRC channel. But depending on what is your goal, there are other great alternatives to signet which are easier to mine or test with.
Alternative testnets
Testnet
Testnet has a special rule, which makes it easy to mine in particular circumstances. If there are no blocks found for more than 20 minutes, the difficulty drops and you can easily mine a testnet block with a normal CPU. Obviously your luck depends on if other powerful miners are mining or not. I use this primitive bash miner script to mine and I found 6 blocks in less than 2.5 months.
Regtest
In many cases you don't need to test on a public blockchain, so why not run a local testnet? It works just like the Bitcoin network, but external connections are disabled and the mining difficulty is set to 0. This allows you to mine as many blocks as you want, making testing faster and easier.
Answer: Signet coins are worthless. They are used for testing Bitcoin software before deploying it on mainnet and protocol development experiments. The signet may be reset occasionally if any projects start to rely on signet for non-testing use-cases.
You can find faucets for small amounts on

signetfaucet.com
alt.signetfaucet.com
signet.bublina.eu.org

If you need a larger amount, legitimate developers are encouraged to ask in the #bitcoin-signet IRC channel on Libera.chat.
Comment: Unfortunately, all three of these faucets appear broken :(
Comment: The first and third work for me right now. The second one does seem to have an issue which I am reporting to the owners.

How can I get signet coins?


Internet Explorer restricted this web page from running scripts or ActiveX controls pop up window

Question: This pop up window appearing in SharePoint Online intranet page: Internet Explorer restricted this web page from running scripts or ActiveX controls.
It is affecting almost for more than 5000 users. I know, how I can configure it to my computer from IE Options->Tools->Advanced->Security and then check for Allow active content to run in files on My Computer. But this is applying only for my computer. How can I enable it for all users? Is there any possible solution?
Answer: To apply IE settings for all users you need to ask your system administrator to create/modify the domain policy to Allow active content to run in files
BTW, I think it isn't a SharePoint question!!
Comment: How to create domain policy?Is it related with coding part?
Comment: https://msdn.microsoft.com/en-us/library/bb742376.aspx
Comment: How can I define that which web part is not allowing to run active content?How can I found from where it comes?


Adding the c wire to a two wire system

Question: I purchased a RTH9585WF smart color thermostat to replace my mercury controlled thermostat. How do I add the blue common wire at the boiler relay where the two wire system is connected?
://i.stack.imgur.com/H6eN9.jpg
Answer: You'll either need to use a separate 24VAC transformer, or replace the boiler relay with something that provides a C terminal
Sadly, your Argo AR821, like many older boiler relays, does not provide a C terminal at all.  As a result, you'll need to either wire an external 24VAC transformer to Rc and C on the thermostat to provide it with power while connecting Rh and W to the relay terminals, or replace your boiler relay with a newer model that provides a C terminal.
Answer: Pop the circuit board out and solder a wire to the back side.
We can faintly see a copper trace from the terminal where your red wire lands going toward the relay. Another trace is visible going from the terminal with the white wire toward the transformer. The red and white wires are reversed: R should be the one that goes to the transformer; W is the one that goes to the relay. It makes no difference whatsoever with a two-wire thermostat, but when you want to add that third wire for C, it starts to matter.
Common is the at the other end of the transformer, where there will be a circuit board trace leading to the relay.
Comment: ProTip™: If "popping the circuit board out" requires removing the wiring from it, label _every_ wire as you remove it from the board so you know _exactly_ where it's supposed to go back! If you don't, once you've removed them all, and bent them out of out of the way, you'll have no clue which white wire was which and where it was supposed to go. Save yourself the trouble and having to ask a new question...
Comment: Take pictures too beforehand.

Adding the c wire to a two wire system


fail2ban statistics?

Question: Is there a program that parses fail2ban.log and produces some statistics? Or should I set out and write something custom for our hosts? We run mostly Debian and fail2ban with iptables.
Answer: I have found this in Google code and it does give some initial statistics per date and service. You can at least use it as a template to get the stats you want
Answer: for graph stat you can use munin:

https://github.com/munin-monitoring/munin

fail2ban statistics?


Android FDE - Why is key stored in RAM at all?

Question: As far as I understand, the device's <code>/data</code> partition remains decrypted once an encrypted devices has been unlocked during boot up. Why does Android have to keep encryption keys within RAM if no "live" decryption / encryption is actually happening?
Comment: Even if it worked the way you imagined, you'd still need the key in RAM to encrypt the data and save it, right? Or do you imagine the user would get prompted for password at every shutdown (or lose data otherwise)?
Answer: I think you understand the concept wrong. The encrypted partition will not be fully decrypted on mounting, then stored somewhere on the device and then encrypted again (to save the changes) whenever the partition gets unmounted. Instead the key is known the the kernel (i.e. it is in RAM) and it can thus decrypt and encrypt data on the fly.
Comment: if the partition was fully un-encrypted and you lost power the un-encrypted files would not be protected, every write uses the in ram key to encrypt and save the file.
Comment: @Pieter: Not to mention the notorious difficulty of securely erasing *anything* on an SSD.  If it wasn't encrypted when it hit the drive, it's effectively compromised for good.


Reduced voltage on circuit

Question: Short version: We had low and possibly fluctuating voltage on one circuit in my house. 4 wall plugs and ceiling fan with light kit. Around 90 volts.
Long version: Entertainment center has Ring alarm base station, TV, Denon AVR, XBox, AppleTV all plugged into one surge suppressor which is plugged into a wall outlet. My wife showed me her phone yesterday morning and she had 130 alerts from Ring of power loss and power restored. I turned on the TV (Dish, TV, Denon all come on) and TV immediately rebooted, the Denon seemed to be rebooting, and the Dish Hopper rebooted.
Turns out that same circuit had the ceiling fan and fan light on the circuit. These were controlled by a Lutron Caseta fan controller and a separate Caseta switch for the fan light. Those switches were installed during a small remodel and have been working for 3 or 4 months with no issues. But my wife noticed the small LED lights on the switches were flashing. I immediately suspected them and uninstalled them by removing their pigtails from their respective wire nuts in the wall box.
When I did this, it dropped the downline voltage (4 wall outlets downstream) to 11vac.
My wife later told me that she had previously plugged in her old Kirby Vacuum cleaner to the female side of the Christmas light string plugged into the first downstream outlet from the light switches that I opened up. A major load, for sure.
When looking at my Circuit Breaker chart, I noticed a note I had made a long time ago that to turn off the Pantry light, one had to flip circuit breaker #8 and #20 simultaneously. Never had this addressed by an electrician.
Turns out the circuit in question is c/b #20. But the pantry lights no longer work now.
So I've turned off #8 and #20 while waiting on an electrician. Would be easier to trace if this wasn't a two story house. 99% sure all the wiring to this problem is routed through the ceiling/under upstairs floor.
Any ideas? ("Sell the place" is taken, we've already put it on the market.)
Thanks. Merry merry.
Comment: You might check the plugs and switches on the circuit and replace any stab-in connections with new which have screw termination.
Comment: Plugged a vacuum cleaner to a Christmas light string? Face, meet palm.
Answer: I was too busy playing football to take electrical trades in high school. Big mistake.
Old man and his son showed up today. He had it diagnosed when he walked in the door. Sounds like a problem with your neutral. Quickly confirmed and redid some wire nuts and all good.

Reduced voltage on circuit


Moss all over soil in garden

Question: Cannot get rid of moss in or on the soil in my garden so what plants can I grow in the moss.
Desperate to have a flower garden not a moss ridden garden!!??
Gill
Comment: We probably need more information to help you -  Location (I assume UK based on your user name and moss issue, but where in the UK? Or do you live somewhere like NZ or Australia?), amount of sun the area gets, soil type (ericaceous? calcareous? Clay? Loam? Sand?), length & width of garden, max height/width of plants you'd like to see in the garden, etc. A photo would also be helpful.
Answer: Moss is generally an indicator of acid soil and low light levels (lots of shading.) If you're not able to cut trees, or you are heavily shaded by things other than trees (as in a city location) you'll have to work with that. If you can remove things causing shade and get more light in, that can help immensely.
Referring to "flowers that are happy in my blueberry bed" (acid, but decent light) Daffodils, bleeding hearts, snowdrops and crocus all do fine, other than the squirrels raiding the crocus bulbs. Not sure any of those would flower much (other than the first season for the bulbs) in low-light conditions.

Moss all over soil in garden


Where to get software name of CLSID

Question: I'm in such a situation that every week I need to find one or two software names and all I know is CLSID. I want to ask if there is any official place where I could look for.
Comment: Are we talking about CLSIDs (for COM interfaces) or about GUIDs in general? Where did you get the CLSID from?
Comment: @ST3 - I know of no database that would hold this information.  I would use your current process.
Comment: @Werner I have some CLSIDs for COM interface. I have them from one registry cleaner.
Answer: If you have a CLSID {xxx} you can take a look at the registry key HKEY_CLASSES_ROOT\CLSID\{xxx}\. The default value for the registry key will give you a description of the CLSID. Other values under the key will give you more information like the DLL that implements the interface and a short name (program ID).
There is an article on codeproject that gives you a good overview over the COM registry keys.

Where to get software name of CLSID


Example of membership sign up?

Question: We're considering Civicrm for our membership database, but my client would like to see an example of what the look/feel would be for a new member signup. Is there an example/demo that someone can point me to?
Answer: There is the generic CiviCRM demo, but that only shows the back-office part (see https://civicrm.org/demo). I assume your client would be interested in the outside facing web part, and that entitely depends on what you can do with Drupal, Wordpress or Joomla. It will be hard to show you one example that gives you an idea of what the new member sign up looks like not because they are not there but because there are so many!
Comment: For a basic idea how the user facing signup could look like, you can use the contribution page in the CiviCRM demo: http://dmaster.demo.civicrm.org/civicrm/contribute/transact?reset=1&id=2
( Contributions >> Manage Contribution Pages: "Links" for the relevant page in the listing)
Answer: Logged out you can see an example membership page here but what you would see would entirely depend on your theming and there is much that can be done via js to manipulate the page to look very different.
A couple of more extreme examples are here (NZ Greens) and here  (Aus Greens) (actually the latter is only donation currently but just trying to give you an idea that what comes out of the box, and what you can get built with time/skills/budget is vastly different)
Comment: Oh wow! I didn't realise that The Greens were using CiviCRM - that's some great themeing work going on there! I don't have anywhere near the level of skills to do custom CSS. Instead, we have a simple 'out of the box' WordPress website. Our membership form looks clunky in comparison but it does the job - people only use it once per year after all ;) http://mltawa.asn.au/about/join/membership-form/

Example of membership sign up?


UTF-8 percentage encoding and python

Question: I'm trying to get python to give me percent encoded strings. The API I'm interacting with (which I think is using percent encoded UTF-8), gives %c3%ae for î. However, python's urllib.quote gives %3F.
import urllib

mystring = "î"
print urllib.quote(mystring)
print urllib.quote_plus(mystring)
print urllib.quote(mystring.encode('utf-8'))

Any help appreciated.
Comment: I've executed your code, it prints `%C3%AE`. `%3F`, btw, is `?` char encoded.
Answer: Your file has to encode your string as utf-8 before quoting it, and the string should be unicode. Also you have to specify the appropriate file encoding for your source file in the coding section:
# -*- coding: utf-8 -*-

import urllib

s = u'î'
print urllib.quote(s.encode('utf-8'))

Gives me the output:
%C3%AE

Comment: Note that in Python3 this will be `import urllib.parse` and then `urllib.parse.quote`.
Comment: Are you sure that your script is saved as `utf-8` encoded file?
Comment: Nope, was in ANSI. Thanks!
Answer: That is because you're not declaring the encoding your file is using, so Python is inferring it from your current locale configuration. I'll suggest you to do this:
# -*- coding: utf-8 -*-
import urllib

mystring = "î"
print urllib.quote(mystring)
print urllib.quote_plus(mystring)

And also make sure your file.py is getting saved to disk with utf-8 encoding.
For me that yields:
$python ex.py
%C3%AE
%C3%AE

Couple of caveats. If your trying this from the interpreter, the # -*- coding: utf-8 -*- won't work if your console encoding isn't utf-8. Instead, you should change it to whatever encoding your console is using: # -*- coding: (encoding here) -*-.
Then, you should decode your string into Unicode using decode method and passing it the the encoding name your console is using as argument:
mystring = "î".decode('<your encoding>')

And later pass it to urllib encoded as utf-8:
print urllib.quote(mystring.encode('utf-8'))
print urllib.quote_plus(mystring.encode('utf-8'))

Hope this helps!
Comment: Thanks. File was ANSI, hence the problem.

UTF-8 percentage encoding and python


How can I install basemap in a python virtual environment on mac?

Question: I'm trying to install basemap to plot lat/long data. I'm following the instructions [at this website](
http://gnperdue.github.io/yak-shaving/osx/python/matplotlib/2014/05/01/basemap-toolkit.html) because they seemed the simplest of all those that I found.
However, I'm getting stuck at the last step, which is to run in Terminal
basemap-1.1.0$ python setup.py install

When I do so, I get the following error:
error: Command "gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/gitanjali/miniconda3/include -arch x86_64 -I/Users/gitanjali/miniconda3/include -arch x86_64 -I/usr/local/geos/include -I['/Users/gitanjali/miniconda3/lib/python3.7/site-packages/numpy/core/include'] -I/Users/gitanjali/miniconda3/lib/python3.7/site-packages/numpy/core/include -I/Users/gitanjali/miniconda3/include/python3.7m -c src/_geoslib.c -o build/temp.macosx-10.7-x86_64-3.7/src/_geoslib.o -MMD -MF build/temp.macosx-10.7-x86_64-3.7/src/_geoslib.o.d" failed with exit status 1

I'm also told that "101 warnings and 15 errors generated".
Despite this dire set of warnings, when I go to examples and run python simpletest.py, there's no problem -- I get a map.
Though I get a map when running commands in Terminal, I'm unable to access basemap as a module in regular python files. That is, when I try to run a file with "import basemap", I get the following error message:
ModuleNotFoundError: No module named 'basemap'

I'm at a loss as to what's going wrong. If anyone could help me troubleshoot, I would really appreciate it.
Comment: "Though I get a map when running commands in Terminal, I'm unable to access basemap as a module in regular python files." - What's the difference then? Running `python somefile.py` is the same as typing `python` and then writing the content in the interpreter.
Answer: I have the same problem, But the problem isn't at venv, is at your python's version, as basemap seems don't work with newer version of python.


What are all these files on my Mac?

Question: I just did a clean install of the latest Catalina on my Mac. I was searching for my documents folder and all these files appear? What are they? can I delete it? is it possible is malware?
Answer: You're in a search screen and it's currently listing all of the files on "This Mac" (your Mac).  It's literally (not figuratively) every single one of your files listed alphabetically in a search window; it's nothing harmful.

Just close out of the search and you'll be fine.  You might want to take a quick read of the Apple document, Get to know the Finder on your Mac.
Answer: Welcome to Ask Different. Some of them would be system files or files associated to applications installed on your Mac. It's unlikely to be malware particularly if it's a clean install.
You can see where these files are installed in their parent directory by enabling the path bar in Finder. You can do this by going to the toolbar and click View drop down menu and select Show Path Bar. The path bar will then be shown at the bottom of the Finder window.
Then, when you select the file in the search results, the path bar will show you which  parent directory the file is located in.
Alternatively you can see all the properties of the file and where it's located by using the Get Info function by selecting the file and pressing ⌘ CommandI.
Finally, if you just want to see your Documents folder, this can be found in the left sidebar as shown in your screenshot. The documents folder is located in <code>/Users/youraccountname/Documents</code>.
I hope this helps, but please let me know if you need any further clarification.
Answer: The search is set to look in "This Mac" instead of the folder that you are in which is "Documents".  Change that and you will be good!

What are all these files on my Mac?


Can someone explain to me how setting shader parameters aren't a bottleneck?

Question: I am trying to understand this.  So I have a bunch of models that need to be rendered.  Each model most likely has various "sub meshes" with their own diffuse, specular, etc textures.  So for each of these models I have to loop through set the diffuse, specular, etc and then a draw call.  Now lets say I do this a couple times for each model, and I have 100 models in a scene.  Since my C++ code that sets these per model parameters is called by the CPU, doesn't it have to bus all that data to the GPU a ridiculous amount of times.  Even if it doesn't and the GPU is caching, wouldn't the CPU still need to make several inquires to make sure the correct resources are cached?  I am asking because I have a, single, high res model I am rendering and once textures are applied I drop from 1000 FPS to 70.  This model has about 20 different textures, and isn't something that will be used in a game, solely using it to stress test and locate bottlenecks. Thanks!
Comment: (Small tip, always measure performance in frametime (ms it takes to render a frame), not fps as results in fps might seem contradictory) http://www.mvps.org/directx/articles/fps_versus_frame_time.htm )
Answer: It isn't entirely clear what you are asking. Setting shader parameters IS a bottleneck - that's why engines batch by material - textures, parameters, lights, etc. While CPUs and GPUs are efficient, in order to get the most out of rendering performance you have to think about these things.
Answer: Look into "Shader Constants Buffers" on DirectX and "Uniform Buffers" on OpenGL. These allow sending shader parameters all at once to the GPU and possibly reusing them every frames without having to resend them over the bus.
Comment: Yeah, that's basically what I am trying to figure out how to batch.  I have a scenemanager that uses an octree to cull visibility, and adds visible items to a vector of priority queues (so I can control render order for opaque/transparent, post-processing effects, etc.)  What I am struggling with is finding an efficient method to batch these by render context and texture context across a priority queue.
Comment: Group shader settings into a material object then sort render batches by material object. One easy way is to use a `std::multimap` all render batches using the same material will be grouped on the same key (the material pointer). You can then iterate over the multimap and only update GPU states when the material (iterator->first) changes.


Why Are My Cache Files & Other "Hidden" Files/Folders Visible? & How Do I Get Rid Of Them?

Question: I hid mach_kernel and private, but the cache.db, cache.db-shm, cache.db-wal of both the system and user folder are, also, visible. Yesterday, I had to restore from a Time Machine backup because something had suddenly eaten all the space on my startup drive. However, these files were visible prior to the restore. So, why are they there and how do I safely dispose of them or hide them to prevent their return to visibility? Thanks.
Answer: try "defaults write com.apple.Finder AppleShowAllFiles NO" in terminal.
or you could do a "chflags hidden /path/to/folder"
how did you hide private and mach_kernel
Comment: I hid private and mach_kernel with "sudo chflags hidden".
Comment: how did the defaults write for appleshowallfiles go?


Tracking movement of individuals

Question: I have a simple Salesforce set up of Accounts and Contacts. My contacts are associated to an account, but they may move to another account at some point in their career. I want to track that - what would be the best way of tracking this? I guess I could use field tracking on the Account field on the Contact object - but any other ideas?
Thanks.
Answer: Generally people do this through affiliations. Affiliations is a custom object to track the relationship from a person to an org. The custom object would then have start/end dates for the relationship. There is a package on the Appexchange for this which is free.

Tracking movement of individuals


Wooden deck butting up to retaining wall not square

Question: My husband built a deck from our house out toward our retaining wall.  The wall is not square with the house.
We are on a budget and want to make this aesthetically pleasing now, and will redo the retaining wall later.  Looking for some inexpensive ideas for covering the gap between the last deck board closest to the wall and the wall itself.  Virtually covering the hole between the deck and the wall and attempting to make it appear square. Thought about building a box up from the deck and half a foot over the flowerbed, to mask the uneven wall.  Would like to keep the flowerbeds but get rid of the rotten boards on the wall. Any other ideas?  Thanks in advance.
Comment: It's hard to see just how out-of-parallel things are, but I'd seriously consider placing your furniture and furnishings and then decide if it's an issue. If you break up the visual enough, 99% of people won't even see it.
Answer: Use a table, circular, or other saw to rip the deck boards to fit.


Log and inverse Data transformation in Linear regression model

Question: I am studying behaviour of particulate matters(pm10) concentration in respose to change in rain and tempretaure.
my data was not normaly distributed so i have to transform data I did log transformation and inverse transformation.The Adjusted R-squared for log transformation is :0.07918 and Adjusted R-squared for inverse transform is :0.1002.Now according to rule i must select model with high value of Adjusted R-square but on the other hand if we look to the QQ-plot and histogram of log(x) and 1/X it seemes that model with log transformation best fits the data. Now i am confused in selecting the best model. your help will be highly appreciated .
all the necessary graphs are attached here Y is pm10 (response) and x represents rain (dependent varaible) .
Comment: You're fixating on whether the response is normally distributed but that's not a requirement for regression. At most it is good if residuals are approximately normally distributed. The graphs don't allow a good recommendation of which model is better because that should depend on physical reasoning; it is far from clear that rainfall should be used as it comes (perhaps it should be cube rooted); and there is no information here on temperature. You want scales on which behaviour is approximately linear; that's immensely more important than whether marginal distributions are normal.
Comment: It difficult to conceive of any situation where any statistic related to R-squared would be valid or useful for comparing fits that differ by some nonlinear re-expression of the *response.*  If you "have to transform," that suggests this might be some kind of textbook exercise.  If so, find a better textbook!
Answer: You write

My data was not normally distributed so i have to transform data

This is not correct. OLS regression makes no assumptions about the distribution of the data, other than the DV having to be continuous. It makes assumptions about the errors, which we examine by looking at residuals.

I did log transformation and inverse transformation.

Do either of these make sense in your context? The inverse of particulate matter per parts of air is parts of air per particulate matter. Does that make sense to use?  The log of a ratio is the log of the numerator minus the log of the denominator. That doesn't seem sensible to me, but I am no expert in this field.
Instead of changing your data to fit the model, change your model to fit the data. You could use robust regression, quantile regression, maybe a regression tree, or something else.

The Adjusted R-squared for log transformation is :0.07918 and Adjusted
R-squared for inverse transform is :0.1002.Now according to rule i
must select model with high value of Adjusted R-square

No, you don't. Data analysis is rarely a matter of rules. You need to think about your problem. As David Cox put it:

There are no routine statistical questions, only questionable
statistical routines

As for your graphs, they are very nice and they show that neither of your models is really great. You do have some extreme values of rain. I'd first check if those were errors. It might make sense to take the log of rain. This essentially changes additivity (what happens when there is 1 more cm of rain?) to multiplicativity (what happens when there is twice as much rain?) and that might be good. It would emphasize small changes at low levels of rain, which might make sense, substantively.
Or, maybe a spline or rainfall would be good.


Delay load of iframe?

Question: I know there are some tools and techniques for delaying the load of javascript, but I have an iframe that I would like to delay loading until after the rest of the page has finished downloading and rendering (the iframe is in a hidden  that will not be revealed until someone clicks on a particular tab on the page.  Is there a way to delay the load of an iframe?  Any suggestions would be much appreciated.  Thanks!
Answer: with jquery it is easy!
either enclose your code which loads the iframe within a $()
or use $(document).ready(function(){})
these both are the same and would execute your code after the DOM is ready!
e.g.
$(document).ready(function(){
    $('iframe#iframe_id').attr('src', 'iframe_url');
});

see more at http://www.learningjquery.com/2006/09/introducing-document-ready
Comment: The number of people answering in jQuery when asked for Javascript is scary these days.
Comment: @PiyushSoni We spend years getting people acclimated to using a comprehensive solution like jQuery to assist with browser consistency and now purists are complaining about it? Educating people works better than complaining. :)
Comment: It turns out your first line solved everything.

I was using a horrible template for tabs that I downloaded from a random website, and it liked to render my hidden iframe in front of everything unti it fully loaded.

When I switched over to using jquery tabs (which looked much nicer to boot!), the iframe rendering was no longer an issue.

jQuery ROCKS!

Thanks :)
Comment: In IE, this may break the back button because it adds the new iframe source to the browser history.
Answer: You can use the loading attribute to lazy load iframes.

Answer: Don't know if need do run without javascript. But the best method is to change the src direct after the iframe:

Using $(document).ready will start the rendering of your Iframe direct after the DOM Tree is build, but before all of the content in your side is loaded, so I think this isn't what you want.
jquery has the event .load, which is same as onload (after all resources are loaded)
$(window).load(function(){  iframe.src = src; }

Comment: Hey Eskimo-

I assume your answer would work, although I wasn't able to make it work (I'm sure it was due to a problem on my end) :)  I don't have enough reputation to vote you up yet, but thanks for the suggestion!
Answer: I don't understand why everyone is confusing JAVASCRIPT with JQUERY, but...
The pure JS solution is below: (basically it waits for the DOM to be built then loads all iframes in your page).

Note: Be careful about using the document.load event. Any resource that has a problem or has to spend 1 minute to load will stop your code from executing. This code snippet is tweaked (replaced load by domcontentloaded) from this reference.
Answer: Use Javascript in the onLoad event, or in the button click handler, to set the src attribute of the iframe.
Answer: This works for me, but has problems if you change the code at all:
function loadIFrame() {
    window.frames['BodyFrame'].document.location.href = "iframe.html";
}
function delayedLoad() {
    window.setTimeout(loadIFrame2, 5000);
}

Using:

Answer: Load iFrame after page has loaded
With JQuery and a little html and js

// Javascript
$(window).bind("load", function() {
  $('#dna_video').prepend('');
});

Comment: This code is the only one that allowed me to load an iFrame after canvas.js. With this code, the canvas instantly appears and the iFrame is delayed, whereas before, the canvas wouldn't appear until after the iFrame loaded. Thanks Amir!
Answer: You can use defer attribute when need load last after css, js etc:
iframe defer src="//player.vimeo.com/video/89455262"

Answer: window.setTimeout(function(){
$("#myframe").attr("src","exp3.html");
$("#myframediv").show("slow");
},4000);

try this, this also works.
Answer: You can also apply display:none to the iframe with CSS, then use jQuery's .show like this:
$(document).ready(function(){
    $('iframe.class_goes_here').show();
});

Comment: The iframe will still load even if in a `display:none` dom subtree - it just won't show.
Answer: Or my favorite use
setTimeout('your app', 6000)

That will make it wait x number of milliseconds to call any function....
Comment: What exactly would `'your app'` in your example stand for?

Delay load of iframe?


How to do multiperson UX tasks in Kanban?

Question: Our UX team is shifting to Kanban so we can manage our workload and projects better. My question is, how do we represent tasks that require a collaborative effort on the board? Do we break it out into cards for each person? How do we then account for the fact that different tasks are different size s without going to scrumban?
Comment: I believe there's also a project management stakexchange forum. You might want to try asking there as well. http://pm.stackexchange.com/
Answer: In the Kanban process, who is doing the actual work, how much collaboration is needed, or even the size/complexity of the work is not terribly important. People will naturally collaborate when they see that a task is not moving on the board.
The strength of the Kanban is to allow the team to easily visualize where a particular item is at a given time. If majority of your larger items require analysis, design, implementation and testing, then create these as columns on your Kanban. When people see an item lingering at a given column, the people with the right expertise will jump on it. You don't need to plan for collaboration beforehand. This avoids a lot of overhead associated with waterfall processes. For smaller items that don't require all the steps, simply skip over the columns. There's no need to explicitly mention the size of the work. Because regardless of its size, if that's the highest priority item, the team should get it done.
It'll be nice for people to know who's working on what for discussions, so definitely have people's avatars on the task they're working on. If people are collaborating, you'll see multiple avatars on the task.
Another way you can facilitate collaboration is through daily stand-ups. The team review the kanban together every morning. Should there be interviews, client session etc that need to be schedule ahead of time, the stand-up is a great time to remind the team about them. Knowing that and seeing the board should be sufficient for people to self organize in getting the work done.
Comment on WIP limit:
A Work In Progress (WIP) limit is important here to help your team stay focus. If you start seeing bottlenecks because you're constantly hitting the WIP limit at a particular stage, then the team can look into addressing the root cause for inefficiencies. Minor task to task variability in lead time washes out over time. In my experience, velocity measurements aren't terribly accurate. So don't be overly concern about fluctuations. The WIP limit bottlenecks are plenty sufficient for identifying problems.
Comment: very nice answer!
Answer: I guess it depends on your process workflow and team structure. It may mean that because you don't have a linear process (e.g. design --> build --> test) or a team where each member has a specific role (e.g. there might be a person doing business analysis while also designing and coding at the same time - unicorn sighting perhaps!) then you will have to cater for it differently.
One approach you can take is to 'tag' each task as having different facets or aspects required for its completion. So in the case where the collaborative effort is due to a task requiring analysis and design (for example) then perhaps you can tag the task with both 'analysis' and 'design' flags instead of creating two separate tasks (which you could do if there are no dependencies). Or in the case where the collaborative effort is due to a task that has external dependencies (e.g. outsourced to an offshore team), then you can tag the task with 'internal' and 'external' teams to indicate collaboration instead of creating two separate tasks (which you could do if there are no dependencies).
In terms of displaying planning and estimation of effort, if you are going to create separate cards then you can estimate separately, or sum the effort estimates if you keep it to a single card. You'll probably have to find a suitable tool to do this kind of process management because most applications cater for very generic scrum processes only.
Comment: Interesting! Though I'm thinking more in terms of capturing the fact that multiple people participate in a task at once. For example, it often takes two people to sit in on interviews, or sometimes it takes the whole team to do an affinity diagram ( and that can't be broken up into several tasks. It's literally several hours of everyone participating in a sticky note exercise.) I imagine combo of single person tasks and multi person tasks would skew the wip?


JDK as Zip File only not JRE

Question: Where can I get the latest jdk as a zip file. I don't want the jre, I want the full jdk. I can't run exe's or even request windows installer so it's impossible for me to download the .exe and run it. Also I can't access some uploading sites like Drop box or 4shared. Is there any ftp or place that I can get just zipped up jdk? Thanks you very much. Jportable is not good enough, Thanks.
Comment: I have deleted my answer as it pertained to the JRE, and not the JDK.  Sorry for the confusion.  You may not have any options at this point.
Comment: Thanks for the feedback thought. Appreciate it.
Comment: Possible duplicate of [How can I get the latest JRE / JDK as a zip file rather than EXE or MSI installer?](https://stackoverflow.com/questions/1619662/how-can-i-get-the-latest-jre-jdk-as-a-zip-file-rather-than-exe-or-msi-installe)
Answer: http://installbuilder.bitrock.com/java/  all the version are available. enjoy. all are ZIP
Comment: Not all versions, are avaible starting from 8 to 15.
Answer: Ideally, Oracle would provide us with the option of downloading the JDK binaries as a ZIP package instead of forcing us to use the Windows installer. But since they don't, why don't you try downloading the ZIP distribution of another Oracle product that already includes a JDK (e.g. Oracle SQLDeveloper). And please be sure to come back here and let us know if this approach worked out for you. I'm sure there are tons of folks out there looking for workaround too.
Answer: It's really simple but, you have to make it yourself.
First, download the JDK from the Oracle Website.
Second, extract all the contents using 7zip or other extracting utility.
Third, navigate through the extracted content and use Java's "unpack200" to convert all the ".pack" files (there's a couple of them) into jar files. You can delete the ".pack" files afterwards if desired.
Note: In order to use unpack200 you need to have a JDK  installed on the system. Navigate to the jdk1.x.x_xx/bin folder an run the utility from the command line.
Example: unpack200 rt.pack rt.jar
Thanks.
Answer: You can install jdk (with installer, uncheck 'public jre' option), zip installation folder.
Then uninstall jdk. Now you have a jdk zip, you can unzip wherever.
I'm using jdk this way on Windows Vista, both jdk 1.6, and 1.7.
Answer: I was also facing the same issue - to get a zip version of JDK7 on my PC. Tried to extract the exe installer and was happy to find that I got a set of folders including jdk,jre, lib,bin etc (similar to the set up that you get by running the installer for Jdk8). But my happiness was short lived - Eclipse did not recognize this path as a valid JDK / JRE installation , while I set up the additional Run time environments.
The fix is to run the exe installer and install it in a different path , outside Program files, so that it doesnt mess up your Java home settings or JRE versions for other client programs.

JDK as Zip File only not JRE


What harm would there be in running strip on all files?

Question: I'm trying to decrease a Linux image running SuSE, and thought about running strip on all of the system's executables. Even though I may not re-gain much disk space this way, would there be any harm in doing so?
Comment: Are you sure they're not already stripped?  Run `file` and see if it reports `stripped` in the output.
Comment: If you run `find / -type f -exec file {} \; | grep 'not stripped'` you should get a list of all not stripped binaries, which should turn to be a rather short list.  Then you only need to run `strip` on that.  It probably is quicker that well too.
Comment: @StephenHarris true, most of them are, but there are some other packages i've installed manually that aren't, so I'm interested in any side-effects of running a system-wide `strip`
Answer: It's not the case for Linux (just checked...), but on other systems (such as BSDs, e.g., OSX) doing this will remove any setuid/setgid permissions as a side-effect.  Also (still looking at OSX), the ownership of the file may change (to the user doing the writing).
For Linux, I recall that early on, stripping a shared library would prevent linking to it.  That is not a problem now, though as the Program Library HOWTO notes, it will make debuggers not useful.  It prevents linking to static libraries.
Further reading:

24.14 Don't Use strip Carelessly  (Unix Power Tools)
How do I strip local symbols from linux kernel module without breaking it?
What Linux and Solaris can learn from each other
Comment: Nice link. The text says to avoid stripping the kernel itself, but doesn't state why. What could be the problem with that?
Comment: The context is "need to debug" (when systems were built by linking object files for a kernel).
Comment: +1 Excellent tip about the shared library. I knew there was at least some problem invalidating binaries, but could not remember which one.
Comment: Also, programs written in the Go programming language will no longer work. The Go runtime uses debugging information to implement things like reflection etc. Don't think you're using anything written in Go? If you use Docker (which is getting REALLY popular these days) then most of the Docker commands and utilities are written in Go.
Answer: Most distributions, including OpenSUSE, strip executables as part of their build scripts. You don't need to strip on the system's executables because it's already been done.
There are binaries that must not be stripped. Package maintainers take care to use correct build options to avoid stripping them. This includes binaries that load libraries dynamically in unusual ways, doing some self-introspection rather than normal startup-time loading or a plain dlopen. This also includes many executables that consist of bytecode plus a bytecode interpreter for which strip mistakes the bytecode for debugging data.

A side note: if you want to save space, OpenSUSE is not the right distribution for you. OpenSUSE has very coarse package granularity. For a smaller system, use a distribution with finer package granularity so that you can install only the parts you need. In the desktop/server range, Debian and Arch are good choices. You may also consider distributions that target embedded systems such as WRT.
Comment: In this case, I'm stuck with SuSE (The commercial distribution) and trying to save space, not the other way around. But I inspected the system binaries and saw mostly stripped files, indeed.
Comment: Some ~20 years ago I used to run SuSE on a dual Pentium II machine, with 64 MB RAM (that's MB, not GB), and two SCSI disks of 300 MB. That machine had 120 users, with maybe 10 logged in simultaneously at any given time from DEC X terminals.  The machine was doing mostly DNS, mail, web serving, and web browsing (with Netscape).  Things have changed in the Linux land since those days.
Answer: If you're running a distribution that installs binary packages from repositories (most distributions, including SUSE, do this), then any changes you make to executables will be overwritten the next time you update (or reinstall) the package that contains them.
Additionally, they'll be reported as having the wrong checksum and size (and date, if you didn't run strip with the --preserve-dates option) whenever you verify installed packages.  You could make the rpm match up with your changes by rebuilding the package from the installed files.
If you want to strip binaries for installation, you may be better off building those packages from source and adjusting the compiler/linker flags.  The package should be built using the distribution's own tools for that task (such as rpmbuild, dpkg-buildpackage, or makepkg).  For people who need to do this kind of customization extensively, there are source-based distributions and even Linux From Scratch.  However, building from source takes much longer, as well as using more disk space than you eventually save with the smaller binaries.


Driver's License shredded, is this legal?

Question: Is it legal for a business owner to to shred a government issued ID card such as a driver's license that has been forgotten and left in their establishment?  If so, is there a minimum time they should hold onto it before shredding?  Or are they required to turn them in to the police or another agency such as the post office?
Comment: Please add a tag for the jurisdiction.
Answer: germany

Is it legal for a business owner to to shred a government issued ID card such as a driver's license that has been forgotten and left in their establishment?

No, since it is not their property.
They would be required to return the property to the owner (if possible with reasonable effort) or give the property over to a competent authority

lost and found office
police
authority that issued the document

otherwise can be charged with Misappropriation §246 (1) StGB.

§965 - Duty of the finder to notify BGB

(1) A person who finds a lost thing and takes possession of it is to notify, without undue delay, the loser or the owner or some other rightful recipient.
(2) If the finder does not know the rightful recipient or does not know their whereabouts, the finder is to notify, without undue delay, the competent authority of the finding and the circumstances that may be material to determine the rightful recipient. If the thing is not worth more than 10 euros, no notification is required.

§246 Misappropriation StGB

(1) Whoever unlawfully appropriates movable property belonging to another for themselves or a third party incurs a penalty of imprisonment for a term not exceeding three years or a fine, unless the offence is subject to a more severe penalty under other provisions.
(2) If, in the cases under subsection (1), the property was entrusted to the offender, the penalty is imprisonment for a term not exceeding five years or a fine.
(3) The attempt is punishable.

Sources:

German Civil Code (Bürgerliches Gesetzbuch BGB)

§965 - Duty of the finder to notify

German Criminal Code (Strafgesetzbuch – StGB)

§246 - Misappropriation (Embezzlement)

§246(1) - Misappropriation
§246(2) - Embezzlement
Comment: Since in Germany, a drivers license isn't really an "ID card", as you cannot identify yourself using it, if it happens to be a "Personal-Ausweis", destroying it would be §303 Sachbeschädigung. It is owned by the government (§4.2 PAuswG). Link to a case: https://www.saechsische.de/ausweis-zerstoert-geldstrafe-3986892.html
Comment: Not just a question of property, but also of value. The card can be presumed to be worth more than €10.
Comment: @o.m. Property fits better to §246(1) than value.


Post Visual Studio 2017 Installation, SharePoint Online Management Shell is not working

Question: Post Visual Studio 2017 Installation, SharePoint Online Management Shell is not working. While starting Shell, i am getting the error below error. Earlier it was working fine. Anyone got the same error ? VS2017 is working fine and i do not see any issues with it so far.
Answer: After trying lot of options, nothing worked. Including Re-installing the SPOL and Visual Studio.
Finally, found the solution. The Execution policy is being reset after installing VS2017. Overiding the Execution policy to remote signed resolved the issue.
Set-ExecutionPolicy RemoteSigned


income tax for purchased/sold short term & long term shares

Question: I have purchased above 600,000 rupees stocks from different company through NSE/BSE exchange.I have  a trading account with canara bank(sb), i deposited  rupees 6 Lacks this year &  purchased almost same amount of stocks throughout the year.I have no Idea about the income tax i have to pay or the tax already deducted when i purchase the share.I used to buy/sell shares on long term,short term also intraday bbasis.kindly guide me regards the tax payment.
Comment: This question cannot be answered unless the OP provides more details. The 600,000 INR deposit into Canara bank: where did it come from? A gift from parents? Savings from salary? Purchase of stocks does not require payment of any kind of tax on the amount but _sales_ require calculating capital gains and losses. The net gain, if any, would be taxable (subject to various exemptions, rules re short-term versus long-term gains, etc). Did the OP bother to keep the _statements_ of the various stock transactions, including intra-day sales?
Answer: As mentioned by Dilip, you need to provide more details.
In general for transacting on stocks;
Long Term: If you hold the stock for more than one year then its long term and not taxable. There is a STT [Securities Transaction Tax] that is already deducted/paid during buying and selling of a stock.
Short Term: If you hold the stock for less than one year, it's short term gain. This can be adjusted against the short term loss for the financial year. The tax rate is 10%.
Day Trading: Is same as short term from tax point of view. Unless you are doing it as a full time business.
If you have purchased multiple quantities of same stock in different quantities and time, then when you selling you have to arrive at profit or loss on FIFO basis, ie First in First Out
Answer: No Tax would have been deducted at the time of purchase/sale of shares.
You would yourself be required to compute your tax liability and then pay taxes to the govt.
In case the shares sold were held for less than 1 year - 15% tax on capital gains would be levied.
In case the shares sold were held for more than 1 year - No Tax would be levied and the income earned would be tax free.
PS: No Tax is levied at the time of purchase of shares and Tax is only applicable at the time of sale of shares.


How does a wire bend the electric field?

Question: The electrons in the current in a wire are constantly colliding with the metal cations which means there must be a constant cause of acceleration: an electric field. How, why is it that the electric field is identical in shape to that of the wire?
Answer: The electric field has to be provided by a battery for example. There is no electric field within a conductor by itself. If a voltage is applied to a bent conductor, surface charges accumulate in curved parts which leads to a net electric field in axial direction.
Answer: The electric field $\vec{E}$ also exists outside the wire. There is however no current there as there are no charges. Inside the wire, for simplicity assumed to be an isotropic conductor, $\vec{E}$ is related to the current density $\vec{j}$ by $\vec{j} = \sigma \vec{E}$, where $\sigma$ is the conductivity. It is not zero unless $\sigma$ is infinite as is the case for a superconductor.


Non-interactive (silent) install of MySQL 5.7 on Ubuntu 16.04 LTS

Question: MySQL 5.7 (5.6+ actually) changed how mysql_secure_installation works. This made it hard to find a working, silent, scripted install for Ubuntu 16.04 LTS. How would you install MySQL securely in a scripted noninteractive way?
Answer: The complete script below can be dropped into a file that we will call "install.sh" and executed by doing the following:
touch install.sh      # Create empty file
chmod 700 install.sh  # Make executable
nano install.sh       # Copy contents into script here
./install.sh          # Run it

Regarding the script below:

Remember to set MYSQL_ROOT_PASSWORD by replacing the question mark on line 4 with your password.
If running as root, remove the sudo's.
The script installs Expect. It can also purge (uninstall) Expect after completion if you uncomment line 50.

Script content:
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive

MYSQL_ROOT_PASSWORD='?' # SET THIS! Avoid quotes/apostrophes in the password, but do use lowercase + uppercase + numbers + special chars

# Install MySQL
# Suggestion from @dcarrith (http://serverfault.com/a/830352/344471):
echo debconf mysql-server/root_password password $MYSQL_ROOT_PASSWORD | sudo debconf-set-selections
echo debconf mysql-server/root_password_again password $MYSQL_ROOT_PASSWORD | sudo debconf-set-selections
#sudo debconf-set-selections <<< "mysql-server-5.7 mysql-server/root_password password $MYSQL_ROOT_PASSWORD"
#sudo debconf-set-selections <<< "mysql-server-5.7 mysql-server/root_password_again password $MYSQL_ROOT_PASSWORD"
sudo apt-get -qq install mysql-server > /dev/null # Install MySQL quietly

# Install Expect
sudo apt-get -qq install expect > /dev/null

# Build Expect script
tee ~/secure_our_mysql.sh > /dev/null << EOF
spawn $(which mysql_secure_installation)

expect "Enter password for user root:"
send "$MYSQL_ROOT_PASSWORD\r"

expect "Press y|Y for Yes, any other key for No:"
send "y\r"

expect "Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:"
send "2\r"

expect "Change the password for root ? ((Press y|Y for Yes, any other key for No) :"
send "n\r"

expect "Remove anonymous users? (Press y|Y for Yes, any other key for No) :"
send "y\r"

expect "Disallow root login remotely? (Press y|Y for Yes, any other key for No) :"
send "y\r"

expect "Remove test database and access to it? (Press y|Y for Yes, any other key for No) :"
send "y\r"

expect "Reload privilege tables now? (Press y|Y for Yes, any other key for No) :"
send "y\r"

EOF

# Run Expect script.
# This runs the "mysql_secure_installation" script which removes insecure defaults.
sudo expect ~/secure_our_mysql.sh

# Cleanup
rm -v ~/secure_our_mysql.sh # Remove the generated Expect script
#sudo apt-get -qq purge expect > /dev/null # Uninstall Expect, commented out in case you need Expect

echo "MySQL setup completed. Insecure defaults are gone. Please remove this script manually when you are done with it (or at least remove the MySQL root password that you put inside it."

Comment: MrClean's answer was great.  But, I was getting some output redirection errors when trying to run the script.  So, I changed the 2 lines under "# Install MySQL".  Since I can't put code in a comment, I'll add an answer to complement MrClean's answer.
Answer: MrClean's answer was great.  But, I was getting the following error when trying to run the script on Ubuntu 16.04 server (bash or fish shell):
Files/scripts/install_mysql.sh: 7: Files/scripts/install_mysql.sh: Syntax error: redirection unexpected

So, I changed the 2 lines under "# Install MySQL" to this instead:
# Install MySQL
echo debconf mysql-server/root_password password $MYSQL_ROOT_PASSWORD | \
  sudo debconf-set-selections
echo debconf mysql-server/root_password_again password $MYSQL_ROOT_PASSWORD | \
  sudo debconf-set-selections

Then, it worked like a charm.
Answer: ROOT_SQL_PASS=foo123
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $ROOT_SQL_PASS"
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $ROOT_SQL_PASS"
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server

Answer: I didn't go for mysql_secure versions check but actually silent install of MySQL 5.7 in Ubuntu 16 was itself a challenge as I was unable to get the password to work that was read in as unput.
So had to install with the default password example root and then changed it to the required one immediately.
Hope this helps.
echo "mysql-server-5.7 mysql-server/root_password password root" | sudo debconf-set-selections
echo "mysql-server-5.7 mysql-server/root_password_again password root" | sudo debconf-set-selections
apt-get -y install mysql-server-5.7 mysql-client >> $LOGFILE 2>&1

mysql -u root -proot -e "use mysql; UPDATE user SET authentication_string=PASSWORD('$MYSQLPASSWORD') WHERE User='root'; flush privileges;"

Note how MySQL 5.7 onwards it implements "authentication_string" to change root password.
BTW this was a part of an unattended LAMP + WORDPRESS install that I was attempting which you can find at https://github.com/suraj2410/autowordpressinstall


Over-the-range Microwave on small-appliance branch circuit

Question: Either there is conflicting information or a lack of when it comes to this question. Is it allowed in NEC code to permit an over-the-range microwave to run off of one of the small-appliance branch circuits?
Answer: Folks may be too wrapped up in the kitchen rules and forgetting the everywhere rule.
No receptacles if fixed loads are >50%
Add up the rated amperage (or VA/120 or watts/120) of each and every load that is either hardwired or permanently installed like the microwave, garbage disposal, fan, lights, yadayada.   Got the total?
Now look at the circuit breaker, it'll be 15 or 20 amps.
If the total of all the fixed, installed loads is more than half the circuit breaker rating, that circuit cannot power receptacles (other than the receptacles for the installed loads.)
Comment: Upvote for finding the flaw in looking at the obvious section.
Comment: I agree about the fixed loads. If the load is less than 50% this logic would say it is legal. The handbook (exact same code book with added explanations and commentary on why each section has its rules by the code committees) says it is not to code for the device to be fixed and connected. A portable trash compactor, dishwasher and microwave are legal to plug in to the small appliance circuits.put them in a cabinet and they are not.
Answer: 210.52 (B)(1) says that the 20A circuits shal serve all wall and floor receptacle outlets covered by 210.52(A), all countertop outlets covered by 210.52(C), and receptacle outlets for refrigeration equipment.
210.52(B)(2) Says that the two or more small-appliance branch circuits specified in 210.52(B)(1) shall have no other outlets.
210.52(A) - General wall outlets 12' O.C.
210.52(C)(5) says that outlets not readily accessible by appliances fastened in place shall not be considered as required outlets.
Given this i take it as an above range microwave is a fastened in place appliance, therefore that receptacle is not covered by 210.52(C).
And since 210.52(B)(1) says that the 2 small appliance circuits shall only cover 210.52(A) and 210.52(C), thus a separate circuit is needed.
Comment: Hello, and welcome to Home Improvement. Nice answer: keep 'em coming!
Answer: I can only access the 2017 NEC, but I don't know of anywhere that has adopted it yet. It's likely, however, to be stricter than whichever year of the NEC is legal in your area. In the NEC 2017, it says

210.52(B)(1) Receptacle Outlets Served.
In the kitchen, pantry, breakfast room, dining room, or similar area of a dwelling unit, the two or more 20-ampere small-appliance branch circuits required by 210.11(C)(1) shall serve all wall and floor receptacle outlets covered by 210.52(A), all countertop outlets covered by 210.52(C), and receptacle outlets for refrigeration equipment.

This would appear to indicate that a separate circuit, exclusively for the microwave, is not required.
Comment: Anyway, i would still like to see some opinions on interpreting the poetry on the permission of an over-the-range microwave on one of the small-appliance branch circuits...Anyone else?
Comment: An over the range micro IS NOT one of the outlets covered in 210.52(A) or (C) or refrigeration. It is not complaint to have one one a SABC. It is also a fixed in place appliance.
Comment: @SpeedyPetey That's my point. It is permitted to be on the SABC, but it does not count as a required receptacle for it. There is an exception on the placement of receptacles that covers fixed-in-place appliances which are often above or below the countertop.
Answer: My answer would be that an additional circuit is required.
I think if you read a bit further exception # 2 specific appliances shall be permitted to be supplied from a 15 a individual branch circuit.
 The built in appliances require a separate circuit in my state but if sitting on the counter the can be powered from one of the 2 small appliance circuits.
The commentary in the hand book for 210.52.B.1 states outlets in cabinets are not allowed only portable appliances used at a kitchen counter.  I believe my state code follows this in requiring fixed in place appliances like microwaves, and dishwashers to be on a separate circuit from the small equipment branch circuits required.
Comment: I was reading into 210.52(C)(5) and it sounds like you are excepted from the countertop receptacle location requirement for "appliances fastened in place." I read that as, "You can have it on the same circuit, but it cannot be one of the required receptacles."
Comment: The exception you mention states that you *may* have additional, dedicated circuits.
Answer: This is how I "red tag" microwaves that are fixed:

Art 90.1 Safeguarding of installation of the appliances.
Art 100 To install the appliance as per manufacturer specifications. This includes all attachments of the electrical in their proper location. Most say dedicated circuit.
Art 210.11 Branch circuits shall be provided for appliance loads
Art 210.21B1 If the appliance is 16amps, you can not put a 15amp receptacle on a 20amp branch circuit;.
Art 210.23(A)(2)At no time may a cooking appliance load exceed the branch circuit rating. At no time may the loads exceed more than 50% that are fixed shared with other receptacles.
Exception – The two small appliance branch circuits required shall only supply the countertop receptacles and adjacent breakfast room and may not feed other "fixed" appliances or receptacles.
Art 210.19A3 Cooking appliances require a branch circuit for that individual appliance.
Art 210.52(3). These circuits are required in addition to the two small appliance countertop circuits in the kitchen. Any appliance mounted in the cupboards or cabinets require their own branch circuit.
422.16(B)(4)(5) A microwave above a cooktop or stove with hood extractor requires a dedicated branch circuit.


Is OpenVPN actually forwarded over TLS?

Question: I'm investigating behavior of SSL decryptors on OpenVPN connections to port 443 and I noticed that device I use as decryption proxy doesn't recognize OpenVPN connections as TLS thus doesn't decrypt them. The question is then - how does OpenVPN protocol differ from standard TLS?
Answer: Openvpn uses TLS for authentication and key exchange but it does not use it for the actual data encyption. When running on UDP openvpn runs the TLS session on top of a custom "reliability layer", i'm not sure what it does when running on TCP.
Furthermore an openVPN network uses it's own CA to authenticate both server and client certificates. So you can't subvert the certificate process by loading a cert into the OS certificate store.
Comment: For reference, OpenVPN uses a control and a data channel multiplexed over the transport layer. **In TLS mode**, a TLS session is used over the control channel (only, not the data channel) in order to authenticate the connection, exchange cryptographic material, etc. OpenVPN uses the following stack: TLS / data channel / OpenVPN multiplexing / transport layer (eg. TCP). In contrast, dissectors (especially when working on port 443) will usually expect TLS / TCP. If you use a OpenVPN dissector (eg. in Wireshark), you will be able to correctly dissect the OpenVPN protocol and see the TLS messages.
Comment: Some clients including one I use don't support server certificate validation thus I'm concerned about decryptors.
Answer: OpenVPN provides different ways to management VPNs on your device.  OpenVPN uses OpenSSL (a TLS implementation) to provide TLS tunneling.  It simply uses the TLS protocol to establish a secure tunnel.
OpenVPN uses its own protocol to authenticate with an OpenVPN server, and manage connections.  However, the actual tunnel is still a standard TLS session.  The authentication is performed prior to establishing TLS.  So your decryption proxy will not know what to do with these authentication type packets when its looking for straight TLS.
This is similar to how Tor uses TLS.  Tor has its own protocol for establishing circuits and authenticating to Tor routers, but the TLS sessions are standard TLS between the routers.  Decryption proxies won't know how to handle the Tor protocol that precedes the establishment of the TLS sessions.
Comment: Tor runs the traffic through TLS (within custom extra layers). OpenVPN uses TLS only for control, but sends data through a separate channel.
Comment: @CodesInChaos OpenVPN is a TLS VPN, there might be separate channels, but my understanding is that TLS is used regardless.  Can you point me towards a reference that explains what you mean?
Comment: @RoraΖ security of OpenVPN data relies on symmetric encryption, whose keys are previously established and exchanged in the TLS negotiation(s). Due to being encrypted, data packets don't need a secure channel and go straight to the UDP or TCP tunnel socket.

Is OpenVPN actually forwarded over TLS?


Git: How to re-stage the staged files in a pre-commit hook

Question: I'm writting a git pre-commit hook.
The script could reformat some code, so it could modify the staged files.
How can I re-stage all files that are already staged ?
Comment: possible duplicate of [Can you change a file content during git commit?](http://stackoverflow.com/questions/16831536/can-you-change-a-file-content-during-git-commit)
Comment: Unless you're willing to break `git add --patch` and cripple `git rebase --interactive`, I'd call this a duplicate of [git pre-commit hook code formatting with partial commit?](http://stackoverflow.com/q/22858850/1290731)
Comment: I rename the question using "stage" instead of "index". It doesn't seem to be a duplicate of the two proposal, for me. I shared 2 answer that helps me below.
Answer: Without the pre-commit hook context, you can get a list of the staged files with the following command:
git diff --name-only --cached

So if you want to re-index the staged files, you can use:
git diff --name-only --cached | xargs -l git add

In the pre-commit hook context, you should follow the advices of David Winterbottom and stash unstaged changes before anything else.
This technique allows you not to be worry about indexing, or alterate, a change that was not staged.
So you don't have to stage all the staged files, but all the updated files:
# Stash unstaged changes
git stash -q --keep-index

# Edit your project files here
...

# Stage updated files
git add -u

# Re-apply original unstaged changes
git stash pop -q

Comment: Does not work for me... when i `stash` it also add staged files. So it properly add updated file to commit, but when I do `stash pop`, it put back previous version to my working directory
Comment: Better to use `git checkout-index` and avoid the issues with `git stash`.
Comment: @CS could you please be more specific? What issues exactly are there to be expected?
Comment: I'm seeing the same issue as @smolarek999. Even when providing `--keep-index`, Git still includes the staged changes in the stash with this option. @Filipe mentions this in [his answer](https://stackoverflow.com/a/66302637/389899) and this is also mentioned in [**warning: small bug in git stash** in a related question](https://stackoverflow.com/a/20480591/389899). I haven't found a workaround for this yet.
Answer: I liked @tzi's answer; however, in David Winterbottom's quoted article there is a edge case concern raised in the comments in which you will lose some commit history. Though, it's not as doom and gloom as the commenter makes it sound, and again is an edge case for people with problematic practices. It happens when

You stage a file (version A)
Edit the same file before committing (version B)
Wished to commit the originally staged file (version A) and not the modified one (version B)

If your commit fails, or succeeds and pops the stash before a committing, you lose your originally staged file (v. A), as it was never commit and is overwritten (with v. B). Obviously not catastrophic, and you still have the latest edit (v. B), but it might hamper some people's workflows and (suboptimal) committing practices.  To avoid this you just check the exit of your script and work some stashing tricks to revert to the original state (index has v. A and WD has v. B).

pre-commit

#!/bin/sh

... # other pre-commit tasks

## Stash unstaged changes, but keep the current index
### Modified files in WD should be those of INDEX (v. A), everything else HEAD
### Stashed was the WD of the original state (v. B)

git stash save -q --keep-index "current wd"

## script for editing project files
### This is editing your original staged files version (v. A), since this is your WD
### (call changed files v. A')

./your_script.sh

## Check for exit errors of your_script.sh; on errors revert to original state
## (index has v. A and WD has v. B)

RESULT=$?
if [ $RESULT -ne 0 ]; then
git stash save -q "original index"
git stash apply -q --index stash@{1}
git stash drop -q; git stash drop -q
fi
[ $RESULT -ne 0 ] && exit 1

## Stage your_script.sh modified files (v. A')

git add -u

You should also move the git stash pop to the post-commit hook, as this is what overwrite the staged file (v. A) with the modified file (v. B) prior to committing. In practice mostly likely your script doesn't fail, but even so your git stash pop in the pre-commit hook creates a merge conflict with your script modified files (v . A') and your unstaged modifications (v. B). This then prevents the file from being committed at all, but you do have your script modified originally staged file (v. A') and your unstaged post-staging modified file(v. B) (arguably not losing any significant history assuming your_script.sh only does stuff such as indenting so v. A and v. A' are pretty much the same).
Summary: If you use best practices and commit staged files before modifying them again, the original answer is easiest and great. If you have, in my opinion, bad habits of not doing so and wanting both versions (staged and modified) in your history, you need to be careful (an argument for why this is a bad practice)! In any case, this could be a possible safety net.
Comment: That's a nice improvement of my answer! Thanks for sharing it ;)
Answer: Sadly, I don't think @NearHuscarl's answer above quite cuts it. It is the closest I've seen, but when you pop the stash in your post-commit hook you will still introduce a merge conflict. That's because what is stashed (even with the --keep-index flag) are both the unstaged changes (which we want) and the staged changes before you run an auto-formatter on them (which we don't want). That will create a merge conflict between the committed auto-formatted changes and the original not-yet-formatted stashed changes. As I understand it there's no easy way to tell git to ONLY stash unstaged changes. The --keep-index flag stashes unstaged changes and staged changes, while leaving the staged changes in place. That differs from the default behavior in that the staged changes will typically also be stashed away alongside the unstaged changes. But it does not stash the unstaged changes exclusively, which is really what we'd need.
I'd love to be wrong about this but I'm pretty sure there is no quick to implement solution in bash. Like any problem, it is of course solvable but it takes quite a bit of legwork. lint-staged handles this quite gracefully actually but not without putting in the work. Here's the PR where they introduced this feature and here's the corresponding discussion on the issue. Even with all that work there remain edge cases where they explicitly fail the hook and reset the WD to its original state. They simply can't always guarantee that they aren't introducing conflicts.
My take away is: if you're dealing with a javascript project, use lint-staged. If you're like me and you really want to stick to a simple bash script it might be worth just checking whether there are any partially staged files before doing anything else and aborting with a message telling the user to fix their partially staged files. Until something like lefthook introduces this feature (issue here), your other options are all pretty heinous.
But I'd love for someone to prove me wrong.
Answer: I too had the same issues as the others above, with files left with conflict markers or just changes not applied when I felt they should. So I tweaked @NearHuscarl's answer just a bit. I admit to not know much about git, so I don't really understand most of why this appears to work for me and that this isn't very efficient, but the end result so far has seemed to fit my personal use case better (small-ish repo, infrequent-ish commits, super computer development environment). YMMV.
I also liked @Filipe's stance, just abort when there are unstaged changes. Probably good practice vice complicated hook scripts.
In any case, my pre-commit ended up like,
#!/bin/bash
#
# Allow disabling feature
suppresscheck=$(git config hooks.suppresschecks)

if [ "$suppresscheck" == "true" ]; then
   exit 0
fi

# Redirect output to stderr.
exec 1>&2

#use the commit hash as a shared variable with the post-commit
tfile=/tmp/$(git rev-parse HEAD)
touch $tfile

git diff --diff-filter=ACMR --name-only > ${tfile}.unstaged
git diff --diff-filter=ACMR --cached --name-only > ${tfile}.staged

#do nothing if no changes to process
[ ! -s ${tfile}.staged ] && exit 0

#stash the working files and leave the staged file
git stash save -q --keep-index "current wd"

./your_script.sh < ${tfile}.staged
RESULT=$?

#check for errors, if found reset everything
if [ $RESULT -ne 0 ]; then
   echo
   echo "pre-commit: you can disable checks with 'git config hooks.suppresschecks true' or 'git commit --no-verify'"
   echo
   git stash save -q "original index"
   git stash apply -q --index stash@{1}
   git stash drop -q; git stash drop -q
   rm -f ${tfile}*
   exit 1
fi

#get the list of files altered
git diff --diff-filter=M --name-only | sort > ${tfile}.cleaned

#save the updates so they are committed
git add -u

#the unstaged changes are placed back during post-commit hook

That left the post-commit being,
#!/bin/bash
#

#pull the prior commit hash as pre-commit used
#that to save off data
tfile=/tmp/$(git log -2 --pretty="%H" | tail -1)

#pre-commit was skipped
if [ ! -f ${tfile} ]; then
   exit 0
fi

#re-apply the stash to the working. had to use apply/drop
#because the pop would leave items in the stash on conflicts
git stash apply -q
git stash drop -q

#for any file that was fully staged prior to commit
#force the working file to match the committed file
while read line; do
   if ! grep -q ^"$line"$ ${tfile}.unstaged ; then
      git reset --quiet -- "$line"
      git checkout -- "$line"
   fi
done < <(git diff --diff-filter=M --name-only )

#generate a list of files that had unstaged changes and were modified
while read line; do
   if grep -q ^"$line"$ ${tfile}.staged ; then
      echo "$line"
   fi
done < <(git diff --diff-filter=M --name-only) | sort > ${tfile}.conflicts

#remove all files that are conflicting from the list of
#files that were altered, just so each file is only in list A or list B
comm -23 ${tfile}.cleaned ${tfile}.conflicts | sponge ${tfile}.cleaned

#tell the user which files are automatically altered
if [[ -s ${tfile}.cleaned ]]; then
  tput setaf 3
  echo
  echo "Following files were auto cleaned"
  tput sgr0
  cat ${tfile}.cleaned
  echo
fi

#tell the user which files may require more work
#the file should have the standard git conflict markers
if [[ -s ${tfile}.conflicts ]]; then
  tput setaf 3
  echo
  echo "Following files may need manual resolution (git mergetool -y)"
  tput sgr0
  cat ${tfile}.conflicts
  echo
fi

rm -f ${tfile}*


Electric lines of force

Question: Why cant electric lines of force pass through the charged sphere? Well, basically that's how a Faraday cage works, but how can it be so?
Comment: Have you tried reading the [wikipedia](http://en.wikipedia.org/wiki/Faraday_cage) page?
Comment: Well, i did....but the confusion grew even more..
Answer: If you mean non-conducting sphere, It can not be like Faraday cage because if you put for example a point charge out of the sphere you will have non-zero electric field inside because the sphere is not able to rearrange charges on it to cancel the effect of external sources
Comment: But even for a conducting sphere, there wont be any flux inside it, ryte?
Comment: @user21475, charged spheres and conducting spheres are very different. Which one do you mean?
Comment: What if i say, charged conducting sphere?
Comment: @user21475: A conducting sphere is only charged at its boundary and neutral everywhere else per definition, see e.g. my literature reference http://physics.stackexchange.com/a/53458/19945
Answer: An electric field line follows the direction of change of an electrostatic potential. If you choose a point where the field line start, the line will go where the electrostatic potential changes most. This is equal to the force which is exerted on a charged particle which resides at a particular point.
Example: Assume a system of two infinitely large capacitor plates. If you start your field line (you can really choose where you want to start it!) in the middle between the two capacitors, it will take the shortest possible route to one of the capacitor plates.
Back to your question/comment: If you have a conducting sphere, the potential in it is constant. Because a field line follows the direction of change, you can't have field lines there.
Mathematically, a field line $\mathbf r(t)$ for an electrostatic potential $\Phi(\mathbf r)$ is defined as
$$\frac{d\mathbf r(t)}{dt}\propto \nabla \Phi(\mathbf r(t))$$
That's not so important, but I note it for the sake of completeness.
Comment: This argument doesn't really answer the question if you ask me.  Sure, if you assume that the potential inside of a conductor is constant, then you find that the field vanishes there because $\mathbf E = -\nabla\Phi$ by definition.  But that simply begs the question: why is the potential inside of a conductor constant?  In the case of electrostatics, the argument for this is relatively simply, but what about if you zap a conductor with a large spark?
Comment: You're right, I'm just treating the static case here, and the argument is indeed simple. My emphasis lies on the explanation of the gradient (=change).

Electric lines of force


Install Whonix on Ubuntu 18.04.1

Question: I followed the instructions for installing Whonix on Linux and I got stuck at installing Virtualbox from Debian backports. I get the following errors after step 3 (here):
W: GPG error: http://cdn-fastly.deb.debian.org/debian stretch-backports InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8B48AD6246925553 NO_PUBKEY 7638D0442B90D010
E: The repository 'http://http.debian.net/debian stretch-backports InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

I tried to replace the recommended line
sudo su -c "echo -e 'deb http://http.debian.net/debian stretch-backports main contrib' > /etc/apt/sources.list.d/backports.list"

with
sudo su -c "echo -e 'deb http://ftp.debian.org/debian stretch-backports main' > /etc/apt/sources.list.d/backports.list"

I got that information from the Debian website:
https://backports.debian.org/Instructions/
Note:
I removed the old backports.list before adding the new with following command:
sudo rm /etc/apt/sources.list.d/backports.list

Well I get quite the same error with the recommended instructions on the Debian site. I wonder now, what to do. Can't I just install virtualbox from the Ubuntu repo? It's a little confusing, since the references on the whonix page at the end of the line "Package virtualbox should be installed from Debian backports." are not working. The browser is just jumping at the top of the site.
Answer: These instructions are for Debian. Backports only required in case of Debian since VirtualBox is unavailable in stretch.
Please install VirtualBox using the usual mechanisms of your Linux distribution.

Install Whonix on Ubuntu 18.04.1


Can I get my Dragon Priest masks back?

Question: I'm playing on xbox and I sold a few of my masks to Niranye. Usually when I sell important items to her, she keeps them even after restocking. Except she didn't keep those. Is there any way I can get them back? Please help if you can!
Answer: I sold some of them too and I can't even remember to which merchant. :/ So far I haven't found a regular way to get them back...
Sorry, for the bad news.

Since you're playing on the XBox this will not be helpful to you, but for others you lost their masks on the PC version:
I think the only way is to "cheat" by using the console and this command:
<code>Player.AddItem <ItemID> <#>
</code>
Read more about the console.
And here you can find the item codes for the masks.
Comment: Hey Exa! I doubt this answer will help the asker much, since she explicitly mentioned she's on the xbox. The first part probably would have sufficed. :)
Comment: I'm playing on xbox though, so console codes aren't an option.
Comment: Oh, my bad :o I changed the answer to make it clear.
Answer: I tried to get my last mask back ever since Skyrim came out and to no avail. So sadly currently right now their isn't a way of getting them back.

Can I get my Dragon Priest masks back?