I have a problem with "pairing" arrays into one (by index). Here is an example:
INPUT:
inputArray = [ [0, 1, 2, 3, 4], [2, 3, 5, 7, 8], [9, 6, 1] ]
OUTPUT:
outputArray = [
[0,2,9],
[1,3,6],
[2,5,1],
[3,7,chooseRandom()],
[4,8,chooseRandom()]]
Questions:
1) How to avoid out of range problem
2) How to write chooseRandom() to choose N neighbour
I'm using python but feel free to share your thoughts in any language.
I recently setup a linux box running Ubuntu 8.04 (to match another server with 8.04). I need to insure that this box has a static IP address and I changed /etc/network/interfaces to set up the static IP address and when I run sudo /etc/init.d/networking restart it works fine for a while, but always reverts back to 10.0.1.24 after being idle for a while.
I also tried stopping/removing the dhcp client, but that didn't help.
sudo /etc/init.d/dhcp stop
sudo apt-get remove dhcp3-client
Here is my /etc/init.d/networking:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 10.0.1.4
netmask 255.255.255.0
broadcast 10.0.1.255
gateway 10.0.1.1
Any thoughts? Thanks.
Today I dediced to make static linking in Qt. I used Qt4 with Visual Studio and static C runtime article. The 3rd step took quite a long time. When it was finished I opened my project in VS 2008, made Build->Clean Solution and try to Release. Unfortunately I got link errors:
warning
LNK4098: defaultlib 'libcmt.lib'
conflicts with use of other libs; use
/NODEFAULTLIB:library
error LNK2019: unresolved external
symbol "private: static struct
QString::Data QString::shared_null"
(?shared_null@QString@@0UData@1@A)
referenced in function "public:
__thiscall QString::QString(void)" (??0QString@@QAE@XZ)
error LNK2019: unresolved external
symbol "private: static struct
QByteArray::Data
QByteArray::shared_null"
(?shared_null@QByteArray@@0UData@1@A)
referenced in function "public:
__thiscall QByteArray::QByteArray(void)"
(??0QByteArray@@QAE@XZ)
error LNK2001: unresolved external symbol
"private: static struct
QByteArray::Data
QByteArray::shared_null"
(?shared_null@QByteArray@@0UData@1@A)
error LNK2001:
unresolved external symbol "public:
static struct QMetaObject const
QDialog::staticMetaObject"
(?staticMetaObject@QDialog@@2UQMetaObject@@B)
error LNK2001:
unresolved external symbol "public:
static struct QMetaObject const
QDialog::staticMetaObject"
(?staticMetaObject@QDialog@@2UQMetaObject@@B)
error LNK2001:
unresolved external symbol "public:
static struct QMetaObject const
QDialog::staticMetaObject"
(?staticMetaObject@QDialog@@2UQMetaObject@@B)
error LNK2019: unresolved external symbol "public: static enum QSysInfo::WinVersion const QSysInfo::WindowsVersion" (?WindowsVersion@QSysInfo@@2W4WinVersion@1@B) referenced in function _WinMain@16
What i did wrong? Help to fix this pls.
Hi guys,
I have a default route configured.
192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.1
I'd like to add a static route to pass traffic destined for 192.168.1.51 via a load balancer's redundant virtual interface at 192.168.1.2.
ip route add 192.168.1.51 mask 255.255.255.255 via 192.168.1.2
When I try to add the static route I get this error.
Error: either "to" is duplicate or "default" is garbage."
It doesn't want to add the static route because it's in conflict with the default route. Is there a way around this?
Regards
Ossan
We have a sandbox server running CentOS that we run inside our office. Our ISP has assigned us a block of 5 static IPs. We now want to assign it a static IP.
DEVICE=eth0
BOOTPROTO=none # have also tried "static" here
HWADDR=00:13:72:*:*:*
ONBOOT=yes
TYPE=Ethernet
NETMASK=255.255.255.0
IPADDR=173.*.*.161
GATEWAY=10.1.10.1
/etc/resolv.cnf is also set with the appropriate name servers from our ISP.
When I ifdown eth0 then ifup eth0 I get...
SIOCADDRT: Network is unreachable
When I switch to DCHP, the machine has an IP assigned and there are no connection problems.
Any ideas?
here is my conf file:
usr/local/nginx/sites-available/default
server {
listen 80;
server_name localhost;
location / {
root html;
index index.php index.html index.htm;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html
{
root html;
}
# serve static files directly
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|swf)$ {
expires 30d;
}
but it doesn't cache static files, how should I fix it? thanks a lot
Today I dediced to make static linking in Qt. I used Qt4 with Visual Studio and static C runtime article. The 3rd step took quite a long time. When it was finished I opened my project in VS 2008, made Build->Clean Solution and try to Release. Unfortunately I got link errors:
warning
LNK4098: defaultlib 'libcmt.lib'
conflicts with use of other libs; use
/NODEFAULTLIB:library
error LNK2019: unresolved external
symbol "private: static struct
QString::Data QString::shared_null"
(?shared_null@QString@@0UData@1@A)
referenced in function "public:
__thiscall QString::QString(void)" (??0QString@@QAE@XZ)
error LNK2019: unresolved external
symbol "private: static struct
QByteArray::Data
QByteArray::shared_null"
(?shared_null@QByteArray@@0UData@1@A)
referenced in function "public:
__thiscall QByteArray::QByteArray(void)"
(??0QByteArray@@QAE@XZ)
error LNK2001: unresolved external symbol
"private: static struct
QByteArray::Data
QByteArray::shared_null"
(?shared_null@QByteArray@@0UData@1@A)
error LNK2001:
unresolved external symbol "public:
static struct QMetaObject const
QDialog::staticMetaObject"
(?staticMetaObject@QDialog@@2UQMetaObject@@B)
error LNK2001:
unresolved external symbol "public:
static struct QMetaObject const
QDialog::staticMetaObject"
(?staticMetaObject@QDialog@@2UQMetaObject@@B)
error LNK2001:
unresolved external symbol "public:
static struct QMetaObject const
QDialog::staticMetaObject"
(?staticMetaObject@QDialog@@2UQMetaObject@@B)
error LNK2019: unresolved external symbol "public: static enum QSysInfo::WinVersion const QSysInfo::WindowsVersion" (?WindowsVersion@QSysInfo@@2W4WinVersion@1@B) referenced in function _WinMain@16
What i did wrong? Help to fix this pls.
Greeting gurus,
I'm trying to develop a DHCP enforcement extension like Microsoft NAP.
My trick to block dynamic-IP requesting machines (that don't meet certain policy) is to strip the default gateway (no default gateway) stated in the IP lease and set the lease subnet mask to 255.255.255.255.
Now I need the blocked machines to be able to reach some specific locations (IPs) on the network. To allow for this, I'm including some static routes in the lease. For example, I'm including 10.10.10.11 via router 10.10.10.254 (the one to which the blocked machine that needs to access 10.10.10.11 is connected).
Unfortunately, as soon as I set the default gateway to nothing, blocked machines cannot reach any of the added static routes. I also tried classless static routes.
Any ideas ? any one knows how MS NAP actually do it ?
Geeko
As an extension the the question "Modify/view static variables while debugging in Eclipse", I'd like to be able to modify static variables while debugging in Eclipse.
For instance and local variables, I can just choose the variable in the "Variables" view of Eclipse, and use the context menu "Change value..." to change the value.
This is not possible for arbitrary static variables, because they do not appear in the "Variables" view.
What I tried:
If you choose "Java / Show static variables" from the triangle menu in the "Variables" view, you can see and modify static member variables of the variables listed in the "Variables view". However, I did not find how to access a static member of a class whose instance does not appear in the "Variables view".
You can of course enter a static member as an expression into the "Expression view" (using fully qualified name). Then you can see the value, but the "Expression view" does not have an option to modify the value (it does allow to modify members of an expression, but not the expression itself, even if the expression is a field).
So, if I have a static variable like a boolean MyClass.disableAllBugs, is there a way to change MyClass.disableAllBugs during debugging?
As an aside: I realize that even having public mutable static fields (i.e. mutable global variables) is very bad style. But some codebases have it, and then it's sometimes useful to modify it while debugging.
I'm trying to set auto static ip.
I've set the content of /etc/network/interfaces to be:
auto lo
auto eth0
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1.
and /etc/resolv.conf to be:
nameserver 192.168.1.1.
It seems that the ip address have set successfully.
However, when I plug out the lan cable and then plug it back, the ip address is not set.
How can I make it automatically set the static ip when the lan cable is connected?
Hello,
The title says it all, really. I'm trying to get an array of (9) numbers squared then printed but I keep coming back with only one result - the number of numbers in the array squared- obviously not what I want. Thanks for any help. Ok, here is my terrible code so far. Trying to pass it to a method as well.
public static void main ( String args[] )
{
double[] nums = {126, 12.939, 795, 320.16,
110, 34.7676, 7773, 67, 567, 323};
System.out.println ("Square root is " +square);
square(nums);
}
public static double square (double [] array) {
double result;
for( double i = 0; i < array.length ; i++ )
result = Math.sqrt(array[i]);
return result;
}
}
I am planning on moving my static files to Google's App Engine. I was wondering if this is a good idea to do.
I have read that is it possible that Google will cache your files on multiple locations, which is a good thing in my opinion.
The setup should also be quite easy in eclipse with the GAE plugins.
But i still have my doubts on the performance of this. Is the setup of App Engine optimized for serving static content. Now I have Nginx server my static content, will App Engine perform the same way.
Are there any other ups or downs using this method?
Hello:
Why is the following code causing a memory leak in an iPhone App?
All of the initted objects below leak, including the arrays, the strings and the numbers. So, I'm thinking it has something to do with the the synthesized array property not releasing the object when I set the property again on the second and subsequent time this piece of code is called.
Here is the code:
"controller" (below) is my custom view controller class, which I have a reference to, and I am setting with this code snippet:
sqlite3_stmt *statement;
NSMutableArray *foo_IDs = [[NSMutableArray alloc] init];
NSMutableArray *foo_Names = [[NSMutableArray alloc] init];
NSMutableArray *foo_IDsBySection = [[NSMutableArray alloc] init];
NSMutableArray *foo_NamesBySection = [[NSMutableArray alloc] init];
// Get data:
NSString *sql = @"select distinct p.foo_ID, p.foo_Name from foo as p ";
if (sqlite3_prepare_v2(...) == SQLITE_OK) {
while (sqlite3_step(statement) == SQLITE_ROW) {
int p_id;
NSString *foo_Name;
p_id = sqlite3_column_int(statement, 0);
char *str2 = (char *)sqlite3_column_text(statement, 1);
foo_Name = [NSString stringWithCString:str2];
[foo_IDs addObject:[NSNumber numberWithInt:p_id]];
[foo_Names addObject:foo_Name];
}
sqlite3_finalize(statement);
}
// Pass the array itself into another array:
// (normally there is more than one array in each array)
[foo_IDsBySection addObject: foo_IDs];
[foo_NamesBySection addObject: foo_Names];
[foo_IDs release];
[foo_Names release];
// Set some synthesized properties (of type NSArray, nonatomic,
// retain) in controller:
controller.foo_IDsBySection = foo_IDsBySection;
controller.foo_NamesBySection = foo_NamesBySection;
[foo_IDsBySection release];
[foo_NamesBySection release];
Thanks for any help!
I'm trying to get my FEDORA12 to have an STATIC IP - inside virtualbox - inside Ubuntu
Let me rephrase that. I have an Ubuntu 9.04 system with vitualbox and a FEDORA12 vm there and I would like to put the fedora with an STATIC IP (amahi needs it), but I'm getting stuck...
I'm using NAT (if that's any help)
I tryid a few tutorials, but no go.
I'm kind of new to the *nix world but I'm old school on M$
input
23 3 4 4 42 n 23 0 9 9 n n n 3 9 9 x
//according to input,i should create int pointer arrays. pointer arrays
// starting from 1 (that is initial arrays is arrays[1].when program sees n ,it
// must be jumb to arrays 2
// the first int input 23 is num_arrays which used in malloc(sizeof(int)*num_arrays
expected output:
elements of arrays[1] 3 4 5 42
elements of arrays[2] 23 0 9 9
elements of arrays[5] 3 9 9
another input
12 2 3 4 n n 2 3 4 n 12 3 x
expected output
elements of arrays[1] 2 3 4
elements of arrays[3] 2 3 4
elements of arrays[4] 12 3
specification:
x is stopper
n is comman to create new pointer array
i am new in this site
anyone help me how can i write
input
23 3 4 4 42 n 23 0 9 9 n n n 3 9 9 x
//according to input,i should create int pointer arrays. pointer arrays
// starting from 1 (that is initial arrays is arrays[1].when program sees n ,it
// must be jumb to arrays 2
// the first int input 23 is num_arrays which used in malloc(sizeof(int)*num_arrays
expected output
arrays[1] 3 4 5 42
arrays[2] 23 0 9 9
arrays[5] 3 9 9
another input
12 2 3 4 n n 2 3 4 n 12 3 x
expected output
arrays[1] 2 3 4
arrays[3] 2 3 4
arrays[4] 12 3
x is stopper
n is comman to create new pointer array
i am new in this site
anyone help me how can i write
input
23 3 4 4 42 n 23 0 9 9 n n n 3 9 9 x
//according to input,i should create int pointer arrays. pointer arrays
// starting from 1 (that is initial arrays is arrays[1].when program sees n ,it
// must be jumb to arrays 2
// the first int input 23 is num_arrays which used in malloc(sizeof(int)*num_arrays
expected output:
elements of arrays[1] 3 4 5 42
elements of arrays[2] 23 0 9 9
elements of arrays[5] 3 9 9
another input
12 2 3 4 n n 2 3 4 n 12 3 x
expected output
elements of arrays[1] 2 3 4
elements of arrays[3] 2 3 4
elements of arrays[4] 12 3
specification:
x is stopper
n is comman to create new pointer array
i am new in this site
anyone help me how can i write
I have an array containing arrays of names and other details, in alphabetical order. Each array includes the first letter associated with the name.
Array
(
[0] => Array
(
[0] => a
[1] => Alanis Morissette
)
[1] => Array
(
[0] => a
[1] => Alesha Dixon
)
[2] => Array
(
[0] => a
[1] => Alexandra Burke
)
[3] => Array
(
[0] => b
[1] => Britney Spears
)
[4] => Array
(
[0] => b
[1] => Bryan Adams
)
)
I'd like to display them grouped by that first initial, eg:
A
-
Alanis Morissette
Alesha Dixon
Alexandra Burke
B
-
Britney Spears
Bryan Adams
etc...
Is this at all possible?
This wasn't the question I was going to ask but I have unexpectedly run aground with JavaScript arrays. I come from a PHP background and after looking at a few websites I am none the wiser.
I am trying to create a multi-dimensional array.
var photos = new Array;
var a = 0;
$("#photos img").each(function(i) {
photos[a]["url"] = this.src;
photos[a]["caption"] = this.alt;
photos[a]["background"] = this.css('background-color');
a++;
});
Error message: photos[a] is undefined. How do I do this? Thanks.
This wasn't the question I was going to ask but I have unexpectedly run aground with JavaScript arrays. I come from a PHP background and after looking at a few websites I am none the wiser.
I am trying to create a multi-dimensional array.
var photos = new Array;
var a = 0;
$("#photos img").each(function(i) {
photos[a]["url"] = this.src;
photos[a]["caption"] = this.alt;
photos[a]["background"] = this.css('background-color');
a++;
});
Error message: photos[a] is undefined. How do I do this? Thanks.
Let's say, hypothetically (read: I don't think I actually need this, but I am curious as the idea popped into my head), one wanted an array of memory set aside locally on the stack, not on the heap. For instance, something like this:
private void someFunction()
{
int[20] stackArray; //C style; I know the size and it's set in stone
}
I'm guessing the answer is no. All I've been able to find is heap based arrays. If someone were to need this, would there be any workarounds? Is there any way to set aside a certain amount of sequential memory in a "value type" way? Or are structs with named parameters the only way (like the way the Matrix struct in XNA has 16 named parameters (M11-M44))?
I've just finished my static website written in plain html.
I've to buy a domain and then some space on the web to host my pages.
What's the best/cheap hosting service that I can use? I just need to host static pages, no php, mysql etc is needed
Hi folks, I think I'm running into an inheritance conceptual wall with my Java arrays. I'm kind of new to Java so please tell me if I have things upside down. In essence, I want to do three things:
Create a runnersArray with the attributes of my Runners class.
Fill my runnersArray using my GenerateObjects method of my GenerateObjects class.
Access the contents of my filled runnersArray in my Evaluating method of my Evaluating class.
The problem seems to be that runnersArray is not visible to the methods in steps 2 and 3 above, but their classes (due to design reasons) cannot inherit or extend Runners class.
Thanks in advance for any suggestions.
Here are some code snippets showing what I'm trying to do:
public class Runners extends Party {
Runners[] runnersArray = new Runners[5];
}
and
public class GenerateObject extends /* certain parent class */ {
public GenerateObject (int arrayNum) {
runnersArray[arrayNum] = /* certain Runners attributes */;
}
}
and
public class Evaluating extends /*certain parent class*/ {
public Evaluating (int arrayNum) {
System.out.println(/* String cast attribute of runnersArray[arrayNum]*/;
}
}
Hi!
Is it smart to keep arrays in table columns? More precisely I am thinking of the following schema which to my understanding violates normalization:
create table Permissions(
GroupID int not null default(-1),
CategoryID int not null default(-1),
Permissions varchar(max) not null default(''),
constraint PK_GroupCategory primary key clustered(GroupID,CategoryID)
);
and this:
create table Permissions(
GroupID int not null default(-1),
CategoryID int not null default(-1),
PermissionID int not null default(-1),
constraint PK_GroupCategory primary key clustered(GroupID,CategoryID)
);
UPD: Forgot to mention, in the scope of this concrete question we will consider that the "fetch rows that have permission X" won't be performed, instead all the lookups will be made by GroupID and CategoryID only
Thoughts?
Thanks in advance!