text:
Q: How to make master-detail model / screen in Django? One thing that I allways collide is how to implement a master-detail application with Django. The tipical example is the Invoice and InvoiceLines.
The things to discuss are:

*

*how to structure code for saving, loading, etc. master and detail models

*views: files and templates, templates for detail lines, how to add dynamically

*autocalculated fields (like the total on parent row), where this code goes ?

Edit/Additions:
About autocalculated fields, here is my first solution, http://pastebin.com/ZGqNnHuC , would not it be better in the save method of model?
The master model needs values from detail models. (i.e. First it is needed to calculate totals on each detail, save each line, and then sum and save master) How it is made in a more Django way than calling calculate() method?

A: *

*master and detail models are two separate models related by a One-to-Many relationship. To incorporate them in the same form you have to use Model Formsets (more details here).

*to dynamically add rows you may consider this answer

*the same applies to autocalculate fields, you can do it in pure javascript or with an ajax call to a "calculation view" (thus the code is in the template or in your views, eventually calling other modules like models, it really depends on which calculation are you doing)


text:
Q: i am working with google map api in android geting unfortanly app was stopped I am new to android app development. From last week and onward, I have been working on Google maps, but I am getting

Unfortunately, APP was stopped.

I am given all permissions and Google play services. This error is being shown in my LogCat which I have shown below.  Please help me... if it is possible, please send me some simple example code on how to put jar files and all please.
 06-11 16:05:48.050: E/AndroidRuntime(851): FATAL EXCEPTION: main
06-11 16:05:48.050: E/AndroidRuntime(851): Process: com.example.onroad, PID: 851
06-11 16:05:48.050: E/AndroidRuntime(851): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.onroad/com.example.onroad.MainActivity}: android.view.InflateException: Binary XML file line #12: Error inflating class fragment
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.app.ActivityThread.access$800(ActivityThread.java:138)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.os.Handler.dispatchMessage(Handler.java:102)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.os.Looper.loop(Looper.java:136)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.app.ActivityThread.main(ActivityThread.java:5026)
06-11 16:05:48.050: E/AndroidRuntime(851):  at java.lang.reflect.Method.invokeNative(Native Method)
06-11 16:05:48.050: E/AndroidRuntime(851):  at java.lang.reflect.Method.invoke(Method.java:515)
06-11 16:05:48.050: E/AndroidRuntime(851):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
06-11 16:05:48.050: E/AndroidRuntime(851):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
06-11 16:05:48.050: E/AndroidRuntime(851):  at dalvik.system.NativeStart.main(Native Method)
06-11 16:05:48.050: E/AndroidRuntime(851): Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class fragment
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
06-11 16:05:48.050: E/AndroidRuntime(851):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:309)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.app.Activity.setContentView(Activity.java:1930)
06-11 16:05:48.050: E/AndroidRuntime(851):  at com.example.onroad.MainActivity.onCreate(MainActivity.java:19)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.app.Activity.performCreate(Activity.java:5242)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
06-11 16:05:48.050: E/AndroidRuntime(851):  ... 11 more
06-11 16:05:48.050: E/AndroidRuntime(851): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.app.Fragment.instantiate(Fragment.java:597)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.app.Fragment.instantiate(Fragment.java:561)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.app.Activity.onCreateView(Activity.java:4788)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
06-11 16:05:48.050: E/AndroidRuntime(851):  ... 21 more
06-11 16:05:48.050: E/AndroidRuntime(851): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.MapFragment" on path: DexPathList[[zip file "/data/app/com.example.onroad-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.onroad-2, /system/lib]]
06-11 16:05:48.050: E/AndroidRuntime(851):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
06-11 16:05:48.050: E/AndroidRuntime(851):  at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
06-11 16:05:48.050: E/AndroidRuntime(851):  at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
06-11 16:05:48.050: E/AndroidRuntime(851):  at android.app.Fragment.instantiate(Fragment.java:583)
06-11 16:05:48.050: E/AndroidRuntime(851):  ... 24 more

A: First Try to learn how to ask question.
Second, check did you really created your app project on google Developers console?..
learn from here about Google Developers Console
also Check your manifest file that you properly add all permissions and mata data.
Error Also Shows that you didn't add "Google Play Services" to your project.
download them from your SDK MANAGER and add it in your project's dependencies

redpajama_set_name: RedPajamaStackExchange


text:
Q: ios: layer is showed outside its hosting view I've read the Apple Core Animation document. It says that Core Animation doesn't provide a means for actually displaying layers in a window, they must be hosted by a view. When paired with a view, the view must provide event-handling for the underlying layers, while the layers provide display of the content.
But I have a problem about it, showing as the following image: the blue rectangle is a  UIView, named blueView, the grey one is a layer which is a sublayer of blueView.layer. The blueView.frame is {0,0}{320,180}. The grey layer's position is {100,190}. Because blueView is hosting the grey layer, I think the grey layer should be showed in the blueView area, because I guess the blueView is the canvas of grey layer. However, the fact is grey layer is showed outside of blueView, why?

A: For performance reasons by default the "clipsToBounds" properties is set to NO. This means that all the subviews/sublayers are drawn regardless if inside or outside the parent view.


text:
Q: DirectX11 CopyResource leave right bottom uncopyed D3D level is D3D_FEATURE_LEVEL_11_0.
I made texture2d with same desc setting.
    CD3D11_TEXTURE2D_DESC desc;
    desc.Width = width;
    desc.Height = height;
    desc.MipLevels = 1;
    desc.ArraySize = _array_size;
    desc.Format =DXGI_FORMAT_R24G8_TYPELESS;
    desc.SampleDesc.Count = 1;
    desc.SampleDesc.Quality = 0;
    desc.Usage = D3D11_USAGE_DEFAULT;
    desc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
    desc.CPUAccessFlags = 0;
    desc.MiscFlags = 0;

But when I render shader resource view for stencil, the right bottom is leave uncopied like below.
Depths are copied well.
enter image description here
The original texture don't make this strange results.
enter image description here
I made depth stencil buffer with this state for rectangle in the picture to make stencil value bigger than 0. For the man upon the rect, with same the desc but stencilEnable off to make stencil value 0.
D3D11_DEPTH_STENCIL_DESC desc;
ZeroMemory(&desc, sizeof(D3D11_DEPTH_STENCIL_DESC));

desc.DepthEnable      = true;
desc.DepthWriteMask   = D3D11_DEPTH_WRITE_MASK_ALL;
desc.DepthFunc        = D3D11_COMPARISON_LESS_EQUAL;
desc.StencilEnable    = true;
desc.StencilReadMask  = 0xFF;
desc.StencilWriteMask = 0xFF;

desc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
desc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_INCR_SAT;
desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;

I used the code below to copy the stencil. The only difference of drawing the original stencil value is just this 1 line.
D3D_Context->CopyResource(copy->GetTex2D(), origin->GetTex2D());

And draw stencil with this state. I tried to draw the rectangle not the man.
D3D11_DEPTH_STENCIL_DESC desc;
ZeroMemory(&desc, sizeof(D3D11_DEPTH_STENCIL_DESC));

desc.DepthEnable      = false;
desc.DepthWriteMask   = D3D11_DEPTH_WRITE_MASK_ALL;
desc.DepthFunc        = D3D11_COMPARISON_LESS_EQUAL;
desc.StencilEnable    = true;
desc.StencilReadMask  = 0x01;
desc.StencilWriteMask = 0x01;

desc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
desc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
desc.FrontFace.StencilFunc = D3D11_COMPARISON_LESS;


text:
Q: How do I fix WiX warning: Component 'X' has both per-user and per-machine data with an HKCU Registry KeyPath I'm trying to maintain some Wix code, and am getting the following warning:
warning LGHT1076 : ICE57: Component 'FILE_MY_ASSOCIATION' has both per-user and per-machine data with an HKCU Registry KeyPath.

From the following code:
<Component Id="FILE_MY_ASSOCIATION" Guid="E1DF42A5-BD00-4a80-9BE5-B66A3EF0576E" Win64="$(var.Variables_Win64)">
  <RegistryKey Root="HKCU" Key="Software\MyComany\MyProduct">
    <RegistryValue Value="" Type="string" KeyPath="yes" />
  </RegistryKey>
  <ProgId Icon="FILE_MY_FILETYPE_ICON" Id="MY_FILE_EXTENSION" Description="My Product File" >
    <Extension Id="myext" Advertise="no" >
      <Verb Id="Open" Argument=""%1"" TargetFile="MYUI_EXE_FILE"/>
    </Extension>
  </ProgId>
</Component>

I'm having trouble working out what's wrong or if this is a warning I really need to worry about.

*

*Do I need to worry about and fix this warning? Could the code as it is currently cause problems in some circumstances?

*Also, I'm wondering, why does the registry key use HKCU instead of HKLM. If I change it to HKLM. the warning goes away, but does this affect the behaviour of the installer?

Thanks.

A: The warning is saying that you are writing both user-specific data and system-wide data in the same component.  Your registry entry is writing to HKCU which will always write to a user-specific piece of the registry.  ProgId, on the other hand, writes registry entries to HKCR which could write to either HKLM or HKCU.  If it does write to HKLM that is a system-wide registry space, your single component is writing to both a user specific registry hive and a system registry hive which is against the rules laid out in the ICE warning you got.

A: It sounds like the compiler is alerting you to behavior which may not be what you want: if you register a file association for the user only, other users will not see that association.  That's an unusual behavior for an application.   So, it depends on your requirements:  do you want the app registered to handle all documents of that type for all users, or only the installing user?


text:
Q: How to bind JSON data with Kendo Grid Using MY WCF Service I am exposing JSON data:
 [OperationContract]
 [WebGet(ResponseFormat=WebMessageFormat.Json)]
 List<ProductDetails> GetProductDetails();

Here is a sample of the returned JSON:

