Wednesday, 11 September 2013

Storyboard app run on iOS 7 OK but Navbar shift view on iOS 6.1

Storyboard app run on iOS 7 OK but Navbar shift view on iOS 6.1

While rebuilding my project with the new Xcode 5 released yesterday, I was
disappointed to see my storyboard view controller shaken up.
After many attempts to fix things, I must conclude I'm stuck with one
remaining issue: Navigation View Controller makes the navigation bar
overlaps with the content of the view. Doing so, the app is ok on a iOS 7
device (no overlapping), but with a iOS 6.1 device, the navbar overlaps.
I ran a sample project from FlatUI to crosscheck the issue, and they have
the same issue. Any idea please?

Delete Trailing Comma - (Did my research before asking this, trust me.)

Delete Trailing Comma - (Did my research before asking this, trust me.)

Ok before you say anything, I've done my research for an hour now and no
techniques are working... proceeding to the question:
I am using a multidimensional array and trying to echo all car models of
one particular make within an array. I have the following code:
<?php
$cars=array("Dodge"=>array("Avenger","Challenger","Charger","Dart"),"Toyota"=>array("Highlander","Tundra","Corolla"),"Nissan"=>array("Sentra","Altima","Maxima"));
echo "Make: Toyota"; echo "<br><br>";
foreach($cars['Toyota'] as $x)
{
$cars['Toyota'] = rtrim($x, ',');
echo "$x, ";
}
?>
Clearly my most recent shot at this was using the rtrim function but that
didn't work for me. Also tried implode function to no success. May I have
some help here? Your time is much appreciated! Thanks.

jQuery - How do I change view based on mouseOver?

jQuery - How do I change view based on mouseOver?

I made the home page of my site so that when you mouse over the different
service offerings that the related image would also display. However when
Malsup's hosting of Cycle came off github the function was lost.
Here is the code I am using that worked before but no longer works
correctly. The slideshow still cycles through, but the mouseover function
does not work correctly.
<script type="text/javascript">
$(document).ready(function() {
$('#slideshow').cycle({
fx: 'fade',
pager : '#slideshow-nav',
pagerEvent: 'mouseover',
pauseOnPagerHover: true,
speed: 1000,
delay: 3000,
timeout: 9000,
pagerAnchorBuilder: function(idx, slide) {
// return sel string for existing anchor
return '.features ul li:eq(' + (idx) + ') a';
},
allowPagerClickBubble: true
});
});
</script>
What changes do I need to make to get it working again?
Thanks.

codeingiter view referencing previous view's call variables

codeingiter view referencing previous view's call variables

I've got a problem I have only recently noticed in my code ingiter app.
I've stripped down the issue to try to locate the problem, but i'm still
lost.
I have the following view (template/assets/box):
<div class="box <? if(isset($class)){echo $class;} ?>">
<?
if(isset($boxtitle) || isset($titleimg)){
?>
<div class="head">
<? if(isset($boxtitle)){ echo '<h3>'.$boxtitle.'</h3>';} ?>
<? if(isset($titleimg)){ echo '<img src="'.$titleimg.'" />';} ?>
</div>
<?
$has_head = 1;
}
?>
<div class="content <? if(!isset($has_head)){ echo 'border-top';}?> <?
if(!isset($footer)){ echo 'border-bottom';}?>">
<?
if(isset($type)){
switch($type){
case 'list':
echo '<ul class="list" >';
foreach($items as $item){
?>
<li><?=$item; ?></li>
<?
}
echo '</ul>';
break;
case 'grid':
break;
default:
echo '<div class="item">'.$content.'</div>';
break;
}
}
else{
echo '<div class="item">'.$content.'</div>';
}
?>
</div>
<?
if(isset($footer)){
?><div class="footer <? if(isset($items)){echo 'border-top';}
?> "><?
echo $footer;
?></div><?
}
?>
</div>
Then, for debugging purposes, i've adding the following into a controller:
public function index(){
// page data
$data['page_title'] = 'Directories';
// load template and output
$this->load->view('template/assets/box',array('boxtitle'=>'foo','content'=>'bar'));
$this->load->view('template/assets/box',array('content'=>'blah'));
$this->load->view('template/assets/box',array());
#$this->Template_model->view('directories/index',$data);
}
however, when I load this controller, I get the following:
<div class="box ">
<div class="head">
<h3>foo</h3> </div>
<div class="content border-bottom">
<div class="item">bar</div>
</div>
</div>
<div class="box ">
<div class="head">
<h3>foo</h3> </div>
<div class="content border-bottom">
<div class="item">blah</div>
</div>
</div>
<div class="box ">
<div class="head">
<h3>foo</h3> </div>
<div class="content border-bottom">
<div class="item">blah</div>
</div>
</div>
Basically, each call to the view seems to cascade the previous variables
to the view unless overwritten. Is this a bug in codeigniter? Is it
something that maybe PHP or CI config might be causing issues? I can't
think of anything I've done which might have caused this problem.

How to position inlines in Django Admin?

How to position inlines in Django Admin?

I have two tables related Quiz and Difficulty_level:
I have created inline in admin.py like this:
class DifficultyLevelInline(admin.TabularInline):
model = DifficultyLevel
and included in QuizAdmin
To arrange the list order, I would do:
list_display = ('name', 'description', 'publication_date', 'category',
'is_active', 'is_premium')
How can I add inlines in the list_display order. I want to display The
DifficultyLevelInline before category.

Tuesday, 10 September 2013

MAMP & OpenDNS - Didn't play well together, now MAMP broken

MAMP & OpenDNS - Didn't play well together, now MAMP broken

