Rectangle 27 26

Here's the proper solution that works very well.

NSData* coreDataImage = [NSData dataWithData:UIImagePNGRepresentation(delegate.dancePhoto)];

Make sure that "coreDataImage" is of type NSData. You have to set type to "Binary data" for "coreDataImage" in your model.

2) Retrieving UIImage from Core Data:

UIImage* image = [UIImage imageWithData:selectedDance.danceImage];

Sorry, didn't see that Brian already answered with almost the exact same solution.

No need to pass UIImagePNGRepresentation to the NSData initializer as it already returns an NSData object.

iphone - Save and Retrieve of an UIImage on CoreData - Stack Overflow

iphone objective-c core-data uiimage save
Rectangle 27 34

I had this problem too. But using the older version is not the proper solution.

Here is the two solution help to fix this certificate error

1. Using the http instead of https will allow you to install the gem without that error

2. Update the certificate based on the solution provided in the below link

Used option 2. Worked like a charm.

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

"certificate verify failed" error when installing Ruby gems on Windows...

ruby windows ssl rubygems
Rectangle 27 34

I had this problem too. But using the older version is not the proper solution.

Here is the two solution help to fix this certificate error

1. Using the http instead of https will allow you to install the gem without that error

2. Update the certificate based on the solution provided in the below link

Used option 2. Worked like a charm.

"certificate verify failed" error when installing Ruby gems on Windows...

ruby windows ssl rubygems
Rectangle 27 12

I've had this issue for a while and came up with a proper solution.

String token = GoogleAuthUtil.getToken(this, accountName, scopeString, appActivities);

This line will either return the one time token or will trigger the UserRecoverableAuthException. On the Google Plus Sign In guide, it says to open the proper recovery activity.

startActivityForResult(e.getIntent(), RECOVERABLE_REQUEST_CODE);

When the activity returns with the result, it will come back with few extras in the intent and that is where the new token resides :

@Override
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
    if (requestCode == RECOVERABLE_REQUEST_CODE && responseCode == RESULT_OK) {
        Bundle extra = intent.getExtras();
        String oneTimeToken = extra.getString("authtoken");
    }
}

With the new oneTimeToken given from the extra, you can submit to the server to connect properly.

This answer should be marked correct. It is the proper way to handle the non-acquisition of the token.

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

oauth 2.0 - Android Google+ integration - repeated UserRecoverableAuth...

android oauth-2.0 google-plus
Rectangle 27 57

Well I tried deleting the log file, it helped at the beginning but then I got the error again. The proper solution is as following:

Jboss_installation_dir\standalone\configuration
standalone.xml
<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.0">
    <deployment-scanner scan-interval="5000" relative-to="jboss.server.base.dir" path="deployments" deployment-timeout="1000" />
</subsystem>
deployment-timeout

is this timeout value in Sec? or milli-sec?

in seconds. the default is 60 seconds, just make it something large enough, now it is 1000 seconds for example

Jboss 7 war deployment failed - Stack Overflow

deployment jboss war
Rectangle 27 8

This will give you a proper solution to the situation

page.evaluate(function(){
    var a = document.getElementById("target_element_to_be_clicked");
    var e = document.createEvent('MouseEvents');
    e.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
    a.dispatchEvent(e);
});
#spr-sign-in-btn-standard
.btn-prim
document.querySelector

javascript - PhantomJS .click() not working - Stack Overflow

javascript click phantomjs
Rectangle 27 3

Your first example is the proper solution.

recursion - Python generator to yield everything from another generato...

python recursion generator yield
Rectangle 27 5

I think that the proper solution is to use the file? method.

using exists? will do a request to the server to check if the file is there, which can be quite slow, especially if it's on a different server or on S3.

using foo.image_file_name.nil? is probably the same as file? under the covers, but ou don't want to dependant on the implementation of paperclip, which could someday change.

ruby on rails 3 - How to know if an image has been uploaded or not? - ...

ruby-on-rails-3 paperclip
Rectangle 27 3

