Wednesday, 2 October 2013

Rescale an Image using Python3.2

Rescale an Image using Python3.2

I'm working on a python code that takes an image name from the command
line, and prints its, rescaled to the user's likings, i.e., the input
python3.2 resize.py image.gif 2 3 would take image.gif and double the
width and triple the height. I've written a code for quadrupling an image:
import sys
from cImage import *
def main():
oldImage = FileImage(sys.argv[1])
width = oldImage.getWidth()
height = oldImage.getHeight()
myWin = ImageWin("Old Image", width, height)
myNewWin = ImageWin("Quadrupled Image", width*4, height*4)
newImage = EmptyImage(width*4, height*4)
for r in range(width):
for c in range(height):
pixel = oldImage.getPixel(r, c)
newImage.setPixel(4*r, 4*c, pixel)
newImage.setPixel(4*r, 4*c+1, pixel)
newImage.setPixel(4*r, 4*c+2, pixel)
newImage.setPixel(4*r, 4*c+3, pixel)
newImage.setPixel(4*r+1, 4*c, pixel)
newImage.setPixel(4*r+1, 4*c+1, pixel)
newImage.setPixel(4*r+1, 4*c+2, pixel)
newImage.setPixel(4*r+1, 4*c+3, pixel)
newImage.setPixel(4*r+2, 4*c, pixel)
newImage.setPixel(4*r+2, 4*c+1, pixel)
newImage.setPixel(4*r+2, 4*c+2, pixel)
newImage.setPixel(4*r+2, 4*c+3, pixel)
newImage.setPixel(4*r+3, 4*c, pixel)
newImage.setPixel(4*r+3, 4*c+1, pixel)
newImage.setPixel(4*r+3, 4*c+2, pixel)
newImage.setPixel(4*r+3, 4*c+3, pixel)
oldImage.draw(myWin)
newImage.draw(myNewWin)
myWin.exitOnClick()
myNewWin.exitOnClick()
main()
But I am having trouble try to figure out how to edit my code so it scales
the parameters requested. I feel that I should probably be able to
implement a for loop, but I'm having a hard time getting things to work.
Any help would be much appreciated!

how can I populate and retrieve table of record using java

how can I populate and retrieve table of record using java

Package, in which I declared my Data Types
create or replace package pkg_var is
type array_table is table of varchar2(50);
type array_int is table of number;
type p_arr_rec is record(p_no number,p_val varchar2(50));
type array_record is table of p_arr_rec;
end pkg_var;
/
My procedure to populate record
create or replace procedure proc1(p_array in pkg_var.array_table,
arr_int in pkg_var.array_int,len out number,arr_rec out
pkg_var.array_record)
as
v_count number;
begin
len := p_array.count;
v_count :=0;
for i in 1..p_array.count
loop
--dbms_output.put_line(p_array(i));
arr_rec(i).p_no := arr_int(i);
arr_rec(i).p_val := p_array(i);
v_count := v_count+1;
end loop;
end;
/
This is my class to call the above procedure to populate array into table
of record
public class TestDatabase {
public static void passArray()
{
try{
dbcon conn = new dbcon();
Connection con = conn.dbstate().getConnection();
String str_array[] = {"one", "two", "three","four"};
int int_array[] = {1, 2, 4,8};
ArrayDescriptor str_des =
ArrayDescriptor.createDescriptor("SCOTT.PKG_VAR.ARRAY_TABLE",
con);
ARRAY arr_str = new ARRAY(str_des,con,str_array);
ArrayDescriptor des =
ArrayDescriptor.createDescriptor("SCOTT.PKG_VAR.ARRAY_INT",
con);
ARRAY arr_int = new ARRAY(des,con,int_array);
CallableStatement st = con.prepareCall("call
SCOTT.proc1(?,?,?)");
// Passing an array to the procedure -
st.setArray(1, arr_str);
st.setArray(2, arr_int);
st.registerOutParameter(3, Types.INTEGER);
st.registerOutParameter(4,OracleTypes.ARRAY,"SCOTT.PKG_VAR.ARRAY_RECORD");
st.execute();
System.out.println("size : "+st.getInt(3));
// Retrieving array from the resultset of the procedure after
execution -
ARRAY arr = ((OracleCallableStatement)st).getARRAY(4);
BigDecimal[] recievedArray = (BigDecimal[])(arr.getArray());
for(int i=0;i<recievedArray.length;i++)
System.out.println("element" + i + ":" + recievedArray[i]
+ "\n");
} catch(Exception e) {
System.out.println(e);
}
}
public static void main(String args[]){
passArray();
}
}
I'm getting java.sql.SQLException: invalid name pattern:
SCOTT.PKG_VAR.ARRAY_TABLE Exception, anyone help me to solve this
exception.
One more question how do I retrieve table of record of SQL in Java ? My
second question is for this code ARRAY arr =
((OracleCallableStatement)st).getARRAY(4);
Is it a valid code to get table of record ?

Is there anyway to extract comments from facebook

Is there anyway to extract comments from facebook

I have project to extract the comments from Facebook and shows than we
will put behavior on it weather is in good mood happy mood sad mood
etc.Actually i don't have an idea where to is there any API available
which programing language will be good please give me a way .

Tuesday, 1 October 2013

Synology Mail server SMTP 535 error

Synology Mail server SMTP 535 error

Good day Ladies and Gentlemen! I don't know if I am allowed to do this,
this is not really a programming problem but a setup problem in my
synology mail server. I can receive mail but the problem is I can't send a
mail. My smtp relay is smtp.gmail.com with a port 587. I really need a
help. I googled it before but it seems that synology forums are not that
active. Thanks and God bless! My NAS is DS1512+

I dropped a table in Oracle, how can I retrieve it from the undo tablespace?

I dropped a table in Oracle, how can I retrieve it from the undo tablespace?

I accidentally dropped a fairly large table -- recycling bin is not
enabled. I'm fairly certain the data still exists in the UNDO tablespace,
but I'm not sure how to get it out. I recreated the table exactly as it
was before it was dropped -- the structure is exactly the same. However,
when I attempt to flashback the table, I get this error:
flashback table tablex to timestamp (systimestamp - interval '120'
minute); Error: 01466 DBD::Oracle::db do failed: ORA-01466: unable to read
data - table definition has changed
Any idea how I can overcome this error? From all of the searching I've
done, it seems as if it believes the table is not structurally the same as
when it was dropped.
Thanks so much!

Making the terminal interface non closable

Making the terminal interface non closable

Let me explain in more details. What i want to do is when i click the
close button on the terminal interface, the terminal should not close. It
should remain open. How can i do this. Thanks in advance.

How to make sure a 3 character filename contains one of 2 characters?

How to make sure a 3 character filename contains one of 2 characters?

So I have to search a directory for files that are of 3 character length.
That is easy, the problem is that at least 1 of the 3 characters needs to
be either a "B" or a "y". I know that [By] would make sure the character
is either a B or a y, however simply doing [By][By][By] would not suffice
since it is not a requirement for all 3 characters to be either B or y;
only 1 of them has to be. Please help.