{"d":[{"__type":"ProductDetails:#NWProducts","Discount":0,"OrderId":10248,"ProductId":11,"UnitPrice":14.0000,"quanity":12},{"__type":"ProductDetails:#NWProducts","Discount":0,"OrderId":10248,"ProductId":42,"UnitPrice":9.8000,"quanity":10},{"__type":"ProductDetails:#NWProducts","Discount":0,"OrderId":10248,"ProductId":72,"UnitPrice":34.8000,"quanity":5},{"__type":"ProductDetails:#NWProducts","Discount":0,"OrderId":10249,"ProductId":14,"UnitPrice":18.6000,"quanity":9},{"__type":"ProductDetails:#NWProducts","Discount":0,"OrderId":10249,"ProductId":51,"UnitPrice":42.4000,"quanity":40}

Trying to bind that to Kendo Grid using :
   <script>
                $(document).ready(function () {
                    $("#grid").kendoGrid({
                        dataSource: {
                            type: "json",
                            transport: {
                                read: "http://localhost/KendoServices/Web/GetProductDetails"
                            },
                            pageSize: 10
                        },
                        groupable: true,
                        sortable: true,
                        pageable: {
                            refresh: true,
                            pageSizes: true,
                            buttonCount: 5
                        },
                        columns: [{
                            field: "OrderId",
                            title: "OrderId",
                            width: 140
                        }, {
                            field: "ProductId",
                            title: "ProductId",
                            width: 190
                        }, {
                            field: "UnitPrice",
                            title: "UnitPrice"
                        }, {
                            field: "quanity",
                            width: 110
                        }]
                    });
                });
            </script>

For some reason, I'm unable to see any data on grid. There might be something wrong with the way I'm trying to bind my data.

A: The resultant JSON is the culprit here.  The kendo dataSource by default looks for the return object to have the items in an array called results. Simple to fix.  Just need to define where the data is in the response JSON object.
dataSource: {
    transport: {
        read: {
             url: "http://localhost/KendoServices/Web/GetProductDetails",
             dataType: 'json'
        }
    },
    pageSize: 10,
    schema: {
        data: function(response) {
            return response.d;
        }
    }
},

--Edit...
Whoops, missed something else. Your type: 'json' should be inside your read object, and should be dataType: 'json'

A: try this
dataSource: {
    transport: {
            read: {
                   url: "http://localhost/KendoServices/Web/GetProductDetails",
                   contentType: 'application/json; charset=utf-8',
                   dataType: "json"
                  }
    },
    schema: {
                 data: "d"
            }
    }
}

A: This is how I've done it:
    $("#grid").kendoGrid({
        dataSource: {
            transport: {
                    read: {
                            url : pUrl,
                            dataType: "json"
                    }
            },
            pageSize:40,
            schema: {
                data: function(response) {
                    return response.json;
                }
            }

        },
        height: 550,
        groupable: false,
        sortable: true,
        pageable: {
            refresh: false,
            pageSizes: false,
            buttonCount: 5
        },
        columns: [
            {
                field: "SEQ_NO",
                title: "No",
                filterable: false,
                width: 120
            }, {
                field: "LOT_NO",
                title: "Lot No (INS' No)"
            }, {
                field: "TYPE",
                title: "INPUT (At 100% Burden)"
            }, {
                field: "ATTRIBUTE01",
                title: "1.0 In"
            }, {
                field: "ATTRIBUTE02",
                title: "2.0 In"
            }, {
                field: "ATTRIBUTE03",
                title: "0.05 In"
            }, {
                   field: "RESILT",
                   title: "RESILT"
            }
        ]
    });


text:
Q: css-loader will not import css into node anymore, throwing error Originally, I had an index.html page with a div containing a
</div element. I have now included handlebars as a template language to serve react ui elements rendered to string.
The problem is, I am using a css-loader to import css into my node project and it's not importing anymore. When I used the index.html file it worked, but now its not, node is throwing an error (not webpack). I'd rather not include the style sheet in a public directory as a <link />. I can't think of a reason to why this is happening.
Error
SyntaxError: /Users/***/Documents/Isomorphic React-Node/
Restuarant /src/components/homePageStyle.css: Unexpected token (6:0)

    import React, {Component}  from 'react';
    import PropTypes from 'prop-types';
    import HeaderMenu from './HeaderMenu';
    import MainVisualDisplay from './MainVisualDisplay';
    import homePageStyle from './homePageStyle.css';

    //HomePage component
     const HomePage = () =>
    {
    return (

        <HeaderMenu item1="Menu" item2="Locations" item3="About Us"/>

    )
}
//
const forHeaderMenu = () => (
    HomePage.item1: PropTypes.string.isRequired,
    HomePage.item2: PropTypes.string.isRequired,
    HomePage.item3: PropTypes.string.isRequired
)

const forMainVisualDisplay = () =>
(
    HomePage.displayImages: PropTypes.array
)

HomePage.propTypes = {
        forHeaderMenu,
        forMainVisualDisplay
    };

export default HomePage;

A: Figured it out. Node was trying to compile the .css extension when it only know .js. I needed to an an extension.
require.extensions['.css'] = () => {
  return;
};


text:
Q: Google api client "Malformed auth code" in Laravel PHP Merchant project I got a problem with a using the google/apiclient package.
When I trying to get an access_token using auth code from front-end I getting back error form google "Malformed auth code".
The google auth code looks like this one:
ya29.A0ARrdaM8wqLBvw5yrNa0wDQGPSUvncigERIqtYC_D2tQl2QCYm3rbcthI_om_BcHGFGcDrN6qgUM37zt9ot7OsgEth5XZzZe__ed5B4artd9QNRRK0WD0wnaDl3kjxPKEcp9o53lbloypz7t7KoxO5Mg2PH0
Thats my code:
/**
 * @return Google\Client
 * @throws Google\Exception
 */
public static function getClientHeaders()
{
    $client = new Google\Client();
    $client->setApplicationName(config('services.google.app_name'));
    $client->setAuthConfig(config('merchant.config_file'));
    $client->setScopes('https://www.googleapis.com/auth/content');
    return $client;
}

/**
 * @param string $token
 * @return Google\Client
 * @throws Google\Exception
 */
public static function getClient(string $token)
{
    $client = static::getClientHeaders();
    if ($client->isAccessTokenExpired()) {
        if ($client->getRefreshToken()) {
            $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
        } else {
            $creds = $client->fetchAccessTokenWithAuthCode($token);
            if (isset($creds['error'])) {
                abort(Response::HTTP_BAD_REQUEST, $creds['error_description']);
            }
        }
    }
    return $client;
}

public function getToken()
{
$client = static::getClient(request()->input('access_token'));
$token = $client->getAccessToken();
}

I am getting an error when I try to run getToken() function. Maybe You can see what am I doing wrong :(


text:
Q: Mocking python HTTP request with an Oauth1 certificate

I'm using the python response library to mock a call with requests, but I get this error:
File "/lib/python3.5/site-packages/requests/api.py", line 110, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/lib/python3.5/site-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/lib/python3.5/site-packages/requests/sessions.py", line 474, in request
    prep = self.prepare_request(req)
  File "/lib/python3.5/site-packages/requests/sessions.py", line 407, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/lib/python3.5/site-packages/requests/models.py", line 306, in prepare
    self.prepare_auth(auth, url)
  File "/lib/python3.5/site-packages/requests/models.py", line 518, in prepare_auth
    r = auth(self)
  File "/lib/python3.5/site-packages/requests_oauthlib/oauth1_auth.py", line 88, in __call__
    unicode(r.url), unicode(r.method), None, r.headers)
  File "/lib/python3.5/site-packages/oauthlib/oauth1/rfc5849/__init__.py", line 313, in sign
    ('oauth_signature', self.get_oauth_signature(request)))
  File "/lib/python3.5/site-packages/oauthlib/oauth1/rfc5849/__init__.py", line 150, in get_oauth_signature
    sig = self.SIGNATURE_METHODS[self.signature_method](base_string, self)
  File "/lib/python3.5/site-packages/oauthlib/oauth1/rfc5849/signature.py", line 505, in sign_rsa_sha1_with_client
    return sign_rsa_sha1(base_string, client.rsa_key)
  File "/lib/python3.5/site-packages/oauthlib/oauth1/rfc5849/signature.py", line 497, in sign_rsa_sha1
    key = _prepare_key_plus(alg, rsa_private_key)
  File "/lib/python3.5/site-packages/oauthlib/oauth1/rfc5849/signature.py", line 574, in _prepare_key_plus
    return alg.prepare_key(keystr)
  File "/lib/python3.5/site-packages/jwt/algorithms.py", line 169, in prepare_key
    key = load_pem_public_key(key, backend=default_backend())
  File "/lib/python3.5/site-packages/cryptography/hazmat/primitives/serialization.py", line 24, in load_pem_public_key
    return backend.load_pem_public_key(data)
  File "/lib/python3.5/site-packages/cryptography/hazmat/backends/multibackend.py", line 312, in load_pem_public_key
    return b.load_pem_public_key(data)
  File "/lib/python3.5/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 1074, in load_pem_public_key
    self._handle_key_loading_error()
  File "/lib/python3.5/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 1289, in _handle_key_loading_error
    raise ValueError("Could not unserialize key data.")
ValueError: Could not unserialize key data

The code I try to mock is the following:
def function_to_test():
        oauth = OAuth1(
            self.consumer_key,
            client_secret=self.consumer_secret,
            resource_owner_key=self.oauth_token,
            resource_owner_secret=self.oauth_token_secret,
            rsa_key=self.rsa_key,
            signature_method=self._signature_method
        )
        return requests.post(url="https://example.com", auth=oauth, cert="/path/to/certificate")