This is more of a hack than a proper solution, but you could always:

  • Create a a copy of the configuration you want for the entire solution with a GUID as its name.
  • Remove the copy from the projects which already have the original configuration (undo changes).
  • Rename the GUID to the original configuration's name using the "Find/Replace in Files" tool.

Even if it isn't a very viable option, it is a pretty good quick fix.

With the solution file opened in a text editor, you will see a block called Global which contains sections. The SolutionConfigurationPlatforms section contains the configuration's definitions. There is also an other section called ProjectConfigurationPlatforms where the configurations are assigned. Simply remove the references to the configuration from both groups and that should do it. If you have more complex solutions, there might be other references to remove. This is just a base case.

How to manually remove configurations from projects: Again, with the project file opened in a text editor, you will see many references to the configuration you want to remove. C# projects have a PropertyGroup with the configuration as a condition. You can simply remove the group entirely. There might be other references to the configuration around the file so make sure to clean everything properly.

Make sure that you have a backup of your files if something goes wrong.

With over 15 different solutions, this would mean that I would have to remove the config from all solutions. Since they all inter-reference each other, would I not run into the same problem once I started adding the config back to ANY of them? In fact, since Configuration Manager does not have a "Remove" function, how would the build config be removed from ANY of them?

I've added more details on how to manually remove configurations from the solution and project files. You can also add them that way if you know enough about the MSBuild configuration system. If you have that many solutions, you could always create one new solution referencing all of the affected projects across all of those 15 solutions. Then simply add the new configuration in this solution like I said. When you're done, edit the solution file with a text editor and copy the lines referencing the configuration manually to all of your 15 solutions.

c# - Copy External Configurations to Local Projects in Visual Studio? ...

c# visual-studio-2010 visual-studio visual-studio-2012
Rectangle 27 145

So, if I'm understanding you correctly, your first solution is suggesting that you're keeping state in your root component? I can't speak for the creators of React, but generally, I find this to be a proper solution.

Maintaining state is one of the reasons (at least I think) that React was created. If you've ever implemented your own state pattern client side for dealing with a dynamic UI that has a lot of interdependent moving pieces, then you'll love React, because it alleviates a lot of this state management pain.

By keeping state further up in the hierarchy, and updating it through eventing, your data flow is still pretty much unidirectional, you're just responding to events in the Root component, you're not really getting the data there via two way binding, you're telling the Root component that "hey, something happened down here, check out the values" or you're passing the state of some data in the child component up in order to update the state. You changed the state in C1, and you want C2 to be aware of it, so, by updating the state in the Root component and re-rendering, C2's props are now in sync since the state was updated in the Root component and passed along.

class Example extends React.Component {
  constructor (props) {
    super(props)
    this.state = { data: 'test' }
  }
  render () {
    return (
      <div>
        <C1 onUpdate={this.onUpdate.bind(this)}/>
        <C2 data={this.state.data}/>
      </div>
    )
  }
  onUpdate (data) { this.setState({ data }) }
}

class C1 extends React.Component {
    render () {
      return (
        <div>
          <input type='text' ref='myInput'/>
          <input type='button' onClick={this.update.bind(this)} value='Update C2'/>
        </div>
      )
    }
    update () {
      this.props.onUpdate(this.refs.myInput.getDOMNode().value)
    }
})

class C2 extends React.Component {
    render () {
      return <div>{this.props.data}</div>
    }
})

ReactDOM.renderComponent(<Example/>, document.body)

No problem. I actually went back after writing this post and reread some of the documentation, and it seems to be inline with their thinking and best practices. React has truly excellent documentation, and every time I end up wondering where something should go, they typically have it covered somewhere in the docs. Check out the section on state here, facebook.github.io/react/docs/

@captray but what about, if C2 have a getInitialState for data and inside the render it uses this.state.data?

@DmitryPolushkin If I'm understanding your question correctly, you want to pass data from your Root Component to C2 as props. In C2, that data would be set as initial state (i.e. getInitialState: function() { return { someData: this.props.dataFromParentThatWillChange } } and you'll want to implement componentWillReceiveProps and call this.setState with the new props to update the state in C2. Since I initially answered, I've been using Flux, and would highly recommend that you look at it as well. It makes your components cleaner and will change the way you think about state.

