Rectangle 27 33

Good questions I have been asked are

  • What do you think is good about .NET?
  • What do you think is bad about .NET?

It would be interesting to see what a candidate would come up with and you'll certainly learn quite a bit about how he/she uses the framework.

Questions every good .NET developer should be able to answer? - Stack ...

.net
Rectangle 27 33

Good questions I have been asked are

  • What do you think is good about .NET?
  • What do you think is bad about .NET?

It would be interesting to see what a candidate would come up with and you'll certainly learn quite a bit about how he/she uses the framework.

Questions every good .NET developer should be able to answer? - Stack ...

.net
Rectangle 27 2543

Check out the documentation to see how decorators work. Here is what you asked for:

def makebold(fn):
    def wrapped():
        return "<b>" + fn() + "</b>"
    return wrapped

def makeitalic(fn):
    def wrapped():
        return "<i>" + fn() + "</i>"
    return wrapped

@makebold
@makeitalic
def hello():
    return "hello world"

print hello() ## returns "<b><i>hello world</i></b>"

Consider using functools.wraps or, better yet, the decorator module from PyPI: they preserve certain important metadata (such as __name__ and, speaking about the decorator package, function signature).

*argsand **kwargs should be added in the answer. Decorated function can have arguments, and they will be lost if not specified.

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

python - How to make a chain of function decorators? - Stack Overflow

python decorator python-decorators
Rectangle 27 2532

Check out the documentation to see how decorators work. Here is what you asked for:

def makebold(fn):
    def wrapped():
        return "<b>" + fn() + "</b>"
    return wrapped

def makeitalic(fn):
    def wrapped():
        return "<i>" + fn() + "</i>"
    return wrapped

@makebold
@makeitalic
def hello():
    return "hello world"

print hello() ## returns "<b><i>hello world</i></b>"

Consider using functools.wraps or, better yet, the decorator module from PyPI: they preserve certain important metadata (such as __name__ and, speaking about the decorator package, function signature).

*argsand **kwargs should be added in the answer. Decorated function can have arguments, and they will be lost if not specified.

python - How to make a chain of function decorators? - Stack Overflow

python decorator python-decorators
Rectangle 27 2530

Check out the documentation to see how decorators work. Here is what you asked for:

def makebold(fn):
    def wrapped():
        return "<b>" + fn() + "</b>"
    return wrapped

def makeitalic(fn):
    def wrapped():
        return "<i>" + fn() + "</i>"
    return wrapped

@makebold
@makeitalic
def hello():
    return "hello world"

print hello() ## returns "<b><i>hello world</i></b>"

Consider using functools.wraps or, better yet, the decorator module from PyPI: they preserve certain important metadata (such as __name__ and, speaking about the decorator package, function signature).

*argsand **kwargs should be added in the answer. Decorated function can have arguments, and they will be lost if not specified.

python - How to make a chain of function decorators? - Stack Overflow

python decorator python-decorators
Rectangle 27 12

This may have been asked before but:

"every link that specifies target="_new" looks for and finds that window by name, and opens in it.

If you use target="_blank," a brand new window will be created each time, on top of the current window."

html - target="_blank" vs. target="_new" - Stack Overflow

html
Rectangle 27 12

This may have been asked before but:

"every link that specifies target="_new" looks for and finds that window by name, and opens in it.

If you use target="_blank," a brand new window will be created each time, on top of the current window."

html - target="_blank" vs. target="_new" - Stack Overflow

html
Rectangle 27 18

The issue is that you have not asked for permissions:

authButton.setReadPermissions(Arrays.asList("user_likes", "user_status","email","user_birthday"));

However, you are using an older Facebook SDK, while the newest SDK is 4.0.+. Below, I will give you a full sample code for Facebook login, based on the newest API. Keep in mind that you first have to add your application in developers.facebook as the documentation mentions out.

public class LoginActivity extends ActionBarActivity{

@Override
protected void onActivityResult(int requestCode, int responseCode, Intent data)
{
    super.onActivityResult(requestCode, responseCode, data);
    callbackManager.onActivityResult(requestCode, responseCode, data);
}

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(this.getApplicationContext());
    setContentView(R.layout.activity_login);
    callbackManager = CallbackManager.Factory.create();
    loginButton = (LoginButton) findViewById(R.id.loginFaceBook_button);
    List<String> permissionNeeds = Arrays.asList("user_photos", "email", "user_birthday", "public_profile");
    loginButton.setReadPermissions(permissionNeeds);

    loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>()
    {
        @Override
        public void onSuccess(LoginResult loginResult)
        {
            System.out.println("onSuccess");
            GraphRequest request = GraphRequest.newMeRequest
                    (loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback()
                    {
                        @Override
                        public void onCompleted(JSONObject object, GraphResponse response)
                        {
                            // Application code
                            Log.v("LoginActivity", response.toString());
                            //System.out.println("Check: " + response.toString());
                            try
                            {
                                String id = object.getString("id");
                                String name = object.getString("name");
                                String email = object.getString("email");
                                String gender = object.getString("gender");
                                String birthday = object.getString("birthday");
                                System.out.println(id + ", " + name + ", " + email + ", " + gender + ", " + birthday);
                            }
                            catch (JSONException e)
                            {
                                e.printStackTrace();
                            }

                        }
                    });
            Bundle parameters = new Bundle();
            parameters.putString("fields", "id,name,email,gender, birthday");
            request.setParameters(parameters);
            request.executeAsync();
        }

        @Override
        public void onCancel()
        {
            System.out.println("onCancel");
        }

        @Override
        public void onError(FacebookException exception)
        {
            System.out.println("onError");
            Log.v("LoginActivity", exception.getCause().toString());
        }
    });
  }
}
Fragment
ActionBarActivity
loginButton.setFragment(this);
<uses-permission android:name="android.permission.INTERNET"/> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
    <!-- your other attrs..-->
    <meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/app_id"/> <!-- Get this one from developers.facebook -->
    <activity
        android:name="com.facebook.FacebookActivity"
        android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:theme="@android:style/Theme.Translucent.NoTitleBar"
        android:label="@string/app_name"/>

You will need to add to your application a hash key too. Here is a way to do this with code:

try
{
    //paste Your package name at the first parameter
    PackageInfo info = getPackageManager().getPackageInfo("PUT_YOUR_PACKAGE_NAME_HERE",
            PackageManager.GET_SIGNATURES);
    for (android.content.pm.Signature signature : info.signatures)
    {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        String sign = Base64.encodeToString(md.digest(), Base64.DEFAULT);
        Log.e("MY KEY HASH:", sign);
        Toast.makeText(getApplicationContext(),sign,     Toast.LENGTH_LONG).show();
    }
}
catch (PackageManager.NameNotFoundException e)
{
}
catch (NoSuchAlgorithmException e)
{
}

After it prints you out the hash key, you copy paste it to your facebook.developer account, where your project is located.

jcenter
repositories
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
dependecies
buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.1.0'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}
allprojects 
{
repositories {
    jcenter()
    /*more project attrs..*/
  }
}

And the other grandle file:

apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "YOUR_PACKAGE_NAME"
    minSdkVersion 14
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
}

In order to track the user's location, you will need a GPS Tracker, something like this. "user_location" permission does not return a lon, lat, but a Page object, which I think is not what you want. So, your permissions should be List<String> permissionNeeds = Arrays.asList("user_photos", "email", "user_birthday", "public_profile"); and now you should be able to retrieve user's email

thank you. i move up to the newest facebook sdk, but i have problem with build.gradle can you send me your gradle please?

@user3921905 I did add the build.grandle files. com.facebook.android:facebook-android-sdk:4.0.0' should do the job here. Let me know if that fixed your problem

Also, here is the full documentation about manifest and grandle set up.

i tried your code but i don't know why my email always return null. and when i make username.setText(name), there is nothing in textview, but i can see the result when i debug the code?

java - Can't get location and email using Facebook API - Stack Overflo...

java android facebook-graph-api
Rectangle 27 79

This is not exactly what you asked for, but for http(s):

  • you can put the password in .netrc file (_netrc on windows). From there it would be picked up automatically. It would go to your home folder with 600 permissions.
  • you could also just clone the repo with https://user:pass@domain/repo but that's not really recommended as it would show your user/pass in a lot of places...
  • a new option is to use the credential helper. Note that credentials would be stored in clear text in your local config using standard credential helper. credential-helper with wincred can be also used on windows.
