You used to be abel to do:
resources :posts, :singular => true
But I tried this in rails and it didn't work. Does anyone know the new way or workaround?
thanks
I heard, templated member functions of a class can't be virtual. Is it true? BTW, if they can be, then please give an example of such a scenario when I would need such function?
Hello,
I have this class constructor:
Pairs (int Pos, char *Pre, char *Post, bool Attach = true);
How can I initialize array of Pairs classes? I tried:
Pairs Holder[3] =
{
{Input.find("as"), "Pre", "Post"},
{Input.find("as"), "Pre", "Post"},
{Input.find("as"), "Pre", "Post"}
};
Apparently it's not working, I also tried to use () brackets instead of {} but compiler keeps moaning all the time. Sorry if it is lame question, I googled quite hard but wasn't able to find answer :/
Thanks.
how do i have to nest multicheckboxes so that they are named like this 'foo[]['bar']' .
i've used subforms but they give me naming like this 'foo[bar][]'.
my code:
$sub = new Zend_Form_SubForm('sub');
$wish = new Zend_Form_Element_MultiCheckbox('bar');
$wish
->setMultiOptions($education_direction->getAll())
->setLabel('Wish')
->setRequired(true);
$sub-addElements(array(
$wish
));
$this-addSubForm($sub, 'foo');
I've created a simple Chrome extension that seeks for certain strings using regex and replaces matches with predefined text. It works well on most websites, but somehow the script doesn't take effect on, for example, Lifehacker (like this page http://lifehacker.com/5939740/five-best-audio-editing-applications?popular=true ).
The code is:
$('p, h1, h2, h3, span, .content, .post-body').each(function(){
//do something with $(this)
});
Any ideas why is Lifehacker's site resistant to my script?
I will take two numbers from user, but this number from EditText must be converted to int. I think it should be working, but I still have problem with compilation code in Android Studio.
CatLog show error in line with:
int wiek = Integer.parseInt(wiekEditText.getText().toString());
Below is my full Android code:
public class MyActivity extends ActionBarActivity {
int Wynik;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
int Tmax, RT;
EditText wiekEditText = (EditText) findViewById(R.id.inWiek);
EditText tspoczEditText = (EditText) findViewById(R.id.inTspocz);
int wiek = Integer.parseInt(wiekEditText.getText().toString());
int tspocz = Integer.parseInt(tspoczEditText.getText().toString());
Tmax = 220 - wiek;
RT = Tmax - tspocz;
Wynik = 70*RT/100 + tspocz;
final EditText tempWiekEdit = wiekEditText;
TabHost tabHost = (TabHost) findViewById(R.id.tabHost); //Do TabHost'a z layoutu
tabHost.setup();
TabHost.TabSpec tabSpec = tabHost.newTabSpec("Calc");
tabSpec.setContent(R.id.Calc);
tabSpec.setIndicator("Calc");
tabHost.addTab(tabSpec);
tabSpec = tabHost.newTabSpec("Hints");
tabSpec.setContent(R.id.Hints);
tabSpec.setIndicator("Hints");
tabHost.addTab(tabSpec);
final Button Btn = (Button) findViewById(R.id.Btn);
Btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(),"blablabla"+ "Wynik",Toast.LENGTH_SHORT).show();
}
});
wiekEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Btn.setEnabled(!(tempWiekEdit.getText().toString().trim().isEmpty()));
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.my, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
I want to define a custom PropertySourcesPlaceholderConfigurer in spring context xml. I want to use there multiple PropertySources, so that I can load part of the configuration from several property files and provide other part dynamically by my custom PropertySource implementation. The advantage is that it should be then easy to adjust the order of loading these property sources just by making modifications to the xml spring configuration.
And here I run into a problem: how to define an arbitrary list of PropertySources and inject it into PropertySourcesPlaceholderConfigurer, so that it uses the sources defined by me?
Seems to be a basic thing that should be provided by spring, but since yesterday I cannot find a way to do it. Using namespace would enable me to load several property files, but I also need to define the id of the PropertySourcesPlaceholderConfigurer (as other projects refer to it), and also I want to use my custom implementation. That is why I am defining the bean explicitly and not using the namespace.
The most intuitive way would be to inject a list of PropertySources into PropertySourcesPlaceholderConfigurer like this:
<bean id="applicationPropertyPlaceholderConfigurer" class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="ignoreResourceNotFound" value="true" />
<property name="order" value="0"/>
<property name="propertySources">
<list>
<!-- my PropertySource objects -->
</list>
</property>
</bean>
but unfortunately propertySources is of type PropertySources and does not accept a list. The PropertySources interface has one and only implementor which is MutablePropertySources, which indeed stores list of PropertySource objects, but has no constructor nor setter through which I can inject this list. It only has add*(PropertySource) methods.
The only workaround I see now is to implement my own PropertySources class, extending MutablePropertySources, which would accept list of PropertySource objects on creation and manually add it via using add*(PropertySource) method. But why so much workaround would be needed to provide something that I thought was supposed to be the main reason of introducing the PropertySources (having flexible configuration manageable from spring configuration level).
Please clarify what am I getting wrong :)
Hello, I'm trying to externalize the QuartzConfig.groovy
I want to be able to set autoStartup to true or false with an external file.
In Config.groovy it is possible to use the grails.config.locations and set properties file that override the properties. Is there something like this in QuartzConfig.groovy ?
Thank you
Hello,
I'm building a shopping cart and I would like to use a JavaScript function to validate user input when entering the quantity value in the quantity text input. I would like to allow the entering of integer values only (no floats, no other characters).
I know that I can apply this function using onKeyUp event and also I found isNaN() function, but it returns true even for floats (which is not ok).
Can you guys help me out with this one?
Thanks.
How would I go about ensuring that the overridden parent method exists before I call it?
I've tried this:
public function func() {
if (function_exists('parent::func')) {
return parent::func();
}
}
However the function_exists never evaluates to true.
I have setAttribute(Qt::WA_OpaquePaintEvent,true) on a widget. From a mouseMoveEvent, I scroll the widget. Now what I need to do is to update the newly exposed area, but it seems that doing this from the paintevent function create an artifact because there is a delay created when the user keeps scrolling. In other words, the widget seems to have scrolled again between the call to scrool and the call or end of paintevent.
For example, while the paint event is trying to draw the desired area, the widget is still scrolling
How can I find out through reflection what is the string name of the method?
For example given:
class Car{
public void getFoo(){
}
}
I want to get the string "getFoo", something like the following:
Car.getFoo.toString() == "getFoo" // TRUE
Time.ToString("0.0") shows up as a decimal "1.5" for instead of 1:30 how can I get it to display in a time format.
private void xTripSeventyMilesRadioButton_CheckedChanged(object sender, EventArgs e)
{
//calculation for the estimated time label
Time = Miles / SeventyMph;
this.xTripEstimateLabel.Visible = true;
this.xTripEstimateLabel.Text = "Driving at this speed the estimated travel time in hours is: " + Time.ToString("0.0") + " hrs";
}
{"paging": {"pageNum":2,"action":"Next","type":"","availableCacheName":"getAllFunds","selectedCacheName":"","showFrom":101,"showTo":200,"totalRec":289,"pageSize":100},
"Data":[{"sourceCodeId":0,"radio_fund":"individua
l","availableFunds":[],"fundId":288,"searchName":[],"fundName":"Asian Equity Fund A Class Income","srcFundGrpId":"PGI","firstElement":0,"las
tElement":0,"totalElements":0,"pageList":[],"standardExtract":true}]
I have json file with above format with two fileds,one paging and one is Data array.
I able to retrieve values of paging,but i am not able to retrieve the values of data array with .each function of jquery.
Any suggestions or inputs really appreciated.
$this->totplpremium is 2400
$this->minpremiumq is 800
So why would this ever return true?!
if ($this->totplpremium < $this->minpremiumq){
The figures are definitely correct and I am definitely using the 'less than' symbol. I can't work it out.
PHPIniDir "D:/Dev/PHP/"
The above instruction can make my apache die on windows.
But I'm just not sure if that's true.
BTW,I found xmpp/wampserver copies the php.ini to the directory of httpd.exe,maybe for the lack of support?
I am using this code to check the checkbox is chekced or not..
$('#nextpage').click(function() {
var result = $('#Details input[type=checkbox]').attr('checked');
if (result == true) {
$("#tabs").tabs('enable', 3).tabs('select', 3);
}
else {
$().ShowDialog('please select atleast one');
}
});
using this I can check only for one checkbox
if I need to check for multipe checkboxes in teh Details page how do I need to loop throw?
thanks
Using prototype, is there a simple method of checking that a group of values match, for example - can this code be refined to a single line or something otherwise more elegant?
var val = '';
var fail = false;
$('form').select('.class').each(function(e){
if(!val){
val = $F(e);
}else{
if(val != $F(e)) fail = true;
}
});
Since attributes don't inherit in C# (at least I didn't think they did) - how does the following code still display the Hello popup when the MyTestMethod test is run:
[TestClass]
public class BaseTestClass {
[TestInitialize]
public void Foo() {
System.Windows.Forms.MessageBox.Show("Hello");
}
}
[TestClass]
public class TestClass : BaseTestClass {
[TestMethod]
public void MyTestMethod() {
Assert.IsTrue(true);
}
}
I am trying to implement an HTML format mail using the Java mail in android. I would like to get results like this:
When I look at the html format sent from lookout in my GMAIL. I don't see any link, but just has this format:
[image: Lookout_logo]
[image: Signal_flare_icon] Your battery level is really low, so we located
your device with Signal Flare.
I was trying the following:
Properties props = System.getProperties();
props.put("mail.smtp.starttls.enable", "true"); // added this line
props.put("mail.smtp.host", host);
props.put("mail.smtp.user", from);
props.put("mail.smtp.password", pass);
props.put("mail.smtp.port", "587");
props.put("mail.smtp.auth", "true");
javax.mail.Session session = javax.mail.Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
InternetAddress[] toAddress = new InternetAddress[to.length];
// To get the array of addresses
for( int i=0; i < to.length; i++ )
{
// changed from a while loop
toAddress[i] = new InternetAddress(to[i]);
}
message.setRecipients(Message.RecipientType.BCC, toAddress);
message.setSubject(sub);
//message.setText(body);
body = "<!DOCTYPE html><html><body><img src=\"http://en.wikipedia.org/wiki/Krka_National_Park#mediaviewer/File:Krk_waterfalls.jpg\">";
message.setContent(body, "text/html; charset=utf-8");
Transport transport = session.getTransport("smtp");
transport.connect(host, from, pass);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
When I look at the html format sent with the above code. I get the following:
<!DOCTYPE html><html><body><img src="http://en.wikipedia.org/wiki/Krka_National_Park#mediaviewer/File:Krk_waterfalls.jpg>
How to make sure the user will not be able to see any html code or URL link like the mail sent by LOOKOUT?
Thanks!
Suppose I have my models set up already.
class books(models.Model):
title = models.CharField...
ISBN = models.Integer...
What if I want to add this column to my table?
user = models.ForeignKey(User, unique=True)
How would I write the raw SQL in my database so that this column works?
I came upon a comment on another forum today and one user responding to another suggested that a CS degree is really only good for one through two years at the most, and after that its as if you never had it. Is this really true? is this what employers think?
When I did CS I never learned anything new, we learned fundamentals like data structures, algorithms, time complexity, OS fundamentals, language characteristics. Most of this stuff has been around for the past 20 years or so.
Based on the suggestion give here, and the information given here on how to make a custom bindingHandler for a forEach, I decided to attempt to write my own custom binding for a forEach and Masonry.
Because the elements are added on the fly the redrawing and moving around of elements to fill the space doesn't occur. So, this functionality needed to be moved after the elements have been rendered or called after each item has been added.
Here is my bindingHandler
ko.bindingHandlers.masonry = {
init: function (element, valueAccessor, allBindingsAccessor) {
var $element = $(element),
originalContent = $element.html();
$element.data("original-content", originalContent);
//var msnry = new Masonry($element);
return { controlsDescendantBindings: true }
},
update: function (element, valueAccessor, allBindingsAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor()),
//get the list of items
items = value.items(),
//get a jQuery reference to the element
$element = $(element),
//get the current content of the element
elementContent = $element.data("original-content");
$element.html("");
var container = $element[0];
var msnry = new Masonry(container);
for (var index = 0; index < items.length; index++) {
(function () {
//get the list of items
var item = ko.utils.unwrapObservable(items[index]),
$childElement = $(elementContent);
ko.applyBindings(item, $childElement[0]);
//add the child to the parent
$element.append($childElement);
msnry.appended($childElement[0]);
})();
msnry.layout();
msnry.bindResize();
}
}
};
and the HTML implementing the handler.
<div id="criteriaContainer" data-bind="masonry: { items: SearchItems.Items }">
<div class="searchCriterion control-group">
<label class="control-label" data-bind="text: Description"></label>
<div class="controls">
<input type="hidden" data-bind="value: Value, select2: { minimumInputLength: 3, queryUri: SearchUri(), placeholder: Placeholder(), allowClear: true }" style="width: 450px">
</div>
<p data-bind="text: Value"></p>
</div>
</div>
When this shows up on the page It stacks all if the elements rendered via the append method right on top of each other.
You can see in my bindingHandler I am calling bindResize as well as layout(), neither of which seem to be having any effect.
Here's a screenshot of what it looks like in the UI.
Hi,
AFAIAK, freeing a NULL will result in nothing.i mean nothing is being done by the compiler/no functionality is performed.
Still i do see some statements where people say that one of the scenario,where a memory corruption can occur is "freeing a memory twice"?
Is this still true?
I want to know how to run a progress bar and some other work simultaneously, then when the work is done, stop the progress bar in Python (2.7.x)
import sys, time
def progress_bar():
while True:
for c in ['-','\\','|','/']:
sys.stdout.write('\r' + "Working " + c)
sys.stdout.flush()
time.sleep(0.2)
def work():
*doing hard work*
How would I be able to do something like:
progress_bar() #run in background?
work()
*stop progress bar*
print "\nThe work is done!"