@DmitryPolushkin I wanted to post this to followup. facebook.github.io/react/tips/ It's ok as long as you know what you're doing and you know that data is going to change, but in many situations you can probably move things around. It's also important to note that you don't have to build this as a hierarchy. You could mount C1 and C2 at different places in the DOM, and they can both listen to change events on some data. I see a lot of people pushing for hierarchical components when they don't need them.

The above code has 2 bugs - both of which involve not binding "this" in the right context, I have made the corrections above and also for anyone who needs a codepen demonstration: codepen.io/anon/pen/wJrRpZ?editors=0011

reactjs - React – the right way to pass form element state to sibling/...

reactjs
Rectangle 27 2

You should delete statement input.val(""); in checkVal() function for a proper solution.

If you're using minified version, you should search and delete statement:

if(!a&&c+1<i)f.val(""),t(0,k);else

I'm not particularly a fan of modifying the binary, if I have a work around?

Hey Dave, i have no idea about doing this another way. can you give me an example please ?

I won't vote down, but almost always it's a really bad idea to modify the source code. Someone else might continue de project and upgrade the components to a new version, throwing away any undocumented change. Even yourself might upgrade it forgeting about some cryptic change you did months ago.

javascript - jquery masked input plugin to not clear field when errore...

javascript jquery maskedinput
Rectangle 27 1

I guess that this is the proper solution:

$id = get_queried_object_id();
function get_queried_object_id() {
    global $wp_query;
    return $wp_query->get_queried_object_id();
}

php - get the current page id inside wordpress plugin page - Stack Ove...

php wordpress
Rectangle 27 1

I guess that this is the proper solution:

$id = get_queried_object_id();
function get_queried_object_id() {
    global $wp_query;
    return $wp_query->get_queried_object_id();
}

php - get the current page id inside wordpress plugin page - Stack Ove...

php wordpress
Rectangle 27 75

As pointed out in the comments, this technically is not a "merge" which is why the link below uses quotes. However, I rarely need anything as complicated as other posters describe, so I think it's useful, if not a proper, solution for the OP's question.

$ git checkout branch1 # i.e. make sure you're in branch1
$ git checkout branch2 file.py

Easy, but that's not actually a merge. It just overwrites file.py with whatever is in branch 2.

Extremely helpful when you want to bring across just a couple of files from a feature early in preparation. We needed some files from a feature branch to index some data before the rest of the feature tries to use the indexed data. Thanks!

What if you merge back the file from branch1 to branch2? You'll get conflict!

How to merge specific files from Git branches - Stack Overflow

git git-merge
Rectangle 27 6

In Python 3, a timeout option has been added to the subprocess module. Using a structure like

try:
    o, e = process.communicate(timeout=10)
except TimeoutExpired:
    process.kill()
    o, e = process.communicate()

analyze(o)

would be a proper solution.

Since the output is expected to contain a new line character, it's safe to assume that it is text (as in printable, readable), in which case universal_newlines=True flag is strongly recommended.

.communicate() waits for the child process to finish. It doesn't answer OPs question if there could be more than one line e.g., imagine a subprocess yields a line every 9 seconds: your code fails on the 2nd line while OPs pseudo-code would read all lines successfully -- it is the difference between the total timeout and a timeout on a single read operation (readline in this case). btw, there is the opposite problem in networking: timeout parameter limits only a single (socket) operation usually -- you have to write your own code to enforce the total timeout limit.

timeout on subprocess readline in python - Stack Overflow

python timeout subprocess
Rectangle 27 2

Try this code instead, not a proper solution, but will fix the issue you are facing:

$(document).on("change", "input.quantity", function(e)
{
    alert('Changed!');
    var $ele = $(this);
    setTimeout(function() {$ele.blur();}, 50);
});

jquery - chrome fires change event twice after enter key pressed and b...

jquery google-chrome onchange blur
Rectangle 27 7

Since this question is still not answered correctly yet ranks quite high for me in Google for "radio button onchange", here's a proper solution for anyone still looking.

If you're using jQuery, just use jQuery's attribute selector as noted by Flavius Stef.

