text:
Q: ACR35: APDU command select file returns status 6A 82 (file not found) I am testing an ACR35 and I am having this issue with the provided SDK.
I have a DESFire EV1 card which has the following file structure:
[ Master File ]
      |
      |___ [ AID - F222222222  (Dedicated file) ]
                   |
                   |___ [ File id - 0001 (Elementary File) ]

I have verified that this file structure really exists on the card with another reader (Android device with integrated NFC reader).
I am selecting the DF (by its AID) with this code:
public void powerOn(){
    if (mReader.piccPowerOn(timeout, cardType)) {
        Log.i(TAG, "poweron true");
        byte[] test = ApduCommand.HexStringToByteArray("00A4040005F222222222");
        /*Transmit the command to the reader with timeout: 5 sec*/
        mReader.piccTransmit(timeout, test);
    }else{
        Log.i(TAG, "poweron false");
        powerOn();
    }
}

And I am waiting for the response here:
/* Set the PICC response APDU callback. */
mReader.setOnPiccResponseApduAvailableListener(new AudioJackReader.OnPiccResponseApduAvailableListener() {
    @Override
    public void onPiccResponseApduAvailable(AudioJackReader reader, byte[] responseApdu) {
        String resultHex = ApduCommand.ByteArrayToHexString(responseApdu);
        Log.i(TAG, "APDU response ("+current_status+")" + resultHex);

        if(resultHex.equals("9000")) {
            if (current_status == STATUS_SELECT_AID) {
                if (mReader.piccPowerOn(timeout, cardType)) {
                    Log.i(TAG, "selecting file");
                    byte[] selFile = ApduCommand.HexStringToByteArray("00A40200020001");
                    current_status = STATUS_SELECT_FILE;
                    mReader.piccTransmit(timeout, selFile);
                } else {
                    Log.i(TAG, "timed out..");
                }
            }else if(current_status == STATUS_SELECT_FILE) {
                if (mReader.piccPowerOn(timeout, cardType)) {
                    Log.i(TAG, "reading binary data");
                    byte[] readBinary = ApduCommand.HexStringToByteArray("00B0000000");
                    current_status = STATUS_READ_DATA;
                    mReader.piccTransmit(timeout, readBinary);
                } else {
                    Log.i(TAG, "timed out..");
                }
            }
        }
    }
});

Here, I get a success status (90 00) on selecting the DF but I get a file not found status (6A 82) while selecting the file.
Log are as follows:
12-28 18:17:02.752 27298-28923/com.example.m1alesis.smartcardreader I/acrx: APDU response (0)9000
12-28 18:17:02.752 27298-28923/com.example.m1alesis.smartcardreader I/acrx: selecting file
12-28 18:17:03.412 27298-28949/com.example.m1alesis.smartcardreader I/acrx: APDU response (1)6A82

Using the same card and the exact same APDU commands on Android NFC reader mode works fine and I am able to select the file but ACR35 doesn't seem to like multiple sequential APDU commands.
Github project: https://github.com/rthapa/smartcardreader

A: Don't call mReader.piccPowerOn(timeout, cardType) between sending APDUs. The method piccPowerOn() will cause the reader to reset the DESFire card. Consequently, the application F222222222 will no longer be selected when you execute the SELECT (by FID) command 00 A4 0200 02 0001.


text:
Q: d3 - Uncaught TypeError: Cannot call method 'attr' of null Here is my code:
var svg = d3.select("body").append("svg");
console.log(svg.attr);
svg.attr("width", width + margin.left + margin.right);
svg.attr("height", height + margin.top + margin.bottom);
svg.append("g");
svg.attr("transform", "translate(" + margin.left + "," + margin.top + ")");

The console.log(svg) outputs:
function (t,e){if(arguments.length<2){if("string"==typeof t){var n=this.node();return t=ja.ns.qualify(t),t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}for(e in t)this.each(xe(e,t[e]));return this}return this.each(xe(t,e))}

However when I try to call svg.attr method right after that, I get this in the console:
Uncaught TypeError: Cannot call method 'attr' of null

Can anybody explain this? Clearly svg is not null as I log it in console before trying to use it...

redpajama_set_name: RedPajamaStackExchange


