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.

how to change the url of the page in asp.net

how to change the url of the page in asp.net

I am using asp.net and i have a hyperlink tag like this:
<asp:HyperLink ID="BusinessWebSiteHyperLink" runat="server"
Text="Hyperlink"></asp:HyperLink>
I am adding the address from code behind like this:
DataTable dt =
objYPSearchResultsDataAccess.GetYPBusinessListingDetails(businessID);
BusinessWebSiteHyperLink.Text = dt.Rows[0]["BusinessWebsite"].ToString();
string Hyperlink = dt.Rows[0]["Hyperlink"].ToString();
if (Hyperlink == "True")
{
BusinessWebSiteHyperLink.NavigateUrl = BusinessWebSiteHyperLink.Text;
}
else
{
BusinessWebSiteHyperLink.NavigateUrl = "";
}
every thing is fine but when i click the Business url in the page then the
page should redirect me to the business website but it is adding
localhost/7467567/...../www.stakeoverflow.com. i just want to redirect my
page to stakeoverflow when it is clicked. how to solve this?

Friday, 27 September 2013

Flex 3 using different services-config.xml files for debug and release build

Flex 3 using different services-config.xml files for debug and release build

I've been unable to find a solution for this so either it's not possible,
or I'm looking for the wrong solution. I am supporting an app that was
written with the Flex 3.6 SDK and writing everything in Flash Builder 4.7.
Basically the issue is that we have two different services-config.xml
files, one that is used when we debug an app (services-config-debug.xml)
and the other is used when we do a release build
(services-config-release.xml). What I'd like to do is to setup the system
to do one of the following two things:
Either have it setup so the compiler to use the correct version based on
the button I click (debug or exprot release build)
Or be notified someway (alert box, color change, etc) that I am using the
services-config-debug.xml file.
We do nightly releases and I am getting tired of having to go into the
compiler, switch the file that is used, export the release build, then
switch the compiler back.
I am open to other suggestions and any help will be useful.
Thanks, Chris

Objective c: download a file with progress view

Objective c: download a file with progress view

Help me! I want download a file. And how display progress bar?
I read a lot of articles and I do not work, do not work, you can explain
to me how to do it?

What piece am I missing to set an iOS background?

What piece am I missing to set an iOS background?

I have:
[A series of if statements sets backgroundImage to be something like
[UIImageNamed @"Background-Default-Landscape"]; am I right to assume that
the device will look for the file named
Background-Default-Landscape@2x.png if it is a Retina display?]
UIImageView *backgroundView = [[UIImageView alloc]
initWithImage:backgroundImage];
CGRect containerRect = CGRectZero;
containerRect.size = [backgroundImage size];
UIView *containerView = [[UIView alloc] initWithFrame:containerRect];
[containerView addSubview:backgroundView];
Right now my app is launching and once it loads displays a white screen,
not a background specified (none of the backgrounds are solid white).
What am I missing to draw a background before I start putting things on
the background, further below in the code?
Thanks,

How to use EasyMock expect

How to use EasyMock expect

The expect doesn't seem to work for me:
package com.jjs.caf.library.client.drafting;
import static org.junit.Assert.*;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test;
import com.jjs.caf.library.client.CustomerManager;
import com.jjs.caf.library.client.UserBookLimiter;
public class DraftTest {
UserBookLimiter userBookLimiter;
int expected = 5;
@Before
public void setUp() throws Exception {
userBookLimiter = EasyMock.createMock(UserBookLimiter.class);
EasyMock.expect(userBookLimiter.getMaxNumberOfBooksAllowed()).andReturn(5);
}
@Test
public final void test() {
assertEquals(expected, userBookLimiter.getMaxNumberOfBooksAllowed());
}
}
It's supposed to be 5, but I'm getting 0 as if the expect wouldn't be
there at all...

Need Help About Android & IOS apps uploading policies

Need Help About Android & IOS apps uploading policies

can two different developers upload apps with same Source code but
Different Skins? or what dodification needs if i have same source code
that the other fellow have?
thanks

Thursday, 19 September 2013

Re-Center Webpage in CSS/HTML

Re-Center Webpage in CSS/HTML

