Monday, April 16, 2012

Database: Oracle queries [closed]

some simple queries could you help? PLEASE



how do i find the subject which has taught within last 5 days?



Subject table holds Sub_ID, sub_name



Lesson holds Les_ID, sub_ID, Lesson_Taken place



SELECT sub_ID, subject



FROM Subject



WHERE date FROM Lesson > 1-4-11 AND < 16-4-11?



Would this be correct?
THANKS!!!!





'Compile Sources' not updated while dragging files to a project in Xcode 4.3.2

I am just not sure if this is a bug in Xcode 4.3.2 or is it supposed to be this way.



When I upgraded to Xcode 4.3.2 some time back and dragged some files onto a newly created project, it repeatedly threw linker errors while compiling. All the required frameworks were already linked. Turned out, that these errors disappeared when I went and manually added the .m files that I had manually dragged onto the project, in the Build Settings - Compile Sources.



I have done the same thing in previous versions of Xcode and never had to update the manually update the compile sources myself. I would assume that if any .m file is dragged into the project, the compile sources should be automatically updated.



I don't have any previous version Xcode currently available with me where I can test it, but would like to know if this really is a bug in Xcode 4.3.2 or is there something else that I am missing.





Importing Confusion Pandas

I had 0.71 pandas before today. I tried to update and I simply ran the .exe file supplied by the website.



now I tried " import pandas" but then it gives me an error



ImportError: C extensions not built: if you installed already verify that you are not importing from the source directory.



I am new to python and pandas in general. Anything will help.



thanks,
MG





characters versus arrays in c

Why do 1, 2, and 3 work when 4 generates a segmentation fault? (See below.)



char c[10];
char* d;



1.
scanf("%s", &c);
printf("%s\n", &c);



2.
scanf("%s", c);
printf("%s\n", c);



3.
scanf("%s", &d);
printf("%s\n", &d);



4.
scanf("%s", d);
printf("%s\n", d);





mysql-python: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

I installed mysql using homebrew.



I'm now trying to install mysql-python and I keep getting the error below when I run mysql.



I'm new to programming and don't know enough to identify the problem.



Any help will be appreciated. Thanks.



 TDNS-Mac-mini:~ TDNS$ easy_install mysql-python
/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install:5: UserWarning: Module pkg_resources was already imported from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.pyc, but /Library/Python/2.7/site-packages/distribute-0.6.24-py2.7.egg is being added to sys.path
from pkg_resources import load_entry_point
/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install:5: UserWarning: Module site was already imported from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.pyc, but /Library/Python/2.7/site-packages/distribute-0.6.24-py2.7.egg is being added to sys.path
from pkg_resources import load_entry_point
Searching for mysql-python
Reading http://pypi.python.org/simple/mysql-python/
Reading http://sourceforge.net/projects/mysql-python/
Reading http://sourceforge.net/projects/mysql-python
Best match: MySQL-python 1.2.3
Downloading http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3.tar.gz
Processing MySQL-python-1.2.3.tar.gz
Running MySQL-python-1.2.3/setup.py -q bdist_egg --dist-dir /var/folders/c9/xzv35t2n3ld9lgjrtl0vd0xr0000gn/T/easy_install-LsUpDW/MySQL-python-1.2.3/egg-dist-tmp-vzGMr9
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
unable to execute gcc-4.2: No such file or directory
error: Setup script exited with error: command 'gcc-4.2' failed with exit status 1

TDNS-Mac-mini:~ TDNS$ mysqld
120414 22:02:41 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
mysqld: Table 'mysql.plugin' doesn't exist
120414 22:02:41 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120414 22:02:41 InnoDB: The InnoDB memory heap is disabled
120414 22:02:41 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120414 22:02:41 InnoDB: Compressed tables use zlib 1.2.5
120414 22:02:41 InnoDB: Initializing buffer pool, size = 128.0M
120414 22:02:41 InnoDB: Completed initialization of buffer pool
120414 22:02:41 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
120414 22:02:41 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
120414 22:02:41 InnoDB: Waiting for the background threads to start
120414 22:02:42 InnoDB: 1.1.8 started; log sequence number 1595675
120414 22:02:42 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist




How do i use PHP to make dynamic entries in a mysql table?

I'm sorry, i Know this must be a basic question, but i cant find the answer in my textbook- i guess i'm not looking in the right places.



If i have a mysql database that keeps track of members and new pages created by members, what php script do i use to append my mysql database dynamically so that the new entries are listed accordingly?





How can I filter a page using drop down selection?

I have a web page that displays a list of people and their nationality.