git config credential.helper store
git config credential.helper 'cache --timeout=3600'

For ssh-based access, you'd use ssh agent that will provide the ssh key when needed. This would require generating keys on your computer, storing the public key on the remote server and adding the private key to relevant keystore.

Can you elaborate on the SSH part? I'm configuring an EC2 instance, and I would like it to pull without requesting my password and the AWS autoscale. This public/private scheme looks like a good solution.

@PedroDusso sounds like this thread is what you're after

i ended using the deploy keys mechanism, which appears to be a good solution. Thanks!

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

bash - How to enter command with password for git pull? - Stack Overfl...

git bash command
Rectangle 27 75

This is not exactly what you asked for, but for http(s):

  • you can put the password in .netrc file (_netrc on windows). From there it would be picked up automatically. It would go to your home folder with 600 permissions.
  • you could also just clone the repo with https://user:pass@domain/repo but that's not really recommended as it would show your user/pass in a lot of places...
  • a new option is to use the credential helper. Note that credentials would be stored in clear text in your local config using standard credential helper. credential-helper with wincred can be also used on windows.
git config credential.helper store
git config credential.helper 'cache --timeout=3600'

For ssh-based access, you'd use ssh agent that will provide the ssh key when needed. This would require generating keys on your computer, storing the public key on the remote server and adding the private key to relevant keystore.

Can you elaborate on the SSH part? I'm configuring an EC2 instance, and I would like it to pull without requesting my password and the AWS autoscale. This public/private scheme looks like a good solution.

@PedroDusso sounds like this thread is what you're after

i ended using the deploy keys mechanism, which appears to be a good solution. Thanks!

bash - How to enter command with password for git pull? - Stack Overfl...

git bash command
Rectangle 27 748

Let's not forget the actual question that was asked:

How to remove the space between inline-block elements? I was hoping for a CSS solution that doesn't require the HTML source code to be tampered with. Can this issue be solved with CSS alone?

It is possible to solve this problem with CSS alone, but there are no completely robust CSS fixes.

The solution I had in my initial answer was to add font-size: 0 to the parent element, and then declare a sensible font-size on the children.

This works in recent versions of all modern browsers. It works in IE8. It does not work in Safari 5, but it does work in Safari 6. Safari 5 is nearly a dead browser (0.33%, August 2015).

Most of the possible issues with relative font sizes are not complicated to fix.

However, while this is a reasonable solution if you specifically need a CSS only fix, it's not what I recommend if you're free to change your HTML (as most of us are).

This is what I, as a reasonably experienced web developer, actually do to solve this problem:

<p>
    <span>Foo</span><span>Bar</span>
</p>

Yes, that's right. I remove the whitespace in the HTML between the inline-block elements.

It's easy. It's simple. It works everywhere. It's the pragmatic solution.

You do sometimes have to carefully consider where whitespace will come from. Will appending another element with JavaScript add whitespace? No, not if you do it properly.

Let's go on a magical journey of different ways to remove the whitespace, with some new HTML:

<ul>
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
</ul>
  • You can do this, as I usually do: <ul> <li>Item 1</li><li>Item 2</li><li>Item 3</li> </ul> http://jsfiddle.net/thirtydot/dGHFV/1362/
<ul>
    <li>Item 1</li
    ><li>Item 2</li
    ><li>Item 3</li>
</ul>
<ul>
    <li>Item 1</li><!--
    --><li>Item 2</li><!--
    --><li>Item 3</li>
</ul>

Or, you can even skip certain closing tags entirely (all browsers are fine with this):

<ul>
    <li>Item 1
    <li>Item 2
    <li>Item 3
</ul>

Now that I've gone and bored you to death with "one thousand different ways to remove whitespace, by thirtydot", hopefully you've forgotten all about font-size: 0.