I have custom built CSS for me but am no longer in contact with the
creator. I wanted to make a div (#rightcolumn) bigger by 55px. I did this
by making iframe in the div bigger and it auto expands for me. However the
banner, (#topsection), became a little short - so I had to add 55px to
that to make it 1255px width.
Now page is off center some. When I try to edit other float commands to
fix, the div's end up all over. I've tried for a few days. If anyone could
help now with re-centering this. I would really appreciate.
Test page: Serious Sports Bigger Link to css: CSS link New Css
body{margin:0;padding:0;line-height:1.5em;background:#C0C0C0;}b{font-size:110%;}em{color:red;}#maincontainer{width:1200px;margin:0
auto;}#topsection{background:#191919;height:90px;width:1255px}#contentwrapper{float:left;width:100%;}#contentcolumn{margin:0
360px 0
180px;color:#F1F1F1;}#leftcolumn{float:left;width:180px;margin-left:-1200px;background:#C8FC98;}#rightcolumn{float:left;width:355px;margin-left:-355px;background:#E5E5E5;}#footer{clear:left;width:100%;background:#191919;color:#FFF;text-align:center;padding:4px
0;}#footer
a{color:#62C301;}.innertube{margin:10px;margin-top:0;}.arrowgreen{width:180px;border-style:solid
solid none
solid;border-color:#94AA74;border-size:1px;border-width:1px;}.arrowgreen
ul{list-style-type:none;margin:0;padding:0;}.arrowgreen li a{font:bold
12px
Verdana,Arial,Helvetica,sans-serif;display:block;background:transparent
url(http://i39.tinypic.com/2r2rhnc.gif) 100% 0;height:24px;padding:4px 0
4px 10px;line-height:24px;text-decoration:none;}.arrowgreen li
a:link,.arrowgreen li a:visited{color:#5E7830;}.arrowgreen li
a:hover{color:#26370A;background-position:100% -32px;}.arrowgreen li
a.selected{color:#26370A;background-position:100% -64px;}

Reading in numbers with getline

Reading in numbers with getline

I have a line that has the format (int,int,int,char) and wish to store the
three ints into x,y,z and then place the char value into that position in
my 3D array. However it is skipping the first number and going to the
second. Any help?
void list_Input(char ***&a, const int &f, const int &n)
{
string line;
while (getline(cin, line, ',') && !line.empty())
{
if (line[0] == '/' )
{
continue;
}
else
{
int y = stoi(line);
getline(cin, line, ',');
cout << line;
int x = stoi(line);
getline(cin,line,',');
int f = stoi(line);
a[z][x][y] = getline(cin,line,')');
}
}
}

C++ Stack and Heap in RAM

C++ Stack and Heap in RAM

I'm running the following c++ code on Ubuntu with 4GBs of RAM
const long long nSize = 400000000;
double Array1[nSize];
for(int i=0; i<nSize; i++)
Array1[i]= 2*2; // store on the stack
And this fits on RAM (and my computer doesn't complain). Confusingly...
htop says barely any additional RAM is being used during runtime... Why?.
(I usually let it sleep for 100 seconds in case it needs to update)
On the other hand, if I dynamically allocate the huge array (as tutorials
like this recommend I should do) -- htop tells me it's using up most of
the RAM (if not all of it and it crashes):
double *pnArray2 = new double[nSize];
for(int i=0; i<nSize; i++)
pnArray2[i] = 2*2; // store on the heap
So why should I use the heap to store big data structures... if (like in
this example) the stack can handle even bigger arrays?
I thought the heap was supposed to be bigger than the stack! Please tell
me where I'm going so wrong.

How to copy a single layout page from an android file and copy it to microsoft word

How to copy a single layout page from an android file and copy it to
microsoft word

I'm just wondering how to copy an android layout page to a Microsoft word
page. I'm doing this because my blue stacks / mobile is not working and
someone would like to see the design of the layout page. Any help would be
great.

jquery only passing dropdownbox highest value

jquery only passing dropdownbox highest value

i've got a dropdownbox which has values assigned to it, and i'm trying to
retrieve that value and perform a .load function and return the value, but
it didn't turned out as so, the value being retrieved is always the top of
the dropdownlist no matter what is selected.
Here's my jquery
<script>
$(document).ready(function(){
var inputField= $('#dateslot').val();
$("#dateslot").change(function(){
$("#timeslot").load('check.php?dateselect='+inputField);
});
});
</script>
While here's my dropdownbox
<select name="dateslot" style="margin-bottom: 20px;" id="dateslot">
<option value="notselected">SELECT A DATE</option>
<?php
for($i = 1; $i/31 != 1; $i++){
$date1 = str_replace('-', '/', $vdate);
$date2 = date('Y-m-d',strtotime($date1 . "+".$i." days"));
$readdate = date('d F Y', strtotime($date2));
echo '<option value="'.$date2.'">'.$readdate.'</option>';
}
?>
</select>
in my check.php i got the dateselect using $_GET and found out that no
matter what i select, the result is always notselected(which is the first
option)
i tried stripping that code out, the value shown is still the first of the
list, i tried taking out the php and use only the options, same result.
any help =/ ?

Overload operator on Matlab dataset array

Overload operator on Matlab dataset array

Following this response, I set out to do something similar for datasets.
The plus function mentioned in that answer, I got working fine for cell
arrays by putting the plus.m in an @cell-folder. However on trying the
exact same (slightly different implementation) in a @dataset-folder,
Matlab still gives an "undefined" error for both Dataset+Dataset and
plus(Dataset,Dataset).
What am I getting wrong?

Python 3.3 socket programming error

Python 3.3 socket programming error

In Python 3.3 I am getting an error while executing this line -->print
("Message from server : ") + msg ,where msg is received data from server
(Trying to do socket programming as you might guess)Can anybody help ???

NSOutlineView add/remove items

NSOutlineView add/remove items

I use NSOutlineView in the my app. And I have some problems with
add/remove items. If I do
[outlineView beginUpdates];
[outlineView removeItemsAtIndexes:[NSIndexSet
indexSetWithIndex:[[[selectedItem parent] children]
indexOfObject:selectedItem]] inParent:[selectedItem parent]
withAnimation:NSTableViewAnimationSlideRight];
[outlineView endUpdates];
Then I get crash with this log:
NSTableView Error: Insert/remove/move only works within a
-beginUpdates/-endUpdates block.
But If I do
[[selectedItem parent] removeObjectFromChildren:selectedItem];
[outlineView reloadData];
Then to add to operating normally, but if I do remove operating then I get
non-selectable cell. It's look like outlineView doesn't clear context. How
I can fix it?

Wednesday, 18 September 2013

dropdown list that refresh a div content upon select

dropdown list that refresh a div content upon select

i have totally no idea about how to do this, so i'm gonna just ask away.
I have a dropdown menu which list dates say
1/2/2013
2/2/2013
3/2/2013
4/2/2013
5/2/2013
6/2/2013
7/2/2013
if you were to select one of the dates, a div will pop out with say 5 choices
A
B
C
D
E
each choices are stored in the database, and if say B item is not
available on 2/2/2013, i would have a script to disable it being selected.
I've figured how to create that in php, but my ultimate question is
how do you select any of the dates but yet still able to retrieve the 5
choices from a database?
I'm currently doing something like this
function TheDisabler($aa)
{
global $con, $vdate;
$myresult = mysqli_query($con,"SELECT * FROM burger WHERE timeslot =
'$aa' AND date = '$vdate'");
list($mycount) = mysqli_fetch_row($myresult);
if($mycount >= 1) {
echo "disabled";
}
}
but i figured that this works only once and if i were to change the date,
the items within the div will not change =/

Backbone - Cannot call method 'each' of undefined

Backbone - Cannot call method 'each' of undefined

I have problem with function each.In my console is error:
Uncaught TypeError: Cannot call method 'each' of undefined
window.App = {
Models: {},
Views: {},
Collections: {}
};
window.template = function (id) {
return _.template($('id' + id).html());
};
App.Models.Table = Backbone.Model.extend({
defaults: {
name: 'Table Name',
},
});
App.Collections.Tables = Backbone.Collection.extend({
model: App.Models.Table,
url: 'tables.json'
});
App.Views.Tables = Backbone.View.extend({
tagName: 'ul',
initialize: function() {
this.collection.fetch({reset:true});
this.collection.on('reset', this.render);
this.collection.on('add', this.addOne, this );
},
render: function () {
this.collection.each(this.addOne, this);
return this;
},
addOne: function(table) {
var table = new App.Views.Table({ model: table });
this.$el.append( table.render().el );
table.render();
}
});
App.Views.Table = Backbone.View.extend({
tagName: 'li',
initialize: function() {
this.model.on('destroy', this.remove, this)
},
render: function () {
this.$el.html( this.model.get('name') );
return this;
},
});
var tablesCollection = new App.Collections.Tables();
var tablesView = new App.Views.Tables({ collection: tablesCollection });
I can't find error nowhere. My json file:
[
{"name": "Table 1","stts": "redstts","id": 1},
{"name": "Table 2","stts": "redstts","id": 2},
{"name": "Table 3","stts": "redstts","id": 3},
{"name": "Table 4","stts": "redstts","id": 4},
{"name": "Table 5","stts": "redstts","id": 5}
]
I wanna render all my objects from collection, and after that I wanna add
event to add next table after click. But my problems is why this is not
function ?

what is the exact use of Stuff in sql server

what is the exact use of Stuff in sql server

In my stored procedure I have a statement like this
select @cols = STUFF((SELECT distinct ',' + QUOTENAME(Vtype) from VType_tbl
FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)') ,1,1,'')
i dont know what exactly would happen with these statement? why we are
using Stuff and QUOTENAME and ; for XML PATH

Bouncy Castle Decryption in c# from private key and encrytedtext

Bouncy Castle Decryption in c# from private key and encrytedtext

Encrytped text is:
wMXLjsRSfO1VngHqotJXoxygP1eTktr3gc3tuhdzXpqOy1N1V8/wflJuHkn1PX7Rf3/ccvL5vzPYYaKIm3s4IMhshrwVH3p4euprwRyNTvlBPLLmZ/b/wuTXkKqRdK81V9oHocIfxerivS4oIJfA4J6fMbtKom6IoE4GVhiAsJs=
My Private Key is:
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQDIlsvQQVhLQsmRFr/KUcAjOE/nlCNPS+0Q+Q8sIhEZFmT9f2qR
3d/9gtaxGY/WYgFwFplMArtaMzqcQSwntH296E1CdDj2U/v1AhTVCupeyNdz7//E
hIWrmlHjkrFynghRBFEEkACDtAV96VdtDvk10Knzl2CZ2kPklGz39sQsgQIDAQAB
AoGBAKVEwYbD4CiaTZNSaBEdTC54njVSs8kI6Ll8S4j0RJwj/G90xOyMH5ozbAqc
4gsj0sV0iTe8ZHsMDHVjqSrJpnMU6wDHhKQpr+zITJUxbTPjxgJf/2tKtsvFIMnb
2ghjTS/lMMzMPyeMhUcsLjPpoK9c+SDkl/PWU9Ay/pYvCCf1AkEA77JrZzn4gdJ3
VqtXUlV/y249frMPwYh+dS+aahyUUw0QW9BVa65Ume2iO5gGFVC3eJBZYxALFGai
ih06j0HOlwJBANY7bvp/2UfM2XWHYXvKXfasq/UzOMnc7jQvGJV6aFvch6mVxuTi
+ah7CCqGPVEbn8ZK92FwtsHYd5EvQO+R2KcCQCDfe1Ng4/AKCUvdm9Ay4Z/oso5Z
yGNmcNFpgefjm4P4WrH81Ho8ImYp7QH3S35I36CtS1UGsj5OBSSj9ZAIGmkCQDI/
xowjKMfamLckhg0PLnMJlVvyI8PVelnrIg0NpSTG2VtBsmFFi+Gk2gl/ayp3HEba
lqPYWEWnjIQVXVnUD8kCQQDJpHSBSFQWRBRGHl2Oyy1SXiBYFdW2FH7+2c1WzN4P
iKkmgOXqC2RfMD0aE/xtMe8F2zFhPKcARIvEvfneVjmT
-----END RSA PRIVATE KEY-----
I am using Bouncy Castle in c# , when i decrypt using the encrytedtext and
private key using below code:
keyPair = (AsymmetricCipherKeyPair)new PemReader(reader).ReadObject();
IAsymmetricBlockCipher cipher = new RsaEngine();
RsaKeyParameters privateKey = (RsaKeyParameters)keyPair.Private;
cipher.Init(false, keyPair.Private);
byte[] deciphered = cipher.ProcessBlock(bytesl, 0, bytesl.Length);
string decipheredText = utf8enc.GetString(deciphered);
I am getting decipheredText as
&#9787;¢À?????U??`?u????|???^H?|???&#9786;????&#9830;M>?¡æ?&¡ê.0p?J??a?¡å?S¡ç$*&#9644;T&#9788;?
xQ??-??Ai9;??siqD??_??? ¢¾¡é¡×?k?Ny??kr?U??¡êz Mazher Ul Haq
but my actual string was "Mazher Ul Haq" , How to get actual string

Which are the "Must Follow" rules of PMD?

Which are the "Must Follow" rules of PMD?

I´m starting to use PMD and I really want to know which are the most
important rules or the rules that anybody can´t miss when using this tool.
Thanks!

I couldnt draw a graph using Json Value in Php

I couldnt draw a graph using Json Value in Php

<?php
$con=mysql_connect("localhost","root","") or die("Failed to connect with
database!!!!");
mysql_select_db("chart", $con);
// The Chart table contains two fields: weekly_task and percentage
// This example will display a pie chart. If you need other charts such as
a Bar chart, you will need to modify the code a little to make it work
with bar chart and other charts
$sth = mysql_query("SELECT * FROM googlechart");
/*
---------------------------
example data: Table (Chart)
--------------------------
weekly_task percentage
Sleep 30
Watching Movie 40
work 44
*/
$rows = array();
//flag is not needed
$flag = true;
$table = array();
$table['cols'] = array(
// Labels for your chart, these represent the column titles
// Note that one column is in "string" format and another one is in
"number" format as pie chart only required "numbers" for calculating
percentage and string will be used for column title
array('label' => 'Weekly Task', 'type' => 'string'),
array('label' => 'Percentage', 'type' => 'number')
);
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
if(!isset($google_JSON)){
$google_JSON = "{cols: [";
$column = array_keys($r);
foreach($column as $key=>$value){
$google_JSON_cols[]="label: '".$value."'}";
}
$google_JSON .= implode(",",$google_JSON_cols)."],rows: [";
}
$google_JSON_rows[] = " {c: ".$r['weekly_task']."} , {v:
".$r['percentage']."} ]}";
}
// you may need to change the above into a function that loops through
rows, with $r['id'] etc, referring to the fields you want to inject..
echo $google_JSON.implode(",",$google_JSON_rows)."]}";
?>
<html>
<head>
<!--Load the Ajax API-->
<script
src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript"
src="https://www.google.com/jsapi"></script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
function drawChart() {
var jsonData = $.ajax({
dataType:"json",
url: "data.php",
async: false
}).responseText;
var jsonData = $.ajax({
dataType:"json",
url: "data.php",
async: false
}).responseText;
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable(jsonData);
var options = {
title: 'My Weekly Plan',
is3D: 'true',
width: 800,
height: 600
};
// Instantiate and draw our chart, passing in some options.
// Do not forget to check your div ID
var chart = new
google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<!--this is the div that will hold the pie chart-->
<div id="chart_div"></div>
</body>
</html>
Output
{cols: [label: 'weekly_task'},label: 'percentage'}],rows: [ {c: Sleep} ,
{v: 30} ]}, {c: Watching_Movie} , {v: 10} ]}, {c: job} , {v: 40} ]}, {c:
Exercise} , {v: 20} ]}]}
Only this is displayed,No Graph. . .. . . .. Thanks in Advance