text:
Q: Compiling WIN32 code with GCC I have tried to compile some C++ WIN32 code with GCC through DevC++ (MinGW GCC). It seams that it failed to link the objects and it didn't give me a clear error message: "[PathToSource] > Error 1".
Tried the same thing with Eclipse (MinGW GCC) and it compiled. However, not all of the resources show as I have an icon set to compile as the icon of the application, it's loaded from the resource files. I also get a console window in the background as I run the application.
What is the cause of this? How can I make the resource files compile with the code and also avoid the loading of a console window in the background.
I was also wondering if there's a way to compile WIN32 code in Linux through GCC, or a way to port it for the same compiler.

A: Try compiling in command prompt and see what happens.
for your resource file try this in the command prompt.
windres resource_file.rc -o resource_file.o and finally to build your code, g++ resource_file.o -o app.exe app.cpp

A:
I have tried to compile some C++ WIN32
  code with GCC through DevC++ (MinGW
  GCC). It seams that it failed to link
  the objects and it didn't give me a
  clear error message: "[PathToSource] >
  Error 1".

Have you included a path to the Windows SDK? On my computer it is at:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\x64
(Note I have Visual Studios Installed on my Computer)
Compile you program with the appropriate gcc library settings.

Tried the same thing with Eclipse
  (MinGW GCC) and it compiled. However,
  not all of the resources show as I
  have an icon set to compile as the
  icon of the application, it's loaded
  from the resource files. I also get a
  console window in the background as I
  run the application.

Check the resource settings to see where Eclipse is referencing your Windows Library.

What is the couse of this? How can I
  make the resource files compile with
  the code and also avoid the loading of
  a console window in the background.

Develop your applications in Visual Studio. If you cannot afford Visual Studio and you are a hobby programm consider Visual Studios Express.

I was also wondering if there's a way
  to compile WIN32 code in Linux through
  GCC, or a way to port it for the same
  compiler.

If you mean the WINAPI, then no, not as far as I know. If you want compatibility you should stick with the standard C++ library.
There are, however, universal libraries that you might find useful:

*

*http://sourceware.org/pthreads-win32/

*http://stdcxx.apache.org/#platforms

*http://www.gtk.org/download-windows.html

*Cross Platform Lbiraries (Stackoverflow)

A: Resource files in Eclipse:
In the Build Steps of the project, there needs to be entered the command and the full path to the resource and its output file.
windres ../Resources/resource_file.rc -o ../Debug/resource_file.o

In the Tool Settings of the project in the linker options, the path to the resource output file needs to be added in order for the resources to be linked into the executable file.
../Debug/resource_file.o

Avoid the console window:
A linker flag needs to be specified for GUI only.
-mwindows

In Eclipse:
Enter the flag in the project Tool Settings in Linker flags.


text:
Q: Why does EF Read my Unchanged Object on SaveChanges? As part of some tests of Entity Framework Code First I'm testing the change tracking. In a small test database I have two cars in a table that I run a test method against:
Debug.WriteLine("Reading cars...");
var cars = context.Cars.ToArray();
Debug.WriteLine("Updating top speed of first car...");
Debug.WriteLine(string.Format("Type of car[0] is {0}", cars[0].GetType().ToString()));
cars[0].TopSpeed = 260;

Debug.WriteLine("Saving changes...");
context.SaveChanges();

I've added trace output to the getters and setters of the TopSpeed and Brand properties of the Car class to see how they are accessed. TopSpeed is an int? and Brand is a navigation property to the Brand entity. Running the above code gives the output below.

Reading cars...
Setting TopSpeed to 210 for ABC123.
Car: Getting TopSpeed for ABC123.
Setting TopSpeed to 250 for XYZ987.
Car: Getting TopSpeed for XYZ987.
Updating top speed of the first car...
Type of car[0] is System.Data.Entity.DynamicProxies.Car_18E3E11297DC48759312BDF1C2FFEBE9F19BAE5D487CED2A9781A6CA730071EA
Setting TopSpeed to 260 for ABC123.
Saving changes...
Car: Getting Brand for ABC123.
Car: Getting Brand for XYZ987.
Car: Getting TopSpeed for ABC123.
Car: Getting TopSpeed for ABC123.
Car: Getting TopSpeed for XYZ987.
Car: Getting TopSpeed for ABC123.
Car: Getting TopSpeed for ABC123.
Car: Getting TopSpeed for ABC123.
Car: Getting TopSpeed for ABC123.
Car: Getting TopSpeed for ABC123.

