text:
Q: Closing and Reopening Android App I'm making an Android app with two activities, a main menu and a game activity. So far the app runs fine, and switching back and forth between activities works as it should. A problem arises though when the game activity is running and I press the home button. When I tap the icon to reopen the game, it opens to a black screen and doesn't do anything. I created all of the life cycle methods and print messages each time one is called, but when I try to reopen the app, it doesn't call onCreate(), onStart(), or onResume() for either of the two activities. If I go to task manager and close the app, then go to reopen it, it opens up to the main menu activity as expected. The problem only arises when I hit the home button and then try to open the app again. Is there any way to fix this?
Here is some code from my game activity, including all the life cycle methods:
public class Klondike extends Activity{

private KlondikeGameView gameView;
private StatsHandler statsHandler;
private KlondikeGameStats gameStats;
private RelativeLayout mainLayout;
public boolean createSavedGame;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    createSavedGame = true;
    setContentView(R.layout.klondike);
    mainLayout = (RelativeLayout) findViewById(R.id.main_klondike_layout);
    DisplayMetrics dm = new DisplayMetrics();
    this.getWindowManager().getDefaultDisplay().getMetrics(dm);

    this.statsHandler = new StatsHandler();
    this.gameStats = new KlondikeGameStats(System.currentTimeMillis());

    gameView = new KlondikeGameView(getApplicationContext(), this, dm.heightPixels, dm.widthPixels, statsHandler, gameStats);
    mainLayout.addView(gameView);
    gameView.startGameThread();
}

@Override
protected void onStart() {
    super.onStart();
    System.out.println("OnStart was called for Klondike");
}

@Override
protected void onResume() {
    super.onResume();
    System.out.println("OnResume was called for Klondike");
    if (KlondikeSaveHandler.checkIfSavedStateExists(getApplicationContext())){
        KlondikeSaveHandler.restoreSavedState(getApplicationContext(), gameStats, gameView.getGameBoard());
    }
}

@Override
protected void onPause() {
    super.onPause();
    System.out.println("OnPause was called for Klondike");
    if (createSavedGame){
        KlondikeSaveHandler.prepareSavedGame(getApplicationContext(), gameStats, gameView.getGameBoard());
        System.out.println("Game saved");
    }
    else {
        System.out.println("Game not eligible for saving");
    }
}

@Override
protected void onStop() {
    super.onStop();
    System.out.println("OnStop was called for Klondike");
}

@Override
protected void onRestart() {
    super.onRestart();
    System.out.println("OnRestart was called for Klondike");
}

@Override
protected void onDestroy() {
    super.onDestroy();
    System.out.println("OnDestroy was called for Klondike");
}
}

After I hit the home button, onPause is called, and the game is saved correctly.
Here is the manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.app.thomas.solitaire" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.app.thomas.solitaire.MainMenu"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.app.thomas.solitaire.Klondike"
            android:label="Klondike"
            android:theme="@style/AppTheme">
        </activity>
    </application>

</manifest>

A: try putting
gameView = new KlondikeGameView(getApplicationContext(), this, dm.heightPixels, dm.widthPixels, statsHandler, gameStats);
mainLayout.addView(gameView);
gameView.startGameThread();

in onResume() than in onCreate()


text:
Q: Separate a five digit integer such as 12345 into 1 2 3 4 5, separating each digit with a tab #include<iostream>
using namespace std;
int main()
{
    int x;
    int a;
    int b;
    int c;
    int d;
    int e;

    cout << "Please enter a 5 digit integer.";
    cin >> x;

    a= x%10 ;
    b= x%100 %10;
    c= x%1000 %10;
    d= x%10000 %10;
    e= x%100000 %10;

    cout << a
         << b
         << c
         << d
         << e;

    return 0;
}

This is what I have so far but I can't seem to cout<< each digit all at once with a tab.I need to add a tab in between each one of the digits.

A: I don't see a problem. If you want a tab between each digit, just put it there:
cout << a << '\t'
     << b << '\t'
     << c << '\t'
     << d << '\t'
     << e << '\n';

However, this cries out for a loop-based solution, something like:
for (int div = 10000; div > 0; div /= 10)
    cout << (x / div) % 10 << '\t';

Or, if you want the last one to be a newline rather than a tab:
for (int div = 10000; div > 1; div /= 10)
    cout << (x / div) % 10 << '\t';
cout << x % 10 << '\n';

Your expressions calculating a/b/c/d/e are wrong by the way, they will all give you the last digit. If you still don't want to use the loop method, at least fix that:
a= x / 10000;
b= x /  1000 % 10;
c= x /   100 % 10;
d= x /    10 % 10;
e= x         % 10;

A: use
cout<<a<<'\t'<<b<<'\t'<<c<<'\t'<<d'\t'<<e;

EDIT
For your problem, change the formula to:
a= x/10000   %10;
b= x/1000    %10;
c= x/100     %10;
d= x/10      %10;
e= x         %10;

redpajama_set_name: RedPajamaStackExchange


text:
Q: Impedance matching method in multilevel inverter I want to use a five-level inverter as  an excitation source for magnetostrictive detection,which should be able to output a 100kHz sinwave. I learned that only if the output impendence of the source is equal to the load, can this source get maximize power transfer.
As this works on magnetostrictive detection, the load type can be consider as an inductance.So I wonder maybe an impendence matching network is necessay.
In the post below, I introduced my inverter in detail.
Diode-clamped five-level inverter simulation with PSpice
Here is how the inverter looks like.

To design a matching network, I should firstly calculate the equivalent output impedance of the inverter. But I don't know much about deriving equivalent impemdance of a five-level inverter.
Does anyone can help me about that? Thanks a lot.

A:
I learned that only if the output impendence of the source is equal to
the load, can this source get maximize power transfer.

Nearly right - if the resistive impedance of the load matches the output resistance of the source (i.e. the other way around to what you said) then you will get maximum power transfer. I'm saying it this way because clearly if the load is 1 kohm and the source impedance is 1 kohm, you won't get as much power transferred as when the source is a lot less than 1 kohm. Do you see the difference here?

the load type can be consider as an inductance. So I wonder maybe an
impendence matching network is necessary.

I see no reason to have an impedance matching network. Also, if the load is basically inductive then power transfer goes out of the window because pure inductors (or capacitors) do not consume power.

To design a matching network, I should firstly calculate the
equivalent output impedance of the inverter. But I don't know much
about deriving equivalent impedance of a five-level inverter.

This isn't required to be done.


text:
Q: How to import XML data from feed I'm trying to get data from a 3rd party feed using their API. The format it comes over in is XML allegedly, but bears little resemblance to it with my untrained eye. Here's what it looks like echoed to the screen with php:
122701 29 Epound_10_-_Epound_20 13 Epound_20_-_Epound_30 1 Epound_30_-_Epound_40 4 Epound_40_-_Epound_50 11 532601 13 4896423 10 283701 6 0 29 0__-_100_ 29 BRAND NEW BOXED 8GB 4TH GEN STYLE MP4 PLAYER MUSIC VIDEO WITH IPOD CONNECTION LIMITED STOCK AT THIS PRICE! PINK RED BLUE SILVER PURPLE BLACK GREEN FEATURES USB 2.0 version with capacity: 8GB Holds Up to 1600 Songs 2 inch TFT Screen, 260K true colors display Support multiple music formats: MP1, MP2, MP3,WMA, http://r.3rdparty.com/r/uk/532601/122701/90/90/http%3A%2F%2Fi.ebayimg.com%2F00%2Fs%2FMzg1WDU5OQ%3D%3D%2F%24%28KGrHqN%2C%21lME6CWISze5BOsD3p%28T0%21%7E%7E60_1.JPG%3Fset_id%3D8800005007/voAX7N1WHJJIu1oTgPhOqVsRjHMhQEX45KQtKDk2t4o- 90 90 http://r.3rdparty.com/r/uk/532601/122701/auto/auto/http%3A%2F%2Fi.ebayimg.com%2F00%2Fs%2FMzg1WDU5OQ%3D%3D%2F%24%28KGrHqN%2C%21lME6CWISze5BOsD3p%28T0%21%7E%7E60_1.JPG%3Fset_id%3D8800005007/voAX7N1WHJJIu1oTgPhOqVsRjHMhQEX45KQtKDk2t4o- http://ecs-uk.3rdparty.com/ctl/go/sitesearchGo?.ts=1352310761409&.sig=v6kMZQynUtJjAqTcYY01ZY_OGEM-&offerId=81b44a3770af829494b013d20aaf433a&searchId=1076987819567_1352310761409_2488241&affiliationId=12345678&country=uk&wait=true&ecs=ok&contextLevel=1&merchantid=532601&comId=532601&catId=122701 http://3rdparty.com/p-mp3-players-122701/bush-mp3-8gb-19657960?partnerId=12345678 eBay.co.uk http://3rdparty.com/data/merchantlogos/532601/ebay-logo-640.jpg 80 24 122701-19657960 Bush MP3 8GB MP3 Players 11.49 2.99 2.99 14.48 0 1 false Sound & Vision:iPods & MP3 Players| iPods & MP3 Players Bush 567 Features: * Connections: 1 x 30 Pin Ipod connection port, 1 x 3.5mm jack headphone output * Playable formats: MP3, AMV, WMV, ASF Video, JPG, TXT, LRC, WAV * Suitable for use with Windows PCs and MAC * Integrated long lasting lithium-ion battery * Built-in equalizer with 7 presets * Built-in Clock * Integrated http://r.3rdparty.com/r/uk/4896423/122701/90/90/http%3A%2F%2Fecx.images-amazon.com%2Fimages%2FI%2F31IHNu5OI5L._SL160_.jpg/Nw1b8PcAtWqiL74fE7oiiBurTgUSoIiWBYGvjkSH8hc- 90 90 http://r.3rdparty.com/r/uk/4896423/122701/auto/auto/http%3A%2F%2Fecx.images-amazon.com%2Fimages%2FI%2F31IHNu5OI5L._SL160_.jpg/Nw1b8PcAtWqiL74fE7oiiBurTgUSoIiWBYGvjkSH8hc- http://ecs-uk.3rdparty.com/ctl/go/sitesearchGo?.ts=1352310761409&.sig=Zh1tMTvh5S8dhWh3uC7CZYgI7rc-&offerId=661a194e6394057cf5315e16c23802b3&searchId=1076987819567_1352310761409_2488241&affiliationId=12345678&country=uk&wait=true&ecs=ok&contextLevel=1&merchantid=4896423&comId=4896423&catId=122701 http://3rdparty.com/p-mp3-players-122701/atlantic-agsil8-8gb-19803999?partnerId=12345678 Amazon Marketplace http://3rdparty.com/data/merchantlogos/4896423/Amazon_marketplace.gif 80 24 122701-19803999 Atlantic AGSIL8 8GB MP3 Players 11.99 3.99 3.99 15.98 0 1 Usually dispatched within 1-2 business days false 0608938410283 Electronics & Photo/Categories/Portable Sound & Vision/MP3 & Digital Media Players Atlantic 11695 brand new 8gb mp4 player very similar to the ipod nano,ipod chargers also work on this 2) Support multi-lanuages:English,French,German, Itlian,Spainish,ect 26 lanuages. 3) Play Mp3 4) Play movies 5) ID3 Lyrics display 6)

