I'm trying to write my first iPhone app, and I'm using a date picker object for the user to enter their date of birth. Part of my app requires the year in int format. I've added the code as below. What's odd is that 'month' gets the right value. But day and year seem to be stuck at MAX_INT (2147483647). Can anyone tell me what I'm doing wrong?
-(IBAction)dateOfBirthChanged:(id)sender {
NSCalendar* calender = [NSCalendar currentCalendar];
NSDateComponents* dateComponents = [calender components:NSMonthCalendarUnit fromDate:[datepicker date]];
NSInteger day = [dateComponents day];
NSInteger month = [dateComponents month];
NSInteger year = [dateComponents year];
label.text = [NSString stringWithFormat:@"Your year of birth is %d", year];
}
i have a string like following:
Assigned to ram on 2010-04-22 12:30:13.0
i need to extract the third word (ram). I tried the below regex, its not working.
/\s[a-zA-Z]*\s/
any help to fix this would be greatly appreciated.
From where should I start if I want to learn any PHP framework? Like Joomla, Cake PHP etc....
I have an experience in PHP core development for 9 months... Please help me out....
Hello,
I have bmp images in image folder on my computer. I named it from 1.bmp to 100.bmp.
And I want to read these images like this:
for i=1:100
s='C:\images'+i+'.bmp';
A=imread(s);
end
But Matlab gave an error. How can I implement this?
I'm trying to do something like:
#include <iostream>
#include <vector>
#include <ctime>
class Clickomania
{
public:
Clickomania();
std::vector<std::vector<int> > board;
bool move(int, int);
bool isSolved();
void print();
void pushDown();
};
Clickomania::Clickomania()
: board(12, std::vector<int>(8,0))
{
srand((unsigned)time(0));
for(int i = 0; i < 12; i++)
{
for(int j = 0; j < 8; j++)
{
int color = (rand() % 6) + 1;
board[i][j] = color;
}
}
}
However, apparently I can't initialize the "board" vector of vectors this way.
How can I create a public member of a 2d vector type and initialize it properly?
I have this code:
a=[['a','b','c'],['a','f','c'],['a','c','d']]
for x in a:
for y in x:
if 'a' in x:
x.replace('a','*')`
but the result is:
a=[['a','b','c'],['a','f','c'],['a','c','d']]
and bot a=[['b','c'],['f','c'],['c','d']]
What should I do so the changes will last?
Hi.
I want to retrieve all hashtags from a tweet using a PHP function.
I know someone asked a similar question here, but there is no hint how exactly to implement this in PHP. Since I'm not very familiar with regular expressions, don't know how to write a function that returns an array of all hashtags in a tweet.
So how do I do this, using the following regular expression:
#\S*\w
Hi,
I was looking at some of the examples from the Deitel and Deitel's book for Programming in Java, and one of the first examples is a very simple Swing display. Hence this snippet of code :
import javax.swing.*;
public class cdea {
public static void main(String args[]){
JOptionPane.showMessageDialog(null,"\"Welcome to Java Programming!\"");
System.exit(0);
//end method main
}
}
I read some stuff regarding how one can get native UI look and feel by using
UIManager.setLookAndFeel(
UIManager.getSystemLookAndFeelClassName());
to the program. However, when I just add this to my main method, it gives me a host of errors. Specifically :
Multiple markers at this line
- Unhandled exception type IllegalAccessException
- Unhandled exception type InstantiationException
- Unhandled exception type ClassNotFoundException
- Unhandled exception type UnsupportedLookAndFeelException
However when I use it as part of a try/catch exception loop (is that what it is called?) as detailed on http://stackoverflow.com/questions/1590863/getting-java-applications-to-look-native-on-windows-how , I get the program running properly.
Could anyone tell me in simple language why this is so? As in, why can't I directly get the System look and feel; why do I have to use it with exception handling? I'm new to Java, and OOP in general, so I'm sorry if I'm being too simplistic.
Hi,
I am having trouble picking the best data structure for solving a problem.
The problem is as below:
I have a nested list of identity codes where the sublists are of varying length.
li = [['abc', 'ghi', 'lmn'], ['kop'], ['hgi', 'ghy']]
I have a file with two entries on each line; an identity code and a number.
abc 2.93
ghi 3.87
lmn 5.96
Each sublist represents a cluster. I wish to select the i.d. from each sublist with the highest number associated with it, append that i.d. to a new list and ultimately write it to a new file.
What data structure should the file with numbers be read in as?
Also, how would you iterate over said data structure to return the i.d. with the highest number that matches the i.d. within a sublist?
Thanks,
S :-)
Hello.
I'm writing some script, that works with web-servers.
So, I have the following code:
client = suds.client.Client(WSDLfile)
client.service.Login('mylogin', 'mypass')
print client.options.transport.cookiejar
#######
sessnum = str(client.options.transport.cookiejar).split(' ')[1]
client = suds.client.Client( WSDLfile, headers= { 'Set-Cookie' : sessnum } )
When running in FreeBSD, it returns
<cookielib.CookieJar[<Cookie sessnum=9WAXQ25D37XY535F6SZ3GXKSCTZG8CVJ for .IP.IP.IP.IP/>]>
but in Windows it returns
<cookielib.CookieJar[]>
How can I fix it?
In Chapter 3 of Programming Scala, the author gives two examples of for loops / for comprehensions, but switches between using ()'s and {}'s. Why is this the case, as these inherently look like they're doing the same thing? Is there a reason breed <- dogBreeds is on the 2nd line in example #2?
// #1 ()'s
for (breed <- dogBreeds
if breed.contains("Terrier");
if !breed.startsWith("Yorkshire")
) println(breed)
// #2 {}'s
for {
breed <- dogBreeds
upcasedBreed = breed.toUpperCase()
} println(upcasedBreed)
HI. I know this is simple question but when I use
FirstPersonTestImage.Save(IIdComboBox.Text + "-" + i + ".jpg");
it works and saves file to folder where is the .exe file . But I want to save it to specific folder like /photo/IO-66/ and tryed to use
String StudentPath = PhotoPath + IGroupNoComboBox.Text + "/" + IIdComboBox.Text + "/" + IIdComboBox.Text + "-" + i + ".jpg";
FirstPersonTestImage.Save(StudentPath);
BUt it gives
An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll
How can I solve this problem? Is is about folder path ? or using "/" ?
EDIT
Here My code for creating and checking existing or not folder
if (!System.IO.Directory.Exists(PhotoPath + "/" + IGroupNoComboBox.Text.ToString().Trim()))
{
Directory.CreateDirectory(PhotoPath + "/" + IGroupNoComboBox.Text.ToString().Trim());
}
if (!System.IO.Directory.Exists(PhotoPath + "/" + IGroupNoComboBox.Text.ToString().Trim()+ "/" + IIdComboBox.Text.ToString().Trim() + "/"))
{
Directory.CreateDirectory(PhotoPath + "/" + IGroupNoComboBox.Text.ToString().Trim()+"/" + IIdComboBox.Text.ToString().Trim() + "/");
}
I'm using Drupal 6. Typically, when the user requests a URL for which Drupal has no response, it uses index.php as the error document. However, I'd like to suspend this behavior for a specific URL. How can I do this?
RewriteCond %{REQUEST_FILENAME} !=fail
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Where "fail" is the path I want to block. So www.example.com/fail should result in a 404.
Incidentally, what does [L, QSA] do? I've looked at documentation without luck.
I am writing this little Lottery application.
Now the plan is, to count how often each number has been drawn during each iteration of the Lottery, and store this somewhere.
My guess is that I would need to use a HashMap, that has 6 keys and increments the value by one everytime the respective keys number is drawn.
But how would I accomplish this?
My code so far:
public void numberCreator()
{
// creating and initializing a Random generator
Random rand = new Random();
// A HashMap to store the numbers picked.
HashMap hashMap = new HashMap();
// A TreeMap to sort the numbers picked.
TreeMap treeMap = new TreeMap();
// creating an ArrayList which will store the pool of availbale Numbers
List<Integer>numPool = new ArrayList<Integer>();
for (int i=1; i<50; i++){
// add the available Numbers to the pool
numPool.add(i);
hashMap.put(nums[i], 0);
}
// array to store the lotto numbers
int [] nums = new int [6];
for (int i =0; i < nums.length; i++){
int numPoolIndex = rand.nextInt(numPool.size());
nums[i] = numPool.get(numPoolIndex);
// check how often a number has been called and store the new amount in the Map
int counter = hashMap.get
numPool.remove(numPoolIndex);
}
System.out.println(Arrays.toString(nums));
}
Maybe someone can tell me if I have the right idea, or even how I would implement the map properly?
I have the following usecase:
A div with some buttons
When the user
clicks on a button, a popup is shown
and the background div is faded out
to 0.5 opacity
The problem is that when the popup comes in, the user is still able to click on the background buttons. At this point, I can remove the entire DIV temporarily but I don't want to do that. Is there anyway I can disable all the previously attached events and then add event handlers ONLY to the current popup? (I mean something like a close button should still work on a popup) Any suggestions?
as we know java is not pure oop because primitive type.
is there any else cause for it
please share..
think static variable and multiple inheritence also have same resp...
Pleas correct me..
I have a text file containing data in rows and columns (~17000 rows in total). Each column is a uniform number of characters long, with the 'unused' characters filled in by spaces. For example, the first column is 11 characters long, but the last four characters in that column are always spaces (so that it appears to be a nice column when viewed with a text editor). Sometimes it's more than four if the entry is less than 7 characters.
The columns are not otherwise separated by commas, tabs, or spaces. They are also not all the same number of characters (the first two are 11, the next two are 8 and the last one is 5 - but again, some are spaces).
What I want to do is import the entires (which are numbers) in the last two columns if the second column contains the string 'OW' somewhere in it. Any help would be greatly appreciated.
this and super are keywords isn't it, then how can we use them for passing arguments to constructors the same way as with a method??
In short how is it that these can show such distinct behaviours??
Hello,
When sending data from a form to a second page, the value of the session is always with the name "Array" insteed of the expected number.
The data should get displayed in a table, but insteed of example 1, 2, 3 , 4 i get : Array, Array, Array.
(A 2-Dimensional Table is used)
Is the following code below a proper way to "call" upon the stored values on the 2nd page from the array ?
$test1 = $_SESSION["table"][0];
$test2 = $_SESSION["table"][1];
$test3 = $_SESSION["table"][2];
$test4 = $_SESSION["table"][3];
$test5 = $_SESSION["table"][4];
What exactly is this, and how can i fix this?
Is it some sort of override that needs to happen?
Best Regards.