<td><?php echo $row['First_Name'] . " " . $row['Last_Name'] ?></td>

<td><?php echo $row['Country'] ?></td>


I would like to add a control to the page that allows the user to apply a filter on the country.



Any suggestions on how I should go about it?





jQuery bind to keyup only, not focus

This seems like a simple thing but google hasn't turned up anything for me:



How can I bind to a text / value change event only, excluding an input gaining focus? Ie, given the following:



$(function(){
$('input#target').on('keyup', function(){
alert('Typed something in the input.');
});
});


...the alert would be triggered when the user tabs in and out of an element, whether they actually input text or not. How can you allow a user to keyboard navigate through the form without triggering the event unless they input/change the text in the text field?





how to save an array in an object at runtime in javascript

i want to save an array in an object in runtime through a loop:
for example i take an input in an array inp=[2,7,20,15,19] and i want to save it in an obj={0:2,1:7,2:20,3:15,4:19} but at run time such that i have a



for(i=0;i<inp.length;i++) 
{ save each element of array into the respective object element }


the problem is that i have to save arrays of different lengths that i am taking as input from user.i am also sorting the object afterwards and returning the indices in another array in my code. i am stuck only at how to save an array in an object during runtime.i searched alot for a clue to get started but i could not find anything.



thanks in advance





jQuery html(text) parsing via ajax

So I have a form which is sent to a python script via ajax. The python script is outputting an entire HTML page which includes content type doctype and all that.



Now I need to insert a part of the response text from the python script, a div element, into a div on the current page.



How do I parse the response text and strip away all of the unnecessary junks like doctype and header?



Thanks.





Kqemu Installation on Fedora 13

Can anyone tell me how to install kqemu on Fedora 13 host machine. I saw somewhere that Kqemu is not supported by Fedora 13, is that true???





Multiple use of customized UIView is invisible

I'm working on the customized UIView, but there's a really weird problem. I create a class called CustomBackgroundView which is a subclass of UIView. This customized view is aiming to work as a default background for other views. Basically, I just added three UIImageViews in CustomBackgroundView.



I added a couple of UIViews to a UIViewController in the storyboard and set the custom class property to CustomBackground for each of the UIViews. However, only the first customized UIView came into being. Others just didn't show up or like transparent.



I don't know whether I have to do something else to reuse a customized UIView in different places. Is it related to the image resource that is used in the customized UIView or is there anything I neglected..



Any help is appreciated! Thanks a lot~!





@Autowired annotation not able to inject bean in JUnit class

my test class:



public class myTest extends TestCase{
@Autowired
BeanClass beanObject
public void beanTest()
{
Classdata data = beanObject.getMethod();
}
}


I am getting a null pointer exception at line:



Classdata data = beanObject.getMethod();


the beanObject.getMethod(); precisely gives nullpointer exception



How should i make possible the autowiring of the field beanObject in my Junit class so that i can use the methods from the "BeanClass" class?






Copied from Comments:




in plain terms.. beanClass is an
interface which has certain methods..
i have tagged that beanClass with
@Service("beanObject")
annotation..that banClass is
implemented by beanClassImpl class
which has the method implementations..
i need to use those implementations in
my testClass to get the data to be
compared.. for that i am doing
@Autowired beanClass beanObject in
my testClass.. m i going terribly
wrong somewhere?






Android scaling javascript

Hi can anyone tell me how to make this javascript code show full screen on browsers? The code is working well but looks too small on larger devices...not sure what to change, thanks for any and all help :)



     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<meta content="width=device-width; initial-scale=1.0; maximum-scale=2.0; user-scalable=1;" name="viewport" />
<style type="text/css">
html{background-color:transparent;height:100%;width:100%;}
body{background-color:transparent;font-size:15pt;font-family:helvetica;color:white;}
img{border:0px;} </style>
</head>
<body>
<!-- MAGIC 8 BALL START --><script>
var t0;
var ar8Ball = new Array;
ar8Ball[0]="Lookin' Good,<br> Right On!";
ar8Ball[1]="Sock It To Me, <br> Ask Again";
ar8Ball[2]="Hey Joe,<br>I Doubt It";
ar8Ball[3]="Outlook Along The Watchtower Not So Good";
ar8Ball[4]="Yeah Man!";
ar8Ball[5]="Outta Sight!";
ar8Ball[6]="Nope,<br> Peace Out";
ar8Ball[7]="Mellow Out,<br>Tell You Later";
ar8Ball[8]="My Foxy Ladies <br> Say No";
ar8Ball[9]="Don't Count On It,<br> Sucka";
ar8Ball[10]="I Can Dig It";
ar8Ball[11]="No Doubt <br>Brothas & Sistas";
ar8Ball[12]="Yes,<br> Can You Dig It?";
ar8Ball[13]="Righteous!";
ar8Ball[14]="Far Out!";
ar8Ball[15]="Excuse Me While I Kiss The Sky,<br> Ask Later";
ar8Ball[16]="Groovy Baby, <br> Yes";
ar8Ball[17]="Reply Purple Hazy, <br> Try Again";
ar8Ball[18]="Most Likely, <br> My Voodoo Child";
ar8Ball[19]="You Have To Go On <br> And Be Crazy";