JDBC driver still pointing to v9.5 JDBC driver, after DB2v10 upgrade, in Sysout logs

JDBC driver still pointing to v9.5 JDBC driver, after DB2v10 upgrade, in
Sysout logs

We recently migrated DB2v9.6 to v10.1 . Even though I created new JDBC
provider and the classpath is pointing to the v10 jar files in the Admin
console of WebSphere Application Server, still the logs are having the
JDBC driver number as 3.59.81 which is v9.6 JDBC provider model number
[9/18/13 9:00:03:378 GMT] 0000002b SystemOut O [AMT] [GWALogger]
[2013-09-18 09:00:03,378] [DEBUG] Setting up a new datasource [9/18/13
9:00:03:992 GMT] 0000002b PrivExAction W J2CA0144W: No mappingConfigAlias
found for ConnectionFactory or DataSource jdbc/isc_tools_cf_aamt_aamtdbDS.
[9/18/13 9:00:05:796 GMT] 0000002b InternalGener I DSRA8203I: Database
product name : DB2/AIX64 [9/18/13 9:00:05:815 GMT] 0000002b InternalGener
I DSRA8204I: Database product version : SQL10012 [9/18/13 9:00:05:818 GMT]
0000002b InternalGener I DSRA8205I: JDBC driver name : IBM DB2 JDBC
Universal Driver Architecture [9/18/13 9:00:05:821 GMT] 0000002b
InternalGener I DSRA8206I: JDBC driver version : 3.59.81 [9/18/13
9:00:05:825 GMT] 0000002b InternalDB2Un I DSRA8212I: DataStoreHelper name
is: com.ibm.websphere.rsadapter.DB2UniversalDataStoreHelper@7a647a64.
[9/18/13 9:00:05:830 GMT] 0000002b WSRdbDataSour I DSRA8208I: JDBC driver
type : 4
I guess it should have been changed to 3.65.77 ?

un expected error getting while executing pivot stored procedure

un expected error getting while executing pivot stored procedure

