Tuesday, 10 September 2013

Mage::getResourceSingleton('core/cache') returns false

Mage::getResourceSingleton('core/cache') returns false

Im having this problem: Fatal error: Call to a member function
getAllOptions() on a non-object in
/home/detona/public_html/app/code/core/Mage/Core/Model/Cache.php on line
456
checking in this file I see that:
protected function _getResource()
{
return Mage::getResourceSingleton('core/cache');
}
returns false..
Checking in the internet I tryed:
1) I deleted the var/cache/ and var/session/
2) /app/etc/config.xml and local.xml are there, and it was working before
Any idea?

Run Specs error: Couldn't load the Unicode tables for

Run Specs error: Couldn't load the Unicode tables for

I tried to run my specs but I got the following error:
No DRb server is running. Running in local process instead ...
1) FinancialAccountsQuery parcial_future_releases LIMIT_DATE_FILTER
transactions
Failure/Error: let(:financial_account) {
FactoryGirl.create(:financial_account_with_church) }
IOError:
Couldn't load the Unicode tables for UTF8Handler (dump format
error(0x6b)), ActiveSupport::Multibyte is unusable
# ./spec/queries/financial_accounts_query_spec.rb:4:in `block (2 levels)
in <top (required)>'
# ./spec/queries/financial_accounts_query_spec.rb:106:in
`create_transaction'
# ./spec/queries/financial_accounts_query_spec.rb:8:in `block (3 levels)
in <top (required)>'
I tried to drop all the databases with rake db:drop, then create them
again with rake db:create and rake db:migrate, but nothing seems to solve
it.
My database.yml
development:
adapter: "mysql2"
encoding: "utf8"
database: "ibc1"
username: "root"
password: ""
host: 127.0.0.1
test:
adapter: "mysql2"
encoding: "utf8"
database: "gi_test"
username: "root"
password: ""
host: 127.0.0.1
Anyone has any idea to solve this ? Thanks :)

Javascript: Body background

Javascript: Body background