My question is, how do I convert this using php and extract the data? There seem to be no fieldnames like there are in the XML data examples I have seen, eg "Title", "Image" etc.
I have read this Stack Overflow question, but it doesn't help me with this feed:
How to use XMLReader in PHP?
Thanks in advance.

A: if you wan't to read xml data please follow those steps,
$xmlURL = "your xml url goes here";
try {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $xmlURL);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-type: text/xml'
    ));
    $content = curl_exec($ch);
    $error   = curl_error($ch);
    curl_close($ch);
    $obj = new SimpleXMLElement($content);
    echo "<pre>";
    var_dump($obj);
    echo "</pre>";
}
catch(Exception $e){
    var_dump($e);exit;
}

You will get array formate of whole xml file.
Thanks.


text:
Q: Using Flask from CGI, possible? Is it in fact possible to use Flask from a CGI?
If so, how?  I am aware of the concise and nice looking documentation for CGI+Flask but it looks to me, like the request.args.get('varname') function is not working, when run as CGI. It certainly works for me on the same (Apache, Ubuntu 12.10) server when run as WSGI.
I came to the conclusion (or strong suspicion, rather) that args.get() is not working, after I ran the CGI script on the command line. It would just not pick up anything in QUERY_INFO.
Am I missing something vital about CGI in general, is it a bug in Flask, or what is going on here?
EDIT
The documentation for Flask is updated in git, but at the time of this writing not yet on the homepage. Just don't use any print in your Flask application and CGI should work fine.

A: The args thing is a red herring.
The problem was in CGI, any print can mess up the output, and in this case it messed up the headers. Solution: don't print any debug info or anything, when run as a CGI.
Also;
"... Google's App Engine, where execution happens in a CGI-like environment"
Apparently Google App Engine is similar to a CGI environment and the same print thing can be an issue there.


text:
Q: white line in bottom of page i can't remove it This Page
Code:

html,
body {
  height: 100%;
  min-height: 100%;
  width: 100%;
  min-width: 100%;
}

body {
  margin: 0;
  padding: 0;
}

#particles-js {
  position: absolute;
  width: 100%;
  height: 100%;
  background: url("../img/background.jpg") no-repeat 50% 50%;
  background-size: cover;
}

Now I need to remove this white line and the scroll I need page full width and height background-image I tried overflow: hidden
but in mobile responsive have problem with login box.

A: Is late to say it but just put:
*{
margin: 0;
}

A: I just had this problem and found the explanation in this answer to be extremely helpful.
You might want to try using the following code to center your image:
html {
  height: 100%
}

body {
  background-image: url("../img/background.jpg");
  height: 100%;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
}

This should remove that white line from the bottom of your page.


text:
Q: Display two single array together I'm struggling here. My program is about a simple sign in and log in using array. Now, whenever I want to sign in, I want all the usernames and passwords to be displayed whenever I want to check if all the accounts I created are successfully collected in an array. Now whenever I want to display all the accounts, usernames aren't displaying, just the passwords.
Here is my code:
    package login;
    import java.util.*;
    import static java.lang.System.out;

    public class login {

         public static void main(String [] args) {

             String user [] = new String [100];
             String pass [] = new String [100];
             int sign=0;

             boolean again=true, logAgain=true;
             Scanner scan = new Scanner (System.in);
             while(again) {
             out.println("[1]Sign-up\n[2]Log-in\n[3]Display Account?\n[4]Exit");
             out.print("Select: ");
             int a=scan.nextInt();
                if (a==1) {
                    again=false;
                    sign++;
                    out.print("Username: ");
                    user[sign]=scan.nextLine();
                    scan.nextLine();
                    out.print("Password: ");
                    pass[sign]=scan.nextLine();
                    out.println("Log in now? [Y/N] : ");
                    String b=scan.next();
                        if(b.equals("Y")||b.equals("y")) {
                            again=true;
                        } else {
                            again=false;
                            System.exit(0);
                        }

                } else if(a==2){
                    again=false;
                    logAgain=true;
                        while(logAgain) {
                        out.print("Username: ");
                        String userU=scan.nextLine();
                        scan.nextLine();
                        out.print("Password: ");
                        String userP=scan.nextLine();

                            if (userU.equals(user[sign])&&userP.equals(pass[sign])) {
                                out.println("You're logged in!");
                                logAgain=false;
                                out.println("Back to menu? [Y/N] : ");
                                String c=scan.next();

                                    if (c.equals("Y")||c.equals("y")) {
                                        again=true;
                                    } else {
                                        System.exit(0);
                                    }
                            }else if (!userU.equals(user[sign])&&userP.equals(pass[sign])) {
                                out.println("Invalid username or Password!");
                                logAgain=true;
                            }else {
                                again=true;
                                logAgain=false;
                                out.println("Please register first!");
                            }
                        }
                } else if (a==3) {
                    again=false;

                        if (sign<1) {
                            out.println("\nNo account to display!\nPlease sign-up first.\n");
                            again=true;
                        } else {
                            System.out.println("");
                            System.out.printf("%-15s%10s\n","Username","Passwords");
                            for (int i = 1; i <=sign; i++)
                            System.out.printf("%-15s%10s\n",user[i],pass[i]);
                            System.out.println("");

                            out.println("Back to menu? [Y/N] : ");
                            String c=scan.next();

                            if (c.equals("Y")||c.equals("y")) {
                                again=true;
                            } else {
                                System.exit(0);
                            }
                        }

                } else if(a==4) {
                    again=false;
                    System.exit(0);
                } else {

                }
         }

        }
}

And my output goes like this:
[1]Sign-up
[2]Log-in
[3]Display Account?
[4]Exit
Select: 3

Username        Passwords
                 Password
                     pass
                evohohivr

Back to menu? [Y/N] :

Thank you in advance.

A: Your discarding the wrong Scanner input. It should read like this:
if (a==1) {
    again=false;
    sign++;
    out.print("Username: ");
    scan.nextLine();                 // This was the wrong order
    user[sign]=scan.nextLine();
    out.print("Password: ");
    pass[sign]=scan.nextLine();
    out.println("Log in now? [Y/N] : ");
    String b=scan.next();
    if(b.equals("Y")||b.equals("y")) {
        again=true;
    } else {
        again=false;
        System.exit(0);
    }
}


text:
Q: How to validade if a Groovy file is with correct syntax without running it? I'd like to run a shell script that would tell me if a Groovy file is syntactically correct without executing it. The code wouldn't be run, just validated.
I see that there are similar questions, but I would like a simple command line command. I thought there would be parameter for the compiler, but couldn't find it.

A: I didn't manage to get a direct answer. My problem was that I was making a Jenkins pipeline script and I'd like to verify it before commit and push. This was I would get simples errors in less time.
I've solved my problem using a VSCode Extension to validate the file before committing. No more typos in committed in my version control.


text:
Q: Synchronously Counting Debounced Button Presses in VHDL The following code is a VDHL module in Xilinx ISE 14.7 that counts debounced button presses (iXXX), tests to see if they have reached a max, and outputs a "value" for each accumulated input to a std_logic_vector (oXXX) that will be displayed on a 7-segment LED (display mux & logic not shown). The resets (clrXX) are switches on the board (Digilent Spartan 3).
When trying to synthesize or checking syntax in XILINX ISE, I get the following errors:
Xst:528 - Multi-source in Unit <BSO_cnt> on signal <Mcount_oOUT_s_cy<0>>;
this signal is connected to multiple drivers.
Xst:528 - Multi-source in Unit <BSO_cnt> on signal <Mcount_oOUT_s_lut<1>>;
this signal is connected to multiple drivers.
Xst:528 - Multi-source in Unit <BSO_cnt> on signal <Mcount_oBALL_s_cy<0>>;
this signal is connected to multiple drivers.
Xst:528 - Multi-source in Unit <BSO_cnt> on signal <Mcount_oBALL_s_lut<1>>;
this signal is connected to multiple drivers.
Xst:528 - Multi-source in Unit <BSO_cnt> on signal <Mcount_oBALL_s_lut<2>>;
this signal is connected to multiple drivers.
Xst:528 - Multi-source in Unit <BSO_cnt> on signal <Mcount_oSTRIKE_s_cy<0>>;
this signal is connected to multiple drivers.
Xst:528 - Multi-source in Unit <BSO_cnt> on signal
    <Mcount_oSTRIKE_s_lut<1>>; this signal is connected to multiple drivers.

How can I fix this? I am fairly new to VHDL, and not sure where to start.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

entity BSO_cnt is
Port ( iBALL        : in    STD_LOGIC;
       iSTRIKE      : in    STD_LOGIC;
       iOUT         : in    STD_LOGIC;
       clrBS        : in    STD_LOGIC;
       clrOUT       : in    STD_LOGIC;
       CLK          : in    STD_LOGIC;
       oBALL        : out   STD_LOGIC_VECTOR (2 downto 0);
       oSTRIKE      : out   STD_LOGIC_VECTOR (1 downto 0);
       oOUT         : out   STD_LOGIC_VECTOR (1 downto 0));
end BSO_cnt;

architecture Behavioral of BSO_cnt is

SIGNAL iBALL_s      :   STD_LOGIC;
SIGNAL iSTRIKE_s    :   STD_LOGIC;
SIGNAL iOUT_s       :   STD_LOGIC;

SIGNAL oBALL_s      :   STD_LOGIC_VECTOR(2 DOWNTO 0);
SIGNAL oSTRIKE_s    :   STD_LOGIC_VECTOR(1 DOWNTO 0);
SIGNAL oOUT_s       :   STD_LOGIC_VECTOR(1 DOWNTO 0);

Begin