It works in FF3.6, IE9RC, O11, Ch9. However, in Safari 5 there still remains a 1px wide gap :(

@thirtydot Could you check out the comment of this answer. It could be that this font-size:0 trick is not such a good idea after all...

I know the poster is looking for a CSS solution, but this solution - which is by far the most voted (30 votes vs 5 as I write this) - has strong side effects and doesn't even work cross browser. At this point it's more pragmatic to simply remove the problematic whitespace in your HTML.

this solution only works if you dont work with EMs for your container sizes

This breaks child elements with relative font-sizes.

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

html - How to remove the space between inline-block elements? - Stack ...

html css
Rectangle 27 64

This question has been asked at the Google I/O 2010, you can watch it here:

Basically what Romain Guy explains is to call getChildAt(int) on the ListView to get the view and (I think) call getFirstVisiblePosition() to find out the correlation between position and index.

Romain also points to the project called Shelves as an example, I think he might mean the method ShelvesActivity.updateBookCovers(), but I can't find the call of getFirstVisiblePosition().

The RecyclerView will fix this in the near future. As pointed out on http://www.grokkingandroid.com/first-glance-androids-recyclerview/, you will be able to call methods to exactly specify the change, such as:

void notifyItemInserted(int position)
void notifyItemRemoved(int position)
void notifyItemChanged(int position)

Also, everyone will want to use the new views based on RecyclerView because they will be rewarded with nicely-looking animations! The future looks awesome! :-)

Good thing! :) Maybe you can add a null check here, too - v may be null if the view is not available in the moment. And of course this data will be gone if the user scrolls the ListView, so one should also update the data in the adapter (perhaps without calling notifyDataSetChanged()). In general I think it would be a good idea to keep all this logic within the adapter, i.e. passing the ListView reference to it.

This worked for me, except - when the view left the screen, when it re-enters the change is reset. I guess because in the getview it is still receiving the original information. How do I get around this?

android - How can I update a single row in a ListView? - Stack Overflo...

android android-listview android-arrayadapter
Rectangle 27 63

This question has been asked at the Google I/O 2010, you can watch it here:

Basically what Romain Guy explains is to call getChildAt(int) on the ListView to get the view and (I think) call getFirstVisiblePosition() to find out the correlation between position and index.

Romain also points to the project called Shelves as an example, I think he might mean the method ShelvesActivity.updateBookCovers(), but I can't find the call of getFirstVisiblePosition().

The RecyclerView will fix this in the near future. As pointed out on http://www.grokkingandroid.com/first-glance-androids-recyclerview/, you will be able to call methods to exactly specify the change, such as:

void notifyItemInserted(int position)
void notifyItemRemoved(int position)
void notifyItemChanged(int position)

Also, everyone will want to use the new views based on RecyclerView because they will be rewarded with nicely-looking animations! The future looks awesome! :-)

Good thing! :) Maybe you can add a null check here, too - v may be null if the view is not available in the moment. And of course this data will be gone if the user scrolls the ListView, so one should also update the data in the adapter (perhaps without calling notifyDataSetChanged()). In general I think it would be a good idea to keep all this logic within the adapter, i.e. passing the ListView reference to it.

This worked for me, except - when the view left the screen, when it re-enters the change is reset. I guess because in the getview it is still receiving the original information. How do I get around this?

android - How can I update a single row in a ListView? - Stack Overflo...

android android-listview android-arrayadapter
Rectangle 27 7

I know this was asked so long ago, but in case anyone else comes across this same problem, I found the answer.

You're using the listener onBeforeSendHeaders, when the only listener that supports viewing the POST data is onBeforeRequest. However, you also need to supply an extraInfoSpec of "requestBody" to the third argument of .addListener. An example is below.

/* The Web Request API */
const WEB_REQUEST = chrome.webRequest;

WEB_REQUEST.onBeforeRequest.addListener(
    function(details) {
        if(details.method == "POST")
            console.log(JSON.stringify(details));
    },
    {urls: ["<all_urls>"]},
    ["blocking", "requestBody"]
);

javascript - How to get post data in chrome extension - Stack Overflow

javascript google-chrome post google-chrome-extension
Rectangle 27 13

  • supports the non-greedy operator ?, as you asked in OP; and
  • doesn't require backwhacking grouping and cardinality operators (an utterly counterintuitive vim syntax requirement since you're not matching literal characters but specifying operators); and

you have [g]vim compiled with perl feature, test using

:perldo s///

Example. Swap src and alt attributes in img tag:

<p class="logo"><a href="/"><img src="/caminoglobal_en/includes/themes/camino/images/header_logo.png" alt=""></a></p>

:perldo s/(src=".*?")\s+(alt=".*?")/$2 $1/

