By default when system() and exec() functions are used in PHP the default user is SYSTEM so I can never see the result. Is there a way to change the user it runs on?
OK, Here is what my table looks like
------------------------------------------------
id type
-----------------------------------------------
1 a
2 b
3 a
4 c
5 c
7 a
8 a
------------------------------------------------
Now, I need a query that can give me this output...
-----------------------------------------------------------------
count(*) | count(type=a) | count(type=b) | count(type=c)
-----------------------------------------------------------------
8 4 1 3
------------------------------------------------------------------
I only know to get the total set using count(*), but how to do the remaining
Hey guys
Now in my one jframe i have used two jtables with different data.
But now what i want is..as soon as user select one cell on first table, then in second table, the cell next to selected cell of the first table should be selected.
means....
if user had selected the cell which is on
column - 3 and row - 1 [ first table cell position ] then next table should automatically select the cell at
column - 4 and row - 1 [ second table cell position ]
i know how to get the selected row and column of jtable but i don't know how to set Select on jtable.
Hi, I'm very new to ruby. I'm trying to search for any instance of a word in a text file (not the problem). Then when the word is discovered, it would show the surrounding text (maybe 3-4 words before and after the target word, instead of the whole line), output to a list of instances and continue searching.
Example
"The quick brown fox jumped over the lazy dog."
Search word = "jumped"
Output = "...brown fox jumped over the..."
Any help is appreciated. Thanks! Ezra
def word_exists_in_file
f = File.open("test.txt")
f.each do line
print line
if line.match /someword/
return true
end
end
false
end
Clicking on the image should show div near it (.show() in jQuery).
But how can i attach div to that image? Is it done with pure css, or javascript?
I tried several "position:absolute", but can't attach it near image.
How it should be done?
I need to determine whether a string (sourceString) contains another string (queryString) and if it does, at what offset.
I'm guessing that NSScanner might do the trick but I don't fully understand the documentation.
Let's say sourceString = @"What's the weather in London today?"
If I set queryString to equal @"What's the weather", I'd like a method that would determine that, in this case, YES (sourceString does contain queryString) and the offset is 0 (i.e. at the start of sourceString).
Any suggestions?
I need to knowingly isolate each row of the vCard and get its value.
For instance, I want to get "5555" from X-CUSTOMFIELD.
So far, my thoughts are:
"X-CUSTOMFIELD;\d+"
I have been looking at some tutorials and I am a little confused with what function to use? What would my regex above return? Would it give me the whole line or just the numerical part (5555)?
I was thinking I i get the whole row, I can use substring to get the digits?
BEGIN:VCARD
VERSION:2.1
N:Last;First;
FN:First Last
TEL;HOME;VOICE:111111
TEL;MOBILE;VOICE:222222
X-CUSTOMFIELD;5555
END:VCARD
This question is similar to http://stackoverflow.com/questions/2835192/linq-group-one-type-of-item but handled in a more generic way.
I have a List that has various derived classes. I may have something like this:
List<BaseClass> list = new List<BaseClass>() {
new Class1(1),
new Class2(1),
new Class1(2),
new Class3(1),
new Class2(2),
new Class4(1),
new Class3(2)
};
I am trying to use LINQ to semi-sort the list so that the natural order is maintained EXCEPT for certain classes which have base.GroupThisType == true. All classes with GroupThisType should be grouped together at the place that the first class of the same type occurs. Here is what the output should be like:
List<BaseClass> list = new List<BaseClass>() {
new Class1(1),
new Class1(2),
new Class2(1),
new Class3(1),
new Class3(2)
new Class2(2),
new Class4(1),
};
I have got a file with following format.
1234, 'US', 'IN',......
324, 'US', 'IN',......
...
...
53434, 'UK', 'XX', ....
...
...
253, 'IN', 'UP',....
253, 'IN', 'MH',....
Here I want to extract only those lines having 'IN' as 2nd keyword. i.e.
253, 'IN', 'UP',....
253, 'IN', 'MH',....
Can any one please tell me a command to grep it.
My application has a SQLite database in the asset folder. When the user launches my application, the database is created and the tables too.
This works fine with a lot of devices (Nexus One, Htc Magic, SGS, X10… and even Htc Desire HD v2.2).
My application works with all versions of Android (tested on my device (1.6, 2.2, 2.2.1 Htc Magic) and on the emulator (v1,5 until v2.3).
I have just a problem with HTC DESIRE HD v2.2.1 1.72.405.3.
The logcat:
android.database.sqlite.SQLiteException: no such table: LISTE: , while compiling: select _id from LISTE
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2833)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2854)
at android.app.ActivityThread.access$2300(ActivityThread.java:136)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2179)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:5068)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.database.sqlite.SQLiteException: no such table: LISTE: , while compiling: select _id from LISTE
at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
at android.database.sqlite.SQLiteCompiledSql.(SQLiteCompiledSql.java:64)
at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:80)
at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:46)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:53)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1417)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1387)
... 11 more
My application create the database but it doesn’t copy the tables of the file of the asset folder in data\data\packagename\databases\mydatabase.
My code:
public void createDataBase() throws IOException{
boolean dbExist = checkDataBase();
if(dbExist){
//do nothing - database already exist
}else{
//By calling this method and empty database will be created into the default system path
//of your application so we are gonna be able to overwrite that database with our database.
this.getReadableDatabase();
try {
copyDataBase();
} catch (IOException e) {
throw new Error("Error copying database");
}
}
}
private void copyDataBase() throws IOException{
//Open your local db as the input stream
InputStream myInput = myContext.getAssets().open(DB_NAME);
// Path to the just created empty db
String outFileName = DB_PATH + DB_NAME;
//Open the empty db as the output stream
OutputStream myOutput = new FileOutputStream(outFileName);
//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer))!= -1){
if (length > 0){
myOutput.write(buffer, 0, length);
} }
//Close the streams
myOutput.flush();
myOutput.close();
myInput.close();
}
I think that the copydatabase function has a problem but I don't see.
This code works fine with all devices except the HTC DESIRE HD v2.2.1 1.72.405.3.
What problems might exist here for the HTC Desire with the given version above? How can this be remedied?
I have a wpf form. Which contains labels and other controls.
Whole form has concrete dataSource. I want labels in this form have another biding. only labels
<Grid>
<Label x:Name="label"/>
<TextBOx />
<Label x:Name="labe2"/>
<TextBOx />
</Grid>
Hi everyone,
I have a PHP mail script that validates name, email address, and phone number before sending the mail. This then means that the Name, Email address, and Phone fields are Required Fields.
I want to have it so that the Name and EITHER Email or Phone are required. Such that if a name and phone are inputted, it sends the mail, or if a name and an email are inputted, it also sends the email.
The way the script works right now is it has several IF statements that check for (1) name, (2) email and (3) phone. Here's an example of an if statement of the code:
if ( ($email == "") ) {
$errors .= $emailError; // no email address entered
$email_error = true;
}
if ( !(preg_match($match,$email)) ) {
$errors .= $invalidEmailError; // checks validity of email
$email_error = true;
}
And here's how it sends the mail:
if ( !($errors) ) {
mail ($to, $subject, $message, $headers);
echo "<p id='correct'>";
echo "?????? ????? ??????!";
echo "</p>";
} else {
if (($email_error == true)) {
$errors != $phoneError;
/*echo "<p id='errors'>";
echo $errors;
echo "</p>";*/
}
if (($phone_error == true)) {
$errors != $emailError;
$errors != $invalidEmailError;
/*echo "<p id='errors'>";
echo $errors;
echo "</p>";*/
}
echo "<p id='errors'>";
echo $errors;
echo "</p>";
}
This doesn't work though. Basically this is what I want to do: If no email address was entered or if it was entered incorrectly, set a variable called $email_error to be true. Then check for that variable, and if it's true, then remove the $phoneError part of the $errors variable.
Man I hope I'm making some sense here. Does anyone know why this doesn't work? It reports all errors if all fields are left empty :(
Thanks!
Amit
I want to list records with a particular month and year. The table name is 'Arrival' and 'date' is the field that stores the date that the record was added. This is to be done from a C# application. For example, if the user selects month as 'April' and year as '2009' in the application, it will list all the records that were added on April,2009. (I only need the query, hope I can figure out the rest :) )
I would like to read values from a text file until that is a float value.
Lets say I have the following file:
14:53:55
Load 300 Speed 200
Distance,m Fz Fx Speed
0.0000 249 4 6.22
0.0002 247 33 16.29
0.0004 246 49 21.02
0.2492 240 115 26.97
0.2494 241 112 21.78
0.2496 240 109 13.09
0.2498 169 79 0.27
Distance,m Fz Fx Speed
0.0000 249 4 7.22
0.0002 247 33 1.29
0.0004 246 49 271.02
0.2492 240 115 26.97
0.2494 241 112 215.78
0.2496 240 109 13.09
0.2498 169 79 0.27
And I need only the values under the first Distance column.
So something like skip the first few rows, then read values from the first column while it is float.
Thanks your help in advance
I do a lot of JRuby on Rails apps, and we have a fair amount of Java .jar dependencies. These become quite annoying in textmate as it really muddies up my lib directory, and I never (obviously) need to actually open these files.
Can someone tell me how I might hide .jar files from my file listing in Textmate??
I have this xml
var testXML:XML = <family>
<father name1="tom" age="5" ><father1 name1="test1"/><father2 name1="test2"/></father>
<mother name1="tomylee" age="55" ><mother1/><mother2/></mother>
<sister name1="sister1" age="35" ><sister1/><sister2/></sister>
</family>;
I want to get the child node with name1 = test1 but i only know family
so is there something like
trace (testXML.children(@name1="test1");
I only know the family node , i don't know where that node is inside the father or not
is there any filter can be applied on root node to find something
Hey all. I know this question's been asked but I still don't have a clear picture of memory management in Objective-C. I feel like I have a pretty good grasp of it, but I'd still like some correct answers for the following code. I have a series of examples that I'd love for someone(s) to clarify.
Setting a value for an instance variable. Say I have an NSMutableArray variable. In my class, when I initialize it, do I need to call a retain on it?
Do I do
fooArray = [[[NSMutableArray alloc] init] retain];
or
fooArray = [[NSMutableArray alloc] init];
Does doing [[NSMutableArray alloc] init] already set the retain count to 1, so I wouldn't need to call retain on it? On the other hand, if I called a method that I know returns an autoreleased object, I would for sure have to call retain on it, right? Like so:
fooString = [[NSString stringWithFormat:@"%d items", someInt] retain];
Properties. I ask about the retain because I'm a bit confused about how @property's automatic setter works.
If I had set fooArray to be a @property with retain set, Objective-C will automatically create the following setter, right?
- (void)setFooArray:(NSMutableArray *)anArray {
[fooArray release];
fooArray = [anArray retain];
}
So, if I had code like this: self.fooArray = [[NSMutableArray alloc] init]; (which I believe is valid code), Objective-C creates a setter method that calls retain on the value assigned to fooArray. In this case, will the retain count actually be 2?
Correct way of setting a value of a property. I know there are questions on this and (possibly) debates, but which is the right way to set a @property?
This?
self.fooArray = [[NSMutableArray alloc] init];
Or this?
NSMutableArray *anArray = [[NSMutableArray alloc] init];
self.fooArray = anArray;
[anArray release];
I'd love to get some clarification on these examples. Thanks!
Hi All,
Question 1
From SUSE man pages, I get the below details for socket connect options
If the initiating socket is connection-mode, then connect() shall attempt to establish a connection to the address specified by the address argument. If the connection cannot be established immediately and O_NONBLOCK is not set for the file descriptor for the socket, connect() shall block for up to an unspecified timeout interval until the connection is established. If the timeout interval expires before the connection is established, connect() shall fail and the connection attempt shall be aborted. If connect() is interrupted by a signal that is caught while blocked waiting to establish a connection, connect() shall fail and set errno to [EINTR], but the connection request shall not be aborted, and the connection shall be established asynchronously.
Question : Is the above contents valid for AIX OS (especially the connection time-out, timed wait ...etc)?Because I do not see it in AIX man pages (5.1 and 5.3)
Question 2
I have a client socket whose attributes are
a. SO_RCVTIMEO ,SO_SNDTIMEO are set for 5 seconds.
b. AF_INET and SOCK_STREAM.
c. SO_LINGER with linger on and time is 5 seconds.
d. SO_REUSEADDR is set.
Note that the client socket is not O_NONBLOCK.
Question : Now since O_NONBLOCK is not set and SO_RCVTIMEO and SO_SNDTIMEO is set for 5 seconds, does it mean
a. connect in NON Blocking or Blocking?
b. If blocking, is it timed blocking or "infinite" time blocking?
c. If it is infinite, How do I establish a "connect" system call which is O_BLOCKING with timeout to t secs.
Sorry if the questions are be very naive.
Thanks in advance for your input.
Hello everyone, i'm looking for a way in python to run an external binary and watch it's output for: "up to date" If "up to date" isn't returned i want to run the original command again, once "up to date" is displayed i would like to be able to run another script. So far I've figured out how to run the binary with options using subprocess but thats as far as I've gotten. Thanks!
Hello friends
I am trying to make a Content Slider for my site. I have multiple HTML files and the structure of these files is like this:
<div id="title"><h2>Title of the Slide</h2></div>
<div id="image"><a href="http://mylink.com"><img src="image.jpg" width="600" height="300" alt="image"</a></div>
<div id="content">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</div>
I have been trying to use the following script get content (but no success):
<?php
function render($position="") {
ob_start();
foreach(glob("/slides/*.html") as $fileName) {
$fname = basename( $fileName );
$curArr = file($fname);
$slides[$fname ]['title'] = $curArr[0];
$slides[$fname ]['image'] = $curArr[1];
$slides[$fname ]['content'] = $curArr[2];
foreach($slides as $key => $value){
?>
<div id="slide-title">
<?php echo $value['title'] ?>
</div>
<div id="slide-content">
<?php echo $value['image'] ?>
</div>
<div id="slide-image">
<?php echo $value['content'] ?>
</div>
<?php
}}
?>
<?php
return ob_get_clean();
}
But then I came to know about a jQuery function.... (again no success)
jQuery.noConflict();
(function($){
$(document).ready(function () {
$('#slide-title').load('slides/slide1.html #title');
$('#slide-content').load('slides/slide1.html #content');
$('#slide-image').load('slides/slide1.html #image');
});
})(jQuery);
Now My questions are.....
Am I using the right syntax.
How do I get the content from multiple files using jQuery.
Please Note : My knowledge on Programming is almost '0'. I have just started learning it.
Hi all
I have a URL such as http://www.domain.com/index.php?p=register. I want to redirect that to use HTTPS (SSL) with .htaccess, but only on this, and a couple of other pages (the login page, etc), but not the entire site. The URLs don't point to directories, but are used to dynamically include different files.
Can someone give me a pointer or an example of how to get a single page redirect to HTTPS please?
Thanks,
James
I have to draw a curve captured on a image using screen pixels (mouse clicks) into a coordinate system. E.g.: Pixels on the screen, from left to right (130 px to 970 px) correspond to the x-axis of my coordinate system (1000 to 6000). Pixels from bottom to top (670 to 99) correspond to the y-axis of coordinate system (0 to 1.2). How can this be done? Maybe there's a function in matlab doing something like that?
Some more explanation:
I have a jpg image of a curve on a coordinate system. I've got pixel positions (x,y) of several points on that curve. Now I want to plot same curve into a matlab figure with same x and y axis as on the jpg image.
Hi
i have a gridview with information about documents: name, document type (policy, guidelines, forms, etc), category, etc. I want to sort the gridview alphabetically (name) and by document type, but always having the 'policy' above the other document types when document name is the same. How do I do that?
eg
If I do
sort by DocumentName, DocumentType ('policy' maybe not be the first one in the list)
but if I do
sort by DocumentType , DocumentName (I would get for example all guidelines first in alphabetical order, then procedures, then policies, etc)
I want to write data at a specified value in a text file from a text box. Here is a example:
item_begin etcitem 3344 item_type=etcitem is first line and item_begin weapon 3343 item_type=weapon is second. Well i want to replace item_type=weapon at second line with item_type=armor. Here is code so far:
var data2 = File.WriteAllLines("itemdata.txt")
.Where(x => x.Contains("3343"))
.Take(1)
.SelectMany(x => x.Split('\t'))
.Select(x => x.Split('='))
.Where(x => x.Length > 1)
.ToDictionary(x => x[0].Trim(), x => x[1]);
But returns error at WriteAllLines.
Here is the readline part code:
var data = File.ReadLines("itemdata.txt")
.Where(x => x.Contains("3343"))
.Take(1)
.SelectMany(x => x.Split('\t'))
.Select(x => x.Split('='))
.Where(x => x.Length > 1)
.ToDictionary(x => x[0].Trim(), x => x[1]);
//call values
textitem_type.Text = data["item_type"];
And want to write the same value I change on textitem_type.Text after read.
I used this to reaplace but replaces all values with same name from line and returns me in text only 1 line. Code:
private void button2_Click(object sender, EventArgs e)
{
var data = File
.ReadLines("itemdata.txt")
.Where(x => x.Contains(itemSrchtxt.Text))
.Take(1)
.SelectMany(x => x.Split('\t'))
.Select(x => x.Split('='))
.Where(x => x.Length > 1)
.ToDictionary(x => x[0].Trim(), x => x[1]);
StreamReader reader = new StreamReader(Directory.GetCurrentDirectory() + @"\itemdata.txt");
string content = reader.ReadLine();
reader.Close();
content = Regex.Replace(content, data["item_type"], textitem_type.Text);
StreamWriter write = new StreamWriter(Directory.GetCurrentDirectory() + @"\itemdata.txt");
write.WriteLine(content);
write.Close();
}