This is my stored procedure:
ALTER procedure [dbo].[performancepivot]
@startdate nvarchar(100), @enddate nvarchar(100)
as
begin
declare @date1 nvarchar(100) = convert(varchar, @startdate+'
00:00:00.000', 120)
declare @date2 nvarchar(100) = convert(varchar, @enddate+'
23:59:59.000', 120)
DECLARE @cols AS NVARCHAR(MAX),@query AS NVARCHAR(MAX)
select @cols = STUFF((SELECT distinct ',' + QUOTENAME(Vtype)
from VType_tbl
FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)') ,1,1,'')
set @query = 'SELECT LocName, ' + @cols + '(
select l.LocName,v.Vtype,[dbo].[testfunctionstacknew](
CONVERT(decimal(10,1), AVG( CONVERT(NUMERIC(18,2),
DATEDIFF(SS,t.Paydate,t.DelDate) ) ))) as Average
from (select l.LocName,Vtype from Transaction_tbl t join
VType_tbl v on t.vtid = v.vtid join dbo.Location_tbl l on
t.locid=l.Locid where dtime between '''+ @date1 +''' and '''+
@date2 +'''
and Status = 5) d pivot ( count(Vtype) for Vtype in (' + @cols +
')) p '
print @query
exec sp_executesql @query;
end
while executing this, I am getting Error like this:
SELECT LocName, [Emaar Staff],[Lost Ticket],[Normal],[VIP],[VVIP](
select l.LocName,v.Vtype,[dbo].[testfunctionstacknew](
CONVERT(decimal(10,1), AVG( CONVERT(NUMERIC(18,2),
DATEDIFF(SS,t.Paydate,t.DelDate) ) ))) as Average
from (select l.LocName,Vtype from Transaction_tbl t join
VType_tbl v on t.vtid = v.vtid join dbo.Location_tbl l on
t.locid=l.Locid where dtime between '2013-01-01 00:00:00.000' and
'2013-08-01 23:59:59.000'
and Status = 5) d pivot ( count(Vtype) for Vtype in ([Emaar
Staff],[Lost Ticket],[Normal],[VIP],[VVIP])) p
Msg 102, Level 15, State 1, Line 8 Incorrect syntax near 'p'.
(1 row(s) affected) what is wrong with my stored procedure

Tuesday, 17 September 2013

Service did not start within a timely fashion - c# windows service

Service did not start within a timely fashion - c# windows service

I have a Windows service which I can install on my local machine using
installutil no problem.
Now, this service has to be installed on a server. I copy all files to the
server and run the same command, set the service to log on as a local user
account and when the service starts I get an error saying "logon failed" -
okay so perhaps the user account is the issue.
So I change the service log on as to local system account. I start the
service and I am told "The service did not respond to the start or control
request in a timely fashion".
So I googled and tried various solutions but to no avail. So I got to
thinking maybe it was something in the OnStart method which broke (even
though I have logging calls which never logged). So I removed all code
from the OnStart event and still the service would not start, I got the
"timely fashion" error.
So where am I at? I believe it could be due to the references I have
defined in the project. To test this I created a new Windows service
template from VS2012 with no references (other than the default ones) and
I can start the service. No issues.
So my question is what could be causing this? In my project the references
point to locations which do not exist on the server, however the directory
where the service resides has all the referenced DLLs.
Edit: Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
namespace RetrieveAndProcessSecurityLogs
{
static class Program
{
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new LogService()
};
ServiceBase.Run(ServicesToRun);
}
}
}
LogService.cs
public partial class LogService : ServiceBase
{
public LogService()
{
InitializeComponent();
this.ServiceName = "Retrieve and Process Security Logs";
this.CanPauseAndContinue = true;
this.CanStop = true;
}
protected override void OnStart(string[] args)
{
//...
}
protect override void OnStop()
{
//...
}
Sorry for the story. Andrew

Using ArrayList or HashMap for better speed

Using ArrayList or HashMap for better speed

I need a 'List' or 'Map',... of object A. This list will be added from
another ArrayList. Object A is considered to be equal to another when id
parameter of A equals.
My problem is I only want add an object that does not exist in my List. I
wonder between the two alternatives for implementation. Using ArrayList or
HashMap
1. ArrayList:
for (A a: source) {if (! (a in ArrayList)) addToArrayList();}
2. HashMap <id, A>
for (A a: source) {hasmap.put (a.id, a)}
Which will give better speed to add a large number (over 1000 objects, or
bigger number of object) Is there a better pattern for my problem???

WSO2 API Manager with Mysql Cluster backend - NDB sql scripts

WSO2 API Manager with Mysql Cluster backend - NDB sql scripts

I'm setting up the WSO2 API Manager with a MySQL Cluster backend. In the
/dbscripts directory within the install directory for the API Manager,
there are .sql scripts for setting up the database with either the
mysql.sql script, which uses InnoDB, or the mysql_cluster.sql script which
uses NDB. My problem is the apimgt database, which from this article:
http://docs.wso2.org/display/Cluster/Clustering+API+Manager , says to use
the script in /dbscripts/apimgt/mysql.sql, but there is no equivalent
script for the MySQL Cluster setup. I attempted to just replace all
instances of ENGINE InnoDB with ENGINE NDB in the script, but when trying
to import that into MySQL I get: ERROR 1215 (HY000) at line 82: Cannot add
foreign key constraint. Does anyone know of a MySQL Cluster script for
this database?
Thanks.

saving and re-applaying checkbox list in jQuery

saving and re-applaying checkbox list in jQuery

So I have dropdown list and multiple checkboxes in div
Checkboxes list populates on change of dropdown list
I want to save checked checkboxes so I could reapply them
I managed to serialize checked checkboxes
$("#category").change(function() {
var formData = $(this).parents('form').serialize();
var checked = $('.check input:checkbox:checked').serializeArray();
$.ajax({
url: '/test/hardwares/getByCategory',
type: 'Post',
data: formData,
success: function(data) {
$('.check').html(data);
}
});
});
Thank you for your help

running clojure with leiningen

running clojure with leiningen

I made a project named my-stuff and added to the project.clj so it looks
like this
(defproject my-stuff "0.1.0-SNAPSHOT"
:description "Testing lein"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.5.1"] [clj-http "0.5.5"]]
:main my-stuff.core)
so i can run the core however when I try to run lein run i get this
Learning\my-stuff>lein run
Exception in thread "main" java.lang.Exception: Cannot find anything to
run for:
my-stuff.core
at user$eval5.invoke(form-init5159589073116828284.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6619)
at clojure.lang.Compiler.eval(Compiler.java:6609)
at clojure.lang.Compiler.load(Compiler.java:7064)
at clojure.lang.Compiler.loadFile(Compiler.java:7020)
at clojure.main$load_script.invoke(main.clj:294)
at clojure.main$init_opt.invoke(main.clj:299)
at clojure.main$initialize.invoke(main.clj:327)
at clojure.main$null_opt.invoke(main.clj:362)
at clojure.main$main.doInvoke(main.clj:440)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:419)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)
\Clojure\Learning\my-stuff>
even tho the core does exist in the source.
what do i do?

How to use JavaScript to style the code in a pre element?

How to use JavaScript to style the code in a pre element?

How is it possible to highlight the code inside a pre element? There is
already questions about highlighting it, but the answers is all in JQuery.
Is it possible to do it without the tags and it's id, for example:
This is with the tags and it's id's:
<pre>
<div id="tag_open">&lt;</div><div id="tag_value">div</div><div
id="tag_attr">id=</div><div id="tag_attr-val">"div"</div><div
id="tag_close">&gt;</div>
</pre>
And it's CSS:
#tag_open {
color: blue;
}
#tag_close {
color: blue;
}
#tag_value {
color: blue;
}
#tag_attr {
color: red;
}
#tag_attr-val {
color: purple;
font-weight: bold;
}
This is without the tags and it's id's:
<pre onload="highlight()">
&lt;div id="div"&gt;
</pre>
And with the JavaScript:
function colorize(){
//the script here
}

