Where Linux/Unix environment variables are kept? How can I add my own environment variable and make it persistent, not only within currently running script?
On a standard linux set up, where can I add a directory to the @INC variable?
In the /etc/profile file, I added:
export PERLLIB=$PERLLIB:/foo/bar
export PERL5LIB=$PERL5LIB:/foo/bar
Thanks
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!
I'm writing a C++ app.
I have a class variable that more than one thread is writing to.
In C++, anything that can be modified without the compiler "realizing" that it's being changed needs to be marked volatile right? So if my code is multi threaded, and one thread may write to a var while another reads from it, do I need to mark the var volaltile?
[I don't have a race condition since I'm relying on writes to ints being atomic]
Thanks!
My favorite candidate again. I am in the process of identifying memory leaks in my app (a puzzling challenge for a newbe like me).
I am using the xCode leak analyzer, but what puzzles me is how to trace back a memory leak to its variable or value. Is there a pointer to the instances that have reserved a memory address where a leak is identifyed?
How do I best go about it?
Using python and wsgiref.handlers, I can get a single variable from a form with self.handler.request.get(var_name), but how do I iterate through all form variables, be they from GET and POST? Is it something like this?
for field in self.handler.request.fields:
value = self.handler.request.get(field)
Again, it should include both fields included in the POST and fields from the query string, as in a GET request.
Thanks in advance folks...
I have the following TSQL Statement:
SELECT ProductId, OwnerId FROM Product
How I can store the ProductId and OwnerId in a TSQL variable and then return it to the calling application?
Let's say that on the C++ side my function takes a variable of type jstring named myString. I can convert it to an ANSI string as follows:
const char* ansiString = env-GetStringUTFChars(myString, 0);
is there a way of getting
const wchar_t* unicodeString = ...
I have the following line of code that I use to update my personal date variable in my projects to todays current date. This line works in Ubuntu's terminal, but the Mac terminal seems to be far behind. Unfortunately, I copied this snippet from some site, so I'm not sure how it exactly works. Suggestions?
grep -ilr --exclude=revar.sh --exclude=README.md "[DATE]" * | grep -v .git | xargs -i@ sed -i "s/\[DATE\]/${today}/g" @
If I want to get a user that has the email address of '[email protected]', how do I pass that as a parameter in linq?
ie.:
var a = from u in Users
where u.Email = @email
Select u;
So this would be used in my method:
public static GetuserByEmail(string email)
Do I just pass in the variable or?
Let's say I have a custom AddMethod to jQuery Validate like:
$.validator.addMethod('min-length', function (val, element) {
// do stuff
// the error message here needs to be dynamic
}, 'The field cannot be less than than '
+ element.attr('data-min') + // it is within the closure, but it can't grab it
' length.');
I can't figure out a way to get the element variable in question, and get any values from it. What am I missing here?
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
system("pause");
return main();
}
The above works,but it hardcoded the main(),is there a magic variable to get the current running function?
This should be really simple but I'm a javascript/jQuery rookie, so here we go:
With the following code I can select a certain element
var user = $(".ui-selected .user-name").html();
But if there are multiple elements with the above classes, only the first value gets selected. What I would like to accomplish is a variable with all the elements seperated by a , like: user1,user2,user3 ... etc.
Any help would be greatly appreciated, thanks in advance!
I would like to validate that customer_price >= my_price. I tried the following:
class Product < ActiveRecord::Base
attr_accessor :my_price
validates_numericality_of :customer_price, :greater_than_or_equal_to => my_price
...
end
(customer_price is a column in the Products table in the database, while my_price isn't.)
Here is the result:
NameError in ProductsController#index
undefined local variable or method `my_price' for #<Class:0x313b648>
What is the right way to do this in Rails 3 ?
Hi,
I need to use volume buttons to control a variable parameter in my application.
I use Activity.onKeyDown to get notified when the button is pressed but the media volume is also increased.
Android is doing something like below when I press the volume key:
1. increase media / ringtone volume
2. pass the event to my application
Is there a way to avoid increasing the system volume and use volume key only for my application ?
Thanks
I have written a text editor using JavaScript.
Here I am not storing the written text in any variable, Now I want to replace some text/string of some selected text with other text/string.
Can anyone suggest me, how to do it using JavaScript.
Thanks
I use the following snippet to filter the list of selected users, where isSelected is a boolean variable. Is there a simpler way (helper function) to populate the selectedUsers collection instead of writing the following lines of code.
List<User> selectedUsers = new ArrayList<User>(0);
for (User user : this.getUsers()) {
if (user.isSelected()) {
selectedUsers.add(user.getId());
}
}
Please help me with this problem. I'm new in extJs and i need a little help.
I have this code
Ext.onReady(function() {
var datesStore = new Ext.data.JsonStore({
start : 'StartTableDate',
end : 'FinishTableDate',
autoLoad : true,
proxy : new Ext.data.HttpProxy({
url : 'dates.json',
method:'GET'
}),
fields : [
// 2 mandatory fields
{name:'StartTableDate'},
{name:'FinishTableDate'}
]
});
// i want to pass to variable start si end the values from JSON
var start = 'StartTableDate';
var end = 'FinishTableDate';
I am having trouble believing the following code is the most efficient way to move a value from the stack to ST(0):
.data
var dd 4.2
tmp dd ?
.code
mov EAX, var
push EAX
; top of stack now contains a value
; move it to ST(0)
pop EAX
mov tmp, EAX
fld tmp
Is the temporary variable really necessary? Further, is there an easier way to get a value from the stack to ST(0)?
I want to generate a bat file for multiple tag processing and the command lines look like this:
"C:\Program Files (x86)\tools\tag.exe" -t Genre="%genre%" "%_folderpath%\%track%. %title%.%_extension%"
IF ERRORLEVEL==1 PAUSE
I can populate all variables automatically but can I replace the %title% variable with a wildcard?
Lets say I have a variable that will always be a string.
Now take the code below:
if($myVar === "teststring")
Note $myVar will always be a string, so my questions is
Which is quicker/best, using === (Indentity) or the == (Equality)?
Dumb question, but whenever you call new, do you always have a pointer?
SomeClass *person = new SomeClass();
And is that because you need a pointer to point to that new space of memory that was allocated for the SomeClass variable person? Thanks!
We can replace strings in a batch file using the following command
set str="jump over the chair"
set str=%str:chair=table%
These lines work fine and change the string "jump over the chair" to "jump over the table". Now I want to replace the word "chair" in the string with some variable and I don't know how to do it.
set word=table
set str="jump over the chair"
??
Any ideas?
DatarowsForOneDay = dt.Select(
dt.Columns[0].Caption + "='" + x.ToString("dd/MM/yyyy HH") + "'");
doesn't work, but
DatarowsForOneDay = dt.Select(
dt.Columns[0].Caption + "='" + x.ToString("dd/MM/yyyy") + "'");
works.
So how can I select the date with a same hour?
Variable x type is DateTime.