Thursday, 3 October 2013

JQuery UI color change

JQuery UI color change

Observed a strange behavior for my UI, when I see my UI which is developed
with JQuery, the color combination changes for a high resolution PC, even
after making all color set up possible. Any Idea how can I fix this?

Wednesday, 2 October 2013

PHP: $_SESSION doesn't seem to get set. Any idea?

PHP: $_SESSION doesn't seem to get set. Any idea?

I got through this SO Q/A while searching why my session wouldn't get set.
On $_GET set $_SESSION won't work
I don't really get whether this applies to my case. Here it goes.
index.php
<?php
session_start();
if (!isset($_SESSION["authenticated"])) $_SESSION["authenticated"] = false;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
...
Then, I call the following when the user authenticates himself.
authenticate.php
<?php
require_once "data/data_access.php";
$userName = "";
$password = "";
if (isset($_REQUEST["userName"])) $userName = $_REQUEST["userName"];
if (isset($_REQUEST["password"])) $password = $_REQUEST["password"];
$isAuthentic = isAuthenticUser($userName, $password);
$_SESSION["authenticated"] = $isAuthentic;
echo $isAuthentic;
?>
I also have this authentication-thing checked every 5 seconds in order to
create the buttons for the section the user is in.
authenticated.php
<?php echo isset($_SESSION["authenticated"]) && $_SESSION != false ?
'true' : 'false'; ?>
and my Ajax call setup:
my_project.js
$(document).ready(function() { startAuthenticationChecking(); });
function startAuthenticationChecking() {
setInterval(function() { ajaxSession("authenticated.php"); }, 5000);
}
function ajaxSession(actionURL) {
var authenticated = false;
$.ajax({
async: false,
url: actionURL,
success: function(authenticated) {
alert(authenticated);
if (authenticated) {
if (("#addNewAtvButtonDiv").is(":empty"))
$("#addNewAtvButtonDiv").add("<button
id='newAtvButton'>Inscrire un nouveau VTT en
inventaire</button>");
if (("#addNewSledButtonDiv").is(":empty"))
$("#addNewSledButtonDiv").add("<button
id='newSledButton'>Inscrire un nouvel UTT en
inventaire</button>");
if (("#addNewUtvButtonDiv").is(":empty"))
$("#addNewUtvButtonDiv").add("<button
id='newUtvButton'>Inscrire une nouvelle
motoneige</button>");
$("button").button();
} else {
$("#addNewAtvButtonDiv").children().remove();
$("#addNewSledButtonDiv").children().remove();
$("#addNewUtvButtonDiv").children().remove();
}
}
});
}
My Problem
Though I set $_SESSION["authenticated"] = false right after the
session_start();, when the ajaxSession() asks whether a user is
authenticated through authenticated.php, it always returns 'false'. Event
after an authentication using authenticate.php with proper credentials.
Related question: PHP / Ajax : How to show/hide DIV on $_SESSION variable
value?
Any help welcome! I've been working on this for a few nights and days
lately, and still am.
Thanks!

Prevent timer from stopping when window is inactive Javascript

Prevent timer from stopping when window is inactive Javascript

Helllo, I'm making a quiz application, and want to set a timer. I want to
make it in Javascript. This is my function:
function countDown(sec, elem) {
_(elem).innerHTML = sec;
if(sec < 1) {
clearTimeout(timer);
endGame ();
return;
}
sec--;
var timer = setTimeout('countDown('+sec+',"'+elem+'")',1000);
}
The problem is that, for example, for mobile Saffari browser, when you
hold your finger on the screen (like scrolling effect), the timer stops,
yet you can still see the questions... So, basically, you can have an
unlimited time. How can I make the timer to run nomatter what?
Thank you in advance!

Java: turning an arraylist into an array with an added element

Java: turning an arraylist into an array with an added element

I know that the code to turn an arraylist into an array is:
private String[] arrayLst_to_array(ArrayList<String> al) {
String[] arr = new String[al.size()];
arr = al.toArray(arr);
return arr;
}
But I want my new array to have a certain string in the beginning and then
after that, I want the rest of the arraylist.
I know that I could just add the string that I want to the beginning of
the arraylist and then convert it, but is there a more efficient way?

Is call to preventDefault() really necessary on drop event?

Is call to preventDefault() really necessary on drop event?

I am learning about Drag & Drop. I have copied a W3Schools example in
JSFiddle.
The W3School example calls preventDefault() in the drop event:
function drop(ev) {
ev.preventDefault();
var data=ev.dataTransfer.getData("Text");
ev.target.appendChild(document.getElementById(data));
}
Yet, I don't understand the need when reading documentation. When I remove
this call, the example still works fine:
function drop(ev) {
var data=ev.dataTransfer.getData("Text");
ev.target.appendChild(document.getElementById(data));
}
So, what is the use of this call to preventDefault()? Do I really need it?
If yes why?

Tuesday, 1 October 2013

disable edit script button in menu sl4a

disable edit script button in menu sl4a

is there some way of hidden or disabbling (graying may be) edit button in
menu of sl4a?
the button in question is that appear when tap or click a name script in
the script list of the sl4a
other: Can I configure these buttons caption and actions?

Visibility Expression regarding data value

Visibility Expression regarding data value

I have a table with 4 columns: AKA, Value, Unit, and Metric.
I have a filter on the dataset on AKA based on a parameter. I am trying to
use the following in the visibility filter:
=IIF(Fields!Metric.Value, "MONTHLY_SummaryStats" = "Availablility", FALSE,
TRUE)
I am getting an error regarding the expression referring directly to a
field without a dataset aggregate.
Any idea why it's asking for an aggregate when I am trying to filter on a
specific value?
Based on the filter on the dataset, this expression should only return 1
value.

Apache and PHP interaction

Apache and PHP interaction

Suppose we have a typical LAMP setup. When a person requests a web page
coded in php, what happens at the Apache level? Does Apache create a new
php instance to create and return that web page? Or is there a continuous
php instance running at all times?
Basically, here is how I think it works:
Person visits http://example.com/index.php
Apache receives the request, spins up an instance of php to create the page
Page is created, sent back to the requesting browser
PHP instance is closed
Thus, only one php instance deals with page requests...Is my thinking
correct on this?

What are these localhosts accessing Apache virtualhost?

What are these localhosts accessing Apache virtualhost?

In my server-status page I see a lot of requests from localhost. what are
these for? are they actually doing anything?
201-0 - 0/0/327 . 0.94 28653 0 0.0 0.00 99.83 ::1
domain.com OPTIONS * HTTP/1.0
202-0 - 0/0/140 . 1.65 28333 0 0.0 0.00 52.80 ::1
domain.com OPTIONS * HTTP/1.0
203-0 - 0/0/359 . 3.15 28425 0 0.0 0.00 88.87 ::1
domain.com OPTIONS * HTTP/1.0
204-0 - 0/0/353 . 4.16 28861 0 0.0 0.00 150.89 ::1
domain.com OPTIONS * HTTP/1.0
205-0 - 0/0/382 . 0.18 28275 0 0.0 0.00 86.17 ::1
domain.com OPTIONS * HTTP/1.0
206-0 - 0/0/242 . 1.19 28586 0 0.0 0.00 119.88 ::1
domain.com OPTIONS * HTTP/1.0
207-0 - 0/0/260 . 1.06 28475 0 0.0 0.00 90.53 ::1
domain.com OPTIONS * HTTP/1.0
208-0 - 0/0/381 . 4.92 28644 0 0.0 0.00 57.20 ::1
domain.com OPTIONS * HTTP/1.0
209-0 - 0/0/172 . 0.81 28273 0 0.0 0.00 101.78 ::1
domain.com OPTIONS * HTTP/1.0
210-0 - 0/0/277 . 1.76 28695 0 0.0 0.00 70.73 ::1
domain.com OPTIONS * HTTP/1.0
211-0 - 0/0/776 . 6.57 20491 0 0.0 0.00 211.93 ::1
domain.com OPTIONS * HTTP/1.0

Monday, 30 September 2013

Journals that publish papers quickly

Journals that publish papers quickly

I have written two papers in Mathematics and want to get them published.
Can you suggest some journals that publish quickly? Besides, how can I
know if a journal is well-regarded or not? I know there's something called
an impact factor but what else? For example how is this journal? IJMRS -
http://www.ijmrs.org/

How to capture serial logs for virtual box android x86 platform

How to capture serial logs for virtual box android x86 platform

I am trying to compile a androidx86 kernel provided by google for
Jellybean filesystem,
While running i want to capture the serial logs, as it will help me in
debugging.Can some one help me in this.
I used the socat mechanism but how do i redirect this socket to a file.

How to store a java.lang.reflect.Method into a database through Hibernate

How to store a java.lang.reflect.Method into a database through Hibernate

I´ve got a class which references a Method (java.lang.reflect), and I need
to store that class and that reference.
Does anybody know how to do it?
It seems to me I can´t do it straightforward, but I think I could
decompose a java.lang.reflect.Method into class-name, method-name,
class-name-parameters, and store those Strings. In that way, I could
re-generate the Method object from them when loading it.
Does it make sense? In that case, any idea about how to do it?
Thanks in advance! Diego.

C# - Find all integers in list of strings

C# - Find all integers in list of strings

Given this list of string values:
"12345", "6789a", "9876", "23467b"
How do we use a Linq statement in C# to select only the integers? In other
words, we only want to return 12345 and 9876. Thanks.

Sunday, 29 September 2013

Get count per year of data with begin and end dates

Get count per year of data with begin and end dates

I have a set of data that lists each employee ever employed in a certain
type of department at many cities, and it lists each employee's begin and
end date.
For example:
name city_id start_date end_date
-----------------------------------------
Joe Public 54 3-19-1994 9-1-2002
Suzi Que 54 10-1-1995 9-1-2005
What I want is each city's employee count for each year in a particular
period. For example, if this was all the data for city 54, then I'd show
this as the query results if I wanted to show city 54's employee count for
the years 1990-2005:
city_id year employee_count
-----------------------------
54 1990 0
54 1991 0
54 1992 0
54 1993 0
54 1994 1
54 1995 2
54 1996 2
54 1997 2
54 1998 2
54 1999 2
54 2000 2
54 2001 2
54 2002 2
54 2003 1
54 2004 1
54 2005 1
(Note that I will have many cities, so the primary key here would be city
and year unless I want to have a separate id column.)
Is there an efficient SQL query to do this? All I can think of is a series
of UNIONed queries, with one query for each year I wanted to get numbers
for.
My dataset has a few hundred cities and 178,000 employee records. I need
to find a few decades' worth of this yearly data for each city on my
dataset.

can not launch app on device

can not launch app on device

I installed Windows 8.1 RTM and installed VS2012 had a little problem
while installing windows phone 8 sdk but i guess it is resolved now but
still i have a weird problem.
Even i select "device" as the launch target when clicked the run button VS
launches the app on the emulator not the phone. Surprisingly if i right
click the project on solution explorer and select debug it this time
launched app on the device.
Is there anybody faced with this kind of problem? I dont want to install
everthing from scratch :)

NullException XML Parsing

NullException XML Parsing

I'm having a problem with parsing XML in C#, my XML file looks like this:
<xml>
<category>books</category>
<id>1</id>
<title>lemony</title>
<sub>
<title>lemonyauthor</title>
</sub>
</xml>
<xml>
<category>comics</category>
<id>2</id>
<sub>
<title>okauthor</title>
</sub>
</xml>
As you can see sometimes the title in "XML" is returned, sometimes not.
My code in C# to parse this looks like:
string _Title;
foreach (XElement str in xmlDoc.Descendants("xml"))
{
_Title = "";
if (str.Element("title").Value != null)
_Title = str.Element("title").Value;
foreach (XElement cha in str.Descendants("sub"))
{
if (_Title.Length < 1 && cha.Element("Title").Value != null)
_Title = cha.Element("title").Value;
}
}
How do I keep the line "if (str.Element("category").Value != null)" from
returning a nullexception? Is using "try" & "catch" the only way?
Thanks.

Use string from MainActivity.java in activity_main.xml

Use string from MainActivity.java in activity_main.xml

I have a string defined in MainActivity.java:
public String counter1 = String.valueOf(e.getCount());
I would like to use this string in activity_main.xml as:
android:text="@string/counter1"
As you can tell I am very new to this so basic steps would be appreciated.
Thanks

Saturday, 28 September 2013

Assembly Objective C class alloc error

Assembly Objective C class alloc error

I have the following assembly code (NASM)
global _main
extern _sizeof
extern _printf
extern _objc_msgSend
extern _objc_getClass
extern _sel_registerName
SECTION .data
alert_text : db "NSAlert", 0
alloc_sel : db "alloc", 0
init_sel : dw "init", 0
alert_class: resb 4
SECTION .text
_main:
; get the class
sub esp, 8
push alert_text
call _objc_getClass
add esp, 12
; save class
mov dword [alert_class], eax
; get alloc selector
sub esp, 8
push alloc_sel
call _sel_registerName
add esp, 12
; allocate it
sub esp, 4
push alloc_sel
; push alert class
mov eax, dword [alert_class]
push eax
call _objc_msgSend
add esp, 12
mov eax, 0
ret
I then assemble it with
$ nasm -fmacho UI.asm -o UI.o
UI.asm:83: warning: uninitialised space declared in __data section: zeroing
$ ld UI.o -macosx_version_min 10.8 -lSystem -framework CoreFoundation
-framework AppKit -o UI
When I run it I get
$ ./UI
2013-09-28 22:29:31.110 UI[60688:707] *** NSForwarding: warning: selector
(0x201c) for message 'alloc' does not match selector known to Objective C
runtime (0x97ee8e93)-- abort
2013-09-28 22:29:31.112 UI[60688:707] +[NSAlert alloc]: unrecognized
selector sent to class 0xacb12514
2013-09-28 22:29:31.112 UI[60688:707] *** Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: '+[NSAlert alloc]:
unrecognized selector sent to class 0xacb12514'
*** Call stack at first throw:
(
0 CoreFoundation 0x99b28e8b __raiseError + 219
1 libobjc.A.dylib 0x9617e52e
objc_exception_throw + 230
2 CoreFoundation 0x99b2c8ed
+[NSObject(NSObject) doesNotRecognizeSelector:] + 253
3 CoreFoundation 0x99a74e87 ___forwarding___ + 487
4 CoreFoundation 0x99a74c32
_CF_forwarding_prep_0 + 50
5 UI 0x00001ff1 main + 71
)
Trace/BPT trap: 5
I can't figure out why it doesn't work, is it something to do with saving
the alert class?

Like/Dislike system without authentication

Like/Dislike system without authentication

I developped a Like/Dislike system on my website WDMND.com.
I am using asp.net with C#.
My goal is to get the feeling of every visitor, even without authentication.
So, I limited the vote on every single control to 1 per IP.
I realised that two users of the same family can't share both their
opinion, because they have the same IP :(
I tought myself "No problem! I'll just limit the votes with the MAC
address :D". Unfortunatly it is not possible :P
I then had the idea of using cookies! The thing is... Some trolls will go
like :
while (!timeToGoToBed)
{
vote --;
cookie.delete();
}
This is where I am in my reflection.. I don't really know what to do with
it. Should I just keep it like this or is there a better way to do this?
I need your opinions and suggestions!
Thank you very much!

Play Iteratee throttling

Play Iteratee throttling

I'm writing a streaming web radio framework using scala and Play. I'm
relying on Iteratees for the actual streaming, but I'm running into an
issue trying to prevent a greedy client from downloading data too quickly,
and consuming the stream for all the clients. To do so I've been trying to
create an Enumeratee that will throttle how quickly the Enumerator
produces data. Here's what my Enumeratee looks like
val throttlingIteratee = Iteratee.foldM[Array[Byte], Array[Byte]](new
Array[Byte](0)) {
(result, chunk) =>
val prom = Promise[Array[Byte]]()
timer.schedule(new TimerTask{
def run() = prom.success(result ++ chunk)
},1000)
prom.future
}
private val chunker = Enumeratee.grouped(
Traversable.take[Array[Byte]](31792) &>> throttlingIteratee
)
The idea is that I use the timer task to create a throttlingIteratee and
pair that with the Enumeratee.grouped function. This seems to work fairly
well, but I'm having trouble figuring out what value to use for the chunk
size. I want to have this produce chunks at about the same rate as the
audio plays. My audio file is encoded at 82kpbs, and I've tried to
calculate that in terms of bytes, but the values I come up with seem to be
too small, and the audio plays faster than the data is streamed.
My question is two fold. Is the basic approach I have in place a good one?
And if it is, how do I go about setting the chunk size in terms of the
audio file's bit rate.