And the testing code:
@responses.activate
def test_token_expired(self):
    responses.add(responses.POST, url='https://example.com/',
                  body='my_expected_result',
                  status=200)
    response = function_to_test()
    self.assertEqual(response.content, 'my_expected_result)

The test is failing with the error displayed above, does it mean that the responses mocking has not worked? Is it related to auth/cert parameters in my requests.post? Am I missing something?

A: I think that your issue is not related to responses library, but to OAuth1 initialisation.
Before even trying to mock the request, OAuth1 fails because he is trying to access the key, which is not probably correctly initialised in your test.
You can either give a fake value for this key, on even mock the OAuth1 object, responses will then be able to mock your call.
We could have expected responses to completely mock the requests call, but it seems that some initialisation still happens before that.


text:
Q: create a loop to the random function I want to create a loop so that the numbers change continuously until the end of the loop, and then when I click the button I want the value to be saved in the variable tot, but I press the button
. thank you
generateOptions function () {
  randomValues var = [];
  var currentValue ;

  while ( randomValues.length <10 ) {
    currentValue = Math.floor ( Math.random () * 11) + 1;

    if ( randomValues.indexOf ( currentValue ) < 0) {
      randomValues.push ( currentValue ) ;
    }
  }

  { return
    option : randomValues ,

  } ;
}

$ (function () {
  var setup = generateOptions ();
  var tot = 0 ; // variable saved total value
  $ ("# button1" ) . val ( setup.opzione [ 0]);
  $ ("# button2 "). val ( setup.opzione [1] ) ;
  $ ("# button3 "). val ( setup.opzione [2] ) ;
  $ ("# Button4 .") val ( setup.opzione [4] ) ;
  $ ("# Button5 .") val ( setup.opzione [5]) ;
  $ ("# button6 .") val ( setup.opzione [6] ) ;
  $ ("# button7 .") val ( setup.opzione [7] ) ;
  $ ("# button8 .") val ( setup.opzione [8]) ;
  $ ("# button9 .") val ( setup.opzione [9]) ;
  $ (" input.finish .") on ( "click" , function () {
    var SelectedValue = parseInt ($ (this). val ( ) , 10);

  });
});

A: It's very hard to understand from your question exactly what you're trying to accomplish. However from the code it looks like you're trying to return an array of random values from a function, output each of these values to different buttons, then store the value of whatever button is clicked. If this is the case other than the syntax errors your code looks like it will work as long as each of your buttons has the finish class. If you would like the value to be stored in the tot variable like your question suggests simply swap out var selectedValue for tot.
You have alot of syntax errors there. I suggest you open the console by pressing f12 and going to the console tab to debug the code, this would be a more helpful exercise than someone just telling you where they are. I suggest you break the code up to do this, try using console.log(generateOptions()) to view what the function returns as well as commenting out different points within the function to see where the problem lies. Once you got the function working try testing with one button to start off then go from there. Hopefully that helps!


text:
Q: Writing data to another hard drive when using Bittorrent Sync I'm probably making a noob mistake, but i was basically trying to learn how to mount another hard drive for use with Bittorrent Sync.
Here is what is DID
Went into the terminal to create my folders and mount my drive:
sudo mkdir /media/MyFolder

sudo mount /dev/sdb1 /media/MyFolder

Now, compared to Windows where administrators identify drives as Letters, it mentioned that the Hard Drives appear as part of the file system.
Now, theory wise, what i really wanted to do was write data to my /dev/sdb1 drive, but instead it added data to my /media/MyFolder drive on my primary Operating System Drive.
What would enable me to "mount" my hard drive into the system so that the data gets written on my /dev/sdb1 drive?

A: After you mounted your disk under /media/MyFolder, all the directory hierarchy that appears under /media/MyFolder will physically reside on the other disk. You can see this with the command df. For example:
(0)samsung-romano:~% sudo mount /dev/sda2 /mnt/tmp
(0)samsung-romano:~% df -h
Filesystem      Size  Used Avail Use% Mounted on
[...]
/dev/sda6       480G  192G  265G  42% /home
/dev/sda2       3.7G   30M  3.5G   1% /mnt/tmp

Look --- the sda2 partition has 30M used. Now if I copy a large file (around 1.9G) under /mnt/tmp:
 (0)samsung-romano:~% sudo cp tmp/00032.MTS /mnt/tmp

Then I have:
(0)samsung-romano:~% df -h | grep sda
/dev/sda1        88G   11G   74G  13% /
/dev/sda6       480G  192G  265G  42% /home
/dev/sda2       3.7G  1.9G  1.6G  55% /mnt/tmp

See? The big file is now on the other disk. If I u(n)mount the disk, now, the bigfile will be invisible.
Look:
(0)samsung-romano:~% ls -l /mnt/tmp/*.MTS
-rw-r--r-- 1 root root 2006482944 Dec  6 21:24 /mnt/tmp/00032.MTS
(0)samsung-romano:~% sudo umount /mnt/tmp
(0)samsung-romano:~% ls -l /mnt/tmp
total 0

Notice: I had to use sudo here because the permission of the mounted disk. You should use a bit more complex command to mount the disk and make it available to write to it as a normal user --- but that would be another question (probably already answered somewhere).


text:
Q: Android : I am trying to search for contacts on basis of their display name I am trying to search for contacts on basis of their display name.
I have taken the reference from sample code given on the android developer site.
https://developer.android.com/training/contacts-provider/retrieve-names.html
In this sample, search performs from the whole contacts details present in contact not only from contacts name.
For example if a user has an email address in his contacts, then the search is performing in matching the emails as well.
 or if a number is stored in home type, then while typing h, the number present in home category also shown up.
I want search to be limited to their display name.
     final static String SELECTION =
            (Utils.hasHoneycomb() ? Contacts.DISPLAY_NAME_PRIMARY : Contacts.DISPLAY_NAME) +
                    "<>''" + " AND " + Contacts.IN_VISIBLE_GROUP + "=1";

These is the selecton clause that i am using taken from sample code.

A: Try This
Cursor cursor = getContentResolver().query(
            android.provider.ContactsContract.Contacts.CONTENT_URI,
            new String[] { ContactsContract.Contacts.PHOTO_ID,
                    ContactsContract.Contacts.DISPLAY_NAME,
                    ContactsContract.Contacts._ID },
            ContactsContract.Contacts.HAS_PHONE_NUMBER, null,
            ContactsContract.Contacts.DISPLAY_NAME);

This cursor gives all the contacts that have any phone number and then i save the unique ID  in an ArrayList like this
cursor.moveToFirst();

    while (cursor.moveToNext()) {
        contactsID.add(cursor.getString(2));
    }

then on selecting the contact i find the contact numbers using this
Cursor cursor = getContentResolver()
                    .query(android.provider.ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                            new String[] {
                                    ContactsContract.CommonDataKinds.Phone.NUMBER,
                                    ContactsContract.CommonDataKinds.Phone.CONTACT_ID,
                                    ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME },
                            ContactsContract.CommonDataKinds.Phone.CONTACT_ID
                                    + " = ?",
                            new String[] { contactsID.get(position) }, null);
            contactNumbers = new ArrayList<String>();
            while (cursor.moveToNext()) {
                contactNumbers.add(cursor.getString(0));
                Log.d("number", cursor.getString(0));
            }

A: The code that does the filtering in the Retrieving a List of Contacts tutorial is here:
Uri contentUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI, Uri.encode(mSearchString));

In the Contacts.CONTENT_FILTER_URI docs it says:

The filter string will be used to match various parts of the contact
  name

So that's not good for you, replace it with:
@Override
public Loader<Cursor> onCreateLoader(int loaderId, Bundle args) {
    Uri contentUri = Contacts.CONTENT_URI; // no longer filters
    String selection = Contacts.DISPLAY_NAME_PRIMARY + " LIKE %" + mSearchString + "%";

    return new CursorLoader(
            getActivity(),
            contentUri,
            PROJECTION,
            selection,
            null,
            null
    );
}


text:
Q: Rest Client Debugger test upload images I m stuck on the following scenario, I do hope some who did it successfully for the past could help me on this problem.
I m using REST CLIENT DEBUGGER which is used to perform HTTP GET and POST to get the desire result. I m working on android and require to upload image from my phone to the server but I not sure how to test the result using this REST CLIENT DEBUGGER written by Chao.
IDE I used: Titanium
Situation:Upload an image from phone to the server

A: Use some sort of Base64 encoder and encode your image.  A quick search turned up:
http://www.motobit.com/util/base64-decoder-encoder.asp
Copy the text the encoder provides into the BODY of your POST to the web service.  Decode the image on the server from base 64 into the image format that you want.
I can't remember who I got this code from, but it wasn't my source (C# Source).
private Image Base64ToImage(string base64String)
        {
            Image image = null;
            try
            {
                // Convert Base64 String to byte[]
                byte[] imageBytes = Convert.FromBase64String(base64String);
                MemoryStream ms = new MemoryStream(imageBytes, 0,
                  imageBytes.Length);

                // Convert byte[] to Image
                ms.Write(imageBytes, 0, imageBytes.Length);
                image = Image.FromStream(ms, true);

            }
            catch (Exception ex)
            {
                writeException(ex);
            }

            return image;
        }

I then take the image and convert it to a png, which is relatively easy in C#.


text:
Q: How to trace the loading process of C++ libraries? I'm developing a small qt app that uses libvlc libraries to provide video playback functionality, but the problem I met is that it needs much time to load all the libraries at first time playback is launched.
So there's the question - is there any ability to trace the process of loading libraries? (It's better to show some kind of "Loading..." window to user.)

A: Rather than monitoring the loading, you can simply trigger loading those libraries during program start.  This will make it invisible to your users, because people expect a program to take a second or two to load anyway.
An easy way to do this might be to call libvlc_new() when your program is starting up.


text:
Q: Oracle 12c Datapatch Error We have an old Oracle 12c database server that is not up to date (version 12.1.0.1.0). Unforunately a full version upgrade is out of scope right now, but I was hoping to at least apply the latest patch bundle we have on hand, which would take us to 12.1.0.1.160719 and fix a few vulnerabilities.
I used OPatch and got everything applied without incident, but when I tried to run the datapatch utility afterward I recieved the following errors:
SQL Patching tool version 12.1.0.1.0 on Thu Oct 17 12:10:58 2019
Copyright (c) 2014, Oracle.  All rights reserved.

Connecting to database...OK
Determining current state...
Currently installed SQL Patches:
Currently installed C Patches: 23530410
Adding patches to installation queue and performing prereq checks...
Installation queue:
  Nothing to roll back
  The following patches will be applied: 23530410
catconInit: database is not open
Installing patches...
Patch installation complete.  Total patches installed: 1
Validating logfiles...
Patch 23530410 apply:
  logfile:  (no errors)

See support note 1609718.1 for information on how to resolve the above errors

SQL Patching tool complete on Thu Oct 17 12:11:41 2019
catconExec: catconInit has not been runcatconWrapUp: catconInit has not been run

I've found similar errors on Google about 'catconInit: database is not open on the default instance' but nothing that is exactly the same message as mine. In fact, when I Google the last error message 'catconExec: catconInit has not been runcatconWrapUp: catconInit has not been run' I only get one result--the Oracle Support page for this error (Doc ID 1609718.1). Unfortunately, we do not have an ongoing support contract and I cannot see the cause/solution for this.
Also:

*

*There is only one database/instance on this server, and I specify
that with the datapatch parameter

*The database is open per V$INSTANCE, and both myself and the application can query it just fine

*I've been a DBA for a few years now, but I'm new to Oracle specifically

Does anyone have any ideas? Can anyone relay the information from the support doc? Thanks in advance.

EDIT

*

*OS is Windows Server 2012 R2 Standard

*Rerun of 'datapatch -verbose -db MyDatabase' produces the exact same output (just with newer timestamps)

*The associated log file from the most recent run of datapatch (D:\oracle\MyDatabase\cfgtoollogs\opatch\opatch2019-11-05_13-29-08PM_1):


text:
Q: Ajax post successful (shown in browser) but no data in $_POST So I'm relatively a beginner in PHP/Javascript/HTML.
Here's what my page looks like:
   I have several forms each with a single dropdown.
   Then, I have one button (in the code, it's located outside the form) to submit all of the said forms.
   Here's my button and its function.
<input type="button" name="order_button" onclick="myFunction()" value="Place Order">

I'm getting a "200 OK" status code in chrome, but $_POST contains nothing (I'm using print_r after posting).
I've been stuck for two days trying to find an answer but couldn't quite see one that exactly fits my situation. Thanks in advance!
**EDIT: ** Here is my form code:

          <?php
            if ($result->num_rows > 0) {
              while($row = $result->fetch_assoc()) {
          ?>

              <img src="pics/cards/<?php echo $row["cardName"] ?>.jpg" alt="" border=3 height=150 width=100>

<?php echo $row["cardName"] ?>

Php <?php echo $row["cardPrice"] ?>.00

 <?php echo rand(10,100) ?> reviews

Quantity:

              <form action="javascript:true;" name="<?php echo $row["cardForSub"]; ?>" id="<?php echo $row["cardForSub"]; ?>">
                <select class="form-control" name="<?php echo $row["cardNickname"]; ?>" id="<?php echo $row["cardNickname"]; ?>">
                <?php
                  $counter = 0;
                  while($counter <= $row["stock"]) {
                ?>
                    <option><?php echo $counter ?></option>

                <?php
                    $counter++;
                    }
                ?>
                </select>
              </form>

          <?php
              }
            }
            else echo "No cards in database.";
          ?>

A: I profess to no jQuery skills but to me it looks like there is something amiss with the function ~ where you call $(document.getElementById()).serialise() - I don't think you need to document.getElementById in there. Also, it would be neater to separate the html, javascript and php a little... and, like @Raj pointed out ~ the url should more likely begin with a slash than end with one.

        <title>Form/ajax</title>

    <form>
        <input type='button' name='order_button' onclick='myFunction()' value='Place Order'>
    </form>

A: Issue 1 :
The Target Page Proj-HOME.php/ It means the file named as index.php or index.html inside Proj-HOME.php
I guess that you are trying to post to the page Proj-HOME.php/ . If so remove the / after the file name i.e., Have like this Proj-HOME.php alone
Note 1 :
Try to print some variable in the Proj-HOME.php and try to see in the ajax success event so that you can make sure that you're pointing on correct page.
Note 2 :
Check whether you included jquery library to make this events works, also try to these code in page source so that you can make sure that these code is getting rendered in page.


text:
Q: I am stuck with an example of direct limits and need help to prove $\mathbb{Q/Z} = \varinjlim \mathbb{Z}/(i)$. Let $N$ denote the set of positive integers that are ordered as $m \le n \iff m | n$.
Let $X_m = \mathbb{Z}/(m)$ denote the set of integers $x \mod m$.
I want to show that the direct limit of $X_i$, over $i \in N$, is $\mathbb{Q/Z}$ (using the definition here).

I have defined maps $f_{mn} : X_m \to X_n$ given by: $x \mod m \mapsto xd \mod n$, where $d$ comes from $n=md$.
I also have maps $\phi_m : X_m \to \mathbb{Q/Z}$ given by: $x \mod m \mapsto x/m$.
Then it was easy to check that $\phi_n \circ f_{mn}=\phi_m$.
Now it gets confusing for me. We have to show that if we pick another object $Y$ together with morphisms $\psi_m : X_m \to Y$ such that we have $\psi_n \circ f_{mn}=\psi_m$ then there exists a unique morphism $u \colon \mathbb{Q/Z} \to Y$ such that $u \circ \phi_m=\psi_m$ and $u \circ \phi_n=\psi_n$. I want to know how to do that?

A: The direct limit of the directed system  $<X_m,f_{mn}>$ in the category of sets is $\sqcup X_i /\text{equivalence relation}$.
Then we define a bijection as follows
\begin{align}
\sqcup X_i /\text{equivalence relation} &\rightarrow \mathbb{Q/Z}\\
x_i&\rightarrow \frac{x}{i}\\
m_n&\leftarrow \frac{m}{n}
\end{align}
where $x_i$ is an integer in set $X_i$, $\frac{m}{n}$ are chosen such that $m<n$.


text:
Q: Remove comments from a comment box as an admin I have a facebook application in which I generate pages for each object:
www.mydomain.com/object.php?object_id=1 --> apps.facebook.com/myapp/obejct.php?object_id=1

In each one of the pages I generate a comment box with the following code:

<fb:comments href="http://www.mydomain.com/object.php?object_id=1" num_posts="10" width="380"></fb:comments>

The comments box shows properly for each object.
I also put myself as an admin in the headers of the page (inside the body tag):
<meta property="fb:admins" content="MY_FACEBOOK_ID"/>
<meta property="fb:app_id" content="MY_APP_ID"/>

When a users comments inside the comment box, it shows the comment.
If I want to delete it, it won't let me. It will only let me "report as abuse" or "spam"
Does anyone know how can I remove the comments?

A: Try this:  http://developers.facebook.com/tools/comments
This will help in Moderate your comments.

A: I found this question via Google after running into this problem with a comment box created using the Drupal "Facebook Social Plugins" module. After trying to figure out where the moderate drop down had gone on the test comment I left and that of another administrator, I realized that it wasn't showing up for me because both the commenters were administrators for the app, so Facebook assumed we didn't need to moderate admins comments.
Once a non-admin left a comment, the moderate drop down gave us the option to delete the comment as normal.

A: use app id
like this :


text:
Q: xattr -w Writing metadata to a file - syntax issue Testing the ability to write metadata to files in Mac OSX. Any help would be appreciated as I know little about unix syntax.
In Terminal.
Why does this work;
xattr -w com.apple.metadata:kMDItemDescription 'Somedescription' /somePath/someFile.pdf
but this does not;
xattr -w com.apple.metadata:kMDItemDescription 'Some\ description' /somePath/someFile.pdf
Obviously I will sometimes need to write to the metadata tag as a string that includes spaces. I would have thought that escaping the whitespace would work.


text:
Q: draw k times from n numbers with replacement, each number appears at least m times The objective is to draw $k$ times from $n$ numbers with replacement and with remembering the order. What is the probability $P(k,n,m)$ that every number ($1\ldots n$) is drawn at least $m$ times?
For $m=0$ the probability is $P(k,n,0)=1$.
For $m=1$ (1498003) the probability is $P(k,n,1)=\mathcal{S}_k^{(n)}n!/n^k$ in terms of the Stirling number of the second kind.
Is there an efficient way of calculating $P(k,n,m)$ for higher values of $m$?
Here's an inefficient way to calculate these probabilities in Mathematica by enumerating all possible drawing results:
f[k_Integer /; k >= 0, n_Integer /; n >= 1] := f[k, n] =
   Reverse@Accumulate@Reverse@BinCounts[
        Min[BinCounts[#, {1, n + 1, 1}]] & /@ Tuples[Range[n], k],
        {0, Floor[k/n] + 1, 1}]/n^k;
P[k_Integer /; k >= 0, n_Integer /; n >= 1, m_Integer /; m >= 0] :=
  With[{L = f[k, n]}, If[m >= Length[L], 0, L[[m + 1]]]]

Test of the known formula for $m=1$:
With[{k = 8, n = 3},
  P[k, n, 1] == StirlingS2[k, n]*n!/n^k]
(* True *)

update: faster code based on solution
@GCab's solution gives an efficient recipe for calculating these probabilities. Simplifying the multinomials and rising factorials a bit,
$$
P(k,n,m)
=\frac{1}{n^k} \frac{k!}{(k-nm)!} \sum_{l_j\ge0\\l_1+l_2+\ldots+l_n=k-n m}\binom{k-nm}{l_1,l_2,\ldots,l_n}\frac{1}{(1+l_1)^{\bar{m}}(1+l_2)^{\bar{m}}\ldots(1+l_n)^{\bar{m}}}\\
=\frac{1}{n^k} \sum_{l_j\ge0\\l_1+l_2+\ldots+l_n=k-n m}\binom{k}{l_1+m,l_2+m,\ldots,l_n+m}\\
=\frac{1}{n^k} \sum_{a_j\ge m\\a_1+a_2+\ldots+a_n=k}\binom{k}{a_1,a_2,\ldots,a_n}
$$
In Mathematica,
P[k_, n_, m_] :=
  1/n^k * Total[(Multinomial @@ #)*(Multinomial @@ Tally[#][[All,2]]) & /@
    IntegerPartitions[k, {n}, Range[m, k-(n-1)*m]]]

The extra factor of Multinomial @@ Tally[#][[All,2]] in this formula counts how many permutation of a given integer partition exist, because IntegerPartitions does not enumerate partitions that differ only by permutation.
recursion
Still much faster is @GCab's recursive solution: in Mathematica,
$RecursionLimit = 10^4;
R[k_, n_, m_] /; k < n*m = 0;
R[k_, n_, 0] = n^k;
R[k_, 1, m_] = 1;
R[k_, n_, m_] := R[k, n, m] =
  n*(R[k-1, n, m] + Binomial[k-1, m-1]*R[k-m, n-1, m])
P[k_, n_, m_] := R[k, n, m]/n^k

With this recursion we can go to large values of $k$ easily:
P[1000, 100, 7] // N // AbsoluteTiming
(* {0.245745, 2.4066*10^-8} *)

A: In terms of combinatorial classes we get
$$\def\textsc#1{\dosc#1\csod}
\def\dosc#1#2\csod{{\rm #1{\small #2}}}
\textsc{SEQ}_{=n}(\textsc{SET}_{\ge m}(\mathcal{Z})).$$
This gives the EGF
$$\left(\exp(z)-\sum_{q=0}^{m-1} \frac{z^q}{q!}\right)^n.$$
The desired quantity is then given by
$$\bbox[5px,border:2px solid #00A000]{
\frac{1}{n^k} k! [z^k]
\left(\exp(z)-\sum_{q=0}^{m-1} \frac{z^q}{q!}\right)^n.}$$
 Addendum. For  computational purposes  it  is best  to use  a
recurrence like the one shown below.

X :=
(k, n, m) ->
1/n^k*k!*coeftayl((exp(z)-add(z^q/q!, q=0..m-1))^n,
                  z=0, k);

R :=
proc(k, n, m)
option remember;

    if n=1 then
        return `if`(k >= m, 1/k!, 0);
    fi;

    add(1/q!*R(k-q, n-1, m), q=m..k);
end;

XR := (k, n, m) -> 1/n^k*k!*R(k, n, m);

 Addendum, II.  If we are required to use  integers only we can
use the  recurrence below  (e.g. for  implementation in  a programming
language that does not provide fractions as a data type).

R2 :=
proc(k, n, m)
option remember;

    if n=1 then
        return `if`(k >= m, 1, 0);
    fi;

    add(binomial(k,q)*R2(k-q, n-1, m), q=m..k);
end;

XR2 := (k, n, m) -> 1/n^k*R2(k, n, m);

A: This the same as
laying $k$ (distinguished, since you consider the extraction order) balls into $n$ (distinguished) bins
but allow me to change $k$ into $s$ so to keep $k$ for use as index, thus
laying $s$ (distinguished) balls into $n$ (distinguished) bins, each bin having at least $m$ balls,
or equivalently
writing words of length $s$, from the alphabet $\{1,\cdots,n\}$, with each character appearing at least $m$ times.
Without the bound on $m$ (i.e. for $m=0$), there are $n^s$ ways of doing that, each represented by one term in the expansion of
$$
\left( {x_{\,1}  + x_{\,2}  +  \cdots  + x_{\,n} } \right)^{\,s}
$$
Since
$$
\left( {x_{\,1}  + x_{\,2}  +  \cdots  + x_{\,n} } \right)^{\,s}  = \sum\limits_{\left\{ {\begin{array}{*{20}c}
   {0\, \le \,j_{\,k} }  \\   {j_{\,1}  + \,j_{\,2} +\, \cdots +\,j_{\,n} \, = \,s}  \\
\end{array}} \right.\;} {\left( \begin{array}{c}
 s \\   j_{\,1} ,\,j_{\,2} ,\, \cdots ,\,j_{\,n}  \\
 \end{array} \right)\;x_{\,1} ^{j_{\,1} } \;x_{\,2} ^{j_{\,2} } \; \cdots \;x_{\,n} ^{j_{\,n} } }
$$
then the multinomial coefficient counts the number of "occupancy" histograms with distinguished balls
corresponding to the same histogram when the balls are undistinguished.
(the number of histograms with undist. balls would be the number of weak compositions of $s$ into $n$ parts).
Now we are looking for
$$
\begin{array}{l}
 P(s,n,m) = \frac{{N(s,n,m)}}{{n^{\,s} }} = \frac{1}{{n^{\,s} }}\sum\limits_{\left\{ {\begin{array}{*{20}c}
   {m\, \le \,j_{\,k} }  \\    {j_{\,1}  + \,j_{\,2}  +  \cdots  + j_{\,n} \, = \,s}  \\
\end{array}} \right.\;} {\left( \begin{array}{c}
 s \\   j_{\,1} ,\,j_{\,2} ,\, \cdots ,\,j_{\,n}  \\
 \end{array} \right)}  =  \\
  = \frac{1}{{n^{\,s} }}\sum\limits_{\left\{ {\begin{array}{*{20}c}
   {0\, \le \,l_{\,k} }  \\    {l_{\,1}  + \,l_{\,2}  +  \cdots  + l_{\,n} \, = \,s - nm}  \\
\end{array}} \right.\;} {\left( \begin{array}{c}
 s \\   m + l_{\,1} ,\,m + l_{\,2} ,\, \cdots ,\,m + l_{\,n}  \\
 \end{array} \right)}  =  \\
  = \frac{1}{{n^{\,s} }}\frac{{s!}}{{\left( {s - nm} \right)!}}\sum\limits_{\left\{ {\begin{array}{*{20}c}
   {0\, \le \,l_{\,k} }  \\    {l_{\,1}  + \,l_{\,2}  +  \cdots  + l_{\,n} \, = \,s - nm}  \\
\end{array}} \right.\;} {\frac{{l_{\,1} !\,l_{\,2} ! \cdots l_{\,n} !}}{{\left( {m + l_{\,1} } \right)!\,\left( {m + l_{\,2} } \right)!\, \cdots \,\left( {m + l_{\,n} } \right)!}}
\left( \begin{array}{c}
 s - nm \\   l_{\,1} ,\,l_{\,2} ,\, \cdots ,\,l_{\,n}  \\
 \end{array} \right)}  =  \\
  = \frac{1}{{n^{\,s} }}\frac{{s!}}{{\left( {s - nm} \right)!}}\sum\limits_{\left\{ {\begin{array}{*{20}c}
   {0\, \le \,l_{\,k} }  \\    {l_{\,1}  + \,l_{\,2}  +  \cdots  + l_{\,n} \, = \,s - nm}  \\
\end{array}} \right.\;} {\left( \begin{array}{c}
 s - nm \\   l_{\,1} ,\,l_{\,2} ,\, \cdots ,\,l_{\,n}  \\
 \end{array} \right)\frac{1}{{\left( {1 + l_{\,1} } \right)^{\,\overline {\,m\,} } \,\left( {1 + l_{\,2} } \right)^{\,\overline {\,m\,} } \,
\cdots \,\left( {1 + l_{\,n} } \right)^{\,\overline {\,m\,} } }}}  \\
 \end{array}
$$
where $x^{\,\overline {\,k\,} }$ represents  the Rising Factorial
Although other manipulations of the above formula are possible, I do not see it possible to reach to a closed
formula, unless (maybe) through the q-Stirling ? (*)
We can however establish a recursive relation in $s$ that might be more practical in computing.
Let's take the "words" scheme and indicate by $N^ *  (s,n,m)$ the
Number of words of length $s$, from the alphabet $\{1,cdots,n\}$, with one character repeated exactly$m-1$ times and the other at least $m$ times.
That is
$$
\begin{array}{l}
 N^ *  (s,n,m) = \sum\limits_{\left\{ {\begin{array}{*{20}c}
   {m\, \le \,j_{\,k} }  \\    {j_{\,1}  + \,j_{\,2}  +  \cdots  + \,j_{\,n - 1}  + m - 1\, = \,s}  \\
\end{array}} \right.\;} {\left( \begin{array}{c}
 s \\   j_{\,1} ,\,j_{\,2} ,\, \cdots ,\,j_{\,n - 1} ,\,m - 1 \\
 \end{array} \right)}  =  \\
  = \sum\limits_{\left\{ {\begin{array}{*{20}c}
   {m\, \le \,j_{\,k} }  \\    {j_{\,1}  + \,j_{\,2}  +  \cdots  + \,j_{\,n - 1} \, = \,s - m + 1}  \\
\end{array}} \right.\;} {\left( \begin{array}{c}
 s \\   j_{\,1} ,\,j_{\,2} ,\, \cdots ,\,j_{\,n - 1} ,\,m - 1 \\
 \end{array} \right)}  =  \\
  = \frac{{s!}}{{\left( {s - m + 1} \right)!\left( {m - 1} \right)!}}\sum\limits_{\left\{ {\begin{array}{*{20}c}
   {m\, \le \,j_{\,k} }  \\    {j_{\,1}  + \,j_{\,2}  +  \cdots  + \,j_{\,n - 1} \, = \,s - m + 1}  \\
\end{array}} \right.\;} {\left( \begin{array}{c}
 s - m + 1 \\   j_{\,1} ,\,j_{\,2} ,\, \cdots ,\,j_{\,n - 1}  \\
 \end{array} \right)}  =  \\
  = \left( \begin{array}{c}
 s \\   m - 1 \\
 \end{array} \right)N(s - m + 1,n - 1,m) \\
 \end{array}
$$
Then a word of length $s+1$, and parameters $n,m$ can be composed
 - either by adding any character to a word $(s,n,m)$,
 - or by adding the missing character to a word counted by $N^* (s,n,m)$.
Therefore we have
$$
\begin{array}{l}
 N(s + 1,n,m) = n\left( {N(s,n,m) + N^ *  (s,n,m)} \right) =  \\
  = n\left( {N(s,n,m) + \left( \begin{array}{c}
 s \\  m - 1 \\
 \end{array} \right)N(s - m + 1,n - 1,m)} \right) \\
 \end{array}
$$
with a suitable tuning of the initial conditions / range of the parameters.
Note(*)
I stumbled now on learning that N(s,n,m) is related to the m-associated Stirling numbers of 2nd kind
$$
{{N(s,n,m)} \over {n!}} = S_{\,m} \left( {s,n} \right)
$$
re. for instance to these links 3, 4, 5.


text:
Q: Given a pointer, how might I find the _HEAP_ENTRY that it belongs to? I'm learning to use WinDbg and I might be way off track on this, but I assume that if my program isn't using a paged heap that instead of _DPH_HEAP_BLOCK structures that "own" a pointer to my allocation, I would instead have a _HEAP_ENTRY for the allocated data.
Given an address to allocated data on the heap, how might I find which _HEAP_ENTRY goes with it (in WinDbg), or does my question not even make sense?
The root of my question is my desire to know if an allocation in a dump was freed or if the heap was corrupted somehow.

A: !heap -p -a <address>
With page heap enabled, this dumps out useful information (potentially including the callstack of the last person to allocate/free this heap block) - I think this visualizes the _DPH_HEAP_BLOCK.
Without page heap enabled it just shows basic info - which isn't that useful. I think this is the regular _HEAP_ENTRY struct. Debugging double frees/etc at the point of the second access is pretty much impossible (by mere mortals such as myself, at least).
When confronted with a heap issue, I immediately enable heap validation via AppVerifier, then repo again. This does two things:

*

*It moves AV's from accessing freed memory "further up" to an earlier point in time, sometimes making the root cause of bugs obvious

*It makes the !heap -p -a <address> command dump out a lot more useful information, including the callstack of who last freed it (!!)
!heap+app verifier is pretty awesome, and probably second only to memory write breakpoints on the list of ninja-windbg-foo that everyone should know.


text:
Q: sbt native packager and app writable directory Using the sbt-native-packager plugin, what's the best approach to have a app-writable directory? In my configuration i use enablePlugins(JavaServerAppPackaging, SystemdPlugin, DebianPlugin, UniversalPlugin) and it all works well except my app needs to write some files for its own functioning, under /usr/share/package-name/ sounds wrong but then i wonder where and how is best to do that, also if i should use debain postinst scripts of try to alter directory permissions from the mappings of the universal pluin.

A: Adding a new writeable directory in a linux distribution means adding a mapping to the linuxPackageMappings (documentation).
linuxPackageMappings += packageTemplateMapping(
  s"/opt/${(packageName in Linux).value}"
)().withUser((daemonUser in Linux).value)
   .withGroup((daemonGroup in Linux).value)
   .withPerms("755")

You can see this with the old sbt syntax in use for the JavaServerApp plugin.
Note: You should NOT set the /usr/share/<packageName> directory writeable. It contains the executables and config files and should only be modifiable for the root user.
cheers,
Muki


text:
Q: How does git filter-branch affect repos used as submodules? I want to use git filter-branch to remove some large files from the commit history of a repository named problems. Does this cause any issues in my repository thesis, which uses the problems repository as a submodule?
Namely, does the force push required with git filter-branch necessitate any special action or consideration in the thesis repository?

A: The short answer is "yes".  Filter-branch works by copying commits, to new-and-improved commits with different hash IDs.
If the copied repository is used as a submodule, the superproject repository contains commits that store the raw hash IDs of the submodule's commits.  Since the new-and-improved commits have different hash IDs, the superproject now holds the old (i.e., wrong) hash IDs, at least for any commits that got copied-and-replaced like this.
What this implies is that you must now replace any commits in the superproject that have, as their gitlink, the hash ID of a commit that was replaced by a new-and-improved commit in the submodule repository.  Doing this is nontrivial.
The filter-branch command can be told to keep a mapping from old to new hash IDs, using the --state-branch option.  (This option was new in Git 2.15.0.)  You'll need this state mapping.  It's not clear off-hand how to use it when running a filter-branch over the superproject, but you'll need a filter that finds commits that contain gitlinks that have old-commit entries and tell the superproject filter to replace those with updated gitlinks.


text:
Q: Shp layer to Fusion Table I need to store a .shp file (vector data file) in Fusion table and then "get" him from the fusion table and use it as a layer/overlay on my MapView in android (using google map Api)
is it possible ?
a sample of how to do it will be helpful...
Thanks in advance ! Tom.

A: I use shpescape.com to convert a shapefile to Fusion Tables, super useful. Getting it in a MapView is a bit trickier, because there is no "official" way to do it in the SDK. You may find some answers here and here.

A: The url that Gady P shared works, but here are some alternative options:
You need to get your shapefile into KML format. You can either use the Layer to KML tool in ArcGIS. It can be found in Toolboxes > System Toolboxes > Conversion Tools > From KML > KML to Layer.
You can also use GDAL/ogr2ogr to convert the shapefile to KML. I wrote a tutorial on doing this at the GISCollective website a few months ago...
http://giscollective.org/tutorials/gis-techniques/spatial-data-conversion-using-python/
It should be enough to walk you through how to convert it to KML.
Once you have it converted to KML just go to Google Drive and create your Fusion Table, then upload the KML from your computer.
EDIT: After re-reading my tutorial, it seems I give an example of converting a shapefile to KML, so this should be exactly what you need


text:
Q: Ubuntu LXD iptables SNAT / Masquarade i have Ubuntu Server with LXD.
Every Container has own IP (local)address.
Example: LXD Host: 10.10.1.200, DNS container: 10.10.1.141, LXC inside address: 10.71.85.107
Ok - that no problem, incoming packages are translate:
iptables -t nat -A PREROUTING -d 10.10.1.141 -i ens160 -p udp --dport 53 -j DNAT --to-destination 10.71.85.107:53

and in iptables i have:
254K   18M DNAT       udp  --  ens160 *       0.0.0.0/0            10.10.1.141          udp dpt:53 to:10.71.85.107:53

work fine.
Problem is with outgoing package:
I need that outgoing packages from container have the same IP address.
The same example:
DNS container: outgoing packages should have address 10.10.1.141
So add to iptables this:
sudo iptables -t nat -I POSTROUTING -s 10.71.85.107 ! -d 10.71.85.0/24 -j SNAT --to-source 10.10.1.141

and in iptables i have this:
 166K   13M SNAT       all  --  *      *       10.71.85.107        !10.71.85.0/24        to:10.10.1.141

330 27582 MASQUERADE  all  --  *      *       10.71.85.0/24       !10.71.85.0/24        /* generated for LXD network lxdbr0 */

works fine!
Real problem is when i restart LXD host, then i have this in iptables:
    330 27582 MASQUERADE  all  --  *      *       10.71.85.0/24       !10.71.85.0/24        /* generated for LXD network lxdbr0 */
     166K   13M SNAT       all  --  *      *       10.71.85.107        !10.71.85.0/24        to:10.10.1.141

Masquerade is on the TOP! and all outgoing package have LXD Host address (10.10.1.200)
Is any chance to change this? Why LXD always set Masquerade first? Is any chance to change this?

A: That's a 2 months old question but as no one gave an answer and google often leads people to any of the Stack* sites, why not giving one.
I am going to focus on the question in the OP. I am completely ignoring the mentioned setup.

Why LXD always set Masquerade first? Is any chance to change this?

Yes, LXC allows you to at least somehow define where it is going to add its rules. Have a look at the Parameter Documentation of LXC-Networking : LXC Network Parameters
The parameter ip4.nat.order defines whether to add lxc NAT rules before or after pre-existing network rules.
You can view networks known to lxc from a shell via lxc network list
Editing a network is done by the command lxc network edit <network name>

Example:
A standard lxc network would be lxdbr0
Therefore just do lxc network edit lxdbr0 and add ip4.nat.order: "after" to the configuration.
config:
  ipv4.address: 10.0.4.1/24
  ipv4.nat: "true"
  ipv4.nat.order: "after"
description: ""
name: lxdbr0
type: bridge
used by:
- /1.0/containers/c1
- /1.0/containers/c2
- /1.0/containers/c3
managed: true
status: Created
locations:
- none

HINT: You can also keep lxc away from doing nat rules by setting ipv4.nat to false. You then need to do the masquerade rule yourself, but there may be use-cases benefiting from a setup like that.


text:
Q: Blade won't show data from PHPMyAdmin I have used a seeder to fill up data on my database! However, it doesn't show up on my blade file! and it just only the table. I tried various methods, including changing the route file and to add data directly from Phpmyadmin.
Blade

        Id
        bedrijven_id
        Body
        Created at
        Updated at
        <button type="button">Soliciteer</button>

    @if(isset($data))
        @foreach($vacatures as $vacature)

                {{$vacature['id']}}
                {{$vacature['bedrijven_id']}}
                {{$vacature['body']}}
                {{$vacature['created_at']}}
                {{$vacature['updated_at']}}

        @endforeach

Controller
class Vacatures extends Controller
{
    function viewLoad()
    {
        return view('vacatures');
    }

    function show() {
        $data = Vacature::all();

        return view('list', ['vacatures' => $data]);
    }
}

Route
Route::get('list',\[Vacatures::class,'show'\]);

A: The $data variable only exists within your controller, it is not passed through to the view.
Change this:
isset($data)

To this:
isset($vacatures)

A: As of comments from @ths and @Omar, the $data is not passed to view.
By additional, $vacatures is instance of Eloquent collection at all.So for readable, you can check $vacatures->isNotEmpty() instead of isset
New laravel version also supports blade @forelse (documentation)

A: Instead of isset($data) use isset($vacatures), because you passed vacatures to view file not data
@if(isset($vacatures))
    @foreach($vacatures as $vacature)

            {{$vacature['id']}}
            {{$vacature['bedrijven_id']}}
            {{$vacature['body']}}
            {{$vacature['created_at']}}
            {{$vacature['updated_at']}}

    @endforeach
@endif


text:
Q: Invalid response I am trying one example link http://www.semurjengkol.com/populating-android-listview-with-json-based-data-fetched-from-mysql-server-using-php/,i tried the same thing but i cant get the solution
activity_list_item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </ListView>

</LinearLayout>

Mainactivity.java
public class MainActivity extends ListActivity implements FetchDataListener{
    private ProgressDialog dialog;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            //setContentView(R.layout.activity_list_item);
            initView();
        }

        private void initView() {
            // show progress dialog
            dialog = ProgressDialog.show(this, "", "Loading...");

            String url = "http://10.0.2.2/test/apps.php";
            FetchDataTask task = new FetchDataTask(this);
            task.execute(url);
        }

        @Override
        public void onFetchComplete(List<Application> data) {
            // dismiss the progress dialog
            if(dialog != null)  dialog.dismiss();
            // create new adapter
            ApplicationAdapter adapter = new ApplicationAdapter(this, data);
            // set the adapter to list
            setListAdapter(adapter);
        }

        @Override
        public void onFetchFailure(String msg) {
            // dismiss the progress dialog
            if(dialog != null)  dialog.dismiss();
            // show failure message
            Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
        }
    }