OP, it's not entirely clear what your code does. Let's assume in your code you want to add the "hidden" class to whatever radio button is active.

$("your selector here").change(function() {
    $('input[name="' + this.name + '"]').removeClass("hidden");

    $(this).addClass("hidden");
});

Please note the difference between $(this) (the jQuery object) and this (the DOM object). Basically I'm removing the "hidden" class from every input that goes by the same name, and then I add the "hidden" class to the current input.

Of course I'm assuming here that you're not using duplicate names for different inputs on the page. Also note that this would only work for radio buttons, as the radio button "change" event only fires when activated, not when deactivated.

In my case, I wanted to add a "checked" class to active radio buttons and checkboxes. Since the checkbox fires the "onchange" event both when checked and unchecked, I needed a bit of extra code.

$('input[type="radio"]').change(function() {
    $('input[name="' + this.name + '"]').removeClass("checked");
    $(this).addClass("checked");
});

$('input[type="checkbox"]').change(function() {
    $(this).toggleClass("checked", ($(this).is(":checked")));
});

The latter function uses toggleClass to set the "checked" class if .is(":checked") is true.

Alternatively you might want to combine the two functions into something like:

$('input[type="radio"], input[type="checkbox"]').change(function() {
    if(this.type == "radio")
        $('input[name="' + this.name + '"]').removeClass("checked");

    $(this).toggleClass("checked", ($(this).is(":checked")));
});

Either way, always be careful when listening for an onclick event as it will not fire when the input is activated through keyboard navigation.

javascript - onchange not working with radio button - Stack Overflow

javascript jquery css radiobuttonlist
Rectangle 27 4

#!/bin/bash

read -p "Enter a filename: " filename

if [[ -f $filename ]] ; then
    echo "The file $filename exists."
    read -p "Enter the word you want to find: " word
    grep "$word" "$filename"
else
    echo "The file $filename does not exist."
fi

Quite a few variants possible.

+1 for a proper solution.

Nice; please replace $filename with "$filename" in the grep command to guard against filenames that need quoting (e.g., embedded spaces); also, references to $str should be to $filename.

The shell script is only answering one half of the script, how can I make it to find the word after finding the existing file?

Can you rephrase? I am not sure I understand. The script will display the line in which the word appears in the file (the grepcommand). To print only the word, use the -o option. To print the line number, use the -n option, to count the occurence use the -coption.

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

linux - Shell script that finds a word within a file selected by a use...

linux bash shell grep
Rectangle 27 19

Personally I don't like this service added to my project files and I think having it is more like a workaround rather than a proper solution. So marking your test projects as test projects seems more correct to me and this can be achieved by adding this to the first PropertyGroup:

<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TestProjectType>UnitTest</TestProjectType>
{3AC096D0-A1C2-E12C-1390-A8335801FDAB}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}

^ I prefer ProjectTypeGuids too but if you're doing cross-platform development and using MonoDevelop you won't be able to open {3AC096D0-A1C2-E12C-1390-A8335801FDAB} projects: "This project type is not supported by MonoDevelop". Both IDEs seems happy if you simply remove the test project type GUID.

I wonder what are other possible types for the <TestProjectType>? Could not find any info about it.

c# - What is "Service Include" in a csproj file for? - Stack Overflow

c# visual-studio visual-studio-2013 csproj
Rectangle 27 19

Personally I don't like this service added to my project files and I think having it is more like a workaround rather than a proper solution. So marking your test projects as test projects seems more correct to me and this can be achieved by adding this to the first PropertyGroup:

<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TestProjectType>UnitTest</TestProjectType>
{3AC096D0-A1C2-E12C-1390-A8335801FDAB}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}

^ I prefer ProjectTypeGuids too but if you're doing cross-platform development and using MonoDevelop you won't be able to open {3AC096D0-A1C2-E12C-1390-A8335801FDAB} projects: "This project type is not supported by MonoDevelop". Both IDEs seems happy if you simply remove the test project type GUID.

I wonder what are other possible types for the <TestProjectType>? Could not find any info about it.

c# - What is "Service Include" in a csproj file for? - Stack Overflow

c# visual-studio visual-studio-2013 csproj