Sunday, 15 September 2013

calculate the record size of HBase issue

calculate the record size of HBase issue

The hbase table scan 'test' like this
010012010114200 column=s:STATION, timestamp=1378892292800,
value=00001
010012010114200 column=s:YEAR, timestamp=1378892292800, value=2010
010012010114210 column=s:DAY, timestamp=1378892292800, value=14
010012010114210 column=s:HOUR, timestamp=1378892292800, value=21
010012010114210 column=s:MINUTE, timestamp=1378892292800, value=0
010012010114210 column=s:MONTH, timestamp=1378892292800, value=1
I want to calculate the record size: Fixed part needed by KeyValue format
= Key Length + Value Length + Row Length + CF Length + Timestamp + Key
Value = ( 4 + 4 + 2 + 1
8 + 1) = 20 Bytes
Variable part needed by KeyValue format = Row + Column Family + Column
Qualifier + Value
Total bytes required = Fixed part + Variable part
1 Column = 20 + (15 + 1 + 7 + 5) = 48 Bytes
1 Column = 20 + (15 + 1 + 4 + 4) = 44 Bytes
1 Column = 20 + (15 + 1 + 3 + 2) = 41 Bytes
1 Column = 20 + (15 + 1 + 4 + 2) = 42 Bytes
1 Column = 20 + (15 + 1 + 6 + 1) = 43 Bytes
1 Column = 20 + (15 + 1 + 6 + 1) = 43 Bytes
one record need 271 Bytes And I hava 2 million record Total Size is about
542MB My Question isF This calculation method is right ?

SQL Azure doesn't support 'select into' - Is there another way?

SQL Azure doesn't support 'select into' - Is there another way?

I have a very complicated table I'd like to take a temporary backup of
whilst I make some changes. Normally, I'd just do the following:
SELECT *
INTO temp_User
FROM dbo.[User] AS u
Unfortunately I'm using Azure, and it appears this isn't supported:
Msg 40510, Level 16, State 1, Line 2 Statement 'SELECT INTO' is not
supported in this version of SQL Server.
Is there a way to re-create this feature into a function, potentially? I
could do this by scripting the table, creating it and then inserting data
using a select statement but given how frequently I use Azure, and how
many databases I need to work on in this area this is very unwieldy.

Primefaces fileUploadListener is not invoked

Primefaces fileUploadListener is not invoked

I'm using,
GlassFish 4.0
JSF 2.0
Primefaces 3.5
I have this fileUpload component on an XHTML page.
<h:form enctype="multipart/form-data">
<p:fileUpload id="txtCatImage"
value="#{testManagedBean.uploadedFile}"
mode="advanced"
sizeLimit="100000"
multiple="false"
showButtons="true" allowTypes="/(\.|\/)(gif|jpe?g|png)$/"
fileUploadListener="#{testManagedBean.fileUploadListener}"/>
<p:message for="txtCatImage" showSummary="false"/>
<p:commandButton id="btnSubmit"
actionListener="#{testManagedBean.insert}"
icon="ui-icon-check" value="Save"/>
</h:form>
This is the corresponding managed bean.
@ManagedBean
@ViewScoped
public final class TestManagedBean implements Serializable
{
private static final long serialVersionUID = 1L;
private UploadedFile uploadedFile;
public TestManagedBean(){}
public UploadedFile getUploadedFile() {
return uploadedFile;
}
public void setUploadedFile(UploadedFile uploadedFile) {
this.uploadedFile = uploadedFile;
}
public void fileUploadListener(FileUploadEvent event)
{
uploadedFile=event.getFile();
System.out.println("fileUploadListener invoked.");
}
public void insert()
{
if(uploadedFile!=null)
{
System.out.println(uploadedFile.getFileName());
}
else
{
System.out.println("The file object is null.");
}
}
}
The file upload listener as mentioned - fileUploadListener() is never
invoked.
The file upload filter is mapped in web.xml as follows.
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<!--<param-value>Development</param-value>-->
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.enableViewStateIdRendering</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.enableRestoreView11Compatibility</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<filter>
<filter-name>SecurityCheck</filter-name>
<filter-class>filter.SecurityCheck</filter-class>
</filter>
<filter-mapping>
<filter-name>SecurityCheck</filter-name>
<url-pattern>/jass/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<!--<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>-->
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<security-constraint>
<display-name>AdminConstraint</display-name>
<web-resource-collection>
<web-resource-name>ROLE_ADMIN</web-resource-name>
<description/>
<url-pattern>/admin_side/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>ROLE_ADMIN</role-name>
</auth-constraint>
<user-data-constraint>
<description/>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<display-name>UserConstraint</display-name>
<web-resource-collection>
<web-resource-name>ROLE_USER</web-resource-name>
<description/>
<url-pattern>/user_side/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>ROLE_USER</role-name>
</auth-constraint>
<user-data-constraint>
<description/>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>projectRealm</realm-name>
<form-login-config>
<form-login-page>/utility/Login.jsf</form-login-page>
<form-error-page>/utility/ErrorPage.jsf</form-error-page>
</form-login-config>
</login-config>
<security-role>
<description/>
<role-name>ROLE_ADMIN</role-name>
</security-role>
<security-role>
<description/>
<role-name>ROLE_USER</role-name>
</security-role>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/utility/Login.jsf</location>
</error-page>
<security-constraint>
<display-name>Restrict direct access to XHTML files</display-name>
<web-resource-collection>
<web-resource-name>XHTML files</web-resource-name>
<url-pattern>*.xhtml</url-pattern>
</web-resource-collection>
<auth-constraint/>
</security-constraint>
<session-config>
<session-timeout>
120
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>utility/Login.jsf</welcome-file>
</welcome-file-list>
</web-app>
I have added Apache-commons-fileupload and Apache-commons-io to the
classpath. The same thing works in my earlier project with Spring/JSF.
I can't see what I'm missing here. Does it have to do something with the
version of the server?

iOS size table row based on content in textView

iOS size table row based on content in textView

I am trying to size a row in my table to the height of a textView so that
the user does not have to scroll the textView, but rather scrolls the
table. What I have implemented so far seems to work most of the time
although sometimes the row height is a little too small, forcing the user
to scroll the textview a little, or the row height is too much create a
lot of whitespace after the text ends. How can I frame it just right?
Code:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// Set the textview frame
CGRect frame = self.contentTextView.frame;
frame.size.height = [self.summary boundingRectWithSize:CGSizeMake(280,
0) options:(NSStringDrawingUsesLineFragmentOrigin)
attributes:@{NSFontAttributeName:self.contentTextView.font}
context:nil].size.height + 60;
self.contentTextView.frame = frame;
}
- (CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return the height for the rows
if (indexPath.section == 0) {
return 60;
}
if (indexPath.section == 3) {
// Size content row based on text
return [self.summary boundingRectWithSize:CGSizeMake(280, 0)
options:(NSStringDrawingUsesLineFragmentOrigin)
attributes:@{NSFontAttributeName:self.contentTextView.font}
context:nil].size.height + 100;
}
return 44;
}