The type of the object is an EF dynamic proxy for change tracking. Still, when calling SaveChanges() the properties of the unchanged XYZ987 car are read. I thought that change tracking would cause EF to only read the objects that were known to change, or am I missing something? Is there something else I need to add to enable change tracking?

A: Even though all requirements for a change tracking proxy was fulfilled, EF still uses the automatic change tracking unless explicitly turned off:
context.Configuration.AutoDetectChangesEnabled = false;

The documentation on AutoDetectChangesEnabled is confusing:

True if the automatic detection of changes in the configuration is
  enabled; otherwise, false.

Looking at the ADO.NET's blog they explain it correctly.

A: There is a bug (or rather, lack of an optimization) in EF 4.1, 4.2, and 4.3 running on .NET 4 which causes DetectChanges to process entities that should be known to not need change tracking. This is because EF running on .NET 4 does not keep track of whether or not there are any entities that need change tracking or not, so it has to check each time.
This is fixed on EF5 when running on .NET 4.5, which will be available in beta very soon now. I just verified that with EF5 on .NET 4.5 the getters for properties of unchanged change-tracking proxies are not called in SaveChanges, even with AutoDetectChangesEnabled set to true.
That being said, even on EF 4.1-4.3 I don't believe that the getter should be called if all EF is doing is checking whether or not the entity is a change tracking proxy, so it seems like there might be another bug here.

A: To enable dynamic change tracking you need make all your scalar(non navigational) properties virtual.


text:
Q: How to center image, when i open it in current window I have a problem with image centering. I open image in current window by clicking on it, but it looks wrong..How it looks now
How I should fix it?
Here is my html markup:

and here is my js methods:
expand = function (a) {
var me = a.src;
$(a).after("");
$('#2rmv').css({
    'position': 'absolute',
    'width': '500px !important',
    'height': '400px !important',
    'right': '1%',
    'z-index': '10001',
    'display': 'block',
    'border': '2px groove white',
    'border-radius': '10px'
});
$('#bgdiv').css({
    'background-color': 'black',
    'height': '100%',
    'text-align': 'center',
    'left': '0px',
    'opacity': '0.7',
    'position': 'fixed',
    'top': '0px',
    'width': '100%',
    'z-index': '10000'
});
$('#bgdiv').on('click', function () {
    $('#bgdiv').removeAttr("style");
    $('#2rmv').remove();
});
};

If I add 'left' parameter instead of 'right', the last element shows wrong..

A: A very quick google Search gave me following answer in under 10seconds:
Apply following css to your image div:
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%)


text:
Q: How to get wkwebView content size in swift How to get wkwebView's scrollView content size in swift. My wkwebView inside collectionViewCell and when i try get content height like this, it returns cell content size
func webView(webView: WKWebView, didFinishNavigation navigation: WKNavigation!) {
        let webHeight = webView.scrollView.frame.height
        htmlContentHeight = webHeight
        print(webHeight)
    }

A: You can try  webView.scrollView.contentSize, but I've found that it not always returns correct values, just for simplest pages. So I've use script like this:
webView.evaluateJavaScript("document.height") { (result, error) in
    if error == nil {
        print(result)
    }
}

webView.evaluateJavaScript("document.width") { (result, error) in
    if error == nil {
        print(result)
    }
}


text:
Q: Rewrite a monad computation in prefix notation I'm trying to figure out how to rewrite a monadic computation with prefix notation (not for real practical goals, just for research), but the problem that one lambda doesn't see another one's parameter
so given a working example
*Main> [1, 3, 4] >>= \x -> [x + 1, x - 1] >>= \y -> return (y*x)
[2,0,12,6,20,12]