Main issue i will mention here..
if i comment out the setcontent view not showing any error i can run also,but in emulatore its shwoing error of Invalid response
if i didnt comment out the linke logcat shows error like this
Content must have a ListView whose id attribute is 'android.R.id.list'
Logcat error:
5-17 11:30:30.649: E/AndroidRuntime(1177): FATAL EXCEPTION: main
05-17 11:30:30.649: E/AndroidRuntime(1177): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.jsonandroid/com.example.jsonandroid.MainActivity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
05-17 11:30:30.649: E/AndroidRuntime(1177):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
05-17 11:30:30.649: E/AndroidRuntime(1177):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-17 11:30:30.649: E/AndroidRuntime(1177):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-17 11:30:30.649: E/AndroidRuntime(1177):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-17 11:30:30.649: E/AndroidRuntime(1177):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-17 11:30:30.649: E/AndroidRuntime(1177):     at android.os.Looper.loop(Looper.java:137)
05-17 11:30:30.649: E/AndroidRuntime(1177):     at android.app.ActivityThread.main(ActivityThread.java:5039)
05-17 11:30:30.649: E/AndroidRuntime(1177):     at java.lang.reflect.Method.invokeNative(Native Method)
05-17 11:30:30.649: E/AndroidRuntime(1177):     at java.lang.reflect.Method.invoke(Method.java:511)
05-17 11:30:30.649: E/AndroidRuntime(1177):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-17 11:30:30.649: E/AndroidRuntime(1177):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-17 11:30:30.649: E/AndroidRuntime(1177):     at dalvik.system.NativeStart.main(Native Method)
05-17 11:30:30.649: E/AndroidRuntime(1177): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
05-17 11:30:30.649: E/AndroidRuntime(1177):     at android.app.ListActivity.onContentChanged(ListActivity.java:243)
05-17 11:30:30.649: E/AndroidRuntime(1177):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:273)
05-17 11:30:30.649: E/AndroidRuntime(1177):     at android.app.Activity.setContentView(Activity.java:1881)
05-17 11:30:30.649: E/AndroidRuntime(1177):     at com.example.jsonandroid.MainActivity.onCreate(MainActivity.java:17)
05-17 11:30:30.649: E/AndroidRuntime(1177):     at android.app.Activity.performCreate(Activity.java:5104)
05-17 11:30:30.649: E/AndroidRuntime(1177):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
05-17 11:30:30.649: E/AndroidRuntime(1177):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
05-17 11:30:30.649: E/AndroidRuntime(1177):     ... 11 more