How do I edit the content of a textview, which was originally being created in XML, from the .java source?

How do I edit the content of a textview, which was originally being
created in XML, from the .java source?

In an XML file, a textview was being made, now I want to edit it's text
property from the .java source file. I tried referring to its id, but
eclipse wont recognize it; "cannot be resolved"
relevant part from XML:
<TextView
android:id="tb_01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
from the source:
Intent intent = getIntent();
String text = intent.getStringExtra(text);
tb_01.setText(text);
also, could someone explain, what this does in an xml, within a editText tag:
android:id="@+id/edit_message"

Ivy buildnumber not working

Ivy buildnumber not working

I am trying to get ivy:buildnumber working for my build's publish target
and am getting a bizarre error.
My publish target:
<target name="publish" depends="package">
<ivy:buildnumber resolver="default-resolver" organisation="myorg"
module="myapp" revision="0.2" />
<ivy:publish resolver="default-resolver"
pubrevision="${ivy.new.revision}" overwrite="true" update="true">
<artifacts pattern="gen/dist/pub/[artifact].[ext]" />
</ivy:publish>
</target>
The error I'm getting:
publish:
[ivy:buildnumber] :: loading settings :: url =
jar:file:/home/myuser/sandbox/dsi/workbench/eclipse/4.2/eclipse/plugins/org.apache.ivy.eclipse.ant_2.3.0.final_20130110142753/ivy.jar!/org/apache/ivy/core/settings/ivysettings.xml
BUILD FAILED
/home/myuser/sandbox/dsi/workbench/eclipse/workspace/myapp/build/build-core.xml:289:
Unknown resolver: default-resolver
The thing is, my Ivy settings file is not located at
org/apache/ivy/core/settings/ivysettings.xml. My Ivy settings file is
located at ~/ivy/ivy-settings.xml.
So I think somehow I'm not configuring ivy:buildnumber correctly, and so
it's defaulting to whatever Ivy settings file that Ivy ships with. And
since my default-resolver isn't defined in that shipped settings file, it
can't find a resolver to publish against.
Any ideas? Thanks in advance!

Want to get times accroding to my time zone not the servers time zone

Want to get times accroding to my time zone not the servers time zone

I'm from India. Hosting my site in 000webhost. I'm tracking the IPs
visiting and their times. but the time is wrong i.e I think times are
according to the time zone of 000webhost server. How to convert them
according to Indian timezone.
this is the code I am using:
date_default_timezone_set('Asia/Kolkata');
$query="INSERT INTO visitor_ip ";
$query.="VALUES('{$_SERVER["REMOTE_ADDR"]}',now())";

Saturday, 14 September 2013

Slicing a Hash into equal slices using Ruby

Slicing a Hash into equal slices using Ruby

How would you slice a hash into an array of equal hash slices using ruby?
Particularly something like this:
ORIGINAL HASH
a = {:a=>1, :b=>2, :c=>3, :d=>4}
EDIT: Adding answer here from below for quick reference. See below for a
better explanation.
SOME CODE HERE TO SLICE INTO SAY 2 EQUAL SLICES
a.each_slice(2).map{|slice| Hash[slice]}
RESULT
a = [{:a=>1, :b=>2}, {:c=>3, :d=>4}]

Hard coded GET values not sent from form

Hard coded GET values not sent from form

In the action attribute of my form element I have specified some get
values, which will be sent along with the value from the actual form.
However the values I have hardcoded in are not sent to the new document,
what am I doing wrong?
<form action="loginForm.php?type=dept" method="get">
<select name="dept" onchange="this.form.submit()">
<option value="">Department</option>
<option value="Bar">Bar</option>
<option value="Cleaning">Cleaning</option>
<option value="Kitchen">Kitchen</option>
<option value="Management">Management</option>
<option value="Maintenance">Maintenance</option>
<option value="Waiting">Waiting</option>
</select>
</form>
At the top of the loginForm file is this code, which will output 'Type not
set' every time
if(!isset($_GET['type']))
{
echo 'Type not set';
}

Flask Interactive Debugger Broken

Flask Interactive Debugger Broken

I'm trying to figure out why the Flask interactive debugger isn't working.
My template application is barebones, with a single error:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
print missing_variable #Error
return 'Hello World!'
if __name__ == '__main__':
app.run(host='0.0.0.0.', debug=True)
But the debugger catches the error, but gives me a non-interactive page
and complains about a lack of Javascript:
The debugger caught an exception in your WSGI application. You can now
look at the traceback which led to the error. If you enable JavaScript you
can also use additional features such as code execution (if the evalex
feature is enabled), automatic pasting of the exceptions and much more.
I haven't disabled Javascript, so I'm not sure why this the interactive
debugger is broken. Thanks!

Make @media max-width behave the same as $(window).width

Make @media max-width behave the same as $(window).width

While working on a website I encountered a major frustrating, yet logical
problem.
Take a look at this fiddle.
Important CSS:
* {
box-sizing: border-box;
-moz-box-sizing: border-box;
}
div#wrapper {
padding: 1em;
}
img {border: 4px solid blue;}
@media screen and (max-width: 480px) {
img {border: 0 none;}
}
Important jQuery:
function imgSize() {
if ($(window).width() < 481) {
$("img").css({
"position": "relative",
"width": $(window).width(),
"max-width": "none",
"left": "-1em",
"float": "none"
});
} else {
$("img").attr("style", "");
}
}
imgSize();
$(window).resize(function() {
imgSize();
});
Try making the result window smaller than 481px and bigger again. Basic
functionality explained: When the window is smaller than 481px in width,
the image will be forced a width that's larger than its parent and equal
to the window width. You cannot do this with CSS. (If you can, please tell
me!) This should give a nice view on mobile devices. To further "beautify"
the image, the original border is removed when the screen is between zero
and 480px, this is done by media queries.
All of this works great, until ... a wild scrollbar appears! What happens
is that jQuery only takes the "window" into account, whereas the media
query also counts the pixels generated by the width of the scrollbar.
Actually, this is quite logical. $(*window*).width() and @media *screen*
but it's super frustrating. What is the best way to deal with this issue?
Write a custom function in jQuery that comes down to "if scrollbar: add x
pixels to the "if window width"-function" in which x is the width of the
scrollbar in a specific operating system. Or should we try to bypass this
with CSS, or just not using jQuery and CSS interchangeably?
I am not focusing on this issue alone, but on the difference between
$(window).width() and media queries in general. In my case, I could
actually add border: 0 none to the jQuery and that's that. But
unfortunately that's not always possible.

How to pass "uniform sampler2D" to glsl shader in libgdx(using modelBatch)

How to pass "uniform sampler2D" to glsl shader in libgdx(using modelBatch)