My MBP 15 on 10.7.5 used to deploy MAMP locally like a dream, but after I
tried out OpenDNS (switching my DNS's to the recommended IPs), whenever I
tried hitting localhost, ODNS blocked/redirected it to a search.
Eventually, I stripped my DNS settings, and it returned back to the
default IP assigned by Comcast (10.x.x.x).
So when opening MAMP now, when I hit Start Servers, I get both green
lights. But the start page comes up, and I get "Firefox can't find the
server at localhost.", "Oops! Google Chrome could not find
localhost:8888". After about 3 hours of cold research and trial-and-error
reinstalling, messing around in Activity Monitor, modifying host files,
httpd.conf, etc. I'm right where I started.
I have no idea how to "clear" the effect ODNS had on my setup, and I have
some certainty that that was the cause, as it worked without a hitch
before. Should I abandon my efforts to MAMP (short of wiping out my
computer)? Or is there a way I can get it back working?
Appreciate your response, Stack Overflow.
Jonathan

Complex mathematical formula in jquery function is not working

Complex mathematical formula in jquery function is not working

This is actually a mortgage calculation.
I've got it working when used the normal way - that is, to determine a
monthly payment when the user inputs four variables (loan amount, down
payment, interest rate, and term years).
But when I try to change the formula to solve for loan amount (an
affordability calculator), I'm getting bad results.
Here's the original formula as explained by the Mortgage Professor:
The following formula is used to calculate the fixed monthly payment (P)
required to fully amortize a loan of L dollars over a term of n months at
a monthly interest rate of c. [If the quoted rate is 6%, for example, c is
.06/12 or .005].
P = L[c(1 + c)n]/[(1 + c)n - 1]
http://www.mtgprofessor.com/formulas.htm
I'll first give the example that is working properly.
HTML:
<form>
<div class="col-md-4">
<h4>Home Price</h4>
<input type="text" id="price">
<h4>Down Payment</h4>
<input type="text" id="down">
</div>
<div class="col-md-4">
<h4>Rate (%)</h4>
<input type="text" id="apr">
<h4>Term (Years)</h4>
<input type="text" id="term">
</div>
<div class="col-md-4">
Your Monthly Payment:
<div id="payment"></div>
</div>
</form>
jQuery:
$(function(){
function calculate_monthly_payment() {
var price = parseFloat($('#price').val());
var down = parseFloat($('#down').val());
var apr_decimal = parseFloat($('#apr').val()) / 100;
var monthly_interest = apr_decimal / 12;
var term = parseFloat($('#term').val()) * 12;
var loan_amount = parseFloat(price - down);
var formula_numerator = monthly_interest * Math.pow((1 +
monthly_interest), term);
var formula_denominator = Math.pow((1 + monthly_interest), term) -1;
var monthly_payment = parseFloat(loan_amount * (formula_numerator /
formula_denominator)).toFixed(2);
if (!isNaN(monthly_payment)) {
$('#payment').html('$' + monthly_payment);
} else {
$('#payment').html('Calculating...');
}
}
$('#price').keyup(calculate_monthly_payment);
$('#down').keyup(calculate_monthly_payment);
$('#apr').keyup(calculate_monthly_payment);
$('#term').keyup(calculate_monthly_payment);
$('#price').mouseup(calculate_monthly_payment);
$('#down').mouseup(calculate_monthly_payment);
$('#apr').mouseup(calculate_monthly_payment);
$('#term').mouseup(calculate_monthly_payment);
});
The part that isn't working properly:
HTML:
<form>
<div class="col-md-6">
<h4>Income (Monthly)</h4>
<input type="text" id="income">
<h4>Debts (Monthly, not including housing costs)</h4>
<input type="text" id="debts">
<h4>Down Payment</h4>
<input type="text" id="down">
<h4>Rate (%)</h4>
<input type="text" id="apr">
<h4>Term (Years)</h4>
<input type="text" id="term">
</div>
<div class="col-md-6">
Monthly Payment:
<div id="monthly-payment"></div>
Loan Amount:
<div id="loan-amount"></div>
Purchase Price:
<div id="purchase-price"></div>
Down Payment:
<div id="actual-down"></div>
Closing Costs:
<div id="closing-costs"></div>
</div>
</form>
jQuery:
$(function(){
function calculate_affordability() {
var income = parseFloat($('#income').val());
var debts = parseFloat($('#debts').val());
var down = parseFloat($('#down').val());
var apr_decimal = parseFloat($('#apr').val()) / 100;
var monthly_interest = apr_decimal / 12;
var term = parseFloat($('#term').val());
var debt_ceiling = income * .08;
var monthly_payment = (income * .28).toFixed(2);
var formula_numerator = monthly_interest * Math.pow((1 +
monthly_interest), term);
var formula_denominator = Math.pow((1 + monthly_interest), term) -1;
var loan_amount = parseFloat(monthly_payment / (formula_numerator /
formula_denominator)).toFixed(2);
var closing_costs = (loan_amount * .03).toFixed(2);
var actual_down = (down - closing_costs).toFixed(2);
var purchase_price = (loan_amount - actual_down).toFixed(2);
$('#monthly-payment').html('$' + monthly_payment);
$('#loan-amount').html('$' + loan_amount);
$('#purchase-price').html('$' + purchase_price);
$('#actual-down').html('$' + actual_down);
$('#closing-costs').html('$' + closing_costs);
}
$('#term').keyup(calculate_affordability);
$('#term').mouseup(calculate_affordability);
});
The above is based on looking at the formula and rearranging it.
Original: x = y(a/b)
Solving for y: y = x/(a/b)
Somehow I've gone wrong with the new formula but I'm not sure where nor
how to fix it.
Thank you for any help!