Best code
I was wondering what state of mind you guys like to be in when you write code. I personally feel I write the best code after I've had about 10 or so of my favorite alcoholic beverages, any more or any less I'm not as effective. How about you?
I also like to code when highly intoxicated, although I prefer to compile when sober. Alchohol seems to make my code more object oriented.
Similar Messages
-
Best code to search about strings
Hi
I have a created a table as a follow
sql> create table emp(emp_id number,emp_name varchar2(20));
I represented my table in a form buider module with text_item for each feild .
I need a code to complete the substring which is entered by the end user into the text_item that represents emp_name field
I have tried lov but lov forces the user to enter the first characters right
for example if the emp_name wanted to search a bout it is abraham
the end user enter braha the code complete it to abraham.
thank in advanceCreate LOV with qry similar to the fol...
select emp_name
from employee_master
where ( emp_name LIKE '%'||:T4||'%' or :T4 Is null)
where T4 is your empname field in the blk ...
Set the item property T4 with LOV name and Validate from list as true
Set the LOV property as Automatic Select Yes... -
Best code to sanitize table_name and schema_name
If one writes utility programs that take typically a table_name and a schema_name and one uses execute immediate then it
is not using bind variables and subject to sql injection. So what should I do to cleanse table_name and schema_name?
I see that names of tables are way more flexible than I thought:
http://docs.oracle.com/cd/B28359_01/server.111/b28286/sql_elements008.htm#SQLRF51109
Well we aren't doing quoted identifiers around here for our tables we created so I'm thinking of going for it in terms of
cleansing those parameters in utility programs solely designed to work on our creations. As a very legacy type, I would not create a table name that was not A-Z 0-9 and _ Unfortunately I totally forgot how to write a regex or whatever to get rid of anything not in A-Z 0-9 and _ .
Anyone care to remind me? (I never was good at regex :-( I know, dumb question.../* Prints how many distinct values there are in each field in the
given table for only fields that are varchar2,date or number
If the number <= 20 it prints each distinct value and count.
create or replace procedure
value_freq (intable in varchar2, inschema in varchar2 default null) is
distinct_count integer;
mystmt varchar2(500) := null;
mytable varchar2(70) := null;
good_name varchar2(40) := '^[[:alpha:]][[:alnum:]_]{0,29}$';
dateformat varchar2(25) := 'mm/dd/yyyy';
clean_table varchar2(30) := null;
clean_schema varchar2(30) := null;
TYPE num_rec IS RECORD
(value number,
value_count integer);
TYPE vchar_rec IS RECORD
(value varchar2(2000),
value_count integer);
TYPE date_rec IS RECORD
(value date,
value_count integer);
TYPE num_table is TABLE OF num_rec INDEX BY binary_integer;
nums num_table;
TYPE vchar_table is TABLE OF vchar_rec INDEX BY binary_integer;
vchars vchar_table;
TYPE date_table is TABLE OF date_rec INDEX BY binary_integer;
dates date_table;
BEGIN
/* This assumes A-Z 0-9 _ table and schema names */
if regexp_like(intable,good_name) then
clean_table := upper(intable);
end if;
if regexp_like(inschema,good_name) then
clean_schema := upper(inschema);
end if;
if clean_schema is null then
mytable := upper(clean_table);
else
mytable := upper(clean_schema) || '.' || upper(clean_table);
end if;
dbms_output.put_line('Distinct value stats for ' || mytable);
FOR mycol IN (SELECT column_name,data_type FROM all_tab_columns where
TABLE_NAME = upper(clean_table)
order by COLUMN_ID ) LOOP
mystmt := 'SELECT COUNT(*) FROM (select distinct ' || mycol.column_name ||
' from ' || mytable || ')';
EXECUTE IMMEDIATE mystmt into distinct_count;
/* thanks to Burleson http://www.dba-oracle.com/plsql/t_plsql_dynamic.htm */
if (mycol.data_type = 'NUMBER') then
if (distinct_count > 20) then
dbms_output.put_line(mycol.column_name || ': ' || distinct_count || ' distinct values too many to print');
else
dbms_output.put(mycol.column_name||': ' ||distinct_count || ' distinct values' );
mystmt := 'select ' || mycol.column_name || ', count(*) from ' || mytable
|| ' group by ' || mycol.column_name || ' order by nvl(' || mycol.column_name || ',-99999)';
--dbms_output.put_line(mystmt);
EXECUTE IMMEDIATE mystmt BULK COLLECT into nums;
dbms_output.put_line(chr(9));
FOR i in nums.FIRST .. nums.LAST LOOP
dbms_output.put(nums(i).value || ': ' ||
nums(i).value_count || chr(9));
END LOOP;
dbms_output.put_line('');
end if;
elsif mycol.data_type = 'VARCHAR2' then
if (distinct_count > 20) then
dbms_output.put_line(mycol.column_name || ': ' || distinct_count || ' distinct values too many to print');
else
dbms_output.put(mycol.column_name||': ' ||distinct_count || ' distinct values' );
mystmt := 'select ' || mycol.column_name || ', count(*) from ' || mytable
|| ' group by ' || mycol.column_name || ' order by nvl(' || mycol.column_name || ','' '')';
--dbms_output.put_line(mystmt);
EXECUTE IMMEDIATE mystmt BULK COLLECT into vchars;
dbms_output.put_line(chr(9));
FOR i in vchars.FIRST .. vchars.LAST LOOP
dbms_output.put(vchars(i).value || ': ' ||
vchars(i).value_count || chr(9));
END LOOP;
dbms_output.put_line('');
end if;
elsif mycol.data_type = 'DATE' then
if (distinct_count > 20) then
dbms_output.put_line(mycol.column_name || ': ' || distinct_count || ' distinct values too many to print');
else
dbms_output.put(mycol.column_name||': ' ||distinct_count || ' distinct values' );
mystmt := 'select ' || mycol.column_name || ', count(*) from ' || mytable
|| ' group by ' || mycol.column_name || ' order by ' || mycol.column_name;
--dbms_output.put_line(mystmt);
EXECUTE IMMEDIATE mystmt BULK COLLECT into dates;
dbms_output.put_line(chr(9));
FOR i in dates.FIRST .. dates.LAST LOOP
dbms_output.put(to_char(dates(i).value,dateformat) || ': ' ||
dates(i).value_count || chr(9));
END LOOP;
dbms_output.put_line('');
end if;
end if; /* is date */
END LOOP;
END;
show errors; -
Recently upgraded my TV's in my house with new Sceptre 40" and 50" TV's - thank you WalMart. Purchased in September 2014. (new / current Sceptre TVs).
All of the Verizon printed, online, and other documentation for the P265V3 RC (model RC2655005/01B) for Sceptre shows to use code '335'. I have tried the '335' code on both of the TV's and no worky at all.
Following the 'Quick Setup Guide-Verizon FIOS remote' steps (paper/PDF instructions with RC Manual):
I can successfully enter the '335' code as outlned in step 4... and 'The RED LED will blink twice and then stay on'. occurs. So far, so good.
Step 5 states, "5. Press and release the <CH +> button repeatedly until the TV turns off......." This happens perfectly... I can press the <CH+>> button a few times, and indeed, my TV turns off.
Now, onto Step 6: "Test that the remote control is programmed for your TV"..... can't get Mute, A/V, other keys to activate /. be recognized - even though I'm followijng "press and hold that key. Release it as soon as it works"
Does anyone have a working code for Sceptre TV's ??? The Verizon '335' code doesn't work for me.
I need the 'best code' anyone has found that works with new Sceptre TV's.... the 335 code that VZ recommends... no worky.Robertop,
have you tried the following? The info below is found here
Turn on your TV and the FiOS TV Set-Top Box.
Make sure you can see live TV.
Press and hold the OK and FiOS TV buttons together then release both buttons.
The red LED light blinks 2 times and then stays on.
Press and hold the Play button.
The remote control tries a new TV code every second.
The red LED light blinks each time a new code is sent.
When the TV turns off, release the Play button immediately.
NOTE: Some TVs may respond slower than others. If necessary, you can press the Ch+ and Ch- buttons to go forward or backward one TV code at a time.
Test your remote to ensure it is working properly:
- Turn on the TV by pressing the TV button on your FiOS TV remote.
- Press the Vol+ and Vol- buttons to ensure that you can control the volume.
- Press the Mute and A/V buttons to ensure they work.
If any of these buttons do not work, press and hold that button. Release the button as soon as it works.
If all the buttons work, press OK to this TV remote code.
The red LED light blinks 3 times and then turns off. Your remote control is now programmed. -
iam editing some videos for the web, and I would like to know which are the best codes, that final cut has. compresor or quicktime conversion etc....
the video are hdv but i can down converted to ntsc.
the video is for you tube or facebook
please let me know, iwant the best quality image
i have fCS 2I'm pretty pleased using H264 - good pix and low data rates.
Don't encode straight to a small frame H264 out of Motion though, go via your existing size & codec - maybe even use a better codec like 10/8bit uncompressed first.
Peter -
Need help with WMI code that will send output to db
'm new to WMI code writing, so I need some help with writing code that we can store on our server. I want this code to run when a user logs into their computer
and talks to our server. I also want the code to:
* check the users computer and find all installed patches
* the date the patches were installed
* the serial number of the users computer
* the computer name, os version, last boot up time, and mac address
and then have all this output to a database file. At the command prompt I've tried:
wmic qfe get description, hotfixid
This does return the patch information I'm looking for, but how do I combine that line of code with:
wmic os get version, csname, serialnumber, lastbootuptime
and
wmic nicconfig get macaddress
and then get all this to output to a database file?Thank you for the links. I checked out http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx and
found lots of good information. I also found a good command that will print information to a text file.
Basically what I'm trying to do is retrieve a list of all installed updates (Windows updates and 3rd party updates). I do like that the below code because it gives me the KB numbers for the Windows updates. I need this information so my IT co-workers &
I can keep track of which of our user computers need a patch/update installed and preferably which patch/update. The minimum we want to know is which patches / updates have been installed on which computer. If you wondering why we don't have Windows automatic
updates enable, that's because we are not allowed to.
This is my code so far.
#if you want the computer name, use this command
get-content env:computername
$computer = get-content env:computername
#list of installed patches
Get-Hotfix -ComputerName $computer#create a text file listing this information
Get-Hotfix > 'C:\users\little e\Documents\WMI help\PowerShell\printOutPatchList.txt'
I know you don't want to tell me the code that will print this out to a database (regardless if it's Access or SQL), and that's find. But maybe you can tell me this. Is it possible to have the results of this sent to a database file or do I need to go into
SQL and write code for SQL to go out and grab the data from an Excel file or txt file? If I'm understanding this stuff so far, then I suspect that it can be done both ways, but the code needs to be written correctly for this to happen. If it's true, then which
way is best (code in PowerShell to send information to SQL or SQL go get the information from the text file or Excel file)? -
New digital Adapter - missing codes for my television
Okay, so today I received the new digital adapter comcast sent, so my son can watch his cartoon network up in his room. So I follow the instructions up to step 4 were I was looking up the code for his tv, which is not there its a Supersonic 13 TV/DVD combo. Then I tried looking all over the internet for one and didnt find anything.
10812 worked on my 24" Supersonic LED/DVD.Here is some info from Supersonic:"Best Codes;
0096, 1610,0002, 0011, 10463, 0135, 330,1035
Comcast 5 digit; 10178 10117 11756 11758 01377 10885 10864 10120
Xfinity, 10178Other Comcast: 10178, 10765, 11523, 12063, 12002, 11991, 11962, 11769, 11767, 11766, 11762, 11687, 11565, 11538, 11385, 11341, 11328, 11327, 11326, 11316, 11314, 11286, 11276, 11262, 10865, 11385"They also recommended: try using Sharp codes or RCA codes." -
Adding data in internal table using extracted data
Hi Experts,
Good day!
I have a requirements in our historical data of material price which adding data that are not existing based on data extracted from standard tables such as A004 and KONP.
Now, i need to use the VALIDFROM (DATAB) value as basis for the latest price.
To make it more clear, see the example below:
Extracted data:
Material Number Valid From Valid to Price
100101 01/01/2008 02/01/2008 100.00
100101 02/02/2008 04/02/2008 100.00
100101 04/03/2008 08/01/2008 200.00
100101 08/02/2008 01/31/2009 300.00
100102 05/02/2008 07/01/2008 10.00
100102 07/02/2008 10/31/2008 15.00
100102 11/01/2008 01/31/2009 20.00
Output:
Material Number Calmonth Price
100101 01/2008 100.00
100101 02/2008 100.00
100101 03/2008 100.00
100101 04/2008 200.00
100101 05/2008 200.00
100101 06/2008 200.00
100101 07/2008 200.00
100101 08/2008 300.00
100101 09/2008 300.00
100101 10/2008 300.00
100101 11/2008 300.00
100101 12/2008 300.00
100101 01/2009 300.00
100102 05/2008 10.00
100102 06/2008 10.00
100102 07/2008 15.00
100102 08/2008 15.00
100102 09/2008 15.00
100102 10/2008 15.00
100102 11/2008 20.00
100102 12/2008 20.00
100102 01/2009 20.00
Text that are in bold are the added data. What is the best code to do with this?
How can i come up with this output? Help me please
Thanks and Godbless,
nipsHi Nips,
Logic shud b sumthing on similar lines
lv_count = 1.
Loop at itab into watab.
if lv_count > 12.
lv_count = 1.
endif.
if watab-date+0(2) = lv_count.
append watab to gt_output.
continue.
else.
concatenate lv_count sy-datum+4(4) into watab-date.
append watab to gt_output.
endif.
endloop.
Best regards,
Prashant -
hi
Experts
i hav e requirement on report in alv oops .
in this , let me know the details how to display the events liken "top-of-page", end of page
and list header , list footer in oops,
please provide the suitable code
Regards
Spandanahi,
Check this link for Events in Alv
https://www.sdn.sap.com/irj/sdn/wiki?path=/pages/viewpage.action?pageId=37715
http://howforge.com/abap-4-example-code-alv-grid-control-by-applying-object-cl-gui-alv-grid
Check out the following link for top_of_page event in OOPs ALV.
Best code
/people/vijaybabu.dudla/blog/2006/07/21/topofpage-in-alv-using-clguialvgrid
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
Reward All Helpfull Answers
Regards
Fareedas -
How to open a text file without using dialog box
I can open a file using dialog box but I want to open a file without using any dialog box for writing.
With the following commands a new file is created.
File outputFile = new File("outagain.txt");
FileWriter out = new FileWriter(outputFile);
I want to open an existing file and put some more text in it using FileWriter or any other object
rgds,
Arsalanimport java.io.*;
class UReader
BufferedReader in;
BufferedReader input;
String fileName;
public UReader(String fileName)
this.fileName = null;
this.fileName = fileName;
try
in = new BufferedReader(new FileReader(fileName));
input = new BufferedReader(new FileReader("A.b"));
catch(IOException _ex) { }
public final String getContent()
String txt = "";
try
while(in.ready())
txt = txt + in.readLine();
txt = txt + "\n";
in.close();
txt.trim();
catch(IOException _ex) { }
return txt;
public final String getLine(int row)
try
input = new BufferedReader(new FileReader(fileName));
catch(IOException _ex) { }
String txt = null;
if(row <= getRows()) {
try
for(int i = 0; i < row; i++)
txt = input.readLine();
input.close();
catch(IOException _ex) { }
} else {
txt = "Index out of Bounds";
return txt;
public final int getRows()
try
input = new BufferedReader(new FileReader(fileName));
catch(IOException _ex) { }
String txt = null;
int rows = 0;
try
while(input.ready())
txt = input.readLine();
rows++;
input.close();
catch(IOException _ex) { }
return rows;
import java.io.*;
import java.util.*;
class UWriter
PrintWriter out;
String fileName;
String[] txt;
static int NEW_LINE = 1;
static int APPEND = 0;
public UWriter(String s)
fileName = null;
txt = null;
fileName = s;
try
out = new PrintWriter(new BufferedWriter(new FileWriter(s, true)));
catch(IOException ioexception) { }
public final void addContent(String s, int i)
int l = 0;
StringBuffer sb = new StringBuffer(s);
s.replaceAll("\n\n", "\n###\n");
StringTokenizer str = new StringTokenizer(s, "\n");
String token = null;
while (str.hasMoreTokens()) {
++l;
token = str.nextToken();
str = new StringTokenizer(s, "\n");
txt = new String[l];
int k = 0;
String test;
while (str.hasMoreTokens()) {
test = str.nextToken();
if (test.equals("###")) test = "";
txt[k++] = test;
if(i == 0) {
try
for (int j = 0; j < txt.length; ++j) {
out.println(txt[j]);
out.close();
catch(Exception ioexception) { }
} else {
try
out.println();
for (int j = 0; j < txt.length; ++j) {
out.println(txt[j]);
out.close();
catch(Exception ioexception1) { }
public final void writeContent(String s)
int l = 0;
s.replaceAll("\n\n", "###");
StringTokenizer str = new StringTokenizer(s, "\n");
String token = null;
while (str.hasMoreTokens()) {
++l;
token = str.nextToken();
str = new StringTokenizer(s, "\n");
txt = new String[l];
int k = 0;
String test;
while (str.hasMoreTokens()) {
test = str.nextToken();
if (test.equals("###")) test = "";
txt[k++] = test;
try
PrintWriter bufferedwriter = new PrintWriter(new BufferedWriter(new FileWriter(fileName, false)));
for (int j = 0; j < txt.length; ++j) {
bufferedwriter.println(txt[j]);
bufferedwriter.close();
catch(IOException ioexception) { }
}Maybe they are not the best codes, i wrote them a long time ago, so dont ask why i did anything wierd. :D
But anyway it works. -
A library program for negative exponents.
Ok im looking to create a program that can take a number and take that number to a negative exponent. such as this
2^(-2) = .25 this is what i would like to accomplish. heres what i have.
public static double power(double base, double expo)
//return 0 if either is negative
double result=1.0;
if (expo<0.0)
expo*=-1.0;
for(double x=expo;x>0.0;x--)
result=result*base;
result=1.0/result;
System.out.println(result);
//compute the power function
if(base<0.0)
{ for(double x=expo;x>0.0;x--)
{ result=(result)*(base);
System.out.println(result);
else
for(double x=expo;x>0.0;x--)
result=result*base;
System.out.println(result);
//return -1 if it gets too big
double almostToBig = 2147483647.0/base;
if(result > almostToBig)
return -1.0;
return result;
ive fooled around with the neg expo part a ton. That wasnt my best code but ive tried every combination i can think of to get it to work. Please let me know what i need to do.Ummm, are you going to call this program ReinventTheWheel? Because there's already a java.lang.Math.pow(double, double) method built-in.
-
Multiple levels in a mobile game
Hi
Im a little confused on multiple levels in a j2me game with respects to re-initialising the level, once level 1 is complete.
How, and what would be the best code practise, once level1=true(complete) to load level 2. Where do i actually send my code back too, to start the next level. Do i do some kind of garbage collection/reset, then simply load all the graphics in for level 2?.
Also, some games feature levels like in an RPG, where each room is loaded when the character reaches the exit - how is this being called from the j2me code?
Thanks
SteveWould you be able to explain it to me? Here is a picture of what i'm trying to do..
When 'player_mc' touches' hitbox_mc', the movieclip 'bat_mc' plays once and erases itself.
And for the level change its the same concept... Player touches box and gets sent to second frame on timeline which is t he next level...
Been trying to figure this out all weekend and just turned to pros for help now.. -
Upload tab delimted file without using GUI_UPLOAD
hi gurus,
my requirement is I have to upload a Tab - delimited text file into a internal table. this should happen as a background job due to which, I cannot use GUI_UPLOAD.
please provide me with code snippets using open dataset and close dataset.
points will be awarded for best code!Hello,
Check this sample.
CONSTANTS: CON_TAB TYPE X VALUE '09'.
OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE.
IF SY-SUBRC = 0.
loop at g_T_outtab.
CONCATENATE G_T_OUTTAB-VBELN
G_T_OUTTAB-POSNR
G_T_OUTTAB-VKBUR
L_F_POSID
G_T_OUTTAB-BSTKD
L_F_NETWR
L_F_ERDAT_OR
L_F_ERDAT_IN
G_T_OUTTAB-VBELN_IN
L_F_ERDAT_DE
G_T_OUTTAB-VBELN_DE
INTO OUTPUT
SEPARATED BY CON_TAB.
TRANSFER OUTPUT TO P_FILE.
endloop.
endif.
CLOSE DATASET P_FILE.
Cheers,
Vasanth -
A variable number of jCheckboxes
Hello,
First, as a heads-up, While I'm relatively new to Swing usage, I'm more than willing to use google to help me understand something, so feel free to use more complex solutions.
I'm working on a relatively simple request one of my teachers had for me. Essentially, this form contains a list of checkboxes and textboxes paralleling an array of Student objects (two fields, isChecked and name) which is contained in a Group object. I've already handled populating this Group object based off either A) a text file or B) a default setup, if the file doesn't exist.
I was wondering if it was possible to have the number of checkboxes and textboxes determined upon running: that is, according to the number of students in the Group. Also included in this idea would be an "Add student" button which adds another checkbox/textfield combo, and a 'remove student' button doing the reverse.
Is this possible? feasible? is there a better way to do it?I think that it's very possible and shouldn't be too difficult to do. A little bit of playing with Swing and you'll probably figure it out. If not, then come on back with your best code attempt. Oh, one more thing: in the future, you'll have a better chance of getting a "real" Swing expert (such as camikr) if you post in the Swing forum.
Much luck! -
Is it possible create a photo gallery with java?How do i do?
I must create a photo gallery and I think the best code is java...but I know a little the code.Help me
Check this list:
http://www.java-tips.org/java-applications/photo-album-software/
They are written in Java. They may help..
Maybe you are looking for
-
Strange VLAN issue on aironet access points
I'm setting up some access points for WPA. I've ran into a strange issue. The client VLAN (VLAN that the users will be put into) is 1, and the native VLAN is 10. The RADIUS server is in VLAN 1 (but I have a test RADIUS server in VLAN 10 as well). I c
-
Hi, How to hide the Query Find window? I have 2 forms(XX, YY) . I'm calling YY from XX. Both forms having Query Find window. While calling from XX, how to hide YY's query find window. I have given like this CALL_FORM('YY'); hide_view('QUERY_FIND'); s
-
Help Urgent : Invoking SMS Web Services Using ABAP FM HTTP_POST
Dear Gurus, Our client requirement is in such a way that , They want to invoke web services for sending SMS through ABAP program. Please suggest the way . I am using FM HTTP_POST in order to call the URL for web service for SMS. My URL is as follows,
-
Any Better EMail Program Out There for Macs?
I used Eudora as my email program for 10 years and loved it. Unfortunately, it became very buggy on the Snow Leopard operating system. Entire mail boxes got corrupted. So, I had to find a new mail program. I was told that Apple Mail was the best and
-
Lost aperture disk and Macbook Pro HDD
My MBP crashed, lost my HDD. I cannot seem to find my original install disc of aperture (bought it full retail before discounts), so dont have the license number. Just bought a new mac mini 2012, hoping to reuse aperture without having to repurchase