What does the word "literal" mean when used in context such as literal strings and literal values? what is the difference between a literal value and value?
i am reading a csv file and i want to store this in datastore, but i am getting string from file for datetime field.
i want to type cast it to datetime
also same for date and time separately
error::BadValueError: Property HB_Create_Ship_Date must be a datetime
New guy here. I asked a while back about a sprite recolouring program that I was having difficulty with and got some great responses. Basically, I tried to write a program that would recolour pixels of all the pictures in a given folder from one given colour to another.
I believe I have it down, but, now the program is telling me that I have an invalid value specified for the red component of my colour. (ValueError: Invalid red value specified.), even though it's only being changed from 64 to 56. Any help on the matter would be appreciated!
(Here's the code, in case I messed up somewhere else; It's in Python):
import os
import media
import sys
def recolour(old, new, folder):
old_list = old.split(' ')
new_list = new.split(' ')
folder_location = os.path.join('C:\', 'Users', 'Owner', 'Spriting', folder)
for filename in os.listdir (folder):
current_file = media.load_picture(folder_location + '\\' + filename)
for pix in current_file:
if (media.get_red(pix) == int(old_list[0])) and \
(media.get_green(pix) == int(old_list[1])) and \
(media.get_blue(pix) == int(old_list[2])):
media.set_red(pix, new_list[0])
media.set_green(pix, new_list[1])
media.set_blue(pix, new_list[2])
media.save(pic)
if name == 'main':
while 1:
old = str(raw_input('Please insert the original RGB component, separated by a single space: '))
if old == 'quit':
sys.exit(0)
new = str(raw_input('Please insert the new RGB component, separated by a single space: '))
if new == 'quit':
sys.exit(0)
folder = str(raw_input('Please insert the name of the folder you wish to modify: '))
if folder == 'quit':
sys.exit(0)
else:
recolour(old, new, folder)
I want to filter some reserved word on my title form.
$adtitle = sanitize($_POST['title']);
$ignore = array('sale','buy','rent');
if(in_array($adtitle, $ignore)) {
$_SESSION['ignore_error'] = '<strong>'.$adtitle.'</strong> cannot be use as your title';
header('Location:/submit/');
exit;
How to make something like this. If
user type Car for sale the sale
will detected as reserved keyword.
Now my current code only detect single keyword only.
I am adapting the Coverflow technique to work with a div. The coverflow function (included as a js file in the head section) is here. When I dynamically add a DIV, it doesn't show up in the coverflow. I am wondering if there is a way to add a destroy function to this js file so that whenever a new div add is added, I can call the destroy method and then reinstantiate. Any suggestions on how I should go about doing this?
Which is the best practice in this situation? I would like an un-initialized array of the same type and length as the original.
public static <AnyType extends Comparable<? super AnyType>> void someFunction(AnyType[] someArray) {
AnyType[] anotherArray = (AnyType[]) new Comparable[someArray.length];
...or...
AnyType[] anotherArray = (AnyType[]) new Object[someArray.length];
...some other code...
}
Thanks,
CB
I know charwise positions of matches like 1 3 7 8. I need to know their corresponding line number.
Example: file.txt
Match: X
Mathes: 1 3 7 8.
Want: 1 2 4 4
$ cat file.txt
X2
X
4
56XX
[Added: does not notice many linewise matches, there is probably easier way to do it with stacks]
$ java testt
1
2
4
$ cat testt.java
import java.io.*;
import java.util.*;
public class testt {
public static String data ="X2\nX\n4\n56XX";
public static String[] ar = data.split("\n");
public static void main(String[] args){
HashSet<Integer> hs = new HashSet<Integer>();
Integer numb = 1;
for(String s : ar){
if(s.contains("X")){
hs.add(numb);
numb++;
}else{
numb++;
}
}
for (Integer i : hs){
System.out.println(i);
}
}
}
I have an array like this:
int a[100];
I am filling only the first 4 elements in this array:
a[0] = 1;
a[1] = 2;
a[2] = 3;
a[3] = 4;
When I do sizeof(a)/sizeof(a[0]) it returns 100.
Is there a way I can get number of elements to which I have assinged a value and thus filtering out the remaining 96 unassigned elements?
thanks
Say i have these classes
ViewA and ViewB
In objective C using the delegate pattern I could do
@protocol ViewBDelegate{
- (void) doSomething();
}
then in ViewB interface:
id<ViewBDelegate> delegate;
then in ViewA implementation i set the delegate:
viewB.delegate = self;
and now I can call in doSomething from viewB onto any that unknown type delegate.
[delegate doSomething];
"C++ How to Program" has been the worse read an can't find simple examples that demonstrates basic design patterns.
What i'm looking for in C++ is:
events ActionScript and java
either delegates or notifications in Objective C
anything that allows class A, Class B and Class C to know that ClassX
didSomething()!!!
thanks
I am trying to write a .sh file that runs many programs simultaneously
I tried this
prog1
prog2
But that runs prog1 then waits until prog1 ends and then starts prog2...
So how can I run them in parallel?
Thanks
We have a an iPhone app project that we wish to deploy multiple times under different client names. The individual apps will be very similar but will have different resources (icon, images etc) and config settings stored in plists (server names, options etc). What is the preferred means to manage this in Xcode? Obviously we really don't want different XCode projects for each App deployment since it's 90% shared code.
A friend of mine is interested in learning how to program computers, but she knows nothing about programming. I suggested that Python might be a good language to start with, but after some googling, I couldn't find any tutorials that covered both programming and Python in an adequate way.
I don't want her to go through the tiresome "learn algorithms in pseudocode first" routine. Instead, I'd like a tutorial that will explain the basic ideas while working towards a real goal, e.g. a very simple console game.
Does anyone know of any such tutorials? Do you think that I'm mistaken in how I'm handling this? Is Python a bad choice? I know that something like C, C++ or Java won't work - too many details will be very counterproductive. On the other hand, I think that Lisp might be too mathematical and abstract. Python, on the other hand, will let her even do something like coding primitive graphical games in a short period of time.
I have the follwing C function. How should I wrap it so it can be called from a Lua script?
typedef struct tagT{
int a ;
int b ;
} type_t;
int lib_a_f_4(type_t *t)
{
return t->a * t->b ;
}
I know how to wrapr it if the function parameter type were int or char *. Should I use table type for a C structure?
EDIT: I am using SWIG for the wraping , according to this doc, It seems that I should automatically have this funtion new_type_t(2,3) , but it is not the case.
If you wrap a C structure, it is also
mapped to a Lua userdata. By adding a
metatable to the userdata, this
provides a very natural interface. For
example,
struct Point{ int x,y; };
is used as follows:
p=example.new_Point()
p.x=3
p.y=5
print(p.x,p.y) 3 5
Similar access is provided for unions
and the data members of C++ classes. C
structures are created using a
function new_Point(), but for C++
classes are created using just the
name Point().
I have grid named 'GridView1' and displaying columns like this
<asp:GridView ID="GridView1" OnRowCommand="ScheduleGridView_RowCommand"
runat="server" AutoGenerateColumns="False" Height="60px"
Style="text-align: center" Width="869px" EnableViewState="False">
<Columns>
<asp:BoundField HeaderText="Topic" DataField="Topic" />
<asp:BoundField DataField="Moderator" HeaderText="Moderator" />
<asp:BoundField DataField="Expert" HeaderText="Expert" />
<asp:BoundField DataField="StartTime" HeaderText="Start" >
<HeaderStyle Width="175px" />
</asp:BoundField>
<asp:BoundField DataField="EndTime" HeaderText="End" >
<HeaderStyle Width="175px" />
</asp:BoundField>
<asp:TemplateField HeaderText="Join" ShowHeader="False">
<ItemTemplate>
<asp:Button ID="JoinBT" runat="server" CommandArgument="<%# Container.DataItemIndex %>"
CommandName="Join" Text="Join" Width="52px" />
</ItemTemplate>
<HeaderStyle Height="15px" />
</asp:TemplateField>
</Columns>
</asp:GridView>
Here what is my requirement is whenever we right click on each row in gridview ,it should display three option join meeting(if we click it will go to
meeting.aspx),,view details(will go to detail.aspx),,Subscribe(subscribe.aspx) just like when we click right any where we can see view,sortby,refresh
like that..Do we need to implement javascript here
Hey I'm wondering how i can get this code to work, basically i want to keep the lines of $filename as long as they contain the $user in the path. Sry, perl noob.
open STDERR, ">/dev/null";
$filename=`find -H /home | grep $file`;
@filenames = split(/\n/, $filename);
for $i (@filenames) {
if ($i =~ m/$user/) {
#keep results
} else {
delete $i; # does not work.
}
}
$filename = join ("\n", @filenames);
close STDERR;
I know you can delete like delete $array[index] but I don't have an index with this kind of loop that I know of.
Hi all,
I'm using Jquery's toggle event to do some stuff when a user clicks a checkbox, like this:
$('input#myId').toggle(
function(){
//do stuff
},
function(){
//do other stuff
}
);
The problem is that the checkbox isn't being ticked when I click on the checkbox. (All the stuff I've put into the toggle event is working properly.)
I've tried the following:
$('input#myId').attr('checked', 'checked');
and
$(this).attr('checked', 'checked');
and even simply
return true;
But nothing is working. Can anyone tell me where I'm going wrong?
Edit - thanks to all who replied. Dreas' answer very nearly worked for me, except for the part that checked the attribute. This works perfectly (although it's a bit hacky)
$('input#myInput').change(function ()
{
if(!$(this).hasClass("checked"))
{
//do stuff if the checkbox isn't checked
$(this).addClass("checked");
return;
}
//do stuff if the checkbox isn't checked
$(this).removeClass('checked');
});
Thanks again to all who replied.
I'm trying to do something like this:
private class aClass
{
private ArrayList<String> idProd;
aClass(ArrayList<String> prd)
{
this.idProd=new ArrayList<String>(prd);
}
public ArrayList<String> getIdProd()
{
return this.idProd;
}
}
So if I have multiple instances of ArrayLIst<String> (st1 ,st2 ,st3) and I want to make new objects of aClass:
{
aClass obj1,obj2,obj3;
obj1=new aClass(st1);
obj2=new aClass(st2);
obj3=new aClass(st3);
}
Will all of the aClass objects return st3 if I access the method getIdProd() for each of them(obj1..obj3)? Is an ArrayList as an instance variable automatically declared static?
I'm new to Java and I have come to having the following problem:
I have created several classes which all implement the interface "Parser". I have a JavaParser, PythonParser, CParser and finally a TextParser.
I'm trying to write a method so it will take either a File or a String (representing a filename) and return the appropriate parser given the extension of the file.
Here is some psuedo-code of what I'm basically attempting to do:
public Parser getParser(String filename)
{
String extension = filename.substring(filename.lastIndexOf("."));
switch(extension)
{
case "py": return new PythonParser();
case "java": return new JavaParser();
case "c": return new CParser();
default: return new TextParser();
}
}
In general, is this the right way to handle this situation? Also, how should I handle the fact that Java doesn't allow switching on strings? Should I use the .hashcode() value of the strings?
I feel like there is some design pattern or something for handling this but it eludes me. Is this how you would do it?
/* in this slice of code I get an output of
bbb 55 66 77 88
aaa
the output I expect and want is
bbb 55 66 77 88
bbb
because I reassign ss from log[0] to log[1]
So my question is why is the output different from what I expect and how do I
change it to what I want?
*/
int w,x,y,z;
stringstream ss (stringstream::in | stringstream::out);
string word;
string log[2];
log[0]="aaa 11 22 33 44";
log[1]="bbb 55 66 77 88";
ss<<log[0];
ss>>word;
int k=0;
ss>>w>>x>>y>>z;
k++;
ss<<log[k];
cout<<log[k]<<endl;
ss>>word;
cout<<word<<endl;
return 0;
I really want to learn how to program. A friend suggested I buy vs 2005 or a newer version if I'm serious about it. Is there a cheaper route? I would like to start with c#.