oBALL       <= oBALL_s;
oSTRIKE     <= oSTRIKE_s;
oOUT        <= oOUT_s;

BALL_PROCESS: PROCESS(CLK)
BEGIN
    IF rising_edge(CLK) THEN
        IF (clrBS = '1') THEN
            oBALL_s <= (OTHERS => '0');
        ELSIF (iBALL_s /= iBALL) THEN
            IF (iBALL = '1') THEN
                iBALL_s <= iBALL;
                oBALL_s <= STD_LOGIC_VECTOR(UNSIGNED(oBALL_s) + 1);
                IF (oBALL_s = "100") THEN
                    oBALL_s     <= (OTHERS => '0');
                    oSTRIKE_s   <= (OTHERS => '0');
                END IF;
            END IF;
        ELSE
            iBALL_s <= iBALL;
        END IF;
    END IF;
END PROCESS;

STRIKE_PROCESS: PROCESS(CLK)
BEGIN
    IF rising_edge(CLK) THEN
        IF (clrBS = '1') THEN
            oSTRIKE_s <= (OTHERS => '0');
        ELSIF (iSTRIKE_s /= iSTRIKE) THEN
            IF (iSTRIKE = '1') THEN
                iSTRIKE_s <= iSTRIKE;
                oSTRIKE_s <= STD_LOGIC_VECTOR(UNSIGNED(oSTRIKE_s) + 1);
                IF (oSTRIKE_s = "11") THEN
                    oSTRIKE_S   <= (OTHERS => '0');
                    oBALL_s     <= (OTHERS => '0');
                    oOUT_s      <= (OTHERS => '0');
                END IF;
            END IF;
        ELSE
            iSTRIKE_s <= iSTRIKE;
        END IF;
    END IF;
END PROCESS;

OUT_PROCESS: PROCESS(CLK)
BEGIN
    IF rising_edge(CLK) THEN
        IF (clrOUT = '1') THEN
            oOUT_s <= (OTHERS => '0');
        ELSIF (iOUT_s /= iOUT) THEN
            IF (iOUT = '1') THEN
                iOUT_s <= iOUT;
                oOUT_s <= STD_LOGIC_VECTOR(UNSIGNED(oOUT_s) + 1);
                IF (oOUT_s = "11") THEN
                    oOUT_s      <= (OTHERS => '0');
                    oBALL_s     <= (OTHERS => '0');
                    oSTRIKE_s   <= (OTHERS => '0');
                END IF;
            END IF;
        ELSE
            iOUT_s <= iOUT;
        END IF;
    END IF;
END PROCESS;

end Behavioral;

A: Your problem has probably something to do with the fact that you drive signals (oSTRIKE_s, oBALL_s, oOUT_s) from several processes. Think of this as short circuits (what value do you expect when the different processes do not agree on the value?).
Why then doesn't it produce errors at compilation and / or simulation?
As most people who do not know about the multiple drive problem, the resolution functions and the resolved types of VHDL (that is, a lot of VHDL programmers and even teachers), you always use the STD_LOGIC type that has a built-in resolution function to compute the resulting value of multiple driving processes. And it works (usually giving a lot of X values)... for simulation only. If you had used an unresolved type (STD_ULOGIC) instead you would have had an error at compilation or simulation because these types do not support multiple drive situations.
Why does it not work in synthesis?
Your synthesiser tries to map your design on the available hardware resources of your target (Spartan FPGA). By chance your target is not equipped with the three-state buffers that could be used to implement your bogus design. So the synthesiser raises errors. I wrote by chance because, if it had been another target capable of implementing this, you could have programmed it and... fuse it, thanks to your nice short circuits. Something would probably have prevented you before it is to late but you never know... So you are lucky, after all.
What to do then?

*

*Never use STD_LOGIC and STD_LOGIC_VECTOR when you do not design something that reasonably makes use of multiple drive. That is, a design where at any time all processes drive the signal with 'Z' (high impedance) except, at most, one that drives a strong value ('0'or '1'). In most cases you do not want to do this and you must use STD_ULOGIC and STD_ULOGIC_VECTOR. If your teacher insists that you use STD_LOGIC and STD_LOGIC_VECTOR, send it to me.

*Drive any signal from one single process in which you deal with all situations (reset, states...).

A: Finally got it! The problem was multiple processes assigning values to the same signal. This was how I corrected the error:
Notice the flag signals {Bmax_s, Smax_s, and Omax_s}. They are used by one process to indicate to other processes that it has reached its max count. Then, each clock cycle, every process uses one or more flags to decide whether to clear, or in the case of OUT_PROCESS increment, its output signal and/or update its own flag.
Now every signal is only assigned by a single process!
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

entity BSO_cnt is
    Port ( inBALL       : in  STD_LOGIC;
           inSTRIKE     : in  STD_LOGIC;
           inOUTS       : in  STD_LOGIC;
           inclrBS      : in  STD_LOGIC;
           inclrOUT     : in  STD_LOGIC;
           CLK          : in  STD_LOGIC;
           outBALL      : out  STD_LOGIC_VECTOR (1 downto 0);
           outSTRIKE    : out  STD_LOGIC_VECTOR (1 downto 0);
           outOUTS      : out  STD_LOGIC_VECTOR (1 downto 0));
end BSO_cnt;

architecture Behavioral of BSO_cnt is
    --inputs
    SIGNAL inBALL_s     :   STD_LOGIC;
    SIGNAL inSTRIKE_s   :   STD_LOGIC;
    SIGNAL inOUTS_s     :   STD_LOGIC;
    --outputs
    SIGNAL outBALL_s    :   STD_LOGIC_VECTOR(1 DOWNTO 0);
    SIGNAL outSTRIKE_s  :   STD_LOGIC_VECTOR(1 DOWNTO 0);
    SIGNAL outOUTS_s    :   STD_LOGIC_VECTOR(1 DOWNTO 0);
    --max count flags
    SIGNAL maxBALL      :   STD_LOGIC;
    SIGNAL maxSTRIKE    :   STD_LOGIC;
    SIGNAL maxOUTS      :   STD_LOGIC;

begin

    --assign signals to module outputs
    outBALL     <=  outBALL_s;
    outSTRIKE   <=  outSTRIKE_s;
    outOUTS     <=  outOUTS_s;

    --count ball pushes & update ball counter
    BALL_PROCESS: PROCESS(CLK)
    BEGIN
        --wait for postive edge of clock
        IF rising_edge(CLK) THEN
            --check for clear ball/strike switch
            IF (inclrBS = '1') THEN
                outBALL_s   <=  (OTHERS =>  '0');
            --check for any max count flags
            ELSIF (maxSTRIKE = '1') OR (maxBALL = '1') OR (maxOUTS = '1') THEN
                --clear ball count
                outBALL_s   <=  (OTHERS =>  '0');
                --clear ball max count flag
                maxBALL     <=  '0';
            --check for change of ball button state
            ELSIF (inBALL_s /= inBALL) THEN
                --if pressed
                IF inBALL = '1' THEN
                    inBALL_s        <=  inBALL;
                    -- check for walk
                    IF (outBALL_s = "11") THEN
                        --set flag
                        maxBALL <=  '1';
                    ELSE
                        --increment ball counter
                        outBALL_s   <=  STD_LOGIC_VECTOR(UNSIGNED(outBALL_s) + 1);
                    END IF;
                --if released
                ELSE
                    inBALL_s    <=  inBALL;
                END IF;
            END IF;
        END IF;
    END PROCESS;

    --Count strike pushes, and update strike counter
    STRIKE_PROCESS: PROCESS(CLK)
    BEGIN
        --wait for positive edge of clock
        IF rising_edge(CLK) THEN
            --check for clr ball/strike switch
            IF inclrBS = '1' THEN
                outSTRIKE_s <=  (OTHERS =>  '0');
            --check for any max counts reached & update strike count
            ELSIF (maxSTRIKE = '1') OR (maxBALL = '1') OR (maxOUTS = '1') THEN
                outSTRIKE_s <=  (OTHERS =>  '0');
                --reset flag
                maxSTRIKE   <=  '0';
            --check for strike button state change
            ELSIF (inSTRIKE_s /= inSTRIKE) THEN
                --if pressed increment strike count
                IF inSTRIKE = '1' THEN
                    inSTRIKE_s      <=  inSTRIKE;
                    --check for strikeout
                    IF (outSTRIKE_s = "10") THEN
                        --set flag
                        maxSTRIKE   <=  '1';
                    ELSE
                        --increment strike count
                        outSTRIKE_s     <=  STD_LOGIC_VECTOR(UNSIGNED(outSTRIKE_s) + 1);
                    END IF;
                --if released
                ELSE
                    inSTRIKE_s  <=  inSTRIKE;
                END IF;
            END IF;
        END IF;
    END PROCESS;

    --Count out pushes, and update out counter
    OUT_PROCESS: PROCESS(CLK)
    BEGIN
        --wait for positive clock edge
        IF rising_edge(CLK) THEN
            --check for clear out switch
            IF inclrOUT = '1' THEN
                outOUTS_s   <=  (OTHERS =>  '0');
            --check for max out count
            ELSIF maxOUTS = '1' THEN
                outOUTS_s   <=  (OTHERS =>  '0');
                --clear flag
                maxOUTS     <=  '0';
            --check for strikeout
            ELSIF maxSTRIKE = '1' THEN
                --check for max outs
                IF (outOUTS_s = "10") THEN
                    --set max outs flag
                    maxOUTS <=  '1';
                ELSE
                    --increment outs
                    outOUTS_s   <=  STD_LOGIC_VECTOR(UNSIGNED(outOUTS_s) + 1);
                END IF;
            --check if button has changed states
            ELSIF (inOUTS_s /= inOUTS) THEN
                --if pressed
                IF inOUTS = '1' THEN
                    inOUTS_s    <=  inOUTS;
                    --check for change of inning
                    IF (outOUTS_s = "10") THEN
                        maxOUTS <=  '1';
                    ELSE
                        --increment outs
                        outOUTS_s   <=  STD_LOGIC_VECTOR(UNSIGNED(outOUTS_s) + 1);
                    END IF;
                --if released
                ELSE
                    inOUTS_s    <=  inOUTS;
                END IF;
            END IF;
        END IF;
    END PROCESS;

end Behavioral;

Below is an image of the simulation output from a test bench that resets, and increments balls & strikes until 3 strikes occur...
ISim TestBench
not bad for my first VHDL project :D


text:
Q: Pivoting data in pandas Suppose I have the following data as a pandas dataframe:
               type      exdiv    paydate  amount