I have trouble with passing sampler2d uniform from my code to shader. I
have this line in my shader:
uniform sampler2D u_texture;
In code, I am using g3db models created in blender(with textures):
AssetManager assets = new AssetManager();
assets.load(data+"/earth.g3db", Model.class);
assets.finishLoading();
Model earthModel = assets.get(data+"/earth.g3db", Model.class);
earthPlanet = new ModelInstance(earthModel,0,-1,0);
I render this using modelBatch:
modelBatch.begin(cam);
modelBatch.render(earthPlanet, shader);
modelBatch.end();
I have shader class in my code, and a render method within:
public void render(Renderable renderable) {
program.setUniformMatrix(u_worldTrans, renderable.worldTransform);
//how to pass texture??
//program.setUniformf(sampler2D, ????);
renderable.mesh.render(program,
renderable.primitiveType,
renderable.meshPartOffset,
renderable.meshPartSize);
}
I would be happy for any response. Thanks!

Binding a Gridview to a child object using an ObjectDataSource

Binding a Gridview to a child object using an ObjectDataSource

I tend to do all data access using an ObjectDataSource (ODS) with custom
business objects, which generally all works fine. But for some reason I
have not until now had the need to have a business object containing a
list of child objects. The following is a simplified example:
Public Class Matches
Public Property MatchCount() As Integer
Public Property Artists() as List(Of ArtistInfo)
Public Sub New(count As Integer, artists As List(Of ArtistInfo))
Me.MatchCount = count
Me.Artists = artists
End Sub
Public Sub New()
End Sub
End Class
Public Class ArtistInfo
Public Property ID() As Integer
Public Property Name() As String
Public Sub New(id As Integer, name As String)
Me.ID = id
Me.Name = name
End Sub
Public Sub New()
End Sub
End Class
I can return a Matches object from my data access layer (DAL). I can also
programmatically call my DAL function and bind a GridView to the Artists
collection. However, I then lose automated paging. But if I use an ODS to
retrieve the Matches object, then I cannot see how to reference the
properties within the ArtistInfo child object. I have seen a post which
suggests that I can refer (e.g. in an Eval) to Artists.ID and
Artists.Name, but I get a data binding runtime error that object
ArtistInfo does not contain such a property. It does not seem to make any
difference whether I specify DataObjectTypeName (which would have to be
Matches as I will need to access other properties of this object) on the
ODS or DataKeyNames on the GridView.
Hope this makes sense.

Friday, 13 September 2013

Empty Cells which has vlookup formula

Empty Cells which has vlookup formula

Formula on Column 'C'=VLOOKUP($B2,Sheet1!$A$2:$C$100,2,0) which gets the
value from sheet1 its okay. Now i want to put a condition If cell D2:D100
is empty then make C2:C100 empty, which contains vlookup forumula. Clean
the forumula from the cell.
Secondly how do we run this in a macro =VLOOKUP($B2,Sheet1!$A$2:$C$100,2,0).

How do I evenly space radio buttons

How do I evenly space radio buttons

My radio button won't space out evenly. I've tried adding, "margin-right:
250px;" along with another method but they will not give me the result
that I'm looking for. I want the buttons to be evenly spaced out on the
page and stay center aligned. Also I've tried adding style the the text
next to the radio buttons but I don't know how to incorporate it in the
CSS of my code. The code does work in the body though.
Here's the JSFiddle: http://jsfiddle.net/2DJsP/embedded/result/
Here's the CSS:
#navlist li {
margin-left: auto;
margin-right: auto;
}
style="color:#fa7f28; font-size:20px; font-weight:bold;

Installing boost 1.52 with VS2012

Installing boost 1.52 with VS2012

I followed these instructions to install boost and to compile all libraries:
https://www.quantnet.com/threads/tutorial-quantlib-boost-installation-in-visual-studio-2012.11891/
Boost Installation The Boost library can be downloaded here. Currently,
the latest version available is Boost 1.52.0. You can build boost by
following the instruction here.
Alternative you can download a pre-built lib from here. Once downloaded,
copy the installer into the Boost 1.52.0 folder and run it. Rename the
folder to lib once done.
So I downloaded boost 1.52, then copied that to C:\Program Files (x86)\boost\
I then downloaded the 1.52 64 bit installer and once downloaded, pasted
that to:
C:\Program Files (x86)\boost\boost_1_52_0\boost_1_52_0\
I executed the installer- it said "extracting" and then many library names.
I then renamed the last folder to lib, so that I had:
C:\Program Files (x86)\boost\boost_1_52_0\lib\
In my VS2012 I then added the previous directory to my project. The
project then starting parsing through the libraries and I had no linker
errors. However, when building the project I still got:
LINK: fatal error LNK1104: cannot open file
'libboost_date_time-iw-mt-gd-1_52.lib'
(The only usage of boost in my project is file_mapping and mapped_region)
Help?

Check if string starts with http or www or /

Check if string starts with http or www or /

This works:
if (strpos($page, 'http') == 0) {
$link = 'Test';
}
But this doesn't:
if (strpos($page, 'http' || 'www' || '/') == 0) {
$link = 'Test';
}
I need to return something if $page does not begin with any of those
three: http, www, or /.

Images issue portmapping server 2012 -> server 2008

Images issue portmapping server 2012 -> server 2008

I have the following issue:
My images are half broken when I try to load them from external.
Setup Windows server 2012 with Hyper-V On Hyper-v I have a Windows 2008
server with IIS.
I have a port mapping port 80 (on Windows 2012 server) to my Windows
server 2008 IIS.
When I try to reach IIS from the windows server 2012 to the Windows server
2008 by local IP there is no problem.
When I try to reach IIS from outside the network I got a broken IIS image.
http://s9.postimg.org/e8wvs3din/Screen_Shot125.jpg
I already tried to disable firewall on both servers. (same problem) I
tried to setup xampp in stead of IIS on 2008 server (same problem)

Thursday, 12 September 2013

How can I tag a property in iOS and track it's state throughout the app?

How can I tag a property in iOS and track it's state throughout the app?

Is there a way to tag a property or Instance variable throughout the life
of the application and see it changes?
The idea would be to see how the property is changed and what class/object
changes it's value when that value is passed around a lot? This way we
could see its value every time it changes instead of filling the code with
breakpoints.

Default Arguments vs. Overloading wrt. Name Lookup?

Default Arguments vs. Overloading wrt. Name Lookup?

In C++, given the alternatives:
void fun(int arg1, int arg2opt = 0);
// vs.
void fun(int arg1, int arg2);
void fun(int arg1) {
fun(arg1, 0);
}
Are there any differences for user code wanting to use this function, that
is, given any code base, which code constructs would break (at compile
time or runtime) when I were to change the first definition into the
second? (Overload resolution? Name lookup? Assigning fun to a function
pointer? Usage in templates? ...)
Or will these be the same semantically? (here are some details that I know
and that are not relevant for this question)

How to make a Java File Reader

How to make a Java File Reader

I'm trying to make a word scrambler for a project in class. It needs to
read in a .txt file and output a String with all of the words in the file;
but scrambled. for example:
Tihs is how the wrdos sulohd be sarcmbeld.
Ignoring punctuation and leaving the first and last letter in place.
I'm having trouble reading in the file into an array. I was planning on
using collections.shuffle to shuffle the inner layers by ignoring the
first and last letter and randomizing the inner letters.
I dont know how to impliment the file reader, but here is my scrambler for
each word.
public static String shuffle(String input){
input = "supercalifragilisticexpialidocious";
int i = 0;
ArrayList<Character> chars = new
ArrayList<Character>(input.length());
String output = "";
char[] characters = input.toCharArray();
char[] newWord = new char[input.length()];
newWord[0] = characters[0];
newWord[input.length()-1] = characters[input.length()-1];
for (i=1; i < input.length()-1;i++ ) {
chars.add(characters[i]);
}
System.out.println(chars);
for (i = 1; i <= input.length()-2; i++)
{
Collections.shuffle(chars);
}
Character[] middle = chars.toArray(new Character[chars.size()]);
for (i = 1; i < newWord.length - 2; i++)
{
newWord[i] = middle[i];
}
System.out.println(newWord);
StringBuffer r= new StringBuffer(output);
for (i = 0; i < newWord.length-1; i++)
{
r.append(newWord[i]);
}
return output;
}
This outputs saxupieipclflaurrtocslcidigaiiois like i want, but now i need
a way to read the .txt file in and split it into separate words.
If anyone can help me that would be great. What I'm really looking for is
if someone can help me with making a file reader for this.