function randomize(lo,hi)
{ return (lo + Math.floor(Math.random()*((1+hi)-lo)));
}

function ksa8Ball()
{
self.clearTimeout(t0);
o = document.getElementById('theBall');
v = '<div id=theBall style=">';
v = v + ' width: 250px; height:380px;';
v = v + '">';
v = v + '<a href="javascript:ask8Ball();">';
v = v + '<img border=0 src="jimiask1.jpg">';
v = v + '</a>';
v = v + '</div>';
o.innerHTML = v;
}

function ask8Ball()
{
o = document.getElementById('theBall');
v = '<div id=theBall style="';
v = v + ' width: 250px; height:380px;';
v = v + ' background-repeat: no-repeat;';
v = v + ' background-image:url(jimianswer1.jpg);';
v = v + ' text-align: center;';
v = v + ' font-family: Arial;';
v = v + ' font-size: 18pt;';
v = v + ' color: #000000;';
v = v + '"><br><br>';
v = v + ar8Ball[randomize(0,19)];
v = v + '</div>';
o.innerHTML = v;
t0 = self.setTimeout('ksa8Ball()',1 * 2500);
}
</script>
<div style="
background-color: #000000;">
<center>
Just think of your question and click on Jimi
<div id="theBall" style="width:250px; height:380px;">
<a href="#" onclick="ask8Ball();"><img border="0" src="jimiask1.jpg" /></a></div>
<!-- MAGIC 8 BALL STOP --></center>
<a href="#" onclick="ask8Ball();"> </a></div>
<p>
<a href="#" onclick="ask8Ball();"> </a></p>
<p>
<a href="#" onclick="ask8Ball();">&nbsp;</a></p>
<p>
<a href="#" onclick="ask8Ball();"> </a><a href="#" onclick="ask8Ball();"> </a></p>
</body>
</html>




SQL using lookup table to create a supplier quote

I have a lookup table called supplier, which has all of my suppliers information.
I also have a lookup table called materials, which has all of my materials information.
I'm creating another table called supplier_quote in which I will store 3 suppliers with at least 3 raw materials each as well as price and quantity.



the purpose of this is that the user in visual basic can call 1 supplier and get a price for each of the 3 materials, call the next supplier and input the price of the same 3 materials and again with the 3rd supplier.



I was thinking a drop down box in the form to display each suppliers name and raw material, but so far I can't seem to understand the logic behind it.



I need something like this



supplier 1
raw material A. $23
raw material B. $25
raw material C $30



supplier 2
raw material A. $22
raw material B. $21
raw material c. $35



supplier 3
raw material A. $23
raw material B. $32
raw material C. $29



all that information would be one record in the supplier_quote table, because it all goes in one same quote. the prices are input by the person doing the quote, so I'm guessing they get stored in this same table.



anyone please help? I appreciate it in advance. I'm using visual basic 2010 and SQL 2008.





Disable scrolling on mousedown-mousemove (Jquery / javascript)

So i want to disable the window scrolling on mousedown+mousemove, i searched everywhere, but i can't find anything.



body { overflow: hidden } doesn't work, you can still scroll if you press the mouse, and you go down.



The problem i have, is that on clicking on an image thumb, it opens a positioned absolute div (100% height & width and a 50% black transparent .png) that shows the original image, and when i press the left mouse button and i move down, all the items behind the absolute div, start to scroll down.



Thanks in advance.