<p class="logo"><a href="/"><img alt="" src="/caminoglobal_en/includes/themes/camino/images/header_logo.png"></a></p>

regex - How can I make my match non greedy in vim? - Stack Overflow

regex vim regex-greedy
Rectangle 27 13

  • supports the non-greedy operator ?, as you asked in OP; and
  • doesn't require backwhacking grouping and cardinality operators (an utterly counterintuitive vim syntax requirement since you're not matching literal characters but specifying operators); and

you have [g]vim compiled with perl feature, test using

:perldo s///

Example. Swap src and alt attributes in img tag:

<p class="logo"><a href="/"><img src="/caminoglobal_en/includes/themes/camino/images/header_logo.png" alt=""></a></p>

:perldo s/(src=".*?")\s+(alt=".*?")/$2 $1/

<p class="logo"><a href="/"><img alt="" src="/caminoglobal_en/includes/themes/camino/images/header_logo.png"></a></p>

regex - How can I make my match non greedy in vim? - Stack Overflow

regex vim regex-greedy
Rectangle 27 13

  • supports the non-greedy operator ?, as you asked in OP; and
  • doesn't require backwhacking grouping and cardinality operators (an utterly counterintuitive vim syntax requirement since you're not matching literal characters but specifying operators); and

you have [g]vim compiled with perl feature, test using

:perldo s///

Example. Swap src and alt attributes in img tag:

<p class="logo"><a href="/"><img src="/caminoglobal_en/includes/themes/camino/images/header_logo.png" alt=""></a></p>

:perldo s/(src=".*?")\s+(alt=".*?")/$2 $1/

<p class="logo"><a href="/"><img alt="" src="/caminoglobal_en/includes/themes/camino/images/header_logo.png"></a></p>

regex - How can I make my match non greedy in vim? - Stack Overflow

regex vim regex-greedy
Rectangle 27 13

  • supports the non-greedy operator ?, as you asked in OP; and
  • doesn't require backwhacking grouping and cardinality operators (an utterly counterintuitive vim syntax requirement since you're not matching literal characters but specifying operators); and

you have [g]vim compiled with perl feature, test using

:perldo s///

Example. Swap src and alt attributes in img tag:

<p class="logo"><a href="/"><img src="/caminoglobal_en/includes/themes/camino/images/header_logo.png" alt=""></a></p>

:perldo s/(src=".*?")\s+(alt=".*?")/$2 $1/

<p class="logo"><a href="/"><img alt="" src="/caminoglobal_en/includes/themes/camino/images/header_logo.png"></a></p>

regex - How can I make my match non greedy in vim? - Stack Overflow

regex vim regex-greedy
Rectangle 27 13

  • supports the non-greedy operator ?, as you asked in OP; and
  • doesn't require backwhacking grouping and cardinality operators (an utterly counterintuitive vim syntax requirement since you're not matching literal characters but specifying operators); and

you have [g]vim compiled with perl feature, test using

:perldo s///

Example. Swap src and alt attributes in img tag:

<p class="logo"><a href="/"><img src="/caminoglobal_en/includes/themes/camino/images/header_logo.png" alt=""></a></p>

:perldo s/(src=".*?")\s+(alt=".*?")/$2 $1/

<p class="logo"><a href="/"><img alt="" src="/caminoglobal_en/includes/themes/camino/images/header_logo.png"></a></p>

regex - How can I make my match non greedy in vim? - Stack Overflow

regex vim regex-greedy
Rectangle 27 13

  • supports the non-greedy operator ?, as you asked in OP; and
  • doesn't require backwhacking grouping and cardinality operators (an utterly counterintuitive vim syntax requirement since you're not matching literal characters but specifying operators); and

you have [g]vim compiled with perl feature, test using

:perldo s///

Example. Swap src and alt attributes in img tag:

<p class="logo"><a href="/"><img src="/caminoglobal_en/includes/themes/camino/images/header_logo.png" alt=""></a></p>

:perldo s/(src=".*?")\s+(alt=".*?")/$2 $1/

<p class="logo"><a href="/"><img alt="" src="/caminoglobal_en/includes/themes/camino/images/header_logo.png"></a></p>

regex - How can I make my match non greedy in vim? - Stack Overflow

regex vim regex-greedy