what it might be the solution,is this any problem in example or URL problem

A: The URL http://10.0.2.2/test/apps.php indicates your localhost. you must have your php files and running php server to successfully execute the client program.


text:
Q: How to convert a whole number(which is minutes) to a time format DD:HH:MM First of all, thank you for reading this question
So, I have a set of data which is the difference between two date in "minutes" the raw data type is "Whole Number"
I would like to convert it to be "DD:HH:MM", not sure if anyone could help me, thank you so much!

A: AFAIK, Power BI does not have or recognize a duration type.  If you want to display in that format, it will need to be text.
In Power Query you can transform that column to text with code such as:
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W0jU0NDVUitUBskwtTSAMYwhtCSZNzCAcCzBlZAjhGhqbQATMzC3NlWJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Minutes = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Minutes", Int64.Type}}),
    #"Transform to Duration" = Table.TransformColumns(#"Changed Type", {"Minutes", each Duration.ToText(#duration(0,0,_,0)), type text})
in
    #"Transform to Duration"

Then, in Desktop, format that column as Text
If you need to do calculations on the duration, you may want to add a column instead of transforming the column, or do the calculations in Power Query.

A: //You can use this
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"duration", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each [duration]/1440),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type duration}})
in
    #"Changed Type1"


text:
Q: react-native : onPress doesn't work I work on an onPress event on react native.
At a first time, I wrote that code :
<TouchableOpacity
    onPress={(this.props.minimum==null||this.props.value-1>=this.props.minimum)
        ? this.props.onDecrement
        :console.log(this.props.texte+" : minimum atteint")}
    style={[buttonSpinner,buttonSpinnerLeft]}>