declared
2014-01-31    final 2014-03-03 2014-03-10    3.10
2014-06-27  interim 2014-08-11 2014-08-18    1.55
2015-01-30    final 2015-03-02 2015-03-09    2.33
2015-01-30    final 2015-03-02 2015-03-09    0.77
2015-06-26  interim 2015-08-07 2015-08-17    1.80
2016-01-29    final 2016-02-29 2016-03-07    3.45

The 2015-01-30 entry is repeated twice. What is the easiest way to sum up that row so that I only have one entry equal to 3.10 for 2015-01-30?
I've tried the following so far:
x=pd.pivot_table(df, values='amount', index=['exdiv','paydate','type'], columns=[])

But this creates a multi-index and I can't use the current index column ('declared').
I know I can add the index as a normal column, run the command and try to convert the multi-index back to a single index, but I'm sure there must be a better method in pandas?

A: Use transform with drop_duplicates:
df['amount'] = df.groupby(level=0)['amount'].transform(sum)
df = df.reset_index().drop_duplicates(subset=['declared','type','exdiv','paydate'])
print (df)
     declared     type       exdiv     paydate  amount
0  2014-01-31    final  2014-03-03  2014-03-10    3.10
1  2014-06-27  interim  2014-08-11  2014-08-18    1.55
2  2015-01-30    final  2015-03-02  2015-03-09    3.10
4  2015-06-26  interim  2015-08-07  2015-08-17    1.80
5  2016-01-29    final  2016-02-29  2016-03-07    3.45

Or add reset_index and aggfunc=sum to pivot_table:
x=pd.pivot_table(df.reset_index(),
                 values='amount',
                 index=['declared','exdiv','paydate','type'],
                 aggfunc=sum).reset_index()
print (x)
     declared       exdiv     paydate     type  amount
0  2014-01-31  2014-03-03  2014-03-10    final    3.10
1  2014-06-27  2014-08-11  2014-08-18  interim    1.55
2  2015-01-30  2015-03-02  2015-03-09    final    3.10
3  2015-06-26  2015-08-07  2015-08-17  interim    1.80
4  2016-01-29  2016-02-29  2016-03-07    final    3.45


text:
Q: Get selected value for hidden tr in table using PHP,AJAX,JQUERY I have the code as below:
<form method ="post" id="myForm">

        Classification socio
 professionnelle à l'embauche :

            <select name="droClassification" class="validate[required]" id="classification">
                <option value="">choisir catégorie </option>
                <option value="Ouvrier">Ouvrier</option>
                <option value="Employe">Employé</option>
                <option value="AgentMaitris">Agent de maitrise</option>
                <option value="Cadre">Cadre</option>
                <option value="Autre">Autre</option>
            </select>

     <?php
        if($_POST['droClassification'] == "Ouvrier" || $_POST['droClassification'] == "Employe"){

            echo '';
        }
    ?>

        This is what I want to hide it, when I select on the Ouvrier or Employe

I need:
  When I select on Ouvrier or Employee,it will be hide
 tag.
Problem:
  I used the PHP code as my code above but it dose not work.So do you have any idea for this? or which technology should I use like AJAX,JQUERY,PHP? Help me please,Thanks.

A: Forget about php or ajax, you don't have to make a request for this behavior.
Use javascript for it, I'll show you how to do it using jQuery.
Try this, using jQuery:
jQuery('#classification').change(function() {
    var selectedValue = $(this).val();
    if(selectedValue == 'Ouvrier' || selectedValue == 'Employe') {
        $('#trHide').hide();
    }
});

demo
If you want to show #classification when change to others you can do the following.
jQuery('#classification').change(function() {
    var selectedValue = $(this).val(),
        $row = $('#trHide');
    if(selectedValue == 'Ouvrier' || selectedValue == 'Employe') {
        $row.hide();
    } else {
        $row.show();
    }
});

demo
Update: according to this comment.
Change to class instead of id.

        This is what I want to hide it, when I select on the Ouvrier or Employe

Then change $('#trHide') to $('.trHide').


text:
Q: Lucas sequence - how to know which terms to calculate when testing if a number is prime? To check if a number is a Lucas pseudoprime, a Lucas sequence is computed. The Lucas sequence is based on a recurrence relation, but there's a method involving inspecting the bits of the number being checked for primatliy to know which terms in the sequence to compute. How exactly does inspecting the bits work?
Wikipedia gives the example

For example, if n+1 = 44 (= 101100 in binary), then, taking the bits
  one at a time from left to right, we obtain the sequence of indices to
  compute: $1_2$ = 1, $10_2$ = 2, $100_2$ = 4, $101_2$ = 5, $1010_2$ = 10, $1011_2$ = 11,
  $10110_2$ = 22, $101100_2$ = 44. Therefore, we compute U1, U2, U4, U5, U10,
  U11, U22, and U44

It says "taking the bits one at a time" but the example clearly is not doing that. Though the end result makes sense because the index each term is either double or one more from the previous, and we have formals to easily compute that. However in example code I've seen it appears one bit at a time is inspected. So how exactly are the bits used to decide which terms to compute?
Are the terms known and advanced or determined while checking each individual bit?

A: The bits are being checked one at a time from left to right, just not in quite the way you're expecting. In particular, if the bit is $0$, just use that bit. However, if it's $1$, use $0$ and then $1$. One way to look at this is that it's checking all of the possible bit values from $0$ up to the actual bit value, inclusive.
With the Wikipedia article's example of $44 = 101100_2$, the first bit is $1$. Since $0$ is not checked, it starts at $1_2 = 1$. The next bit is $0$, so it just checks $10_2 = 2$. The next bit after this is $1$, so it checks first with $0$, i.e., $100_2 = 4$, and then $1$, i.e., $101_2 = 5$. After this, the next bit is $1$ again, so it checks $1010_2 = 10$ and $1011_2 = 11$. The second last bit is $0$, so it just checks $10110_2 = 22$. Finally, the last bit is $0$, so it just checks $101100_2 = 44$.
Regarding the example code you've linked to, I took a look but found it somewhat hard to follow regarding exactly what it's doing. Although it does inspect one bit at a time, as you state, it seems to handle the $1$ bits by basically repeating certain calculations compared to the $0$ bits. First, note the following comment part of the LucasUVthTerm function:
    '''
    BIT MANIPULATION OF P TO CREATE LUCAS CHAIN.
        Lucas chain help us to know when to double and when to add one to 0btain next terms
        example:let nth term be 24 and 112, below are its lucas chains
            24 <- 12 <- 6 <- 3 <- 2 <- 1 <- 0
            112 <- 61 <- 60 <- 30 <- 15 <- 14 <- 7 <- 6 <- 3 <- 2 <- 1 <- 0
        We need to read this sequence from right to left.
        here is how we do it without pre calculation of chain
        1. we double the value add one when nth bit in the bitstring of p is 1,
            so one carry two processes
        2. we only double when nth bit in bitstring is zero
        Note our terms start from zero index
    '''

In the first example of the Lucas chain starting at $24 = 11000_2$, reading from right to left, you get $0 = 0_2$, $1 = 1_2$, $2 = 10_2$, $3 = 11_2$, $6 = 110_2$, $12 = 1100_2$ and $24 = 11000_2$. Apart from starting at $0$, this matches what Wikipedia states and I described above. However, their second example has a typo as the initial number should be $122$. With this correction, the rest of the values follow the expected pattern. Since $122 = 1111010_2$, the values are $0 = 0_2$, $1 = 1_2$, $2 = 10_2$, $3 = 11_2$, $6 = 110_2$, $7 = 111_2$, $14 = 1110_2$, $15 = 1111_2$, $30 = 11110_2$, $60 = 111100_2$, $61 = 111101_2$ and $122 = 1111010_2$.
Also, their "1." point's (for if the bit is $1$) second line says

so one carry two processes

Once again, this implies the process is repeated twice.
Later, in the code itself, there's
        # when nth bit is !, double and add one
        if bit == "1":
            #doubling from k to 2k
            Uk = V * U
            Vk = V**2 - 2 * Qk
            k = 2 * k

            #adding one from 2k to 2k + 1
            Uk1 = (P * Uk + Vk) * (p + 1) // 2
            Vk1 = (D * Uk + P * Vk)  * (p + 1) // 2
            #cahnging alues of our Lucas parameters
            U, V = Uk1 % p, Vk1 % p
            Qk = (Qk**2) % p
            Qk = (Qk * Q) % p
            k = k + 1
        else:
            # doubling only
            Uk = V * U
            Vk = V**2 - 2 * Qk
            U, V = Uk % p, Vk % p
            Qk = (Qk**2) % p
            k = 2 * k

As you can see, the $1$ bit conditional code section involves basically repeating certain calculations compared to the $0$ bit part.

A: Maybe the recursive solution to this problem is more straightforward. We have
$$
   (U_k, V_k) = \begin{cases}
       (U_{k/2} \cdot V_{k/2}, \frac12(V_{k/2}^2 + D U_{k/2}^2)) & \text{ if $k$ is even,} \\
       (\frac12(P \cdot U_{k-1} + V_{k-1}), \frac12 (D \cdot U_{k-1} + P \cdot V_{k-1}))  & \text{ if $k$ is odd.}
   \end{cases}
$$
This can be directly turned into code in the form of a recursive function.
Your ultimate goal is to computer $(U_{44}, V_{44})$; this recurrence will tell you that you need to know $(U_{22}, V_{22})$ first, and for that you need to know $(U_{11}, V_{11})$, and so forth.

This is, in disguise, exactly the logarithmic algorithm for computing the $k^{\text{th}}$ power of some kind of object $\alpha$:
$$
   \alpha^k = \begin{cases} (\alpha^{k/2})^2 & \text{ if $k$ is even,} \\ \alpha^{k-1} \cdot \alpha & \text{ if $k$ is odd.} \end{cases}
$$
We turn that into an algorithm for computing $(U_k, V_k)$ by using the relation $$\left(\frac{P + \sqrt D}{2}\right)^k = \frac{V_k + U_k \sqrt D}{2}.$$
Equivalently, this is a matrix power:
$$
   \begin{bmatrix}U_k \\ V_k\end{bmatrix} = \begin{bmatrix}P/2 & 1/2 \\ D/2 & P/2\end{bmatrix}^k \begin{bmatrix}1 \\ P\end{bmatrix}.
$$
Either way, we're taking the $k^{\text{th}}$ power of some fancy object, and what multiplying or squaring it does is exactly the thing in the original algorithm.


