Sunday, 15 September 2013

reading excel file in windows using perl

reading excel file in windows using perl

How do I read an .xlsx file in windows7 using perl module use
Spreadsheet::ParseExcel. it gives me an error that no excel data in
file.Does windows require some other module to read data from an excel
file. please help

Memory leak - multiple instance of activity

Memory leak - multiple instance of activity

I've got a couple of activities. The thing is the app is running out of
memory. I tried to gc.clean() in all activities (in onDestroy), null
references, launchMode="singleTop" but without any success.
In MAT i've found out that I have multiple objects of the same activity
and it a default behaviour, if I'm not mistaken.
If i launch at first time, for example i will have main activity: 1, if i
will quit and launch again i will have 2 instance.
that the VM budget just grow and make force close dialog.
Example of my code:
public class Splash extends Activity { private RelativeLayout splash_layout;
private RelativeLayout welcome_message_layout;
private TextView welcome_message_text;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.splash_layout);
splash_layout = (RelativeLayout)findViewById(R.id.splash_layout);
welcome_message_layout =
(RelativeLayout)findViewById(R.id.welcome_message_layout);
welcome_message_text = (TextView)findViewById(R.id.welcome_message_text);
if(ref.getBoolean("LANGUAGEMODECHANGE",false))
{
welcome_message_layout.setBackgroundResource(R.drawable.welcome_message);
welcome_message_text.setText(getString(R.string.welcome));
switch(ref.getInt("LANGUAGEMODENUMBER",Consts.DEFAULT))
{
case Consts.HEBREW:
splash_layout.setBackgroundResource(R.drawable.welcome_hebrew);
break;
case Consts.ENGLISH:
splash_layout.setBackgroundResource(R.drawable.welcome_english);
break;
case Consts.RUSSIAN:
splash_layout.setBackgroundResource(R.drawable.welcome_russian);
break;
case Consts.ARABIC:
splash_layout.setBackgroundResource(R.drawable.welcome_arabic);
break;
default:
splash_layout.setBackgroundResource(R.drawable.bg);
break;
}//close switch
}
}//close onCreate
}//close Splah
Where is the leak?

Saturday, 14 September 2013

Warning: include(../../inc/functions.php): failed to open stream: no such file or directory

Warning: include(../../inc/functions.php): failed to open stream: no such
file or directory

This is the situation that I face off, the following is the structure of
the site:
[root]
index.php
[inc] // inside of this folder is functions.php
[css]
[img]
[connect] // inside of this folder is db.php and setup.php
[admin]
index.php
[img]
[css]
**[inc] // inside of this folder is functions.php**
[connect] // inside of this folder is db.php and setup.php to connect
the admin
[content] // here is page.php
[op] // here are add.php, modify.php, delete.php
I've tested using absolute and relative paths, DIR,
$_SERVER['DOCUMENT_ROOT'], etc
the problem is when I tried to include the functions.php file from the
folder inc to the folder content or op. I've tested in some different ways
and checks some answers from here I cannot fixed it.
Could someone fix this issue?

Embedding Image Data in CSS with System.Web.Optimization

Embedding Image Data in CSS with System.Web.Optimization

I have been searching all day reading articles, blogs, forums about this,
but either I'm not understanding it well or I truly haven't found the
answer.
On my site, I have implemented microsft.web.optimization v.1.0.0 and found
an extension method below (which can be found at Optimizing without
drawbacks):
public class CssImageEmbedTransform : CssMinify {
private static readonly Regex url = new
Regex(@"url\((([^\)]*)\?embed)\)", RegexOptions.IgnoreCase);
private const string format = "url(data:image/{0};base64,{1})";
public override void Process(BundleResponse bundle) {
base.Process(bundle);
string reference = HttpContext.Current.Request.ApplicationPath +
"includes/css/";
// Before Using BundleTable to ResolveUrl in head control
// HttpContext.Current.Request.Path.Replace("/barry.css", "/");
// debug stuff
// HttpContext.Current.Response.Write("<br />Before Matches<br />");
//
HttpContext.Current.Response.Write(url.Matches(bundle.Content).Count
+ "<br />");
foreach (Match match in url.Matches(bundle.Content)) {
var file = new FileInfo(HostingEnvironment.MapPath(reference +
match.Groups[2].Value));
if (file.Exists) {
string dataUri = GetDataUri(file);
bundle.Content = bundle.Content.Replace(match.Value,
dataUri);
HttpContext.Current.Response.AddFileDependency(file.FullName);
}
}
// debug stuff
// HttpContext.Current.Response.Write("After Matches");
// HttpContext.Current.Response.End();
}
private string GetDataUri(FileInfo file) {
byte[] buffer = File.ReadAllBytes(file.FullName);
string ext = file.Extension.Substring(1);
return string.Format(format, ext, Convert.ToBase64String(buffer));
}
}Along with this code:
private void SetupBundles() {
BundleTable.Bundles.EnableDefaultBundles();
Bundle css = new Bundle("~/mycc.css",
typeof(CssImageEmbedTransform));
css.AddFile("~/includes/css/mycss.css");
BundleTable.Bundles.Add(css);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}What that did was convert background-image:
url(Images/myImage.png?embed); to background-image:
url(data:image/png;base64,iVBORw0KGgoA...lFTkSuQmCC);.
I have recently updated my site to use system.web.optimization v.1.1.0
(found at Bundling and Minification) and I'm wondering if there is
something similar or better (maybe built-in) to accomplish the same?
Thanks!

Record last activity of a logged in user in Pyramid

Record last activity of a logged in user in Pyramid

In an application I am building in Pyramid,I have a users table with a
field called 'last_activity'. This field is intented to store the
timestamp of the last time a user visited a page in the system.
Since I'm still a bit new in pyramid, I don't know if pyramid has some
sort of way to create a "common" view that can be executed everytime a
user visits any page in the site (in order to update the 'last_activity'
field in this view function). Is this possible?
If that is not possible, what would you recommend me to do this?
Thanks in advance.

(Homework) Converting an NFA to a DFA with a lambda transition, but no transition for some a in the alphabet

(Homework) Converting an NFA to a DFA with a lambda transition, but no
transition for some a in the alphabet

If my alphabet is {a,b} and my nfa has a state q0 with the following
transition:
State | a b (no input)
--------------------------------------------
q0 q1 null q1
Is this table wrong? should delta(q0, b) = q1 because q0 can move on (no
input) to state q1?

How to calculate address subtraction in c++

How to calculate address subtraction in c++

I am a little surprised by the output of the following code:
double array[] = {4, 5, 6, 8, 10, 20};
double* p = array + 3;
//Print array address
cout << (unsigned long)(array) << endl; //This prints 1768104
cout << (unsigned long)(p) << endl; //This prints 1768128
//print p - array
cout << (unsigned long)(p - array) << endl; // This prints 3
I am surprised that the last line prints 3. Shouldn't it print 24 = 3 * 8
bytes? Also, as expected, the address of p is the address of array + 3 * 8
bytes. This seems inconsistent. In fact, it is not even a legal assignment
to write: p = p - array; // can't assign an int to type double* No idea,
why this is an int.