Open specific Excel file in new instance of Excel when file is opened

Open specific Excel file in new instance of Excel when file is opened

Info:
I have an Excel file named Demo.xlsm
This file contains a userform named UserForm1 which automatically loads
when the file is opened.
The workbook named Demo.xlsm is also visible in the background behind the
userform when the file is opened.
Problem:
I often have an Excel application already open on my desktop with various
workbooks and worksheets containing information I use on a daily basis. As
it stands, if I go to open the Demo.xlsm file, it will open in the current
Excel application along with all of the other workbook/worksheets I am
using.
First: I would like for the Demo.xlsm file to automatically open in an
entirely separate instance/Excel application than my other works.
Second: I would like for only the userform to be visible. (I have no
need/use for the workbook/worksheets to be visible in the background.)
Third: If its possible to have the 2nd instance of the Excel application
to be minimized while still displaying the userform, that would be
perfect. (Currently, if I attempt to minimize the 2nd instance of the
Excel application, the userform is also minimized)
Private Sub Workbook_Open()
Dim objExcel
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
UserForm1.Show
End Sub
I feel that I am not going about this the right way...
Any help with this would be greatly appreciated!

Permalink Redirection and Regular Expressions

Permalink Redirection and Regular Expressions

I've got a pretty basic RegEx question but it's pressing enough that I
don't have time to run down a tutorial on RegEx in order to answer it
myself.
In short, I need: /2009/01/28/post-name/
redirected to /post-name/
As well as /post-name/author-name/
redirected to /post-name/
I promise to go take a class in RegEx before the month is out. Deal?
PS. Yes, I know that the Wordpress Redirection plugin will automate
.htaccess but it won't write RegEx for me.



Solved using the Redirection plugin.
Source URL: /(\d*)/(\d*)/(\d*)/([A-Za-z0-9-]*) Target URL: /$4

Why would one put `#! /usr/bin/false` in a Perl Module?

Why would one put `#! /usr/bin/false` in a Perl Module?

I was looking at the source code for the CPAN Perl module
Digest::MD5::Perl and noticed that it has the she bang #! /usr/bin/false.
Here's the first few lines of Digest/Perl/MD5.pm ...
#! /usr/bin/false
#
# $Id: MD5.pm,v 1.19 2004/02/14 02:25:32 lackas Exp $
#
package Digest::Perl::MD5;
use strict;
use integer;
use Exporter;
use vars qw($VERSION @ISA @EXPORTER @EXPORT_OK);
... why would the author of Digest::Perl::MD5 use #! /usr/bin/false? And
what if my system does not have /usr/bin/false but has /bin/false instead?

NSDateFormatter: Date according to currentLocale, without Year

NSDateFormatter: Date according to currentLocale, without Year

This can't be too difficult..
I want to display a date without the year. For example: "Aug, 2nd" (USA)
or "02.08." (GERMANY) It must work for a bunch of other locales as well.
My only idea so far is to do a normal format with year, and then remove
the year-portion from the generated string.

Behaviour of @Post callback methods i.e. @PostUpdate, @PostCreate etc. in JPA 2.0

Behaviour of @Post callback methods i.e. @PostUpdate, @PostCreate etc. in
JPA 2.0

Hi All,
I am not able to understand the exact behavior of @Post callback methods.
As mention in ProJPA book "When the SQL for deletion of an entity finally
does get sent to the database, the PostRemove event will get fired. As
with the PostPersist lifecycle event, the PostRemove event does not
guarantee success. The enclosing transaction may still be rolled back".
My concern here is, if SQL DELETE statement is already fire then how
transaction will be rolled back? If SQL DELETE statement is not able to
delete the object then exception will be thrown and @PostDelete will not
be executed. So, under what scenario transaction can be rolled back??
Thanks all for your time!!

Wednesday, 11 September 2013

Easier way to create a DataContext than implementing INotifyPropertyChanged?

Easier way to create a DataContext than implementing INotifyPropertyChanged?

As far as I know, there are 2 common ways to create a DataContect class,
one is to implement INotifyPropertyChanged and the other one is to derive
from DependencyObject.
Lots of people say the first way of implementing INotifyPropertyChanged is
simpler and I agree.
But I don't agree totally because I think even implementing
INotifyPropertyChanged is not simple enough but very tedious, because I
must rewrite every setter function for the properties and fire the event,
it's mostly copy & paste & modify things, which I dislike a lot. It's not
elegent.
So I'm curious, are there any other ways to create a DataContext, for
example, just derive from some class and all is done?
I know if the datacontext is a collection, there is a very easy way to do
it, just inherit from ObservableCollection<>, which I think is a very good
solution. But how about other classes?
Some 3rd party framework?

Uninitialized constant in view

Uninitialized constant in view

I have two models:
Post:
class Post < ActiveRecord::Base
has_many :exes
end
Exe:
class Exe < ActiveRecord::Base
belongs_to :post
end
What I am getting in my view on http://localhost:3000/posts/index is:
NameError in Posts#index
uninitialized constant Post::Ex
It says just Ex for some reason.
The code of line ruby is complaining on is <% post.exes.each do |exe| %>
which looks right to me.
So I don't really know why this is happening. If have also checked the
following as i thought this might be the reason but no:
2.0.0-p247 :004 > ActiveSupport::Inflector.pluralize('Exe')
=> "Exes"
2.0.0-p247 :005 > ActiveSupport::Inflector.singularize('Exe')
=> "Exe"
Thanks in advance!

using jquery UI how to add an image to the dialog

using jquery UI how to add an image to the dialog

i am using Jquery UI and i want to add an icon within the dialog box can
anyone help me ??? the dialog work fine but what i need to add a picture
to be more attractive i will appreciate any help
code
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Dialog - Modal message</title>
<link rel="stylesheet"
href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<!--<link rel="stylesheet" href="/resources/demos/style.css" />!-->
<script>
$(function() {
$( "#dialog-message" ).dialog({
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
});
</script>
</head>
<body>
<div id="dialog-message" title="Download complete">
<p>
<!--<span class="ui-icon ui-icon-circle-check" style="float: left; margin:
0 7px 50px 0;"></span>!-->
<span img src = "img1.jpg" style ="float: left; margin:0 7px 50px 0;
width:50px; height:50px;"></span>
Your files have downloaded successfully into the My Downloads folder.
</p>
<p>
Currently using <b>36% of your storage space</b>.
</p>
</div>
<p>Sed vel diam id libero <a href="http://example.com">rutrum
convallis</a>. Donec aliquet leo vel magna. Phasellus rhoncus faucibus
ante. Etiam bibendum, enim faucibus aliquet rhoncus, arcu felis ultricies
neque, sit amet auctor elit eros a lectus.</p>
</body>
</html>

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.