I'm not that good with Javascript but because I felt I needed it for
making the more modern websites I decided to make a function that changes
the body background image after every 10 seconds.
function Background()
{
var Background_Stage;
switch(Background_Stage)
{
case 0:
{
$('body').css.toogle("slide").('background', '#000
url(../../Styles/Callum_Project1/Images/BACKGROUND_1_TEST.png)
no-repeat');
Background_Stage++;
setInterval(function(){Background()},10000);
}
case 1:
{
$('body').css.toogle("slide").('background', '#000
url(../../Styles/Callum_Project1/Images/BACKGROUND_2_TEST.png)
no-repeat');
Background_Stage++;
setInterval(function(){Background()},10000);
}
case 2:
{
$('body').css.toogle("slide").('background', '#000
url(../../Styles/Callum_Project1/Images/BACKGROUND_2_TEST.png)
no-repeat');
Background_Stage = 0;//Reset
setInterval(function(){Background()},10000);
}
}
}
However hen I did something like this
<body onload="Background()"></body>
It doesn't seem to do anything, this might be a dumb thing to ask for help
with but this is the first I did when I was learning JavaScript, I should
say that I used jQuery for most of this.

Icons not aligned properly in JQuery Mobile 1.3.2

Icons not aligned properly in JQuery Mobile 1.3.2

I have just downloaded that last JQuery Mobile 1.3.2 version.
I have noticed all my icons are now out of position.
If you look at the images below, you can see they are slightly to the left
/ top of the buttons.
Has anyone else got this bug / know a solution?

Add a timestamp to file name

Add a timestamp to file name

To avoid name collisions, I need to add a timestamp like extension to
files my server creates. I was thinking to something like yyyymmddhhss.
What is the efficient way to generate a string like '201309091725' (with
eventually more digits) ?
select cast( sysdatetime() as varchar) does include spaces, colons and
dots, making that unusable.

Monday, 9 September 2013

How to increase test coverage in salesforce for external api callout

How to increase test coverage in salesforce for external api callout

I have apex class in which i am getting lots of count from external api.
External 'api' return counts in json format. For decode this json i am
using following code,
ddDashboard obj = (ddDashboard) System.JSON.deserialize(json,
ddDashboard.class);
here 'ddDashboard' is my class name. using this i am getting counts and i
am directly assign this count to class variable.
account_total_processed_records_count=
obj.account_total_processed_records_count;
here if i write this assignment the test coverage is decreases.
Anybody can help me how can i increase test coverage for above problem OR
how can i write test method for assing count value to class variable from
external API call.
Thank you in advance, Rajendra J.

Why is univariate Horner in Fortran faster than NumPy counterpart while bivariate Horner is not

Why is univariate Horner in Fortran faster than NumPy counterpart while
bivariate Horner is not

I want to perform polynomial calculus in Python. The polynomial package in
numpy is not fast enough for me. Therefore I decided to rewrite several
functions in Fortran and use f2py to create shared libraries which are
easily imported into Python. Currently I am benchmarking my routines for
univariate and bivariate polynomial evaluation against their numpy
counterparts.
In the univariate routine I use Horner's method as does
numpy.polynomial.polynomial.polyval. I have observed that the factor by
which the Fortran routine is faster than the numpy counterpart increases
as the order of the polynomial increases.
In the bivariate routine I use Horner's method twice. First in y and then
in x. Unfortunately I have observed that for increasing polynomial order,
the numpy counterpart catches up and eventually surpasses my Fortran
routine. As numpy.polynomial.polynomial.polyval2d uses an approach similar
to mine, I consider this second observation to be strange.
I am hoping that this result stems forth from my inexperience with Fortran
and f2py. Might someone have any clue why the univariate routine always
appears superior, while the bivariate routine is only superior for low
order polynomials?
Here is my code, a script for automated benchmarking and 2 plots:
polynomial.f95
subroutine polyval(p, x, pval, nx)
implicit none
real(8), dimension(nx), intent(in) :: p
real(8), intent(in) :: x
real(8), intent(out) :: pval
integer, intent(in) :: nx
integer :: i
do i = 1, nx
pval = pval*x + p(nx-i+1)
end do
end subroutine polyval
subroutine polyval2(p, x, y, pval, nx, ny)
implicit none
real(8), dimension(nx, ny), intent(in) :: p
real(8), intent(in) :: x, y
real(8), intent(out) :: pval
integer, intent(in) :: nx, ny
real(8) :: tmp
integer :: i
do i = 1, ny
call polyval(p(:, ny-i+1), x, tmp, nx)
pval = pval*y + tmp
end do
end subroutine polyval2
benchmark.py (use this script to produce plots)
import time
import numpy as np
from numpy import f2py
import matplotlib.pyplot as plt
# Compile and import Fortran module
fid = open('polynomial.f95')
source = fid.read()
fid.close()
f2py.compile(source, modulename='polynomial')
import polynomial
# Create random x and y value
x = np.random.rand()
y = np.random.rand()
#==============================================================================
# Array containing the polynomial order + 1 for several univariate
polynomials
n_uni = np.array([2**i for i in xrange(1, 21)])
# Initialise arrays for storing timing results
time_numpy = np.zeros(n_uni.size)
time_fortran = np.zeros(n_uni.size)
for i in xrange(len(n_uni)):
# Create random univariate polynomial of order n - 1
p = np.random.rand(n_uni[i])
# Time evaluation of polynomial using NumPy
t1 = time.time()
np.polynomial.polynomial.polyval(x, p)
t2 = time.time()
time_numpy[i] = t2 - t1
# Time evaluation of polynomial using Fortran
t1 = time.time()
polynomial.polyval(p, x)
t2 = time.time()
time_fortran[i] = t2 - t1
# Speed-up factor
factor_uni = time_numpy / time_fortran
plt.figure()
plt.plot(n_uni, factor_uni)
plt.title('Univariate comparison')
plt.xlabel('# coefficients')
plt.ylabel('Speed-up factor')
plt.xlim(n_uni[0], n_uni[-1])
plt.ylim(0, max(factor_uni))
plt.xscale('log')
#==============================================================================
# Array containing the polynomial order + 1 for several bivariate polynomials
n_bi = np.array([2**i for i in xrange(1, 11)])
# Initialise arrays for storing timing results
time_numpy = np.zeros(n_bi.size)
time_fortran = np.zeros(n_bi.size)
for i in xrange(len(n_bi)):
# Create random bivariate polynomial of order n - 1 in x and in y
p = np.random.rand(n_bi[i], n_bi[i])
# Time evaluation of polynomial using NumPy
t1 = time.time()
np.polynomial.polynomial.polyval2d(x, y, p)
t2 = time.time()
time_numpy[i] = t2 - t1
# Time evaluation of polynomial using Fortran
t1 = time.time()
polynomial.polyval2(p, x, y)
t2 = time.time()
time_fortran[i] = t2 - t1
# Speed-up factor
factor_bi = time_numpy / time_fortran
plt.figure()
plt.plot(n_bi, factor_bi)
plt.title('Bivariate comparison')
plt.xlabel('# coefficients')
plt.ylabel('Speed-up factor')
plt.xlim(n_bi[0], n_bi[-1])
plt.ylim(0, max(factor_bi))
plt.xscale('log')
plt.show()