With that, my button works, but onPress is called automatically on each render() call.
I search and I found a solution here : React Native onPress being called automatically.
But now, if I don't have any automatic call... I don't have call when I press on my Touchable component.
I try some versions :
const p=this.props;
//some other code
<TouchableOpacity
    onPress={()=>(p.minimum==null||p.value-1>=p.minimum)
        ? p.onDecrement
        :console.log(p.texte+" : minimum atteint")}
    style={[buttonSpinner,buttonSpinnerLeft]}>

--
const p=this.props;
// some other code
<TouchableOpacity
    onPress={(p)=>(p.minimum==null||p.value-1>=p.minimum)
        ? p.onDecrement
        :console.log(p.texte+" : minimum atteint")}
    style={[buttonSpinner,buttonSpinnerLeft]}>

--
<TouchableOpacity
    onPress={()=>(this.props.minimum==null||this.props.value-1>=this.props.minimum)
        ? this.props.onDecrement
        :console.log(this.props.texte+" : minimum atteint")}
    style={[buttonSpinner,buttonSpinnerLeft]}>

Without success...
Precision, I work on a separated component. This component is called in a main render like that :
<NumberSpinner
    onDecrement = {()=>this.onDecrement(elt.idCat,idElt)}
    onIncrement = {()=>this.onIncrement(elt.idCat,idElt)}
    minimum = {0}
    maximum = {null}
    texte = {elt.slug}
    value={elt.qteTxt}
/>

A: Try to move your logic in a function so use the onPress with a function call only
<TouchableOpacity
         onPress={this.onPress}
       >
   <Text> Touch Here </Text>
</TouchableOpacity>

and your function:
onPress = () => {
   //your logic here
  }

A: You need to import TouchableOpacity from react-native instead of importing it from react-native-gesture-handler. The version in react-native-gesture-handler is 100% broken. The version in react-native works.
The accepted answer does not solve this problem.


text:
Q: Rails Association, Scope, JoinModel UPDATE: Here is how we settled it.  ran MYSQL Explain on the sql generated by both snippets of code:
Manifest.where(assembly_id => @assembly.id).where(part_id => @part.id).exists?
NO JOINS AND RAN FASTER -- SO IT WON!
I have the following situation:
class Assembly < ActiveRecord::Base
  has_many :manifests
  has_many :parts, :through => :manifests