PS: I apologize if i made any grammar or spelling mistake. (English isn't my native language)





perl date calculation with dates of the format 2012-02-03 00:00:00

I need some help with date calculations in perl with dates for the format "2012-02-03 00:00:00". In particular is there a tool I could use to just increment the days and it switches to month and year correctly? Thanks.





how to include c++ header file in objective c header file

I want to parse xml files in my project recently. I choosed tinyxml. It only have two files. tinyxml2.h and tinyxml2.cpp.



I know a little about objective c++, I can include tinyxml2.h in .mm file. the compiler will treat it as objective c++ source code. But I can not include tinyxml2.h in any .h file.



So, my question is how to include tinyxml2.h in my objective c header file.



thanks in advance.





Compile Vim with Python support on OS X

I start in the Vim src directory



$ pwd
~/vim/src
$ ./configure \
> --prefix=$HOME/Applications/vim-compiled \
> --enable-rubyinterp=yes \
> --enable-pythoninterp=yes \
> --with-python-config-dir=/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config
$ make


At the end of make, I get the following error



ld: warning: in /Library/Frameworks//Python.framework/Python, missing required architecture x86_64 in file
Undefined symbols:
<very long list of Undefined symbols>
...
...
...
<very long list of Undefined symbols>
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [vim] Error 1


What's causing the error? I've found answers in similar questions that advise using MacPorts, Homebrew, or MacVim. I don't want to use any of those. Is there some other way around?



UPDATE: This is the output listing the Undefined symbols http://pastebin.com/ggV87ReF





how to change andoird overflow menu icon

How do i change the Overflow Menu icon on the far right of the actionbar as seen in the image below? My Holo theme specifies this 3 row black stack icon by default and i want something else. i can't seem to find a solution for this. I have looked at the documentation on http://developer.android.com/guide/topics/ui/menus.html but it doensn't seem to lend much help.



Thanks!



"ActionBar"





Swapping array values with for and yield scala

I am trying to swap every pair of values in my array using for and yield and so far I am very unsuccessful. What I have tried is as follows:



val a = Array(1,2,3,4,5) //What I want is Array(2,1,4,3,5)

for(i<-0 until (a.length-1,2),r<- Array(i+1,i)) yield r


The above given snippet returns the vector 2,1,4,3(and the 5 is omitted)



Can somebody point out what I am doing wrong here and how to get the correct reversal using for and yields?



Thanks





Loop through JSON object List

I am returning a List<> from a webservice as a List of JSON objects. I am trying to use a for loop to iterate through the list and grab the values out of the properties. This is a sample of the returning JSON:



{"d":[{"__type":"FluentWeb.DTO.EmployeeOrder",
"EmployeeName":"Janet Leverling",
"EmployeeTitle":"Sales Representative",
"RequiredDate":"\/Date(839224800000)\/",
"OrderedProducts":null}]}


So I am trying to extract the contents using something like this:



function PrintResults(result) {

for (var i = 0; i < result.length; i++) {
alert(result.employeename);
}


How should this be done?





Android - How can I prevent view focus changes?

I´d like to implement something like a "beforeLosingFocus" event to my controls (EditText) and I want to be able to prevent the focus changes so my control must have the focus until the user type allowed values.



I tried to use onFocusChange event but this event is fired after the focus changes.
This event is fired two times (because one control lost the focus while another control get it).



Is possible to prevent that another control get the focus in a generic way?
(because the focus can change by a tap in another control or a "Next" key click)





Arduino + bluetooth module + Android

I'm trying to think of a way to do a simple home automation project that involves an arduino, bluetooth module and android phone. The idea is that I have 2 arduino boards in different parts of my home. And if I walk into a room then a LED lights up on the board that has discovered my phone. If I walk out of the bluetooth range the LED should turn off.



I have tried the DomoticHome project with a router, but it's only for manual on/off and it's based on the ethernet module.



I don't want to make an android app from scratch, but I would like to take some existing open-source app that I could extend to use bluetooth and/or turn on the LED automatically.





STL algorithm function templates

The program has to finds an element in a sorted array and implement this function template:



bool find(T *p, T value, int &index=null)


I have completed a part, but when I try to do the Null part all my number goes to zeros. Also I do not know how to implement the index. Can someone help me please.



int main()
{
vector<int> numbers;
vector<int>::iterator iter;

for (int x = 0; x < 15; x++)
numbers.push_back(x);

cout << "The numbers in the vector are:\n";
for (iter = numbers.begin(); iter != numbers.end(); iter++)
cout << *iter << " ";
cout << endl << endl;

iter = find(numbers.begin(), numbers.end(), 5);
cout << *iter << endl;




TI-84 Multiple Menu Program

So when you make a menu using the Menu() function, It goes:



Title

Option 1

Option 2

Option 3

Etc...



But almost every menu already on the calculator has multiple titles that you can choose from, then each with their own options. How would you program that in?



End product being:



Main Secondary Ternary

1. Option 1

2. Option 2

3. Option 3

Etc...



Also, how could I make it so it has more than seven items? Thanks.





Java sudoku solver not changing empty cells

I am in the process of writing a sudoku solver (still need to write the box check and actually complete the program) but I'm testing it as I know. The puzzle I'm testing right now is "very easy" as in there is only one empty cell in any row/column. THe puzzle starts with "empty" cells as zeros. My issues is that when I run the program and print out the puzzle after solve() is called, the zeros aren't changing and the original puzzle is just printed out. Not sure what my issue is, would appreciate some direction!



public ArrayList<Integer> create(){

ArrayList<Integer> possible = new ArrayList<Integer>();

for(int i=1; i<10; i++){
possible.add(i);
}
return possible;
}
public sudoku( int size )
{
SIZE = size;
N = size*size;

Grid = new int[N][N];
for( int i = 0; i < N; i++ )
for( int j = 0; j < N; j++ )
Grid[i][j] = 0;
}

public void solve()
{
int a, b, c, d, i, j, k, l;

int count = 0;
int value= 0;

for(i=0; i<N;i++){
for(j=0; j<N;j++){
if(Grid[i][j]==0){

ArrayList<Integer> possible = create();

//check row
for(a=0; a<N;a++){
for(b=0; b<N; b++){
if(Grid[a][0]==possible.get(a)){
possible.set(a, 0);
}
}
}
//check column
for(c=0; c<N;c++){
for(d=0; d<N;d++){
if(Grid[0][d]==possible.get(d)){
possible.set(d,0);
}
}
}
for(k=0; k<9; k++){
if(possible.get(k)!=0){
count++;
}
}
if(count==1){
for(l=0; l<9; l++){
if(possible.get(l)!=0){
value=possible.get(l);
}
}
}
Grid[i][j]=value;
}
}
}
}




JSF 2 - How to destroy a session-scoped bean

How can I destroy a session-scoped bean?



The purpose of this would be to control the lifetime of the bean so it only lives when a tab in the web application is active. (Using Ajax Based Tab Navigation in the webapp)



Is there a better way to do that? (Custom Scoped Beans?)





'syntax error, unexpected T_CONSTANT_ENCAPSED_STRING' Adding google event tracking to button in Wordpress Plugin

I'm attempting to add a google event tracking to a wordpress plugin. The code for the submit button in this plugin is:



{
return "<input type=\"submit\" ".
"name=\"".fm_form_submit_btn_name()."\" ".
"id=\"".fm_form_submit_btn_id()."\" ".
"class=\"submit\" ".
"value=\"".fm_form_submit_btn_text()."\" ".
"onclick=\"".fm_form_submit_btn_script()."\" ".
" />\n";
}


I'm trying to add google analytics tracking code onclick=_gaq.push(['_trackEvent', 'Form', 'Submit', 'Apply']) to the above block, and eventually replace 'Apply' with fm_form_the_title() which returns the title of the form.



The problem: No matter what arrangement of quotes I use when inserting the tracking code block, I am faced with an error 'syntax error, unexpected T_CONSTANT_ENCAPSED_STRING' or 'T_STRING' which shuts down the entire site.



EDIT: The code block above works, and does not need simplifying, and is part of a much larger project. My question is how to add onclick=_gaq.push(['_trackEvent', 'Form', 'Submit', 'Apply']) and eventually replace 'Apply' with fm_form_the_title() and NOT break my website.





JavaScript convert mouse position to selection range

I would like to be able to convert the current mouse position to a range, in CKEditor in particular.



The CKEditor provides an API for setting the cursor according to a range:



var ranges = new CKEDITOR.dom.range( editor.document );
editor.getSelection().selectRanges( [ ranges ] );


Since CKEditor provides this API, the problem may be simplified by removing this requirement and just find a way to produce the range from the mouse coordinates over a div containing various HTML elements.



However, this is not the same as converting a mouse coordinate into the cursor position in a textarea since textareas have fixed column widths and row heights where the CKEditor renders HTML through an iframe.



Based on this, it looks like the range may be applied to elements.



How would you figure out the start/end range which is closest to the current mouse position?



Edit:
An example of how one might use the ckeditor API to select a range on the mouseup event.



editor.document.on('mouseup', function(e) {
this.focus();
var node = e.data.$.target;

var range = new CKEDITOR.dom.range( this.document );
range.setStart(new CKEDITOR.dom.node(node), 0);
range.collapse();

var ranges = [];
ranges.push(range);
this.getSelection().selectRanges( ranges );
});


The problem with the above example is that the event target node (e.data.$.target) is only firing for nodes such as HTML, BODY, or IMG but not for text nodes. Even if it did, these nodes represent chunks of text which wouldn't support setting the cursor to the position of the mouse within that chunk of text.