Saturday, 31 August 2013

setcontext always starts from function line

setcontext always starts from function line

I am implementing a userthread library. When I try to swap the context
when the yield is called, the swapped function is always starting from the
first line. The program counter is not updated I guess. For Example,
consider there are two Threads, say
T1: {
printf("Inside T1. Yielding to Other \n");
ThreadYield();
MyThreadExit();
}
T2: {
ThreadCreate(t1, 0);
printf("Inside T2. Yielding to Other \n");
ThreadYield();
}
In this case, when I use the setcontext/swapcontext, always the thread
starts from the line 1. So many threads are created and it goes to a
infinite loop. Can anyone tell me what is going wrong

Java Comparator compareToIgnoreCase

Java Comparator compareToIgnoreCase

I am trying to sort an array of strings using compareToIgnoreCase.
The string contain names ex: Billy Jean
When I try to compare them I get a null pointer exception. I think this is
because of the space between the first and last name. How can I compare
whole name?
Thanks
class CompareStudentNames implements Comparator{
//Sorts the students by name ignoring case.
@Override
public int compare(Object o1, Object o2) {
String name1 = ((Student)o1).getName();
String name2 = ((Student)o2).getName();
return (name1.compareToIgnoreCase(name2));
}
}

Content going beyond page with sticky footer

Content going beyond page with sticky footer

I have a basic website with a header, content area and footer. I'm trying
to create a sticky footer so when there is little content, the footer
still stays at the bottom of the page. For some reason, when there is a
lot of content, it just overflows beyond the browser and no scroll bar
appears.
Here is the page in question: http://swif.co/msb/page.html
I used many tutorials to get it working but the latest one I used was
http://css-tricks.com/snippets/css/sticky-footer/.

Changing the tabs manually in jquerytools to have a default tab when mouse is out of the tab container

Changing the tabs manually in jquerytools to have a default tab when mouse
is out of the tab container

I have a perfect working jquerytools accordion / tabs that change with
mouse hover.
I want that when the mouse is out of the tabs container, a default tab to
be activated instead the last activated tab.
My javascript is as follows:
$(function() {
$("#accordion").tabs("#accordion div", {
tabs: 'img.tab',
effect: 'fade',
event: 'mouseover'
});
});
$('#accordion').mouseout(function(){
// How should I activate a special tab?
});

How to chain two nongeneric functions in opencpu

How to chain two nongeneric functions in opencpu

OpenCPU is said to support chaining of function calls to calculate e.g.
f(g(x), h(y))
The docs about argument formats:
https://public.opencpu.org/api.html#api-arguments includes an example that
illustrates this by calculating
summary(read.csv("mydata.csv"))
In this example f is the generic function summary that takes as an
argument an object.
I need to calculate something like:
mycalc(read.csv("mydata.csv")) or
myplot(read.csv("my data.csv"))
where f take as an argument a dataframe
This doesn't seem to work when giving as object argument the sessionid or
hash key returned by the read.csv function.
How can this chaining of two nongeneric functions be solved ?

Concatenating video files with ffmpeg, no sound in output file

Concatenating video files with ffmpeg, no sound in output file

I am concatenating different AVI video files.
ffmpeg -f concat -i inputs.txt -c copy output.avi
The input files has been specified in input.txt in the order required.
First video file does not have sound track, but subsequent files have.
After completion the resulting the operation, the output does not have audio!
If I remove first video files from input then resulting video gets sound.
So it means the output format follows the first item in input list. How
can I solve this problem.
Please suggest the options in ffmpeg or avconv not in any other tools like
mencoder.
Thank you

Loading json data to div using jquery ajax call

Loading json data to div using jquery ajax call

Can anyone please tell me what is wrong with the given below code. I am
trying to load data in a div using json call.
function getData(){
$.ajax({
url: "http://echo.jsontest.com/key/value/one/two",
type: "get",
dataType: "JSON"
}, function(data){
$('#99').append(JSON.stringify(data));
});
return false;
}
It would be great if someone can put some light on $.ajax, $.get, $.post
and $.getJSON

Run linux Script from Java

Run linux Script from Java

I have the following java code
ArrayList<String> argList = new ArrayList<>();
argList.add("Hello");
argList.add("World");
String[] args = argList.toArray(new String[argList.size()]);
Process p =Runtime.getRuntime().exec("echo '$1 $2' ", args);
result is $1 $2 but i want to print Hello World. Can anybody help me?

Friday, 30 August 2013

MSVC Compiler Error C2688: Microsoft C++ ABI corner case issue?

MSVC Compiler Error C2688: Microsoft C++ ABI corner case issue?