text:
Q: Make ms access database trusted for all users on network disc I have made a GUI using python and tkinter, which allows the user to choose search criterias to be used in an MS Access query. Upon a buttonclick, the script opens Access and runs a macro which in turn launches a function that reads the user input, performs the query and prints reports. The code used to do this is:
objAccess = win32com.client.Dispatch("Access.application")
objAccess.Visible = False
objAccess.OpenCurrentDatabase(filepath)
objAccess.DoCmd.RunMacro("Macro1")
objAccess.Quit()

My problem is that I want to put the database and the python script on a network drive so that my coworkers may use the script to generate reports without having to open the database in Access (and inevitably make inadvertent changes). Whenever the script is run for the first time from someone else's PC, it will not complete, as the macros have not been enabeled from that pc. If they open the database and enable macros and make the document "trusted", the script will work fine.
What I want to know is if there is any way to enable macros permanetly for all users for that particular Access database, or if I can modify my script to check if the database has macros enabled or not, and to enable macros if they are disabled.
I know that the disabling of macros is a security measure, so I guess I may just have to ask my users to manually enable macros before running the script. Not very elegant.

A: There are two ways of enable macro permanently.

*

*Trusted Location: A path/location, where stored databases are always trusted.

*Trusted Publisher: Sign database with certification

You can set/edit them in the trust center settings in File > Options > Trust Center > Trust Center Settings.
But you have to set it up for every user/access-installation at least once.
Here is the official link from MS how to do it:
https://technet.microsoft.com/en-us/library/dn166703.aspx
Be aware, that Microsoft does not recommend to set network pathes as trusted locations. Also, you should consider @Krish KMs comment suggestion, to create a local front end for the users. This would also need a trusted location or publisher, but not on network drive, but on a local drive.


text:
Q: Dual Booting Ubuntu and Windows 8 causes Realtek audio problem For a long time I thought it was Windows which randomly caused the headphone audio jack to not work randomly but finally I found out the source of the problem.
I have a dual boot, windows 8 and ubuntu 13.10 , both 64bit, whenever I boot into ubuntu and then boot back to windows, the audio problem starts ,
it is very strange problem, I wanna fix it or at least undrestand how could it happen ?
how audio on another operating system on another partition, can affect the audio driver behavior on another operating system?
do you think there is a flag or something on the hardware level that ubuntu changes that affects windows ? any suggestion to fix this ?
(some other person also has exactly this problem on tomshardware forums so it is not just me)

A: I'm having the exact same problem, and I haven't been able to find an ideal solution. However, there is a workaround. My headphones WILL work correctly in Windows if I shutdown the computer first, then boot into Windows. Using 'Restart' from either Ubuntu or Windows will still result in audio problem on Windows, though.
So it's not ideal, but it works for me (i.e. I only use Windows for playing games, and it's a just a small nuisance to shutdown and power on for Windows only).


text:
Q: How to get only the required table from excel sheet I am trying to retrieve data from an Excel sheet. I am getting the table data along with other extra data. So how to retrieve only the table from the Excel sheet.
Here is what i am getting:
I don't want the first 3 rows.
                    sdfdsfdsf
                       dfg      hjk

Sl No   Name    Code    Date    Time    Door Name   Shift   Department  Grade
1   Channabasappa   535 01/Dec/08   9:37    WORK CENTER IN  General Shift   Payroll A
2   Channabasappa   535 01/Dec/08   13:42   WORK CENTER OUT General Shift   Payroll A
3   Channabasappa   535 01/Dec/08   15:40   WORK CENTER OUT General Shift   Payroll A
4   Channabasappa   535 01/Dec/08   16:09   WORK CENTER IN  General Shift   Payroll A
5   Channabasappa   535 01/Dec/08   17:42   WORK CENTER OUT General Shift   Payroll A
6   Channabasappa   535 01/Dec/08   17:43   WORK CENTER IN  General Shift   Payroll A
7

A: We would need to see your code to pass comment.
But I think you'll find this blog post very useful, it explains a number of quirks to be aware of when reading Excel worksheets using ADO.NET.


text:
Q: Function name aliasing I have a library that calls a function: eg malloc.
I use the library in my application. I want that the library do not call malloc but a function that i have defined "mymalloc" everytime the malloc is invoked.
In short i want resolve the malloc symbol using a my symbol with a different name.
I have tried this linker option: -Wl,--defsym=malloc=mymalloc
And it works but just for the calls that are in the application
ie: every call to malloc in the program resolves to mymalloc, but the calls in the library still calls to the stdlibc malloc.
Thanks a lot,
Davide

A: This is crude but you could use the preprocessor - the advantage being that the preprocessor runs prior to compilation:
#define malloc mymalloc
You would have to #include the file containing the declaration of mymalloc before any standard library includes.
You would also have to rebuild any compiled libraries yourself. In reality I'd advise doing this in production: I think the code will be brittle and you have the potential of mismatched mallocs lurking round every corner.


text:
Q: why django makemigrations can not detect my models
*

*create a empty database in mysql

*create a project

*create a app named test_mod

*creare a dir mod in test_mod, with init.py and mod.py in mod dir, and a simple model class(mod_test) declared in mod.py
test_mod

---views.py

---models.py

---mod

------mod.py

------__init__.py

*add app test_mod to INSTALLED_APP, and do a makemigrations, there are no changes be detected. and migrate will not create test_mod_mod_test table in database

*insert a statement into test_mod.models.py (a file create by startapp command):
 from mod.mod import test_mod

*now the makemigrations will detect the model mod_test, but if the statement in step 6 was insert into views.py (any file except models.py), the mod_test will not be detected.

*test in django 1.7 and 1.8, same result.
I get confused by this, and no interpretation was found from django official document.
I am gratful for any hints and help.
thanks.

A: *

*You need to create an __init__.py file in every directory of your project for python to recognize those directories as modules. Add __init__.py to the root level of the test_mod directory.

*Declare all your model classes for this application (app) in the models.py file. It is the accepted solution for model files. Why you need to declare an addition models class in another file and/or sub-directory?


text:
Q: shell script for chmod file name but only on new files since last run of the script i have a directory where new files are uploaded and receive numeric filename as they are uploaded. the file name is numbers that go up.
i need to change permissions for the file but only on new files that were uploaded since the last chmod.
any ideas?

A: When doing the each chmod action, touch a file, e.g. touch /tmp/foo.
When the next iteration comes around, use find -newer, e.g. find . -newer /tmp/foo -exec chmod 755 {} \; and then touch /tmp/foo.

A: If you like to achieve this, you need to compare the "ctime" of the files
with the "atime" of the script. This cannot be done by a vanilla find(1) implementation but only by an extended find.
With a modern find(1) implementation like the BSD find or sfind, you may use -newerXY, in your case:
find . -newerca script
and this will find all files with a status change after the last read on "script".
Beware that some Linux distros by default mount filesystems with -noatime.


text:
Q: No FileSystem for scheme: hdfs I have the following error when I'm running my Storm Topology that contains an Hbase Bolt.
    java.io.IOException: No FileSystem for scheme: hdfs
    at org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:2298) ~[hadoop-common-2.0.0-cdh4.7.0.jar:na]
    at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2305) ~[hadoop-common-2.0.0-cdh4.7.0.jar:na]
    at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:89) ~[hadoop-common-2.0.0-cdh4.7.0.jar:na]
    at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2344) ~[hadoop-common-2.0.0-cdh4.7.0.jar:na]
    at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2326) ~[hadoop-common-2.0.0-cdh4.7.0.jar:na]
    at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:353) ~[hadoop-common-2.0.0-cdh4.7.0.jar:na]
    at org.apache.hadoop.fs.Path.getFileSystem(Path.java:194) ~[hadoop-common-2.0.0-cdh4.7.0.jar:na]
    at org.apache.hadoop.hbase.util.DynamicClassLoader.<init>(DynamicClassLoader.java:104) ~[hbase-common-0.98.1-hadoop2.jar:0.98.1-hadoop2]
    at org.apache.hadoop.hbase.protobuf.ProtobufUtil.<clinit>(ProtobufUtil.java:201) [hbase-client-0.98.1-hadoop2.jar:0.98.1-hadoop2]
    at org.apache.hadoop.hbase.ClusterId.parseFrom(ClusterId.java:64) [hbase-client-0.98.1-hadoop2.jar:0.98.1-hadoop2]
    at org.apache.hadoop.hbase.zookeeper.ZKClusterId.readClusterIdZNode(ZKClusterId.java:69) [hbase-client-0.98.1-hadoop2.jar:0.98.1-hadoop2]
    at org.apache.hadoop.hbase.client.ZooKeeperRegistry.getClusterId(ZooKeeperRegistry.java:83) [hbase-client-0.98.1-hadoop2.jar:0.98.1-hadoop2]
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.retrieveClusterId(HConnectionManager.java:857) [hbase-client-0.98.1-hadoop2.jar:0.98.1-hadoop2]
    at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.<init>(HConnectionManager.java:662) [hbase-client-0.98.1-hadoop2.jar:0.98.1-hadoop2]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [na:1.7.0_72]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) [na:1.7.0_72]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [na:1.7.0_72]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526) [na:1.7.0_72]
    at org.apache.hadoop.hbase.client.HConnectionManager.createConnection(HConnectionManager.java:414) [hbase-client-0.98.1-hadoop2.jar:0.98.1-hadoop2]
    at org.apache.hadoop.hbase.client.HConnectionManager.createConnection(HConnectionManager.java:393) [hbase-client-0.98.1-hadoop2.jar:0.98.1-hadoop2]
    at org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:274) [hbase-client-0.98.1-hadoop2.jar:0.98.1-hadoop2]
    at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:194) [hbase-client-0.98.1-hadoop2.jar:0.98.1-hadoop2]
    at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:156) [hbase-client-0.98.1-hadoop2.jar:0.98.1-hadoop2]
    at org.apache.storm.hbase.bolt.HBaseBolt$1.run(HBaseBolt.java:97) [storm-hbase-0.1.2.jar:na]
    at org.apache.storm.hbase.bolt.HBaseBolt$1.run(HBaseBolt.java:94) [storm-hbase-0.1.2.jar:na]
    at java.security.AccessController.doPrivileged(Native Method) [na:1.7.0_72]
    at javax.security.auth.Subject.doAs(Subject.java:415) [na:1.7.0_72]
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1438) [hadoop-common-2.0.0-cdh4.7.0.jar:na]
    at org.apache.storm.hbase.bolt.HBaseBolt.prepare(HBaseBolt.java:94) [storm-hbase-0.1.2.jar:na]
    at backtype.storm.daemon.executor$fn__3352$fn__3364.invoke(executor.clj:690) [storm-core-0.9.2-incubating.jar:0.9.2-incubating]
    at backtype.storm.util$async_loop$fn__452.invoke(util.clj:429) [storm-core-0.9.2-incubating.jar:0.9.2-incubating]
    at clojure.lang.AFn.run(AFn.java:24) [clojure-1.5.1.jar:na]
    at java.lang.Thread.run(Thread.java:745) [na:1.7.0_72]