end

class Manifest < ActiveRecord::Base
 belongs_to :assembly
 belongs_to :part
end

class Part < ActiveRecord::Base
 has_many :manifests
 has_many :assemblies, :through => :manifests

end
So, as geeks do my colleagues and I got into a contentious argument about the following:
Given a part and an assembly find if they are on the same manifest.
Solution one (using associations):
 @part.assemblies.include? @assembly

Solution two (using scopes):
 Manifest.where(assembly_id => @assembly.id).where(part_id => @part.id).exists?

Solution one does an inner join to get the data and it drove the camp that hates spanning tables nuts.  But it is terse and not ugly.
Solution two does not do an inner join and uses scopes (ie the where clauses), but it is a bit ugly.
Solution one is being called inefficient and when profiled it does in fact run a tiny bit slower.
Any thoughts on best practices for this situation.
Btw, I grabbed the code from the Rails guides in order to illustrate the issue.

A: I would do it one of the following 2 ways, not for performance reasons, just for clarity of expression:
Are there any manifests belonging to @assembly and @part?
Manifest.where(assembly_id: @assembly.id, part_id: @part.id).any?

Or, do @assembly and @part share any manifests?
(@assembly.manifests & @part.manifests).any?


text:
Q: How to send custom get request using Odata4j I want to send following GET request using Odata4j
http://**.**.***.***:****/sap/opu/odata/sap/
                                         MOBILE_SERVICES/EmpPernrs
                                               (name='abc',lastName='xyz')

can anybody tell me how to send such request to OData server using OData4j consumer object.
I have created consumer object like:
ODataConsumer.Builder builder = ODataConsumers
                    .newBuilder("http://**.**.***.***:****/sap/opu
                    /odata/sap/MOBILE_SERVICES/");
builder.setClientBehaviors(authenticationBehavior);
consumer = builder.build();


text:
Q: Star Wars: Battlefront II EA Trailer - Who is the figure in red giving Versio orders? ** WARNING POSSIBLE SPOILERS AHEAD **
Judging by the color and style of his apparel, I am guessing he is perhaps a member (or ex-member) of the Imperial Guard. Possibly the Captain. Because the majority of the single player storyline will take place after the destruction of the second Death Star and the Emperor's demise, it is not unlikely that the Captain of his Imperial Guard would be left in some position of High Imperial Command. (Admittedly unlikely however, that he would be given command of a ship. Imperial Guards aren't trained for naval command.)
Also I believe I have identified his species. Judging by the pale skin and black rhombus-like line tattoo, he is Rattataki. However he is only seen through what appears to be some sort of holoprojection device (as seen by the static and glitches that can be noticed), perhaps projecting the image of his head over a robotic body. Therefore the pale skin could simply be the blue tint of the holo, but the tattoo is still present and I stand by my claim.
It's not entirely impossible either that he is some type of Sith, however plenty of other Star Wars stories have already bent (if not flat out broken) the rule of two. Ex: The Force Unleashed Series, Star Wars Rebels, Mara Jade (Multiple Appearances), etc. | Which leads me to believe EA may not want to add their game to that list with the overdone plot.
So who and what is he? Any help on this matter or additional theories would be greatly appreciated, many thanks to those who contribute.

A: The figure in red is a sentinel, a type of droid that gave out orders to Imperial commanders after Palpatine's death. They were used to direct and brief high-ranking Imperials on initiating  Operation: Cinder.


text:
Q: Simple QR Code - Merge text within the QR-Code / save numbers as png I'm currently using this Plugin to generate QR-Codes on my site. These QR-Codes are used for products, so it refers to a special product when downloading.
This is the code I use to generate it and make it able to be downloaded:
   <a href="data:image/png;base64, <?php echo base64_encode(QrCode::format('png')->size(500)->encoding('UTF-8')->errorCorrection('H')->generate('https://localhost/product/'.$product->id));?> "
                                           download=<?=$product->name."_QRCode";?>>
                                            <img src="data:image/png;base64, <?php echo base64_encode(QrCode::format('png')->margin(1)->size(50)->encoding('UTF-8')->errorCorrection('H')->generate('https://localhost/product/'.$product->id));?>">

Now comes the clue: Like this, somebody could download 10 QR-Codes but would have no idea, where this QR-Code belongs to. Therefore, I want the downloaded QR-Code to be merged with a string... But as the docs say, that The merge method only supports PNG at this time I guess it's not possible to do this directly. But I'm wondering if there is a way in PHP (and also with Laravel, which I'm using, if this changes something) to generate an image (a png) out of a string I enter, so something like (pseudoCode follows):
$mergeText = $product->name;
$image = stringToPng($mergeText);
//maybe instead convert to base64 image, like the qr-code? don't know
QrCode::format('png')->size(500)->encoding('UTF-8')->errorCorrection('H')->merge($image)->generate('https://localhost/product/'.$product->id));?>

Does anybody know if this is possible?

A: It's possible, but not in the way you are trying to do it.
First, you have to convert your text to an image. How to do this should be your main question, you can try with this answer: convert text to image in php.
When you already have the PNG image, then you will be able to use the merge method.


text:
Q: Regarding scope of some variable Can I use the "str" named variable in the code below outside of try block the way I have?
I am a bit confused.
if ()
{
 try
 {
  String str;
 }
 catch
 {
  //exception
 }
 String result=str; // Will this work ??? It's inside of IF block only.
}

A: Assuming you wanted to have string result = str; ... no it wont work.

A: No, anything you declare inside the try block can only be used within the scope of the try block.
The only way to access a variable you use in the try block somewhere else would be to declare it before the try block.

A: I think your question is can you reference a variable that's defined in a try block from outside the try block. The answer is no, however you can reference a variable defined outside the try block and set within the try block as follows:
string myVar;

try
{
   myVar = "something";
}
catch {}

// now you can set otherVar to "something"
string otherVar = myVar;

A: Always declare variables before the try catch block and initialise it to null or default value, whichever is applicable.
Doesn't matter if you'll use variable in try or catch or finally or won't use it at all. It will save you trouble in future and it will improve the readibility of your code.
public void processSomeRequest()
{

   string firstVariable = null;
   string secondVariable = null;
   int someInt = 0;

   try
   {
       // Initialise variables
       firstVariable = "test";
       secondVariable = "blah";

       // Process request code
   }
   catch(Exception e)
   {
       logException(e);
       throw;
   }

}

Basic example, but you know what you are going to work with from very start. Unused variables will be highlighted.

A: No.  The declaration is limited to the try block only.  You won't even be able to use it in the catch block.

A: If you declare a variable within a scoped block (anything within {}), it can only be using within it.

A: No, declare your "str" outside of the try {} block.