A very specific corner case that MSVC disallows via Compiler Error 2688 is
admitted by Microsoft to be non-standard behavior. Does anyone know why
MSVC++ has this specific limitation?
The fact that it involves simultaneous usage of three language features
("virtual base classes", "covariant return types", and "variable number of
arguments", according to the description in the second linked page) that
are semantically orthogonal and fully supported separately seems to imply
that this is not a parsing or semantic issue, but a corner case in the
Microsoft C++ ABI. In particular, the fact that a "variable number of
arguments" is involved seems to (?) suggest that the C++ ABI is using an
implicit trailing parameter to implement the combination of the other two
features, but can't because there's no fixed place to put that parameter
when the function is var arg.
Does anyone have enough knowledge of the Microsoft C++ ABI to confirm
whether this is the case, and explain what this implicit trailing argument
is used for (or what else is going on, if my guess is incorrect)? The C++
ABI is not documented by Microsoft but I know that some people outside of
Microsoft have done work to match the ABI for various reasons so I'm
hoping someone can explain what is going on.
Also, Microsoft's documentation is a bit inconsistent; the second page
linked says:
Virtual base classes are not supported as covariant return types when the
virtual function has a variable number of arguments.
but the first page more broadly states:
covariant returns with multiple or virtual inheritance not supported for
varargs functions
Does anyone know what the real story is? I can do some experimentation to
find out, but I'm guessing that the actual corner case is neither of
these, exactly, but has to do with the specifics of the class hierachy in
a way that the documenters decided to gloss over. My guess it that it has
to do with the need for a pointer adjustment in the virtual thunk, but I'm
hoping someone with deeper knowledge of the situation than me can explain
what's going on behind the hood.

Thursday, 29 August 2013

Updating foreign key references on the DbContext ChangeTracker

Updating foreign key references on the DbContext ChangeTracker

I work with EF 5.0, DB first in a web project.
For our service layer, we use Agatha with AutoMapper, so all data arrives
in the service layer as POCO objects.
I have a data structure that look like this:
public class FirstClass
{
public int Id { get; set; }
public int? SelectedSecondClassId { get; set; }
public SecondClass SelectedSecondClass { get; set; }
public ICollection<SecondClass> MySecondClasses { get; set; }
//other properties go here
}
public class SecondClass
{
public int Id { get; set; }
public int ParentSecondClassId { get; set }
public SecondClass ParentSecondClass { get; set; }
//other properties go here
}
Now imagine I try to update a FirstClass object and do the following in 1 go:
Create 2 new Secondclass objects in the MySecondClasses collection (both
with id 0)
Set one of these newly created objects as the SelectedSecondClass
Then EF refuses to play ball. I can't get it to work. If I look in the
changetracker, I see that the SelectedSecondClass on the entity is empty
again, but the SelectedSecondClassId is set to 0. And that's something he
can't resolve, because there are 2 objects with Id 0, before they are
properly created.
If I do this, I can get stuff fixed:
var newId = -1;
foreach (var newSecondClass in firstClass.MySecondClasses.Where(x => x.Id
<= 0))
{
newSecondClass.Id = newId;
newId --;
}
if (firstClass.SelectedSecondClass != null)
{
firstClass.SelectedSecondClassId = firstClass.SelectedSecondClass.Id;
}
// Send the updates to EF
As you understand, I feel like this is a bit hacked together and it would
be easy for another developer to forget something like this. I would like
to have a better way of doing this. Preferably in a way that I can 'fix'
situations like this just before a SaveChanges() in my DbContext wrapper.
Can anybody point me in the right direction?

Will stream classes or connections considered as a resource leak in Java

Will stream classes or connections considered as a resource leak in Java

Java has no lifetime for an object, this is managed by the garbage
collector. And if I use some IO classes without closing it, or some
DBConnection, will this considered a resource leak? In another words, will
IO object be collected and destroyed by garbage collector, AFAIK, the
garbage collector is for memory only. For example:
BufferedReader br = new BufferedReader( new FileReader( new File("path") ) );

Wednesday, 28 August 2013

Singleton objects in Servlets

Singleton objects in Servlets

pI am unfamiliar with how the Tomcat6/Spring Server/Servlet performs
operations. /p pI recently ran into situation where I wanted the
servlet(s) to have a singleton class that would persist information
generated in the servlet class./p pFor instance, in one request a user
would specify some data, and the servlet would store the data into a
Singleton class./p pIn the next request, the user would send information
to the server that would modify the singleton class./p pHowever, in the
next request, it never seems like the data is persisted. Is it a bug in my
program, or is the lifetime of the singleton class different in the
webserver?/p pPS, I know that using a Singleton class to perform this
operation is stupid, but I am just trying to explain the problem./p

How to execute a Selenium test in Java

How to execute a Selenium test in Java

So I used Selenium IDE to create a test case for some automation I want
done. I want to be able to create some looping/flow control for this case
so I figured I would need to export it out of Selenium IDE to something
like Java (I'm most familiar with Java). I exported to Java/JUnit4/Web
Driver. I think trying to execute the java file through Eclipse would work
best, although if someone knows something easier, let me know. Anyway, I
have found NO GOOD EXPLANATION on how to execute this Java through
Eclipse.
Most things I read tell me to make sure my Build Path libraries includes
the Selenium Standalone Server. Virtually all things I read tell me to use
the Selenium Remote Control. However, I thought the RC was depreciated,
and I am wondering if there is anyway to make it work with the more recent
Web Driver stuff I downloaded from Selenium. Also, most things I read tell
me I need to use public static void main(), which is a little awkward
because I don't know how to alter the code the exported selenium gives me
(obviously I can't just paste it all in the main method).
If anyone could walk me through from exportation of Selenium to Java to
executing the code, I will be forever in your debt.
The code Selenium gives me: package com.example.tests;
package com.rackspace;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class RackspaceContactAutomation {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl =
"https://cp.rackspace.com/Exchange/Mail/Contacts/List.aspx?selectedDomain=blahblahblah.com";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testContactAutomationJava() throws Exception {
driver.get(baseUrl +
"/Exchange/Mail/Contacts/List.aspx?selectedDomain=blahblahblah.com");
driver.findElement(By.linkText("Mr. Man")).click();
driver.findElement(By.linkText("Contact Information")).click();
new
Select(driver.findElement(By.id("PhoneNumberType"))).selectByVisibleText("Mobile");
driver.findElement(By.id("MobilePhone")).sendKeys("999-999-9999");
new
Select(driver.findElement(By.id("PhoneNumberType"))).selectByVisibleText("Fax");
driver.findElement(By.id("Fax")).sendKeys("999-999-9999");
driver.findElement(By.cssSelector("button.primary")).click();
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
private boolean isAlertPresent() {
try {
driver.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}
private String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alertText;
} finally {
acceptNextAlert = true;
}
}
}
This gives me 4 errors (3 for the annotations, which I could just delete,
and one for fail in the tearDown() method. It's not the errors I'm
concerned about so much the how do I make this code actually execute?
Thanks!

Beautify urls in Symphony CMS?

Beautify urls in Symphony CMS?

I need to Beautify urls in Symphony CMS. I have a list of about 10
searches, static URLs, that looks like this:
http://www.domain.com/#!district=1&region%5Bcity%5D=&region%5Bregion%5D=&type=Butik&size%5Bmin%5D=0&size%5Bmax%5D=2500&string=&sort=1&page=sv%2Flediga-lokaler
The goal is to have them look like this:
http://www.domain.com/stockholm/butiker
What is the fastest way to achieve this? With .htaccess? How would such a
rewrite rule look like?

Preconditions don't work with GNAT?

Preconditions don't work with GNAT?

I'm still kind of new to Ada and I think I'm misunderstanding the use of
Preconditions, because looking through GNAT RM it seems the checks aren't
performed at runtime. Also, the GNAT RM for Precondition here doesn't
specifiy which exception is thrown if the precondition is not met.
Here is the code I'm trying:
procedure Test is
begin
generic
type Element_Type is private;
use System.Storage_Elements;
procedure Byte_Copy (Destination : out Element_Type;
Source : in Element_Type;
Size : in Storage_Count := Element_Type'Size)
with Pre =>
Size <= Destination'Size and
Size <= Source'Size;
procedure Byte_Copy (Destination : out Element_Type;
Source : in Element_Type;
Size : in Storage_Count := Element_Type'Size)
is
subtype Byte_Array is Storage_Array (1 .. Size / System.Storage_Unit);
Write, Read : Byte_Array;
for Write'Address use Destination'Address;
for Read'Address use Source'Address;
begin
Ada.Text_IO.Put_Line("Size to copy =" & Size'Img &
" and Source'Size =" & Source'Size'Img);
if Size > Destination'Size or else Size > Source'Size then
raise Constraint_Error with
"Source'Size < Size or else > Destination'Size";
end if;
for N in Byte_Array'Range loop
Write (N) := Read (N);
end loop;
end Byte_Copy;
procedure Integer_Copy is new Byte_Copy(Integer);
use type System.Storage_Elements.Storage_Count;
A, B : Integer;
begin
A := 5;
B := 987;
Ada.Text_IO.Put_Line ("A =" & A'Img);
Ada.Text_IO.Put_Line ("B =" & B'Img);
Integer_Copy (A, B, Integer'Size / 2);
Ada.Text_IO.Put_Line ("A = " & A'Img);
Ada.Text_IO.Put_Line ("B = " & B'Img);
Integer_Copy (A, B, Integer'Size * 2);
Ada.Text_IO.Put_Line ("A =" & A'Img);
Ada.Text_IO.Put_Line ("B =" & B'Img);
end Test;
If I understand things correctly, then this programme should raise some
unspecified exception before even calling the Put_Line procedure. But you
can see that when I run the programme, the procedure is called with an
invalid Size argument which violates the Precondition Destination'Size ¡Ý
Size ¡Ü Source'Size. Instead, I have to place an if statement to actually
catch the error and raise the exception Constraint_Error to keep things
sane.
$ ./test
A = 5
B = 987
Size to copy = 16 and Source'Size = 32
A = 987
B = 987
Size to copy = 64 and Source'Size = 32
raised CONSTRAINT_ERROR : Source'Size < Size or else > Destination'Size
I have tried variations like adding pragma Precondition ( ... ) but that
doesn't work either.
One weird thing is that the programme actually compiles if I repeat the
with Pre => clause in the generic procedure body/definition. It normally
doesn't allow this for procedures and raises an error (i.e., Preconditions
should only be in formal declarations, not in the definition). Are generic
procedures an exception in this case?
I'm also surprised that use clause can be added in generic procedure
declarations. This makes defining formal parameter names easier (ones
which are obscenely long) but looks more like a bug because this cannot be
done for normal/regular procedure declarations.
P.S. I wanted to implement my closest possible imitation of memcpy() from
C, in the Ada language for learning purposes.

Tuesday, 27 August 2013

How can I modify this outlook macro and related queries ( to remove older emails in email thread with same subject )?

How can I modify this outlook macro and related queries ( to remove older
emails in email thread with same subject )?

A macro noob here!
This macro was found
online(https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&cad=rja&ved=0CD4QFjAC&url=http%3A%2F%2Fdevsac.blogspot.com%2F2009%2F06%2Fvb-macro-for-deleting-duplicate-outlook.html&ei=h38dUuO3DYq6sQS-h4HoBg&usg=AFQjCNEtgpYzqIn5zBNYWbBwOQU_v72lGw&sig2=_3c3PePjsDolGRE2FqBqbg)
and people who used were extremely happy about it.
I have few queries regarding the scope of utility wrt to my situation.
1)Does this macro work only for the same subject ? Or does it look for the
same subject line in the subject of other emails as well ? ( For e.g. can
it differentiate between subject='Server log is late' and subject='RE:
Server log is late' ?. This is from the same email thread where one is the
first email in the thread and other is its reply)
2) I have a common inbox (that is accessible to all the members in my
group i.e for our group email ID )where all the mails turn up . Can this
macro be used for such an email inbox that is shared with everyone in my
group?
3) Also, is it possible to modify the code such that it can pick emails
(from the same inbox) that have the same subject but ignores the emails
with same subject that contains 'FW:' at the beginning of the subject line
?
4) Does this works for pst only or will it work for the emails currently
residing in the inbox as well ?
i.e ' FW: RE:RE: hello ' will be ignored whereas ' RE:RE: hello' and
'RE:RE:FW: RE: hello' will be marked.
Since at times when an email is forwarded , a new email thread gets
created containing different conversation. So I don't want conversations
that are different from the main email thread to be marked as it has
different emails under the same subject line.
Thanks.
Vincen



Const PST1_NAME = "NewBackup"
Const PST2_NAME = "NewBackup"
Const FOLDER1_NAME = "Inbox"
Const FOLDER2_NAME = "OldInbox"
Const CATEGORY_SEPERATOR = ","
Const FINAL_PROGRESS_ALLOCATED = 20 ' between 1 and 100
Public progressValue 'this holds the percentage completed.
Public progressStatus 'this holds the current status.
' sample with hardcoded psts & folders
Private Sub markDuplicateEmails()
markDuplicates PST1_NAME & SEPERATOR & FOLDER1_NAME, PST2_NAME & SEPERATOR
& FOLDER2_NAME, DEFAULT_CATEGORY
End Sub
' actual method which takes dynamic pst\folder source and destination
Public Sub markDuplicates(source, destination, category)
Dim myOlApp, myNameSpace
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Dim tmpArray, pst1Name, pst2Name, folder1Name, folder2Name
tmpArray = Split(source, SEPERATOR)
pst1Name = tmpArray(0)
folder1Name = tmpArray(1)
tmpArray = Split(destination, SEPERATOR)
pst2Name = tmpArray(0)
folder2Name = tmpArray(1)
Dim folder1Size, folder2Size
folder1Size = myNameSpace.Folders(pst1Name).Folders(folder1Name).Items.Count
folder2Size = myNameSpace.Folders(pst2Name).Folders(folder2Name).Items.Count
Dim array1() As cstData, array2() As cstData
ReDim array1(folder1Size)
ReDim array2(folder2Size)
Dim outlookItem1, outlookItem2, i, j
Dim theCstmData As Module1.cstData
Dim startTime, endTime
'populate array1
i = -1
startTime = Now
progressStatus = "Indexing set1..."
For Each outlookItem1 In
myNameSpace.Folders(pst1Name).Folders(folder1Name).Items
i = i + 1
Set theCstmData.item = outlookItem1
theCstmData.subject = outlookItem1.subject
theCstmData.creationTime = outlookItem1.creationTime
array1(i) = theCstmData
progressValue = 100 * (i / (folder1Size + folder2Size + (folder1Size +
folder2Size) * (FINAL_PROGRESS_ALLOCATED / 100)))
DoEvents
Next outlookItem1
progressStatus = "Indexing set1 Complete."
' populate array2
i = -1
progressStatus = "Indexing set2..."
For Each outlookItem2 In
myNameSpace.Folders(pst2Name).Folders(folder2Name).Items
i = i + 1
Set theCstmData.item = outlookItem2
theCstmData.subject = outlookItem2.subject
theCstmData.creationTime = outlookItem2.creationTime
array2(i) = theCstmData
progressValue = 100 * ((folder1Size + i) / (folder1Size + folder2Size +
(folder1Size + folder2Size) * (FINAL_PROGRESS_ALLOCATED / 100)))
DoEvents
Next outlookItem2
progressStatus = "Indexing set2 Complete."
progressStatus = "Indexing time: " & (Now - startTime) * 60 * 60 * 24
'loop through each item in array1
progressStatus = "Applying Category labels on duplicates..."
For i = 0 To folder1Size - 1
'loop through each item in array 2 comparing each array2Item with current
array1item
For j = 0 To folder2Size - 1
' if it is a match mark the item in array2 as duplicate
If array1(i).subject = array2(j).subject And _
array1(i).creationTime = array2(j).creationTime Then
If array1(i).item.Categories = "" Then
array1(i).item.Categories = category
Else
array1(i).item.Categories = array2(j).item.Categories & CATEGORY_SEPERATOR
& category
End If
array1(i).item.Save
If array2(j).item.Categories = "" Then
array2(j).item.Categories = category
Else
array2(j).item.Categories = array2(j).item.Categories & CATEGORY_SEPERATOR
& category
End If
array2(j).item.Categories = category
array2(j).item.Save
End If
DoEvents
Next j
progressValue = (100 - FINAL_PROGRESS_ALLOCATED) +
(FINAL_PROGRESS_ALLOCATED * (i / folder1Size))
Next i
progressStatus = "Total Time: " & (Now - startTime) * 60 * 60 * 24
progressStatus = "All done."
End Sub

How to run a cable and an ADSL internet connection simultaneously for increased uptime?

How to run a cable and an ADSL internet connection simultaneously for
increased uptime?

I have a cable connection and an ADSL connection. I often play online
games and I want an uninterrupted connection. I have only one ethernet
port on my computer.
So, when I'm in the middle of a game, if one connection drops out, I have
to pull out one cable and connect the other cable. This takes some time,
plus the ADSL connection takes some time to come up.
What I want is to run both connections at the same time, so if one happens
to drop out, the other takes over automatically. I was searching for
information on how to do this and I came across "dual routers", but I
didn't find any detailed information.
Basically, I'm looking for a checklist on what I should be looking for
when buying these, and the estimated cost of one that would do the job for
me. Also, if there is any other way of accomplishing this, I'd like to
know that as well.

Get substring between two characters

Get substring between two characters

How do you build a regex to return for the characters between < and @ of a
string?
For example <1001@10.2.2.1> would return 1001.
Would something using <.?> work?

Responsive image align center bootstrap 3

Responsive image align center bootstrap 3

I do catalog on Bootstrap 3, in the version for tablets product image
looks ugly because of their small size (500x500) with a width of 767
pixels in your browser. I want to put the image in the center of the
screen, but for some reason I can not. Who be will help solve the problem?

A living example you can look here

JAXB generated classes from WSDL (what was used to generate the stub?)

JAXB generated classes from WSDL (what was used to generate the stub?)

Hy there,
Could anyone tell me what was used to generate the following Stubs out of
a WSDL file if the generated classes have this signature from its creator?
// This file was generated by the JavaTM Architecture for XML
Binding(JAXB) Reference Implementation, vIBM 2.2.3-11/28/2011 06:21
AM(foreman)
e.g.
// This file was generated by the JavaTM Architecture for XML
Binding(JAXB) Reference Implementation, vIBM <version>-mm/dd/yyyy hh:mm
{AM|PM}(foreman)
Thank you very much you took the time to read this.
Have a great day Regards Jan

Monday, 26 August 2013

Harris Affine Keypoint in Opencv

Harris Affine Keypoint in Opencv

I am new to this and i might sound silly since i dont understand what is
Harris Affine keypoint means for feature detection.
From my research I feel its the harris corner detector but can someone
confirm this for me please. I want to use harris affine keypoint in my
school project but I am not sure if it is truely the harris corner
detector.
Briefly, i want to use Affine keypoint and compute descriptor using sift.
this is because in my object sift is not giving good result.
Thanks you

Note naming convention while creating scales – music.stackexchange.com

Note naming convention while creating scales – music.stackexchange.com

I am having some trouble with naming notes in a major scale. The major
scale formula is 0 , 1, 1 , 1/2 , 1 , 1 , 1 , 1/2 If I use this formula to
calculate notes in G# major scale, I get the notes …

Centre multiple elements within div using css

Centre multiple elements within div using css

I'm new to html and css and I'm trying to create a website, part of the
code is here:
HTML:
<div class="row">
<div class="circle"></div>
</div>
<div class="row">
<div class="circle"></div>
<div class="circle"></div>
</div>
<div class="row">
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
</div>
<div class="row">
<div class="circle"></div>
<div class="circle"></div>
</div>
<div class="row">
<div class="circle"></div>
</div>
CSS:
.circle
{
border-style: solid;
border-color: red;
width: 70px;
border-radius: 40px;
float:left;
margin: 2px;
}
.row
{
border-style: solid;
border-color: black;
height: 100px;
width: 700px;
margin: 10px;
}
http://jsfiddle.net/ubd9W/
I'm trying to centre red circles (horizontally and vertically) within the
black boxes but I can't seem to manage it. I've tried using 'text-align'
and setting the left and right margin to auto but that doesn't work. I
also can't use 'absolute' positioning because I have a fixed menu bar at
the top of the page and that gets ruined if you scroll.
Any help will be greatly appreciated. Thanks

What is a nice design/implementation for "back to the top"? – tex.stackexchange.com

What is a nice design/implementation for "back to the top"? –
tex.stackexchange.com

I want the reader of output of a PDFLaTeX be able to go back to the table
of content or first page. What is a good way of doing this? Most PDF
readers provide a TOC and navigation system but I was …

Not able to distinguish between hidden cells and others. Using POI 3.8 and xls/xlsx format

Not able to distinguish between hidden cells and others. Using POI 3.8 and
xls/xlsx format

Not able to distinguish between hidden cells and others. Using POI 3.8 and
xls/xlsx format. baseRow.getZeroHeight(),
baseCell.getCellStyle().getHidden(),
baseSheetX.getColumnStyle(14).getHidden() all return false though entire
column is hidden. Please guide.

Selecting a specific row in UITableview

Selecting a specific row in UITableview

I have a Address Book in my app. In that, there is a tableview and a
contact details page(refer screenshot). When i add a new contact, the most
recently added contact details are displayed in the contact detail page
but how to make the recently added contact be selected in the tableview..?
Note: the contacts are sorted in alphabetical order in the tableview..

[Other]How can i get into the top 100 University in USA if my major is not computer

[Other]How can i get into the top 100 University in USA if my major is not
computer

hey~everyoneCi want to get a master degree about software and my plan is
going to USA's top 100 university but our country's agency told me that
you can't get into that level's university because your major has no
relationship with computer. i'm very very disappointed.I've been working
as a software engineer for 2 years.and i like this job very very much.my
dream is to be a famous developer and i want to develop app which can make
people happy.so i want to know is it true that i can't apply computer
master degree?

Sunday, 25 August 2013

Javascript, regular expression and link

Javascript, regular expression and link

i have this part of code
<a href='project.php?id=5'>test</a>
where id number can have different length and i need to extract only this
number. Is it possible through regular expression, or something better?

How to set Ember environment variable of in qunit

How to set Ember environment variable of in qunit

I am settingENV.HELPER_PARAM_LOOKUPS = true for Ember.js so the linkTo
helper will perform property look up instead of a hardcoded route. For
example, I could do
The way I set the environment variable is inside the tag of my
application.html.erb layout (I am using rails 4.0 by the way), as follow:
<script type="text/javascript" >
// Ember environment variable
ENV = {
HELPER_PARAM_LOOKUPS: true
};
</script>
However, when I run the qunit test, it gives error as:
The attempt to linkTo route 'view.path.index' failed. The router did not
find 'view.path.index' in its possible routes:
It also gives the deprecation warning:
DEPRECATION: You provided a quoteless destination route parameter of
view.path to the linkTo helper. Soon, this will perform a property lookup,
rather than be treated as a string. To get rid of this warning, wrap
view.path in quotes. To opt in to this new behavior, set
ENV.HELPER_PARAM_LOOKUPS = true
Apparently, qunit is not configuring Ember.js as I intended. How to make
qunit read my environment setting for ember when the test is loaded.
Here is the code in my qunit test:
module("Frontend Test", {
setup: function() {
Ember.run(App, App.advanceReadiness);
},
teardown: function() {
App.reset();
}
});
test("Check HTML is returned", function() {
visit("/").then(function() {
ok(exists("*"), "Found HTML!");
});
});

Code giving me an ArgumentExeption?

Code giving me an ArgumentExeption?

This code is giving me an ArgumentExeption when the correct values are put
in both ComboBoxes, executing the code. The code basically just deletes a
file and replaces it with a modified version taken from another folder.
Here is the exact text of the error message: An unhandled exception of
type 'System.ArgumentException' occurred in Microsoft.VisualBasic.dll
Additional information: The given file path ends with a directory
separator character.
Here's the code: If ComboBox1.Text = "Nokia" And ComboBox2.Text = "HTC"
And My.Computer.FileSystem.FileExists("C:\Users\" + user +
"\Documents\Fiddler2\Scripts\CustomRules.js") Then
My.Computer.FileSystem.DeleteFile("C:\Users\" + user +
"\Documents\Fiddler2\Scripts\CustomRules.js")
My.Computer.FileSystem.CopyFile("Config\OEM\NokiaHTC.js",
destinationFileName:="C:\Users\" + user + "\Documents\Fiddler2\Scripts\")
Else My.Computer.FileSystem.CopyFile("Config\OEM\NokiaHTC.js",
destinationFileName:="C:\Users\" + user + "\Documents\Fiddler2\Scripts\")
End If

[ Other - Environment ] Open Question : Are there any other places like the zhangjiajie national forest park?

[ Other - Environment ] Open Question : Are there any other places like
the zhangjiajie national forest park?

As in, similar landscapes. Or natural structures or whatever.

select data between 2 dates in SQL

select data between 2 dates in SQL

I have a problem with the following code: SELECT PM.PM_Eng_Name,
ISNULL(SUM(PMOutput.Quantity),0) AS TotalOut FROM PM LEFT OUTER JOIN
PMOutput ON PM.PM_code = PMOutput.PM_code WHERE (PMOutput.Output_Date
BETWEEN '2013-01-01' AND '2013-08-25') GROUP BY PM.PM_Eng_Name
When I run this query I got the total output only for the materials that
have output transactions during the selected date rang, while I need to
generate the total output for all the PM_Eng_Names I have, with the value
0 for the materials that have no output transaction in the selected date
range Note: I got the perfect report when I remove the WHERE clause, but
the date is important for my project Anyone can help me please?

Saturday, 24 August 2013

How can I add dynamic crystal report and customize it at run time in ASP.Net?

How can I add dynamic crystal report and customize it at run time in ASP.Net?

I just want to ask if there is any way in which I can add and customize
crystal report at run time?. In other words I want an ASP.net web page to
let me add new crystal report, then change the design of it and the user
can click save button. Is there any way to do this? I have this code as a
start :
ReportClass rc = new ReportClass();
CrystalReportSource crs = new CrystalReportSource();
crs.ID = "crs1";
CrystalReportViewer crv = new CrystalReportViewer();
crv.ReportSourceID = crs.ID;
Process p = new Process();
// Run viewer in the process.
Any Help is appreciated.

I am a troll. I am a troll

I am a troll. I am a troll

I am a troll. I am a troll. I am a troll. I am a troll. I am a troll. I am
a troll.

Anonymous method for event handler in for loop

Anonymous method for event handler in for loop

Can this be done in a for loop?
TickEventArgs targs1 = new TickEventArgs(lbl1_up_time,
_elapsedTime_up1);
timer_up1.Tick += (sender, e) => Tick(targs1);
TickEventArgs targs2 = new TickEventArgs(lbl2_up_time,
_elapsedTime_up2);
timer_up2.Tick += (sender, e) => Tick(targs2);
TickEventArgs targs3 = new TickEventArgs(lbl3_up_time,
_elapsedTime_up3);
timer_up3.Tick += (sender, e) => Tick(targs3);
TickEventArgs targs4 = new TickEventArgs(lbl4_up_time,
_elapsedTime_up4);
timer_up4.Tick += (sender, e) => Tick(targs4);
TickEventArgs targs5 = new TickEventArgs(lbl5_up_time,
_elapsedTime_up5);
timer_up5.Tick += (sender, e) => Tick(targs5);
This doesnt work because i is out of bounds (5)
targs[0] = new TickEventArgs(lbl1_up_time, _elapsedTime_up1);
targs[1] = new TickEventArgs(lbl2_up_time, _elapsedTime_up2);
targs[2] = new TickEventArgs(lbl3_up_time, _elapsedTime_up3);
targs[3] = new TickEventArgs(lbl4_up_time, _elapsedTime_up4);
targs[4] = new TickEventArgs(lbl5_up_time, _elapsedTime_up5);
timers[0] = timer_up1;
timers[1] = timer_up2;
timers[2] = timer_up3;
timers[3] = timer_up4;
timers[4] = timer_up5;
int i = 0;
for (i = 0; i <= 4; i++)
{
timers[i].Tick += (sender, e) => Tick(targs[i]);
}

PHP - Codeigniter removing dash and brackets while inserting to DB

PHP - Codeigniter removing dash and brackets while inserting to DB

So I've tried to debug this to some extend but I have no idea why this is
happening. So after retrieving info from and excel file I try to database,
for the most case this works, but I have 2 exceptions that are giving me a
hard time. Firstly a part no. with a "-" is removed while inserting (ex:
sxrv-11 becomes sxrv11) in the db and second brackets (ex: (pv) is
converted to a 1 so (pv)tr55x would become 1tr55x)
here is an example var_dump of the array:
array(20) {
["stock_no"]=>
float(127)
["part_no"]=>
string(9) "SIFR6A-11"
["pop_code"]=>
string(3) "D-N"
["jobber"]=>
float(15.2)
["sell_out"]=>
string(0) ""
["suggested_qty"]=>
float(4)
["box_qty"]=>
string(1) "1"
["case_qty"]=>
float(120)
["description"]=>
string(50) "LASER IRIDIUM SPARK PLUG / BOUGIE IRIDIUM AU LASER"
["individual_upc"]=>
string(12) "087295101278"
["box_upc"]=>
string(12) "087295001271"
["case_upc"]=>
string(14) "10087295001278"
["part_status"]=>
string(0) ""
["product_desc"]=>
string(0) ""
["box_size"]=>
string(0) ""
["fk_id_brand"]=>
int(1)
["fk_id_category"]=>
string(1) "1"
["fk_id_subcategory"]=>
string(1) "5"
["description_en"]=>
string(24) "laser iridium spark plug"
["description_fr"]=>
string(23) "bougie iridium au laser"
}
This is the insert function that uses that data array to insert:
public function insert_product($product)
{
echo "<pre>";
var_dump($product);
echo "</pre>";
$this->db->set('fk_id_category', $product['fk_id_category']);
$this->db->set('fk_id_subcategory', $product['fk_id_subcategory']);
$this->db->set('fk_id_brand', $product['fk_id_brand']);
$this->db->set('stock_no', $product['stock_no']);
$this->db->set('part_no', $product['part_no']);
$this->db->set('pop_code', $product['pop_code']);
$this->db->set('jobber', $product['jobber']);
$this->db->set('part_status', $product['part_status']);
$this->db->set('sell_out', $product['sell_out']);
$this->db->set('suggested_qty', $product['suggested_qty']);
$this->db->set('box_qty', $product['box_qty']);
$this->db->set('case_qty', $product['case_qty']);
$this->db->set('description_en', $product['description_en']);
$this->db->set('description_fr', $product['description_fr']);
$this->db->set('product_desc', $product['product_desc']);
$this->db->set('box_size', $product['box_size']);
$this->db->set('individual_upc', $product['individual_upc']);
$this->db->set('box_upc', $product['box_upc']);
$this->db->set('case_upc', $product['case_upc']);
$this->db->insert('product');
}
Once in the database it's modified to the examples described before. I've
tried different mysql collations and it doesn't change anything.
The oddest part about all this is that the "pop_code" keeps the "-" when
inserted in the database. They are both varchar() 20 and 5 respectively.
I can't tell if it's a PHP issue, codeigniter issue, mysql issue,
phpmyadmin issue. Does anyone have a clue?

portqry to check connectivity

portqry to check connectivity

Is it possible to check the connectivity between 2 remote servers using
portqry given that the portqry.exe command is executed on another server.
for example, check the connectivity between serverA and serverB where the
portqry.exe command is running on serverC
Also please advise what is best solution/way to automated this
Thanks in advance for your help

android-maven-plugin Error on Build

android-maven-plugin Error on Build

i need to build an android project using maven, i have managed to
configure everything but i guess this is something missing as i encounter
this issue:
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 35.303s
[INFO] Finished at: Sat Aug 24 04:02:27 GMT 2013
[INFO] Final Memory: 28M/68M
[INFO]
------------------------------------------------------------------------
[ERROR] Failed to execute goal
com.jayway.maven.plugins.android.generation2:andr
oid-maven-plugin:3.6.0:generate-sources (default-generate-sources) on
project mo
bile-widgets-android: Execution default-generate-sources of goal
com.jayway.mave
n.plugins.android.generation2:android-maven-plugin:3.6.0:generate-sources
failed
: Error reading
C:\Users\user1\Desktop\adt-bundle-windows\tools\source.propertie
s -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the
-e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions,
please rea
d the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutio
nException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the
command
ADT version 22, Android Target Level API 10, JRE version 1.6
mvn -version output:
C:\src>mvn -version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19
13:51:
28+0000)
Maven home: C:\JavaLibs\apache-maven-3.0.5\bin\..
Java version: 1.6.0_33, vendor: Sun Microsystems Inc.
Java home: C:\Program Files (x86)\Java\jdk1.6.0_33\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
my pom build content:
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
<version>3.6.0</version>
<configuration>
<sdk>
<platform>10</platform>
</sdk>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse
m2e settings only. It has no influence on the Maven build
itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
com.jayway.maven.plugins.android.generation2
</groupId>
<artifactId>
android-maven-plugin
</artifactId>
<versionRange>
[3.1.1,)
</versionRange>
<goals>
<goal>
generate-sources
</goal>
<goal>proguard</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
while googling the similar issue was produced using the maven android
compiler below the 3.6.0, on m2 folder i have the 3.6.0 which makes me
really confused about this issue.
any help is much appreciated.

What are the crunchy bits on top of Thai mango with sticky rice?

What are the crunchy bits on top of Thai mango with sticky rice?

My favorite Thai restaurant makes a fantastic mango and sticky rice
dessert, and it seems like it'd be pretty simple to recreate at home. I've
searched around the internet for mango and sticky rice recipes, and have
found many, but none seem to have the crunchy bits that I find in my local
restaurant's version.
Obviously, I can ask at the restaurant next time I'm there, but I'm
curious if anybody here knows what these could be?
They are crunchy and about the size of grains of rice, which make me think
they might be toasted grains of sticky rice? They could also be some kind
of seed or nut...
Does anybody know of any crunchy bits that are traditional on Thai sticky
rice with mango?

Merge files in STATA

Merge files in STATA

pHi I am using STATA 12 and trying to merge two files with variable ID,
the ID is not unique in the file I am using, but it is in the other file
so I use the syntax:/p precodemerge m:1 ID using massi.dta /code/pre pBut
I always get the following error message:/p pvariable ID not found
r(111)/p pAnd I am sure that the variable ID are in both files and I have
been trying to figure this out without success, can anybody please help
me?/p

Friday, 23 August 2013

I am getting the black screen in startup

I am getting the black screen in startup

I am using Ubuntu 12.04 LTS. Actually i upgraded my system from 11.10 to
12.04 using terminal. after some days. I am getting the black screen while
starting the system. I am able to login after 4 to 5 times of rebooting
every day. some times it takes 10 times to login.
and i tried other answers in askubuntu.com it doesn't worked for me.
what am i supposed to do. Please do let me know

Python timestamp for pcap files

Python timestamp for pcap files

I am fairly new to Python, and i came across some code that parsed through
a pcap file. The only problem is that this code contained the line
datetime.datetime.now() which it would use to print out the time stamp for
the connections in the file, however it prints out the times stamp of when
it was just accessed. What i want to do however is to print out the
original time stamps for the connections in the file.
For example, if i used the code to parse through the pcap file now, the
first connection would have a time stamp of August 23, 2013 9:04 (or
however specific it gets). Where as the file has the original time stamp
of July 3, 2008 3:05 (which is what i want to actually print out).
I was wondering if anyone knew a simple python solution or any other help
is appreciated.

Getting UIElement from Storyboard in Completed event Windows 8 App

Getting UIElement from Storyboard in Completed event Windows 8 App

I have an Image that i'm animating with a Storyboard. I want to be able to
change the source of the image after the storyboard animation has
completed. However, I don't know how to access the Image in the Completed
event handler. How can I gain access to the Image through a Storyboard
object.
private void AnimateImage() {
Image i = new Image();
//Set name and source of image here
i.RenderTransform = new CompositeTransform();
Duration d = new Duration(TimeSpan.FromSeconds(2));
DoubleAnimation anim1 = new DoubleAnimation();
DoubleAnimation anim2 = new DoubleAnimation();
anim1.Duration = d;
anim2.Duration = d;
Storyboard sb = new Storyboard();
sb.Duration = d;
sb.Children.Add(anim1);
sb.Children.Add(anim2);
Storyboard.SetTarget(anim1, i);
Storyboard.SetTarget(anim2, i);
Storyboard.SetTargetProperty(anim1,
"(UIElement.RenderTransform).(CompositeTransform.TranslateX)");
Storyboard.SetTargetProperty(anim2,
"(UIElement.RenderTransform).(CompositeTransform.TranslateY)");
//Set anim1/anim2 To/From properties
sb.Completed += StoryboardCompleted;
sb.Begin();
}
private void StoryboardCompleted(object sender, object o) {
Storyboard sb = (Storyboard) sender;
//How can I gain access to the Image?
}
I'm doing this animation many times with multiple images so I cant simply
make a member variable. I need to know which Image is done in the
Completed event.

java I'm making a game and I keep getting an error

java I'm making a game and I keep getting an error

I'm trying to make a loading and saving system so I can implement it into
the game, but I keep getting a error when trying to generate the level!
Please help me resolve this problem! If you do, Ill give you the link to
the pre alpha 3.0 (nothing yet thought).
Here is the error:
Exception in thread "main" java.lang.NullPointerException
at level.level.generatelevel(level.java:86)
at level.level.loadlevel(level.java:54)
at Window.Game.start(Game.java:121)
at Window.Game.main(Game.java:96)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at level.level.savelevel(level.java:70)
at Window.Game.stop(Game.java:114)
at Window.Game.windowClosing(Game.java:185)
at java.awt.Window.processWindowEvent(Unknown Source)
at javax.swing.JFrame.processWindowEvent(Unknown Source)
at java.awt.Window.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown
Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown
Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown
Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Here is the link to the code:
Click me for the code

How implement security with the mvcSiteMapProvider?

How implement security with the mvcSiteMapProvider?

I need to implement Role security with my mvcSiteMapProvider V4 software.
I am using it with MVC3.
Example mvcSiteMap Code:
<mvcSiteMapNode roles="Admin" title="Your Subscription (All Users)"
controller="SOU" action="ListSubscribers">
This roles attribute value has no effect:
<mvcSiteMapNode roles="NoAdmin" title="Your Subscription (All
Users)" controller="SOU" action="ListSubscribers">
This is the same. I would expect the above to not work if the Admin was
logged in? I would expect the first example to work if only the user was
logged in.
... But no effect .
Many thanks

Acronyms sorted alphabetically in Index

Acronyms sorted alphabetically in Index

I am using glossaries package with the acronym option
\usepackage[acronym,toc,shortcuts]{glossaries}. When my Index is
generated, the acronyms are not listed alphabetically but rather as a
"Symbol" entry within the index (image below). I am writing a thesis and
have a separate list of Acronyms so this "Symbol" entry in the Index is
rather useless for me. Is there a way that the acronyms can be sorted
alphabetically in the Index just like the rest of the entries?
MWE:
\documentclass[11pt]{article}
\usepackage{makeidx}
\makeindex
\usepackage[acronym,toc,shortcuts]{glossaries}
\makeglossaries
\newacronym{cd}{CD}{compact disk}
\begin{document}
\noindent
First\index{first} use of \gls{cd}\\
subsequent\index{subsequent} use of \gls{cd}\index{\glsfirst{cd}}
\printglossaries
\printindex
\end{document}

Thursday, 22 August 2013

using foreach to iterate simultaneously through multiple lists (syntax sugar)

using foreach to iterate simultaneously through multiple lists (syntax sugar)

Hi is there a way to do things like this:
for (int i = 0; i < Math.Min(a.Count, b.Count); i++)
{
// Do stuff
//a[i]
//b[i]
}
with Foreach?
because it would be nice to write something like
foreach(var item1 in list1 and var item2 in list2 /* ....*/)
{
item1.use(item2);
}

What software is this in my system tray?

What software is this in my system tray?


Right beside the Alfred icon, there's a small up and down arrow indicating
bandwidth upload and download speeds.
I remember downloading and installing something for this, and now I can't
remember the name of it. I'm trying to enter the settings for it and also
add in the RAM tickers.
Any ideas on the name? It was a very famous Mac OSX product.

bindAttr and registerBoundHelper together

bindAttr and registerBoundHelper together

Is it possible to use a registerBoundHelper when changing the value of an
attribute using bindAttr? HTML
<div class="bar" {{styleWidth bindAttr style="value"}}></div>
JS
Ember.Handlebars.registerBoundHelper('styleWidth', function(width){
return ("width: " + width + "px;");
});
Many Thanks

Complete Graph Invariant

Complete Graph Invariant

A graph invariant $I(G)$ is called complete if the identity of the
invariants $I(G)$ and $I(H)$ implies the isomorphism of the graphs $G$ and
$H$. I'm looking for some examples.

Overcoming the reserved word "IN" in sql server

Overcoming the reserved word "IN" in sql server

Just for reference I am using SQL Azure.
I noticed when I am trying to select data from a table based on a license
plate and the state of that plate I get no results back if the state is
"IN". I realize the word "IN" is reserved in SQL server; however, I am
containing that within quotes in my query. I currently am in testing phase
and have only one record in the table which has a lisence plate 287YGB and
state IN.
If I write my query as follows I get nothing back.
SELECT MakeModel, CitizenID, VehicleID FROM tblVehicles WHERE
tblVehicles.Lisence = '287YGB' AND tblVehicles.PlateState = 'IN'
If I write my query this way I get back my result. But this is not good
enough.
SELECT MakeModel, CitizenID, VehicleID FROM tblVehicles WHERE
tblVehicles.Lisence = '287YGB'
And finally, if I write my query this way I get the only row in the table.
SELECT MakeModel, CitizenID, VehicleID FROM tblVehicles
From these tests I can see that the last where parameter is causing the
problem. I am assuming it is due to the fact that the word "IN" is
reserved. Is there a way around this?

Remove the response wrapper from web service response?

Remove the response wrapper from web service response?

Is it possible to remove the what appears to be automatic
notificationRequestResponse node from the response?
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
...
<soap:Body>
<notificationRequestResponse xmlns="...">
<notificationResponse xmlns="...">
<success xmlns="">boolean</success>
<fault xmlns="">
...
</fault>
</notificationResponse>
</notificationRequestResponse>
</soap:Body>
</soap:Envelope>
I need to return the below:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
...
<soap:Body>
<notificationResponse xmlns="...">
<success xmlns="">boolean</success>
<fault xmlns="">
...
</fault>
</notificationResponse>
</soap:Body>
</soap:Envelope>
I want the notificationRequestResponse to be the root of the response!
The WebMethod currently has no logic but:
return new notificationResponse()
Where is the notificationRequestResponse coming from? I can rename it
using WebMethod SoapDocumentMethod(ResponseElementName="new name") but I
want it gone. Working to a provided spec and have no choice.
Appreciated.

Using EntityFramework with SAP Business One without losing warranty?

Using EntityFramework with SAP Business One without losing warranty?

i'd like to know if someone is using EntityFramework with SAP Business
One? If yes how do you handle the warranty. SAP only allows to
Insert/Update/Delete through their DI Server API otherwise you lose the
warranty. So if i am only allowed to select i can only use Entity
Framework for reading data, is that correct?
Anyway would you recommend to use EntityFramework with SAP Business One or
are there performance issues with an high amout of data?
Greetings.

Wednesday, 21 August 2013

Convert HTML to word file ?

Convert HTML to word file ?

How to convert ruby file in word file i.e (docx file). For pdf, we prawn
gem. But is there any gem for word file. I am trying to convert my html
file in word file so that it can be editable for user too. What should do
in that case ? I was planning to convert that file in word file. Will it
be possible or not.

RSpec stop method

RSpec stop method

Quick rspec question here.
Given the following test...
it 'sets the correct params' do
property = 'blahblah'
expect(ConnectionClass).to receive(:new).with({ opt1: param1, opt2:
property })
subject.send(:do_things, nil, nil).and_return_nil
end
and the following method...
private
def do_things(param1, param2)
connection = ConnectionClass.new(opt1: param1, opt2: param2)
##
# How do i stop the test from continue beyond this point? :(
##
some_var = connection.build_request do |blah|
# ...
end
some_var.some_attribute
end
Running the test results in the following failure:
Failures:
1) Klass#do_things sets the correct params
Failure/Error: subject.send(:do_things, nil, nil).and_return_nil
NoMethodError:
undefined method `build_request' for nil:NilClass
# ./lib/blah/Klass.rb:46:in `make_request'
# ./spec/lib/blah/Klass_spec.rb:79:in `block (3 levels) in <top
(required)>'
For this test, all i care about is that ConnectionClass is initialized
correctly -- how can i prevent the call to build_request and eventual
some_attribute?
Thank you

iTextSharp Linq Query

iTextSharp Linq Query

is there a way to print linq queries with itextsharp ? Like below sample?
from cx in OrderDetails
join dx in Orders on cx.OrderID equals dx.OrderID
join fx in Customers on dx.CustomerID equals fx.CustomerID
join px in Products on cx.ProductID equals px.ProductID
group cx by new {cx.OrderID,dx.CustomerID,px.ProductID} into g
where g.FirstOrDefault().ProductID==3
select new
{
ProductName=g.FirstOrDefault().Product.ProductName,
UnitsInStock=g.FirstOrDefault().Product.UnitsInStock,
Discount=g.FirstOrDefault().Discount,
OrderDate=String.Format("{0:d}",g.FirstOrDefault().Order.OrderDate),
Quantity=g.FirstOrDefault().Quantity,
UnitPrice=String.Format("{0:c}",g.FirstOrDefault().UnitPrice)
}

Getting XML from web request

Getting XML from web request

I have an api built by another member of my team, and neither of us is
sure how to get it to respond with xml (currently it is responding with
JSON).
The URL in question is here
When that url is called by a browser, the browser defaults kick in and it
displays in XML for chrome and json for firefox and IE. I'm using an
android application to pull the xml data, so I need to be able code the
application to request the xml form of the data, instead of the json
(knowing how to force it to do json instead would be useful as well, even
though the thing currently defaults to json).
Here is the code that connects to the page:
the call in code:
parser.setInput(new InputStreamReader(getUrlData(args[0])));
the class:
public InputStream getUrlData(String url) throws URISyntaxException,
ClientProtocolException, IOException {
// Used to get access to HTTP resources
DefaultHttpClient client = new DefaultHttpClient();
// Retrieves information from the URL
HttpGet method = new HttpGet(new URI(url));
// Gets a response from the client on whether the
// connection is stable
HttpResponse res = client.execute(method);
// An HTTPEntity may be returned using getEntity() which tells
// the system where the content is coming from
return res.getEntity().getContent();
}
Any help is greatly appreciated.

Online classes/books in multivariable calculus?

Online classes/books in multivariable calculus?

So does anyone know of any good online courses in multivariable calculus?
(Or in a possible alternative leap of curriculum, if said path has proven
to be better/moar interesting.) I'm coming straight from BC Calc (5); but
my high school doesn't offer math past that.
As for descriptions of the course...not being free is tolerable. The only
real requirement-requirement would be that the class does not require
presence in an online classroom, since I live in Europe. Also something
that is important for me is I need some way of getting credit for the
course--not necessarily high school type credits, but more of just a
general report-card type thing which ensures to my high school that I'm
learning math. (So MIT OCW would be difficult in this aspect...)
As for books, I have the book Calculus, a New Horizon (ISBN 0471482730)),
which is just a normal textbook that tided me over through single variable
calc and supposedly should last through multivariable calculus as well.
However if you know of books that are significantly better, please name
them!

binary tree compare nodes' feature from leaves to root python ete2 tools

binary tree compare nodes' feature from leaves to root python ete2 tools

I have a binary tree:
root
/ \
g h
/ \ / \
d a e f
/ \
b c
each node has 'seq' feature which stores the dna sequence of each node
('AACCGGT')
the sisters who are both leaves (b,c and e,f) have each one a score (float
) what I want is to :
compare score of leaf which has score with it's sister b.score with c.score
d.score = max (b.score,c.score)
same for e, f and h
compare a.seq with d.seq ==> d and e will have a score
g.score max (e.score, a.score) ... till arrive to the root NOte: every
leaf node has 'model feature' I compare b.seq with c.seq based on b.model
==>I got b.score then based on c.model ==> I got c.score I did some tries
:
def affect_score(n): if (n.score)==0:
n.score=affect_score(n.get_children()[0]) result=n.score if not
n.is_root(): sis=n.get_sisters()[0] else: sis=n if sis.score==0:
sis.score=affect_score(sis.get_children()[0]) if result
Can anyone helps me by telling what shall I do ? Note that It's my first
time working with tree data sturcture and recursion thanks in advance for
any suggestion

Tuesday, 20 August 2013

Determine what was clicked on previous page - JQUERY

Determine what was clicked on previous page - JQUERY

i have two divs in one page (div A and div B) and by default Div A is set
as display block and Div B is set as display none. For a user to land on
this particular page, he has to click on a link in a dialog box. Like
this:
<div id"dialog-box">
<a href="/newpage.html" class="firstlink"> First Link </a>
<a href="/newpage.html" class="secondlink"> Second Link </a>
</div>
<div class="newpage">
<div class="divA" style="display:block">
</div>
<div class="divB" style="display:none">
</div>
</div>
What i want to achieve is something like this:
$(".firstlink").click(function(){
$(".divA").css("display","none");
$(".divB").css("display","block");
});
$(".secondlink").click(function(){
$(".divA").css("display","block");
$(".divB").css("display","none");
});
But the above would of course not work because divA and divB is in a
different page... And i dont want to use cookies for this small task.

Define a Cucumber step in a Before block

Define a Cucumber step in a Before block

Before('@scoped_step')
Given(/^Some step$/) do
puts "Success!"
end
end
However, Cucumber just thinks I'm trying to call a step:
WARNING: Using 'Given/When/Then' in step definitions is deprecated, use
'step' to call other steps instead
I'm trying to track down how to do this via the Cucumber code base, but
I'm getting a bit lost.
Any ideas how to achieve this? Something like
"Cucumber::Steps.register_step(...)`?

posgresql query for intervals of 1 min with accumulated sum over all the timeframe

posgresql query for intervals of 1 min with accumulated sum over all the
timeframe

So i'm struggling with this query so far i can create the intervals of 1
min but the sum of the two columns that I need is given for just that min
and not the accumulated sum over time
SELECT
TIMESTAMP WITH TIME ZONE 'epoch' +
INTERVAL '1 second' * round(extract('epoch' from "Timestamp") / 60) * 60
as "Timestamp", SUM("Particles"), sum("Bio")
from "Results"
where "SampleID" = 50
GROUP BY
round(extract('epoch' from "Timestamp") / 60)
ORDER BY "Timestamp" DESC
that is the query that i'm using and the results are these
Timestamp |Sum |Sum
"2013-08-09 14:17:00-07" | 61 | 4
"2013-08-09 14:16:00-07" | 64 | 6
"2013-08-09 14:15:00-07" | 29 | 5
"2013-08-09 14:14:00-07" | 96 | 1
"2013-08-09 14:13:00-07" | 43 | 2
but i need the accumulative sum of those last two colums

Handlebar - dynamic element attributes

Handlebar - dynamic element attributes

I want to do something like this:

<span class="{{user.female ? 'female-span' : 'male-span'}}">
This is easily doable in something like angularjs but I cannot do this
handlebar. What is the idiom/pattern to follow in handlebar when I want to
dynamically change element attributes? Are there any handlebar plugins
that do this?

LEFT JOIN (SELECT) Syntax Error In From Clause

LEFT JOIN (SELECT) Syntax Error In From Clause

Can some one point out to me the error in this sql statement?
SELECT CommTypes.Description
FROM CommTypes
LEFT JOIN
(
SELECT *
FROM IntroducerBasis
WHERE IntroducerBasis.IntroducerCode='AG'
AND IntroducerBasis.BasisNumber=1
) AS Intro
ON CommTypes.ID = Intro.CommTypeID;
The error highlights the subsequent SELECT statement as the source of the
error.

Can't get my verification code for developer registration

Can't get my verification code for developer registration

Dear Facebook help center,
I'm a current Facebook user and I've just created a page. I wanted to add
a page tab to my page and I needed to register as a developer as advised
by your FAQ. However, the registration process prompted me to verify by my
phone number, yet the system wouldn't send verification code to my mobile
phone. Upon checking the accuracy of my own number, I've repeated the
request several times so far. Still there's not a single incoming message.
Could you please kindly see into the problem about what's going wrong?
Your help will be much appreciated.
Regards, Kafka Tom Kongsuwan

How to Bind TextBlock Width when it is part of style

How to Bind TextBlock Width when it is part of style

I created my own class for AutoComplete and in its Style I made it in such
away that if the text is nothing it shows a textblock. Everything works
well except when text is nothing the TextBlock is smaller than the
AutoComplete Element. I used Stretched="Fill" but this make the TextBlock
stretched and the text inside of the textblock will stretched as well and
look so ugly. I am thinking of binding the width of the textbloxk to the
ActualWidth of the AutoComplete element but problem is that textblock is
in the style and I cannot use the ElementName. Is there any way that Bind
the width without using ElementName?
Thank you so much
<Style BasedOn="{StaticResource {x:Type ComboBox}}" TargetType="{x:Type
src:AutoCompleteSearchControl}">
<Setter Property="IsEditable" Value="true"></Setter>
<Style.Triggers>
<Trigger Property="IsEditable" Value="True">
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Padding" Value="0,1"/>
<Setter Property="Template" Value="{StaticResource
AutoCompleteComboBoxEditableTemplate}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Text" Value="" />
</MultiTrigger.Conditions>
<Setter Property="Background">
<Setter.Value>
<VisualBrush Stretch="None">
<VisualBrush.Visual>
<TextBlock Text="Press F12"
Margin="5,5,5,5"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Foreground="Gray"
Background="White"
FontSize="16" />
</VisualBrush.Visual>
</VisualBrush>
</Setter.Value>
</Setter>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Validate" Value="True"/>
<Condition Property="SelectedItem" Value="{x:Null}"/>
<Condition Property="IsEnabled" Value="True"/>
</MultiTrigger.Conditions>
<MultiTrigger.Setters>
<Setter Property="BorderBrush" Value="Red"/>
<Setter Property="BorderThickness" Value="1"/>
</MultiTrigger.Setters>
</MultiTrigger>
</Style.Triggers>
</Style>

Monday, 19 August 2013

ASP.NET: dropdownlist not retaining values on submit

ASP.NET: dropdownlist not retaining values on submit

<asp:DropDownList ID="ddl1" runat="server" AutoPostBack="True" Width="110px">
<asp:ListItem>Test1</asp:ListItem>
<asp:ListItem>Test2</asp:ListItem>
<asp:ListItem>Test3</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddl2" runat="server" Width="110px">
</asp:DropDownList>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
I am trying to add list items to ddl2 on ddl1.SelectedIndexChanged based
on the selected index.
ddl2.Items.Insert(0, New ListItem("Please Select", "-1"))
ddl2.Items.Insert(1, New ListItem("value2", "1"))
ddl2.Items.Insert(2, New ListItem("value3", "2"))
On submit i am unable to retain the selected value of ddl2.
Please provide me a working solution in VB.NET. I have tried using hidden
values, still unsuccessful.
Note: I am using an user control.
Thank You.

PHP Upload File leads to blank page

PHP Upload File leads to blank page

I have the following code:
<html>
<body>
<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
<?php
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
}
?>
When I upload I just eventually get a The connection was reset page
I have nginx as a frontend and php-fpm as the backend
php settings are set very high so no limits.
What should I try to debug this? I don't have anything in the error_log
for PHP.

Configure Apache to use ODBC authentication

Configure Apache to use ODBC authentication

I'm trying to connect to a Sql Server via ODBC to serve as the
Authentication mode to a locally installed CollabNet Subversion Server on
a Server running Windows Server 2008 x64.
I found this link that attempted this with an ODBC connection and Apache
2.2. I started by creating an ODBC connection using
"C:\Windows\SysWOW64\odbc32.dll" that successfully connected to the
server. When I attempted to make the same changes in the post with
CollabNet Subversion Server build 4.0.1-3680.113 which uses Apache 2.4, I
got the following error:
ERROR console.CommandLineService - Exit status=1 Process err output:
AH00526: Syntax error on line 5 of
C:/csvn/data/conf/svn_viewvc_httpd.conf:
Can't load driver file apr_dbd_odbc.so
I checked and there was a apr_dbd_odbc-1.dll file in my bin directory, but
I didn't find the .so file anywhere in my C:\csvn directory. I also
checked the folder priveleges, just to make sure it wasn't a permission
issue, and I opened it to Everyone wihtout success. I found a related post
that talked about how to theoritically do this here: Configure Apache to
use SQL Server authentication, but there didn't appear to be any
troubleshooting options.
I don't need to use an ODBC connection, it just looked like my only option
with Windows because FreeTDS and PostgreSQL were only commonly supported
on *nix systems.
Here is my svn_viewvc_httpd.conf file:
LoadModule dbd_module lib/modules/mod_dbd.so
LoadModule authn_dbd_module lib/modules/mod_authn_dbd.so
<IfModule dbd_module>
DBDriver odbc
DBDParams "DATASOURCE=OdbcName, USER=db_user, PASSWORD=xxxxxx"
</IfModule>
Include "C:/csvn/data/conf/ctf_httpd.conf"
SSLEngine On
RedirectMatch ^(/svn)$ $1/
<Location /svn/>
DAV svn
SVNParentPath "C:/SubversionRepositories"
SVNReposName "CollabNet Subversion Repository"
AuthType Basic
AuthName "CollabNet Subversion Repository"
AuthzSVNAccessFile "C:/csvn/data/conf/svn_access_file"
SVNListParentPath On
<IfModule deflate_module>
SetOutputFilter DEFLATE
</IfModule>
AuthBasicProvider dbd file
Require valid-user
# mod_authn_dbd SQL query to authenticate a logged-in user
AuthDBDUserPWQuery \
"SELECT [u].[hash] FROM [dbo].[user] u WHERE [u].[username] = %s"
</Location>
Is there a file that I'm missing in my build? Or am I looking for a
configuration change?
I appreaciate any assistance.

lock tables sql+php PDO

lock tables sql+php PDO

I want to lock a table before doing the action on the table in PDO, so two
users will not be able to do the same action in the same time.
I tried as follow:
$this -> link ->beginTransaction();
$this -> link ->exec('LOCK TABLES `MYTABLE` WRITE;');
//do something...
$this -> link ->exec('UNLOCK TABLES');
$this -> link ->commit();
but if two users try this query, they both stack. what I do wrong?
thanks!!

Sunday, 18 August 2013

How to export csv nodejs

How to export csv nodejs

Hey I am trying to export a csv from node.js (pulling the data from
mongodb). I already have the data being pulled and separated by commas and
all, but now I am trying to figure out how to actually send it... I am
sticking this code in my routes file. Any advice on how to take the array
of data and send it to a user straight for download on request.
here is the code: (I attempted the save part but, it does not work
correctly and I get the content error and what not, not sure if that has
to do because it is not in the app.js aka main file)
exports.downloadContacts = function(req, res) {
async.waterfall([
function(callback) {
var source = [];
Friend.find({userId: req.signedCookies.userid}, function(err,
friends) {
if(err) {console.log('err with friends for download');
} else {
var userMap = {};
var friendIds = friends.map(function (user) {
userMap[user.friend_id] = user;
return user.friend_id;
});
console.log(friends);
User.find({_id: {$in: friendIds}}, function(err, users) {
if(err) {console.log(err);
} else {
for(var i = 0; i < users.length; i++) {
console.log('users')
//console.log(users[i]);
source.push(users[i].firstNameTrue,
users[i].lastNameTrue, users[i].emailTrue,
users[i].phone, users[i].emailList,
users[i].phoneList)
}
console.log(source);
callback(null, source);
}
});
}
});
}
],
function(err, source) {
var result = [];
res.content('csv');
csv()
.from(source)
.on('data', function(data){
result.push(data.join());
})
.on('end', function(){
res.send(result.join('\n'));
});
});
};

AngularFire auth failing silently on Facebook login

AngularFire auth failing silently on Facebook login

I'm trying to log my user into Facebook using AngularFire auth. When I
click login I see the error event fire - angularFireAuth:error but the err
array is empty. I have no idea what is wrong or how to debug. Any ideas?
View:
<div ng-controller="UsersCtrl">
<div id="loginDiv">
<a href="#" ng-click="logout()">Logout</a>
<span ng-show="user">
{{user.name}}
<a href="#" ng-click="logout()">Logout</a>
</span>
<a href="#" ng-hide="user" ng-click="login()">Login</a>
</div>
</div>
Controller:
myApp.controller('UsersCtrl', ['$scope', 'angularFireAuth',
function UsersCtrl($scope, angularFireAuth) {
var url = 'https://inviter-dev.firebaseio.com';
angularFireAuth.initialize(url, {scope: $scope, name: "user"});
$scope.addUser = function(user) {
console.debug("new user", user)
users.push(user);
}
$scope.login = function() {
console.debug("logging in")
angularFireAuth.login("facebook");
};
$scope.logout = function() {
angularFireAuth.logout();
};
$scope.$on("angularFireAuth:login", function(evt, user) {
console.debug("login event", user)
});
$scope.$on("angularFireAuth:logout", function(evt) {
console.debug("logout event", user)
});
$scope.$on("angularFireAuth:error", function(evt, err) {
console.debug("auth error", err)
// There was an error during authentication.
});
}
]);

C#: How to add a class member named "protected"

C#: How to add a class member named "protected"

I'm fairly new to C# but have extensive experience in Objective-C and OOP.
I'm using Json.NET to automatically parse API responses to objects. It so
happens that one of the objects returned has a property named protected.
Obviously this is a problem, because protected is a keyword for class
member declaration.
"protected": true
Is it possible to add a member with the name protected at all?
Is it possible to add setters and getters that get triggered, if the
parser tries to set the protected property? (but assign the value to a
private member named _protected)
Should I modify the parser to behave different when he encounters a
property named protected?
Thanks for any advice.

Spammy spam spam spam is spammy

Spammy spam spam spam is spammy

Please delete my spammy spammy post

match_parent not performing as expected

match_parent not performing as expected

I imagine this should be a fairly easy one to answer, if you understand
XML Layouts better than I do that is. I don't seem to get what I was
thinking I should when using the match_parent layout_height.
I have a LinearLayout root element with android:orientation="vertical".
Inside this LinearLayout I want three elements: - TextView - ListView -
TextView
For both the TextViews I set android:layout_height="wrap_content" so that
they will be only as tall as is necessary to display their contents. The
thing is, I want the one TextView to sit at the top of the form, the other
one to sit at the bottom of the form while the ListView fills up whatever
space is available on the form. So here is what my xml layout looks like:
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="Top TextView" />
<ListView
android:id="@+id/listView_Species"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="Bottom TextView" />
But it doesn't work. Here's what I get. I've selected the ListView so that
it will be highlighted. Notice how it extends all the way to the bottom of
the form, pushing the bottom TextView off the form.
When I change the layout_height property of the ListView to some fixed
value, like 180dp, this is what the form looks like. I'm just posting this
to prove that the bottom TextView is there but I still don't know how to
get it to be fixed to the bottom of the screen while the ListView takes up
whatever space remains, but in between the two TextViews.

Thanks in advance.

Updating a Coloumn in SQLdatabase table when month changes

Updating a Coloumn in SQLdatabase table when month changes

Iam working on fee collection system I need to update the value of Feedue
field when month changed
Ex: IF month changed from August to September Feedue field need to update as
Value of feedue field=value in fee field +value of feedue field
I've tried in many ways but not succeded

Saturday, 17 August 2013

check for java methods used in velocity

check for java methods used in velocity

I want to validate if the methods used in velocity template are valid. For
eg, for a string varaiable if user gives name.substrig(), I want to show
the error msg (substrig doesnot belong to String or something like that).
How can I validate this like if the method used is correct?

How can I get Nautilus to work with X11 forwarding over SSH? I'm getting a bunch of errors related to D-Bus

How can I get Nautilus to work with X11 forwarding over SSH? I'm getting a
bunch of errors related to D-Bus

Here's where things stand right now.
I have Nautilus successfully running under Mac OS X 10.8 on a Mac Mini,
installed via MacPorts.
I am trying to pull it up on a second screen on a Raspberry Pi running
Raspbian. Or really on any other computer.
I have been able to successfully run simple X11 apps like xeyes via X11
forwarding, so I am confident I have forwarding set up correctly.
When I try to run Nautilus via forwarding, I get this long list of errors.
I've put it up on pastebin.
I definitely have dbus installed on the Pi, though I don't really know
what it is. I'm not sure what's behind these errors or if there's anything
I can do about it. Anybody have any thoughts?

Need help with this regular language proof

Need help with this regular language proof

I'm trying to prove that if $L$ is regular, then $L_S$ is regular as well.
$L_s$ = {$x$ | $Î$ $w ¸ ƒ°^*$ such that $wx¸L$}
I know one way to do this would be to create an NFA that accepts $L$, then
modify it so it accepts $L_S$ as well.

using inner class object in outer class java

using inner class object in outer class java

I am facing a problem converting json object to POJO class.
I have a public class called Service and it has an inner class User. I
want to use the inner class as a container/object to hold the variables
for all my outer class methods. I am trying to do the below, but I am
getting compilation errors. Please show how I can do this and please
correct the mistake I am doing in my code below.
Trial 1:
public class Service {
// Method
public boolean createUserAccount(JsonNode node) throws Exception {
ObjectMapper mapper = new ObjectMapper();
User user=null;
try {
Service service=new Service();
user = mapper.readValue(node, User.class);
} catch (Exception e) {throw new Exception("failed to bind json",
e);}
System.out.println("Use this anywhere in method"+userNode.firstName);
}
}
// Inner class
public static class User {
public String firstName;
public String lastName;
}
}
OUTPUT:
NULL POINTER EXCEPTION AND user=null even after execution of
mapper.readValue() statement

Core data: to-many relationship removing target object when removing from relationship

Core data: to-many relationship removing target object when removing from
relationship

Image I have 2 Core Data entities, namely EntityA and EntityB.
EntityA has many EntityB's and EntityB belongs to one EntityA, i.e.:
EntityA ----- (entities) ->> EntityB
EntityB ----- (entity) ----> EntityA
Now image I have a EntityA *entityA which already has some entities.
Now I do the following:
entityA.entities = @[/* some new entityB's */];
Now the "old" entityB's will have a entity of nil and are thus "dangling".
I want to remove these entityB's, is there an option to do so? Of course I
could do it manually, but I feel like Core Data has some method of doing
this automatically.

Generic constrained Map using higher-kinded-types?

Generic constrained Map using higher-kinded-types?

I am trying to implement a result cache (Loader class) that maps hashable
instances of class Resolver[T] to Result instances, where T is has type of
Result. Of course a user is given the possibility to specialize the the
Result class providing extra methods that are application specific. The
point is that using the Loader.get method the user has also to specify the
resulting type:
val s = Loader.get(new
SpecializedResolver()).asInstanceOf[SpecializedResult]
What I want is to avoid the cast and make it implicit so the code should
be something like:
val implicitS = Loader.get(new SpecializedResolver())
The code I have at the moment is the following:
import scala.language.existentials
abstract class Result {
def computed: Boolean
}
abstract class Resolver[T <: Result] {
def result(): T forSome {type T <: Result}
}
class SpecializedResult extends Result {
def computed = true
def special() = 42
}
class SpecializedResolver extends Resolver[SpecializedResult] {
def result = new SpecializedResult
}
object Loader {
val cache = collection.mutable.Map[K forSome {type K <: Resolver[_]}, V
forSome {type V <: Result}]()
def get[K <: Resolver[_]](k: K): V forSome {type V <: Result} = {
cache.getOrElseUpdate(k, { k.result } )
}
}
object Runner {
def main(args: Array[String]) {
val s = Loader.get(new
SpecializedResolver()).asInstanceOf[SpecializedResult]
println("Value is: %d".format(s.special))
val implicitS = Loader.get(new SpecializedResolver())
// test.scala:34: error: value special is not a member of Result
println("Value is: %d".format(implicitS.special))
}
}
Since I am relatevely new to the scala language my question is: is it even
possible to achieve this implicit cast by using higher-kinded-types
feature that scala provides? I took a look at the talk 'High Wizardry in
the Land of Scala' where the speaker Daniel Spiewak introduces a
higher-order HOMap that does something similar but I still don't well
understand how to adapt his solution to my case.