16:44:32.839 [Thread-31-HbasePersistorBolt] INFO  backtype.storm.daemon.executor - Prepared bolt HbasePersistorBolt:(5)

Here is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>

aid-cim
fr.aid.cim
0.9-SNAPSHOT

4.0.0
event-struct-topology
<dependencies>
    <!-- Hadoop Hbase Storm Kafka dependencies-->
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-client</artifactId>
        <version>${org.apache.hadoop.version}</version>
        <exclusions>
            <exclusion>
                <artifactId>com.google.protobuf</artifactId>
                <groupId>protobuf-java</groupId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.google.protobuf</groupId>
        <artifactId>protobuf-java</artifactId>
        <version>2.5.0</version>
    </dependency>

    <dependency>
        <groupId>com.github.ptgoetz</groupId>
        <artifactId>storm-hbase</artifactId>
        <version>${storm-hbase.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.storm</groupId>
        <artifactId>storm-kafka</artifactId>
        <version>0.9.2-incubating</version>
    </dependency>

    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka_2.10</artifactId>
        <version>0.8.1.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
            </exclusion>
            <exclusion>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-- END Hadoop Hbase Storm Kafka dependencies-->

    <!-- Project Dependencies -->
    <dependency>
        <groupId>fr.aid.cim</groupId>
        <artifactId>commons</artifactId>
        <version>${project.version}</version>
    </dependency>

    <dependency>
        <groupId>fr.aid.cim</groupId>
        <artifactId>storm-hazelcast</artifactId>
        <version>${project.version}</version>
    </dependency>
    <!-- END Project Dependencies -->

    <!-- Integration TEST Dependencies -->
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-core</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-common</artifactId>
        <type>test-jar</type>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase</artifactId>
        <version>${org.apache.hbase.version}</version>
        <type>test-jar</type>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-hdfs</artifactId>
        <version>${org.apache.hadoop.version}</version>
        <type>test-jar</type>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-hdfs</artifactId>
        <version>${org.apache.hadoop.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.zookeeper</groupId>
        <artifactId>zookeeper</artifactId>
        <scope>test</scope>
    </dependency>
    <!-- END TEST Dependencies -->

    <!-- Other Dependencies -->
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20140107</version>
    </dependency>

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>11.0</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
    </dependency>
    <!-- END Other Dependencies -->

</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
        </plugin>
    </plugins>
</build>

<profiles>
    <profile>
        <id>local</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <dependencies>
            <dependency>
                <groupId>org.apache.storm</groupId>
                <artifactId>storm-core</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
            </dependency>
        </dependencies>
    </profile>
    <profile>
        <id>cluster</id>
        <dependencies>
            <dependency>
                <groupId>org.apache.storm</groupId>
                <artifactId>storm-core</artifactId>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </profile>

</profiles>

Any ideas ? Thanks

A: Try to add hadoop-hdfs as maven dependency:
<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-hdfs</artifactId>
    <version>${org.apache.hadoop.version}</version>
</dependency>

A: Try to add the following code
 Configuration conf = new Configuration();
 conf.set("fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem");

Perhaps the following links will yield an answer.https://www.cnblogs.com/justinzhang/p/4983673.html


text:
Q: Find x such that $495x \equiv 90 \pmod{6}$ or explain why it does not exist The questions are:
i) Find $\gcd(315, 495)$
ii) Find $x$ such that $495x \equiv 90 \pmod{6}$ or explain why it does not exist
I did (i) and got $\gcd(315, 495)=45$. How do I find the answer for (ii)? How is it related to (i)?
Here's my attempt for (ii): (I did not use the equation in (i))
$495x \equiv 90 \mod{6}$
whereby $495 \equiv 3 \pmod{6}$
$$3x \equiv 90 \pmod{6}$$
$$3x \equiv 0 \pmod{6}$$
Hence, the smallest integer of $x$ is $2$?
I would like to know if there's a solution that uses the equation in (i)

A: The common thread between these two questions is that they both involve breaking integers down into their unique prime factor decomposition (using the Fundamental theorem of arithmetic).  This allows you to find common factors in the relevant expressions and simplify to obtain solutions.

(i) When you want to find the greatest common divisor of two numbers, the simplest thing to do is to break those numbers down into their unique prime factor decomposition:
$$\begin{equation} \begin{aligned}
315 &= 3^2 \cdot 5 \cdot 7, \\[6pt]
495 &= 3^2 \cdot 5 \cdot 11. \\[6pt]
\end{aligned} \end{equation}$$
The greatest common divisor of these two numbers will consist of the shared prime factors, so it is:
$$\text{gcd}(315, 495) = 3^2 \times 5 = 45.$$

(ii) For the latter problem, you are trying to find integers $x$ and $k$ for which:
$$495 \cdot x = 6 \cdot k + 90.$$
Again, we can break the relevant numbers down into their unique prime factor decomposition:
$$3^2 \cdot 5 \cdot 11 \cdot x = 2 \cdot 3 \cdot k + 2 \cdot 3^2 \cdot 5.$$
Eliminating the common factor and grouping terms gives:
$$3 \cdot 5 \cdot 11 \cdot x = 2 \cdot (k + 3 \cdot 5).$$
So a solution is obtained by taking $k=3 \cdot 5 \cdot 10 = 150$ and $x=2$.  That is:
$$990 \equiv 90 \quad \text{(mod } 6 \text{)}.$$

A: I wonder if the question is expecting you to use the fact:
If $\gcd(a,b) = d$ and $a|bm$ then $a|dm$ (as none of the factors other than $d$ will have any factors in common with $a$).
so $495x \equiv 90 \pmod 6$ means
$6|495x - 90 = 45(11x - 2)$ and as $\gcd(6, 45)=3$
$6|3(11x-2)$ so $2|11x - 2$ and so $2|11x$ and so $2|x$.
For any even $x$ we have $495x \equiv 90 \pmod 6$.
.... which seems a pretty convoluted way to do it.
===
Far more straightforward would be
$495x \equiv 90 \pmod 6$
$3x \equiv 0 \pmod 6$
$6|3x$ so $2|x$


text:
Q: Modifying regression model equations to perform OLS? I'm not really sure why I couldn't take any of these models and perform OLS on them. Would appreciate help in understanding/finding the answer

A: Recall that one of the assumptions (actually, a constraint) of the OLS method is a linearity over the parametric set, i.e., check whether the first derivative w.r.t $\beta$ depends on the unknown $\beta$.
1) Simple linear regression. $\frac{\partial }{\partial \beta} \mathbb{E}[Y|X=x] = \ln (x) $. You can denote $\ln(x) = x^*$ if you find it more convenient.
2) Try $1/Y_i = \beta_1 + a \frac{1}{X_i}\to Y_i^* = \beta_0^* + \beta_1^*X_i^*$.
3) $\ln Y_i = \ln(a) + \beta_1\ln(X_i)$
4)Just denote $X_i^2 = X_i^*$.
5) $\ln(Y_i) = \ln (a) + \beta_1X_i. $


text:
Q: FrameLayout after ScrollView allways on bottom I need to made layout that will contain ScrollView with some dynamic length text and Button in FrameLayout after(below). With long text all is okay, but when text is short button stuck right below bottom of ScrollView text part. I want a FrameLayout in the bottom of the screen when text is short and right below ScrollView text part when text long .
Can it be done?
My XML
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".TeacherFullActivity"
    tools:showIn="@layout/app_bar_teacher_full">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <include
                layout="@layout/listview_element_teachers"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/job_title"
                    style="@style/TitleMain"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/teacher_job_title" />

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/job_dynamic"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/subject_title"
                    style="@style/TitleMain"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/teacher_subject_title" />

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/subject_dynamic"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/workPlace_title"
                    style="@style/TitleMain"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/teacher_workplace_title" />

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/workplace_dynamic"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />

            </LinearLayout>

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0"
                android:paddingLeft="35dp"
                android:paddingTop="5dp"
                android:paddingRight="35dp"
                android:paddingBottom="5dp">

                <Button
                    android:id="@+id/teacher_external_link"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/btn_rounded"
                    android:text="@string/open_link"
                    android:textAllCaps="false"
                    android:textColor="@android:color/white"
                    android:textSize="17sp"
                    android:textStyle="bold"
                    />
            </FrameLayout>
        </LinearLayout>
    </ScrollView>
</android.support.constraint.ConstraintLayout>

A: You can use the android:fillViewport attribute of ScrollView to accomplish this.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">

            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"/>

        </FrameLayout>

    </LinearLayout>

</ScrollView>

What this does is make it so that, in the case where the contents of the LinearLayout are not large enough to fill the screen, the LinearLayout is stretched to fill the screen anyway. That gives the FrameLayout room to grow (based on its layout_weight attribute), which in turn lets the Button float to the bottom of the screen (because of its layout_gravity attribute).
In cases where the contents of the LinearLayout are larger than the screen, no stretching happens. The button is pushed off-screen, but appears when you scroll down (with no space between it and the text).

A: You can try this code for your approach:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".TeacherFullActivity"
tools:showIn="@layout/app_bar_teacher_full">

<ScrollView
    android:id="@+id/scrollview"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:constraintTop_toTopOf="parent"
    app:constraintStart_toStartOf="parent"
    app:constraintEnd_toEndOf="parent"
    app:constraintBottom_toTopOf="@id/frame">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <include
            layout="@layout/listview_element_teachers"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TextView
                android:id="@+id/job_title"
                style="@style/TitleMain"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/teacher_job_title" />

            <android.support.v7.widget.RecyclerView
                android:id="@+id/job_dynamic"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TextView
                android:id="@+id/subject_title"
                style="@style/TitleMain"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/teacher_subject_title" />

            <android.support.v7.widget.RecyclerView
                android:id="@+id/subject_dynamic"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TextView
                android:id="@+id/workPlace_title"
                style="@style/TitleMain"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/teacher_workplace_title" />

            <android.support.v7.widget.RecyclerView
                android:id="@+id/workplace_dynamic"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

        </LinearLayout>
    </LinearLayout>