the rewritten one shows the error on not seeing the parameter of other lambda
*Main> (>>=) ( (>>=)  [1, 3, 4] (\x -> [x + 1, x - 1]) ) (\y -> return (y*x))
<interactive>:133:68: Not in scope: `x'

but if I make the last one not using it (by replacing x with y), the computation starts working
*Main> (>>=) ( (>>=)  [1, 3, 4] (\x -> [x + 1, x - 1]) ) (\y -> return (y*y))
[4,0,16,4,25,9]

So does full rewriting in prefix notation technically possible? Or this property of accessing other lambdas parameters is exclusive to the infix notation?

A: The problem is that you got the precedences slightly wrong, see also Haskell Precedence: Lambda and operator
The body of a lambda-expression extends as far to the right as possible. Then your example is parenthesized as follows:
[1, 3, 4] >>= (\x -> [x + 1, x - 1] >>= (\y -> return (y*x)))

Bringing it into prefix form results in
(>>=) [1, 3, 4] (\x -> (>>=) [x + 1, x - 1] (\y -> return (y*x)))

Now x is visible inside the body of \y -> ....


text:
Q: Symfony2 - Differentiating between the way a user logged in Software/Bundles: Symfony2 + FOS User+FacebookBundle
The Problem:
A user can login via the "Login with Facebook"-Button and a regular "Login Form" (Standard Login Form).
The task is to differentiate which login method the user used, in the login process, so that custom logic can be executed, based on which way the user took to access the website.

A: i think there will be no other way than to extend the bundles (not components) login action to save a custom flag into user session.
if your custom logic is just redirect the user to a different action then you will need only to alter the redirect logic of the login actions in your used bundles
you can check the official bundle documentation on how to do it:
Overriding Default FOSUserBundle Controllers


text:
Q: ExtJS custom bind I have a form within a form. I need to bind the hidden property of a field in the outer form to the checked state of a field in the inner form. I assume I can do this with binding by setting up a custom getter/setter but not exactly sure... here's the idea:
Sencha fiddle

A: You can do something like this:
Ext.define('Test.InnerForm', {
    extend: 'Ext.form.Panel',
    xtype: 'innerform',

    defaultListenerScope: true,

    config: {
        isFoo: false
    },

    twoWayBindable: {
        isFoo: true
    },
    publishes: ['isFoo'],

    items:[{
        xtype: 'checkbox',
        fieldLabel:'cb',
        listeners: {
            change: 'onCheckChange'
        }
    }],

    onCheckChange: function(box, checked) {
        this.setIsFoo(checked);
    }
});

Ext.define('Test.OuterForm', {
    extend: 'Ext.form.Panel',
    xtype: 'outerform',
    viewModel: true,
    items:[{
        xtype:'innerform',
        reference: 'innerform'
    },{
        xtype: 'textfield',
        fieldLabel: 'want to hide this when cb is checked',
        bind: {
            hidden: '{innerform.isFoo}'
        }
    }]
});

Ext.create('Test.OuterForm', {
    title: 'Outer form',
    width: 500,
    height: 500,
    bodyPadding: 10,
    renderTo: Ext.getBody()
});


text:
Q: how do i acces variables inside a typedef struct Okay so, i only recently started studying coding and i barely understand it.
at the start of it before the main() part of the program i have this.
typedef struct verado
{
    int id;
    char nev[30];
    char verCs[4];
    char email[30];
    int adas;
};

this stores 10 of each variable.
further on i have several functions, some of which are inside eachother and i have trouble accessing the variables from the aforementioned part.
void email(verado *v,int *h)
{
    char vercs[4];
    int opc;
    printf("1:A+ 2:B+ 3:AB+ 4:0+ 5:A- 6:B- 7:AB- 8:0-\n") ;
    scanf(" %d", &opc);

    switch(opc)
    {
    case 1:
        vercs[0]='A';vercs[1]='+';vercs[2]='\0';
        printf("%s %s", vercs,(*v)[1].verCs,*h );
        break;
    default:
        printf("\nerror\n");
        break;
    }
    return 0;
}

further on it needs to be able to compare the selected bloodtype with the bloodtypes of the stored ppl, but i can't do that if im unable to find out how to even access them.

A: In general, to access the so called "member variables" of a struct, you'd have to use the point notation like is used e.g. in this answer to a different question.
In your case however, your function has access to a pointer as parameter. So you don't actually have an instance of struct verado, you have a pointer to it.
That means you should use the arrow operator. E.g. v->id to access the variable id.
The arrow does the same thing as this does: (*v).id. It dereferences the variable and then accesses the member variable.
As somebody explained in the comments, you also want to give your struct verado a type name. This way you won't have to type struct verado every time. So a small example showcasing what I just said could look like this:
#include<stdio.h>

typedef struct verado {
    int id;
} typeOfVerado;

void email(struct verado *v){
    printf("verado id: %d\n", v->id);
}

void main(){
    typeOfVerado myVerado  = { id: 3};
    email(&myVerado);
}

I'm not the most proficient in C, but I hope this is enough to give you some clarity for starters.