text:
Q: Embedding algebraic surfaces in projective space Suppose I have a smooth complete surface $S$ embedded in $\mathbf{P}^n$. Is there a known or conjectured lower bound (preferably sharp) on the degree of $S$ in terms of its numerical invariants?
In the case of curves this is the classical Castelnuovo bound (http://en.wikipedia.org/wiki/Castelnuovo_bound).

A: This is not really an answer, but it's too long for a comment: since Alex was asking for bound in terms of numerical invariants, I'll try to give another point of view (which will be certainly less precise of Harris' result explained by jvp) which could perhaps be of some interest.
Let $S$ be a smooth surface and suppose $A\to X$ is an ample line bundle. Then some multiple $m_0 A$ of $A$ will give an embedding of $S$ in some projective space $\mathbb P^N$. After the embedding, the very ample line bundle $m_0 A$ "becomes" isomorphic tautologically to the restriction $\mathcal O_X(1)$ of $\mathcal O(1)$ to $X$, and the degree of $S$ relative to this embedding is just $\mathcal O_X(1)^2=m_0^2 A^2$.
Now, given an ample line bundle $A$ on a $n$-dimensional smooth projective manifold, an important problem of algebraic geometry is to find effective bounds $m_0$ such that multiples $mA$ of $A$ become very ample for $m \ge m_0$ . From a theoretical point of view, this problem has been solved by Matsusaka and Kollár-Matsusaka. Their result is that there is a bound $m_0 = m_0 (n, A^n, A^{n−1}\cdot K_X )$ depending only on the dimension and on the first two coefficients $A^n$ and $A^{n−1}\cdot K_X$ in the Hilbert polynomial of $A$.
Later on, Siu gave an effective version of the Big Mastusaka theorem, which reads as follow:
Theorem. (Siu '93). Let $A$ be an ample holomorphic line bundle over a compact complex manifold $X$ of complex dimension $n$ with canonical line bundle $K_X$. Then $mA$ is very ample for
$$
m\ge m_0:=\frac{(2^{3^{n-1}}5n)^{4^{n-1}}(3(3n-2)^nA^n+K_X\cdot L^{n-1})^{4^{n-1}3n}}{(6(3n-2)^n-2n-2)^{4^{n-1}n-\frac 23}(A^n)^{4^{n-1}3(n-1)}}.
$$
Thus, if you fix any polarization on your (abstract) manifold, then you get a lower bound on the degree of the embedding with respect to this polarization only in numerical terms.

A: Perhaps this paper of Harris is what you are looking for: A bound on the geometric genus of projective varieties.  It generalizes Castelnuovo's bound to smooth projective varieties of arbitrary dimension. In page 44, we find the following statement:

Theorem. Let $V$ be a non-degenerated smooth
  and irreducible variety of dimension
  $k$ and degree $d$ in $\mathbb P^n$.
  If we set $M=\left[
> \frac{d-1}{n-k}\right]$ then  $$
>  h^0(V,\Omega^k_V) \le \binom{M}{k+1} (n-k) + \binom{M}{k} (d-1-M(n-k)). $$
  In particular, if $d \le k(n-k) + 1$ then $h^0(V, \Omega^k_V)=0.$


text:
Q: android onWindowFocusChanged i want to override the method onWindowFocusChanged, but everytimei write it elcipse gives me a error message saying @override annotation is wrong, which means that i am not overriding the method but creating a new one.
maybe i havnt included the package necessary ???

A: are you using the following code:
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    // your code here
}

The difference is there is a Boolean type and a boolean type.  This code gives me no annotation warnings in Eclipse.

A: This is due to you having Java version set to something other than 1.6. Go to project->properties->Java compiler and set compliance level to 1.6

A: Check your super-class and get the method signature from there, including visibility (private, protected, public...) return type, method name, and arguments.


text:
Q: Zero-Initialize array member in initialization list I have a class with an array member that I would like to initialize to all zeros.
class X
{
private:
    int m_array[10];
};

For a local variable, there is a straightforward way to zero-initialize (see here):
int myArray[10] = {};

Also, the class member m_array clearly needs to be initialized, as default-initializing ints will just leave random garbage, as explained here.
However, I can see two ways of doing this for a member array:
With parentheses:
public:
    X()
    : m_array()
    {}

With braces:
public:
    X()
    : m_array{}
    {}

Are both correct? Is there any difference between the two in C++11?

A: Initialising any member with () performs value initialisation.
Initialising any class type with a default constructor with {} performs value initialisation.
Initialising any other aggregate type (including arrays) with {} performs list initialisation, and is equivalent to initialising each of the aggregate's members with {}.
Initialising any reference type with {} constructs a temporary object, which is initialised from {}, and binds the reference to that temporary.
Initialising any other type with {} performs value initialisation.
Therefore, for pretty much all types, initialisation from {} will give the same result as value initialisation. You cannot have arrays of references, so those cannot be an exception. You might be able to construct arrays of aggregate class types without a default constructor, but compilers are not in agreement on the exact rules. But to get back to your question, all these corner cases do not really matter for you: for your specific array element type, they have the exact same effect.

A: The types of initialization can be kind of tedious to go through, but in this case it is trivial. For:
public:
    X()
    : m_array()
    {}

since the expression-list between the parentheses are empty, value-initialization occurs. Similarly for:
public:
    X()
    : m_array{}
    {}

list-initialization occurs, and subsequently value-initialization since the brace-init-list is empty.

To give a more comprehensive answer, let's go through §8.5 of N4140.

*If no initializer is specified for an object, the object is
  default-initialized. When storage for an object with automatic or
  dynamic storage duration is obtained, the object has an indeterminate
  value, and if no initialization is performed for the object, that
  object retains an indeterminate value until that value is replaced
  (5.17).

This indeterminate value is what you refer to as garbage values.

*To zero-initialize an object or reference of type T means:
— if T is an array type, each element is zero-initialized

*To value-initialize an object of type T means:
— if T is a (possibly cv-qualified) class type ... then the object is default-initialized; ...
— if T is an array type, then each element is value-initialized;
— otherwise, the object is zero-initialized.

*The semantics of initializers are as follows. ...
  — If the initializer is a (non-parenthesized) braced-init-list, the object or reference is list-initialized (8.5.4).
— If the initializer is (), the object is value-initialized.

So far it's clear that value initialization will make each element of the array zero since int is not a class type. But we have not yet covered list initialization and aggregate initialization, since an array is an aggregate.
§8.5.4:

*List-initialization of an object or reference of type T is defined as follows:
— If T is an aggregate, aggregate initialization is performed (8.5.1).

And back to §8.5.1:

*If there are fewer initializer-clauses in the list than there
  are members in the aggregate, then each member not explicitly
  initialized shall be initialized from its brace-or-equal-initializer
  or, if there is no brace-or-equal-initializer, from an empty
  initializer list (8.5.4).

And we end with §8.5.4 again:

*List-initialization of an object or reference of type T is defined as follows:
— Otherwise, if the initializer list has no elements, the object is value-initialized.

Since traversing the (draft) standard can take breath out of you, I recommend cppreference as it breaks it down pretty good.
Relevant links:
cppreference:

*

*aggregate initialization

*value initialization
Draft standard:

*

*N4140

A: Parentheses work in C++98, and are calling for zero initialization, which is what you want. I verified on gcc 4.3. Edit: removed incorrect statement about C++11. I also confirmed that empty braces perform empty-list-initialization using clang 3.4 with -std=c++11.


text:
Q: Local dns server acts unreliably In our local subnetwork we have a domain server. It's a Windows Server 2008 R2.
It was configured by following this guide I think.
My main domain is wm.local. My server is domainserver.wm.local. My devices are dev1.wm.local, dev2.wm.local etc.
It works fine most of the time, but sometimes a client cannot resolve an other device's domain name. For example I can ping the IP address of an other client, but pinging the FQDN results in: `Ping request could not find host dev2.wm.local. Please check the name and try again.'
when I whip up nslookup, I can actually look up dev2.wm.local without any problems:
> set q=a
> dev2.wm.local
Server:  domainserver.wm.local
Address:  192.168.1.203

Name:    dev2.wm.local
Address:  192.168.1.102

So the given domain can be resolved.
Restarting my network adapter solves the problem temporarily.
But for example ipconfig /flushdns does not solve the problem, the host is still unreachable for any request (ping, http, and remote desktop are the ways I'm trying).
Since this happens on more than one clients, I'm guessing that there is something misconfigured on the server.
What would be the best way to find the source of the problem?
Since I'm a programmer and not a system administrator I'm trying to search for a solution on the internet, but I have no first hand experience on how to configure a dns server.
Here is the output for ipconfig /all:
Windows IP Configuration

   Host Name . . . . . . . . . . . . : DEV7
   Primary Dns Suffix  . . . . . . . : wm.local
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : wm.local

Ethernet adapter Local Area Connection 2:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : TAP-Win32 Adapter OAS
   Physical Address. . . . . . . . . : XX-XX-XX-XX-XX-XX
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Broadcom NetLink (TM) Gigabit Ethernet
   Physical Address. . . . . . . . . : XX-XX-XX-XX-XX-XX
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 192.168.1.107(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.253
   DNS Servers . . . . . . . . . . . : 192.168.1.203
                                       194.149.0.157
                                       194.149.0.156
   NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter VirtualBox Host-Only Network:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : VirtualBox Host-Only Ethernet Adapter
   Physical Address. . . . . . . . . : 08-00-27-00-54-58
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::1122:84df:5fdf:99bd%20(Preferred)
   Autoconfiguration IPv4 Address. . : 169.254.153.189(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.0.0
   Default Gateway . . . . . . . . . :
   DHCPv6 IAID . . . . . . . . . . . : 369623079
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-14-DD-C7-42-F0-4D-A2-2F-40-D5

   DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
   NetBIOS over Tcpip. . . . . . . . : Enabled

Tunnel adapter isatap.{C60B2904-AF7F-4C0F-94C3-AFF4718D6AE8}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft ISATAP Adapter
   Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

Tunnel adapter Teredo Tunneling Pseudo-Interface:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Teredo Tunneling Pseudo-Interface
   Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

Tunnel adapter isatap.{E3A87D29-B780-42CC-86F7-654B994B6BB2}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft ISATAP Adapter #3
   Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

Tunnel adapter isatap.{9CC8F02B-BC21-4D34-8484-300C76989FC4}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft ISATAP Adapter #5
   Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

A: The problem is you have 3 DNS servers listed.  and 2 of them appear to be your ISPS. Remove 194.149.0.157 and 194.149.0.156 as DNS servers, since if you ask them you will get NXdomain.  DNS doesn't ask all 3 for an answer, it picks one and if it doesn't answer tries another, but if it answers (even negatively) that answer will be used.   You can add those 2 name servers as forwarders to take advantage of their cache. but do that from your dns server, not the clients.


text:
Q: jQuery - how to loop remove only certain child nodes? Say I have something like this:

I want jQuery to loop through the p tag and remove all the line break tags. Keep in mind I have to find the p element by first finding the image element which is the only element that has a unique identifier.
I tried some loops and looked in the docs but don't seem to get it right.

A: $("#unique").parent().find("br").remove();

A: Is this what you're looking for?
   $("#unique").parent('p').find('br').remove();

A: you can select the #unique and the closest() p tag using the following
$('#unique').closest('p'))

or,
$('#unique').parent()

Then to select the br, you can chain any of the above:
$('#unique').parent().find('br')

For deleting, the complete code is:
$('#unique').parent().find('br').remove()

A: Try this
$("p").each(function(){
     $(this).find("br").remove();
});

A: See it here http://jsfiddle.net/arvind07/EqVf5/
if ($('p').has('#unique')) {
    $('p').find('br').remove();
}


text:
Q: Where to place files when File.Exists is executed in a class library but called from a MVC project? I have a solution which has two presentation layers. One is using ASP.NET MVC, the other WinForms.
Both projects depend on a third projecs which does some business logic and is a class library. The third project has the following method which works fine in WinForms, but doesnt work in MVC:
    public static string[] Dictionary()
    {
        if (_dictionary == null)
        {
            if (File.Exists("dict.txt"))
                _dictionary = File.ReadAllLines("dict.txt");
        }

        return _dictionary;
    }

So when I am using the WinForms GUI the file is found, but when I am using the MVC website, the project can't find it.
When building the solution dict.txt is placed in bin/debug of the WinForms project.
It is placed in /bin in the MVC project.
Where should I place the file in the MVC proejct?

A: You can place them in the App_Data Forlder, and then reference them like this
 var fileName = Path.Combine(System.Web.HttpContext.Current.Server.MapPath(@"~/App_Data"),"dict.txt");

A:
So when I am using the WinForms GUI the file is found, but when I am using the MVC website, the project can't find it.

To answer the reason why you are observing the difference is called the current working directory. By default, when VS.NET launches Windows apps or consoles, the working directory is to the relevant bin directory.
All relative file operations, such as File.ReadAllLines("the.file"), will concatenate to an absolute file path as per below.
Path.Combine(Directory.GetCurrentDirectory(), "the.file");

ASP.NET's working directory would not correlate to the root of your web application.

Where should I place the file in the MVC proejct?

As suggested by @dariogriffo, it should be placed in the ~/App_Data/* directory.

I have a solution which has two presentation layers. One is using ASP.NET MVC, the other WinForms. Both projects depend on a third projecs which does some business logic and is a class library.

So now you are in a little bit of a pickle over here with your current implementation and the way the current working directory is implemented. Without delving into too much detail, I suggest that the code figures out how to load the file indirectly such as passing in an interface with a contract such as the following.
public interface IDictionaryRepository {
    IEnumerable<string> LoadAllWords();
}

With the above, you can change your business logic to the following
public static string[] Dictionary()
{
    if (_dictionary == null)
    {
        _dictionary = _dictionaryRepository.LoadAllWords().ToArray();
    }

    return _dictionary;
}

The benefit of the above abstraction is that you may then easily substitute the file finding logic as per the other suggestions easily, and maybe migrate your dictionary to be hosted in a database somewhere.

A: server applications can have 2 paths - virtual and logical. You can reference to one or another using MapPath() method.
Server.MapPath("."), Server.MapPath("~"), Server.MapPath(@"\"), Server.MapPath("/"). What is the difference?
I thinki you need to provide full path to this file in MVC, check this out:
Server.MapPath("~\\bin\\dict.txt")


text:
Q: Do We Have Any Special Transform For $(i)(e^{(-2iw)})$ I have Signals and Systems course. Generally we use $j$ instead of $i$. So in here you can think $j$ as a complex number $i$.
In the solution which uses Euler's first step, i see that transform.
$2j(e)^{-j2w}\sin(2w)=2\sin(2w)\cdot (e)^{j(\pi/2-2w)}$.
I underlined it in the screenshot. How can we have transform like that?

A: Think of the intuition behind complex multiplication. Recall that any complex number $|z|=1$ (The distance from the origin to $z$) can be represented on the unit circle by Euler's Theorem as $z=e^{j\theta}$, where $\theta$ is that angle between the ray that runs from the origin to $z$ and ray starting at the origin and running along the x-axis.
By this result, the product of two complex numbers $z_1,\: z_2$ can be expressed as $z_1z_2=e^{j(\theta_1+\theta_2)}$. All we are doing here is rotating the point around the origin.
To complete the idea, note that $j$ corresponds to a ray along the y-axis, and $|j|=1$. Hence, $j=e^{j\pi/2}$. Your result follows.
Source
https://en.wikipedia.org/wiki/Euler%27s_formula