</ScrollView>

<FrameLayout
            android:id="@+id/frame"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:paddingLeft="35dp"
            android:paddingTop="5dp"
            android:paddingRight="35dp"
            android:paddingBottom="5dp"
            app:constraintTop_toBottomOf="@id/scrollview"
            app:constraintStart_toStartOf="parent"
            app:constraintEnd_toEndOf="parent"
            app:constraintBottom_toBottomOf="parent">

            <Button
                android:id="@+id/teacher_external_link"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/btn_rounded"
                android:text="@string/open_link"
                android:textAllCaps="false"
                android:textColor="@android:color/white"
                android:textSize="17sp"
                android:textStyle="bold"
                />
        </FrameLayout>
</android.support.constraint.ConstraintLayout>

Explaination:
What i did was took FrameLayout containing Button out side of ScrollView so that it can always be at bottom of the Container.


text:
Q: Grid View With Top, Bottom And Right Side Scroll Bar I think I am close to having this all set-up following the jsFiddle I found here:
JsFiddle however, the issue I run into is that, I do not actually have a scrollbar on the top, and due to setting the height of div2 the bottom scrollbar is way down on the page.  What needs to be edited in order to have the grid view auto size height wise, and to have the scroll bar at top and bottom?

    <asp:GridView ID="returndata" runat="server" Visible="True" AutoGenerateColumns="false"
        ShowFooter="true" Width="1000px" Height="300px" >
        <columns>
            <asp:BoundField DataField="abcd" HeaderText="J12121212e" />
            <asp:BoundField DataField="efg" HeaderText="12112" />
            <asp:BoundField DataField="hij" HeaderText="2323" />
            <asp:BoundField DataField="klm" HeaderText="S" />
            <asp:BoundField DataField="nop" HeaderText="C" />
            <asp:BoundField DataField="qrs" HeaderText="88"  />
            <asp:BoundField DataField="tuv" HeaderText="8" />
            <asp:BoundField DataField="wzr" HeaderText="8888" />
            <asp:BoundField DataField="erre" HeaderText="22222" />
            <asp:BoundField DataField="aca" HeaderText="1111"/>
            <asp:BoundField DataField="acsa" HeaderText="222" />
            <asp:BoundField DataField="ere" HeaderText="3131" />
            <asp:BoundField DataField="asdf" HeaderText="31" />
            <asp:BoundField DataField="dasf" HeaderText="33" />
            <asp:BoundField DataField="qq" HeaderText="3" />
            <asp:BoundField DataField="xga" HeaderText="21" />
            <asp:BoundField DataField="qqqqq" HeaderText="2" />
            <asp:BoundField DataField="mm" HeaderText="1" />
            <asp:BoundField DataField="adfasdf" HeaderText="11" />
        </columns>
    </asp:GridView>


text:
Q: Fastest method for fingerprinting an array (calculating a unique hash from an array of data) I am using a lot of caching and buffering of API calls in my WWW Framework and one of the things that I end up using all around is 'fingerprinting' data in order to match cache filenames as well as detecting API calls that have already been made.
A lot of data is moved in arrays, like GET, POST and so on. As a result the uniqueness of an API call depends on the data.
As a result I need to fingerprint this information. To do it requires generating a 'fingerprint' from the data array as well and hashing it into a string that I can store and compare against.
For array serialization there is serialize() and json_encode() in PHP. After various benchmarks I consider json_encode() the faster method for serializing an array and am quite happy with it.
For hashing there is md5() and sha1() functions, of which md5() is faster according to my benchmarks.
So my current fingerprint algorithm is:
$fingerprint=md5(json_encode($array));

But I am having doubts whether this is the 'fastest possible' method for fingerprinting an array in PHP. I have tried Google and StackOverflow and have not found good alternatives though. Am I on a right track or do I need to do something different?

A: Once you've got your array json_encoded, you should probably go with a non-cyrptographic hash function if you're primarily concerned with speed. Different hash functions are good for different things. MD5 and Sha1 are called cryptographic because they are hard to reverse (note they are widely considered deprecated for security purposes due to vulnerabilities). CRC  (cyclic redundancy check) functions are error detecting codes and would be ill-suited for uniqueness anyways.
Wikipedia is a decent place to start for this, if only because contributions there generally have external links to library implementations: List of hash functions. I would recommend reading up on a few of the non-cryptographic libraries there and benchmarking them. The non-cryptographic functions are more written for speed and reasonable degrees of uniqueness, sacrificing security, error detection and other interesting properties, which from your description is exactly what you want.
One final note to consider if you're mainly concerned about speed is how you are going to store and compare the fingerprints themselves. MD5 outputs 128 bits of data, which won't fit into a numeric type in php without some extra library calls and overhead. For my money, I would bet that you could get the best speed of comparison and storage would come from an hash function that can output 64 bit numbers directly. Note that to get 64 numbers natively in php, you need to have 64 bit hardware and have php configured/installed in 64 bit mode. I have some code around here somewhere I used to test our staging and prod environments I could probably dig up if you're interested.
Btw, I don't think you're going to get any faster stringification of an array than json-encode. The heart of that problem is array walking and string manipulation, so essentially the speed is proportional to the verbosity of the output. JSON-encode is very terse compared to php's serialize or export functions. I bet if you looked through enough comments on the php documentation pages, you could find someone who wrote a hash function that takes an array as an input directly, but it would be a gamble whether it was any good at all.
Feel free to ask questions if I was unclear on anything.

A: I tested various methods on 7000 arrays in 100 loops and fastest is crc32(serialize($arr)) (avg. 0.65 sec)
    $arr = ['name' => $name, 'category' => $category, 'hits' => $hits];

    md5(var_export($arr, true));
    md5(serialize($arr));
    md5(json_encode($arr));

    hash('md5', var_export($arr, true), "");
    hash('md5', serialize($arr), "");
    hash('md5', json_encode($arr), "");

    hash('md4', var_export($arr, true), "");
    hash('md4', serialize($arr), "");
    hash('md4', json_encode($arr), "");

    crc32(var_export($arr, true));
    crc32(serialize($arr));
    crc32(json_encode($arr));

    sha1(var_export($arr, true));
    sha1(serialize($arr));
    sha1(json_encode($arr));

    spl_object_hash((object) $arr);

A: I think that @Patrick M explanation is really good, I just want to add some extra data here.
As @Patrick M said, md5 is a cryptographic hash, which will make some extra efforts to add security (even if nowadays is deprecated for that purpose).
You can check which hash functions you have available with hash_algos function.
However, here you can see a benchmark of those algorithms, where it says (I didn't try myself) that the faster is md4, and then md5, etc.
To be fair, the benchmark should use the specific function as well, if any, to be sure (md5, sha1, crc32,...), as it may be faster (or slower, who knows).
In conclusion, I think that your approach looks like a pretty good one.
Just keep in mind that md5 is not secure, as it's described in the PHP's Password Hashing FAQ, so if you need to store credit cards fingerprints or something of sorts (that I don't think it's your case), you may need another function as well as adding some extra steps.
As an alternative, you may want to check spl_object_hash.


text:
Q: Calculate percentage in MS SQL Server with int columns I am trying to calculate the total amount for charity. Each row has a bid amount and a charity percentage.
The structure of the fields looks like this:
CurrentBid INT
CharityPercentage INT <-- 0-100, where 100 is donating all to charity
So i tried this:
SELECT CurrentBid, CharityPercentage, CurrentBid * (CharityPercentage / 100) AS TotalCharity FROM Items

However it yields this:
50  100 50
70  100 70
25  50  0
50  25  0
30  10  0
55  15  0

It works as long as the percentage is 100. Anything below and its 0. My guess is that it has to do with the int column.
Any ideas on how to solve it? I have also tried to convert the int using a CAST in the select statement but that did not work. Its a very big procedure to change the INT column to something else.

A: Explicitly make at least one value a decimal/float/etc. In your case, you already have a literal numeric value, 100; so, simply change it to, 100.0:
CurrentBid * CharityPercentage / 100.0 AS TotalCharity

A: don't CAST -- instead, just multiply by 1.00.  This does the CASTing implicitly.
SELECT CurrentBid, CharityPercentage, (1.00 * CurrentBid * CharityPercentage) / 100 AS TotalCharity FROM Items


text:
Q: Unwanted space on left side of header I have a spacing on the left side of my header that I am having troubles getting rid of. If anyone can help me out I would greatly appreciate it. Here is my html and css below.
HTML
<!DOCTYPE html>

    <meta charset="UTF-8">
    <link rel="stylesheet" href="style.css"/>
    <title></title>

home

about me

portfolio

blog

contact

CSS
body{
    width: 100%;
}

header{
    margin: 0;
    padding: 0;
    width: 100%;
    height: 77px;
    background: #cccccc;
}

#logo{
    float: left;
}

nav{
    float: left;
}

ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
}

li{
    display: inline;
}

A: I had to add a margin:0 to my body in css.


text:
Q: Core Data Setting Up Multiple managedObjectContexts In an app that I am working on I need to access and write to Core Data at the same time. I have been able to gather that this means that I need to user multiple managedObjectContexts but I don't understand how I am supposed to setup those two managedObjectContexts.
I understand that once I have them setup I need to do the write operations on a background thread on its managedObjectContext and then merge the data through an operation like this: Core Data and threads / Grand Central Dispatch .
So my question is, how would I go about initiating two separate managedObjectContexts so that I can then use them as described?

A: You have to create two separate NSManagedObjectContexts with the same NSPersistentStoreCoordinator like this,
First create two NSManagedObjectContexts name as backgroundManagedObjectContext and mainBackgroundManagedObjectContext in your model class like this
+ (NSManagedObjectContext *)backgroundManagedObjectContext
    {
        static NSManagedObjectContext * backgroundManagedObjectContext;
        if(backgroundManagedObjectContext != nil){
            return backgroundManagedObjectContext;
        }
        @try {
            NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
            if (coordinator != nil) {
                backgroundManagedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
                [backgroundManagedObjectContext setPersistentStoreCoordinator: [self persistentStoreCOordinator]];
            }
        }
        @catch (NSException *exception) {
            NSLog(@"Exception occur %@",exception);
        }
        return backgroundManagedObjectContext;

    }

then both will need get the same persistentStoreCoordinator
then need to merge your backgroungManagedObjectContext to mainBackgroundManagedObjectContext, for that create NSNotification whenever you save the data into backgroundManageObjectContext like this
[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(contextDidSave:)
                                                 name:NSManagedObjectContextDidSaveNotification
                                               object:nil];

then you have to implement this notification method for updating your mainManagedObjectContext like this
- (void)contextDidSave:(NSNotification *)notification
    {
        SEL selector = @selector(mergeChangesFromContextDidSaveNotification:);
        [[self mainManagedObjectContext] performSelectorOnMainThread:selector withObject:notification waitUntilDone:YES];

    }

A: If you really want to do concurrent reads and writes, you might be interested in the setup presented during WWDC 2013. It uses two NSPersistentStoreCoordinator's, each with one context. You merge changes between them manually, thus achieving nice, non UI blocking code.
It's described in the following sessions:

*

*207 - What's New in Core Data (starting from slide number 145).

*211 - Core Data Performance (starting from slide number 91),


text:
Q: Does indoor odor smell travel up or down? Does odor smell, let's say it's from caulk off-gasing, travel upward or downward in the air?
Are all odor smell lighter than air?

A: For reasons of simplicity, suppose you are talking about a building that is left alone, and hence, there is no forced air movement (e.g. from people walking around, dehumidifiers, draught, thermal buoyancy due to heating, etc.).
Whether odor smells will travel upward or downward then is not determined by the mass of their constituting particles (related to their vapor densities) but rather by their initial concentrations (or rather their gradients). If the initial odor concentrations are already at their thermodynamic equilibrium values, nothing will "travel" at all.
But if you have initially high concentrations of, say, acetic acid fumes from fresh silicone caulk in the basement of your building, while the top floor is still uncaulked and free from acetic acid vapor, the acid smell will definitely travel upward. Conversely, if you have first caulked the top floor before the basement, the odor will travel downwards.
In both cases, the process just follows the concentration gradients according to Fick's laws, and it will continue until thermodynamic equilibrium is reached, or rather say approximated (at least if you do not disturb equilibrium by ventilating the building or caulking for the rest of your life). For all practical matters, "equilibrium" simply means "equal concentration everywhere" (see point 1 below for an explanation).
What is determined by the particle masses are

*

*the equilibrium pressures and concentrations (very slightly less equilibrium odor density at the top floor compared to the basement); since mass differs by gas, the different gases in a mixture change differently with height; see this answer for the calculation of the relative particle concentrations (e.g. for the mixture of air and some defined odor) with height; the differences are minute: only 0.4% for a whopping 100u particle mass difference and a height difference of 10 meters; probably not even a detection dog, walking from basement to top floor, can notice a 0.4% relative concentration difference before the background concentration (dogs can, of course, detect very small absolute concentrations before zero); therefore, we can practically assume that equilibrium concentration is homogeneous for every component gas and is determined by Dalton's law applied at ground level

*the speed of travel; at the same pressure, regions with a higher proportion (see again Dalton's law) of heavier particles tend to be denser and will cause diffusive buoyancy of the less dense regions, which can be considered a fast bypass to the otherwise slow diffusion processes; this does in fact constitute an up/down preference, theoretically; however, as already noted by Philip Wood, the typical concentrations of odor molecules are very very small (for a typical building I would say, a few grams of acetic acid in a few hundred kilograms of air, so more like 1:100000 to 1:1000000 and less), i.e. even big relative changes in the concentrations of heavy odor molecules will change the density of the air/odor mixture only negligibly; therefore, diffusive buoyancy is irrelevant for smell distribution speeds

*the diffusivity of the particles, but this is not a gravitational effect but rather an inertial (collisional) effect, i.e. some substances travel faster than others, but it is not that diffusion prefers up or down (other than due to concentration gradients)

If, contrary to my above assumption, the building is not left alone, there is an extremely wide range of possible convection scenarios, some of which might change the speed of odor travel dramatically (by many orders of magnitude). But then again, this does not have any much significance with respect to gravitational mass/density of the odor in question.
As to the question if all odor molecules are lighter than air: most odor molecules are organic and often contain a benzene ring or a chain of several carbon atoms (e.g. esters in scents), making them clearly heavier than all air molecule types. Nitrogen has a molar mass of 28 grams, oxygen has 32 grams. By comparison, benzene has a molar mass of 78 grams, whereas my silicone caulk example, acetic acid has 60 grams. The lightest olfactorily active substance is methane (no! see p.s. at the bottom of this answer) with a molar mass of 16 grams, followed by ammonia with 17 grams and hydrogen fluoride with 20 grams. Ethylene is already at 28 grams and ethane at 30 grams. So, if we exclude hydrogen fluoride (which you will probably only smell right before you die), only methane and ammonia are stinks that are significantly lighter than air. All others are at least about as heavy as air or even (much) heavier.
Also note that the transport speed or concentration of an odor is often much less relevant than the olfactoric activity itself. Some substances can be detected by the nose in extremely low concentrations, which can be achieved very rapidly, surprisingly far away from the source, even if nominal diffusivity seems low. If, after first detection, concentrations rise, the nose gets numb to these smells, and we think nothing has changed ("the smell isn't moving anymore") although concentration changes more than ever. An extreme example for that numbing effect is hydrogen sulfide (fowl eggs' smell), which can be smelled very sensibly at first, but after a few minutes of exposure can't be smelled at all! Since hydrogen sulfide is toxic in higher concentrations, this effect can be very dangerous.
Sorry, small correction necessary: methane is characterized as odorless. People (including myself) often think that it stinks because it mostly occurs (like in cow dung) together with other stinky substances, e.g. sulfuric compounds. For methane (as well as propane and butane) fuel the stinky compounds are even deliberately added for safety reasons in order to make the (toxic and flammable) methane easily detectable by humans.

A: Most smells consist of relatively few (probably fewer than 1 in 1000) molecules mixed in with air molecules, and the spread of the smell is largely governed by the draughts and convection currents which the air would experience even without the odour molecules.
In still air the odour molecules will spread by diffusion, that is by the speeds (usually several hundred metres per second) that they naturally possess at a given temperature; but they travel only very short distances before encountering collisions with air molecules, so diffusion is at far lower speeds.
For gases that are denser than air, that is those with molecules of more mass than those of oxygen or nitrogen, the pull of the Earth's gravity will favour downward diffusion, but upward diffusion will be favoured for lighter molecules. So to know which will be favoured you must find out whether the molecular mass of the odour molecule is larger or smaller than about 30 u (that is 30 Da). I believe that most odour molecules (particularly those of scents) have a significantly greater mass than 30 u, but it would be unsafe to assume that this is the case for all odour molecules. Note also that although downward diffusion is favoured for heavier molecules, they will still diffuse upward and sideways as well.

A: I follow here the concept that laconic, not elaborated questions, if not already closed, do not ask for long, elaborated, detailed and exhaustive answers.
If the smelling stuff is locally a major air component, affecting air density, then it depends on the overall mean effective molar mass. As gas density, if taken as an ideal gas, is $\rho=\frac{pM}{RT}$. A dense gas would flow down and vice versa. Near all smelling stuff would be denser than air, with few exceptions like ammonia or hydrogen fluoride or methane (smelling if scented as NG).
If it is just a trace addition to air, changed air density does not play any role. Therefore, the direction of smell spreading depends on already existing air convection, either thermal or forced.
If both effects are in place then the result is subject of vector addition of both effects.
Aside of both ways of macroscopic convection, there is omnidirectional gas diffusion according to the concentration gradient.


text:
Q: autorun methods I have developed a small desktop application in c#(using windows forms). For this project I need mysql, MySql.Data.dll and some property files...
I am ready with my project but  I need to burn it on a disk(with Autorun express).
when I run that cd

*

*It should ask me to check whether the system has mysql installed in it or not,if not installed already then it should install now in the specified location

*run some database scripts to generate database and relationships and constraints

*and finally it should copy my .exe file on to the hard disk (specified location).

Thanks,
srini.

A: It sounds like you're trying to use autorun to kick off an installer. Take a look at the built-in Installer project in Visual Studio, or take a look at WiX.

*

*"Check whether the system has mysql"

*

*To validate whether the machine you
has MySql, you'll need to define
what you're looking for. As for most
products, you can find them in the
registry. I'm not sure where MySql
puts that info.

*"Run some database scripts"

*

*You can kick off a custom action that will
properly install the database.

*"Copy my .exe file"

*

*Specify where you want the installer to put your
executable and other binaries
(MySql.Data.dll).

A: NSIS is another good choice for an installer.  I used that one pretty extensively, and am using WiX on my current project mostly just to try a different approach.  The one included with Vistual Studio 2005 is very buggy, but I have not tried the included ones for Visual Studio 2008 and later.
NSIS and WiX follow very different approaches for creating the installer file.  You may find one or the other easier for you to understand.  Both seem to have pretty active communities that will help if you get stuck (or ask here of course).


text:
Q: The result of proposition with paradox I'am not sure this question fits with this site.
If not, I will delete it.
I just wonder a proposition as follows:
A statement 'S' is true => paradox
So.. what's the reulst?  The 'S' is true, false or undecidable?
Maybe it's undecidable. Why? I thought 'S' should be false.


text:
Q: R - recode from percentage to a scale from 1-10 The variable I'm working with is described as;
4.111.108 School enrollment, preprimary (% gross) (wdi_gerpp)
Total enrollment in pre-primary education, regardless of age, expressed as a percentage of the total population of ocial pre-primary education age. GER can exceed 100% due to the inclusion of over-aged and under-aged students because of early or late school entrance and grade repetition.
I want to recode the percentages to a scale from 1-11, e.g the countries that have 1-10% preprimary enrollment get the number 1, the countries with 11-20% get the number 2 etc. And the countries above 100% get the number 11. I can really figure out how to do it after researching on YouTube for an hour now. thank you! :D
I tried this, but I don't really now what to put inside the brackets.
percent_vec = paste(1:177, "%", sep = "")
as.numeric(sub("%", "", percent_vec))


text:
Q: Prove that $x=-1$ if and only if $x^3+x^2+x+1=0$ Let $x\in\mathbb{R}$. Prove that $x=-1$ if and only if $x^3+x^2+x+1=0$.
This is a bi-conditional statement, thus to prove it we need to prove:

A: $$x=-1\implies x^3+x^2+x+1=(-1)^3+(-1)^2+-1+1=-1+1-1+1=0.$$

A: You did the hard(er) part.
To prove the other implication, you simply need to show that $x=-1$ satisfies the cubic equation.
Substitute and simplify!