c# system.drawing.color array maximum size
i just received out of memory exception when tried to create Color[] array
with the length 33747648.
What the max size of Color array i can create ?
Thursday, October 3, 2013
Wednesday, October 2, 2013
How do I use JUnit to test two classes (a client and a server) that both have main methods in Java?
How do I use JUnit to test two classes (a client and a server) that both
have main methods in Java?
I have a client class that uses a main function and a server class that
uses a main function. Junit won't let me use classes with a main function.
I can easily create the two classes without the main functions, but will
they both be able to run side by side???
have main methods in Java?
I have a client class that uses a main function and a server class that
uses a main function. Junit won't let me use classes with a main function.
I can easily create the two classes without the main functions, but will
they both be able to run side by side???
Android not opening dropdown menu from select element
Android not opening dropdown menu from select element
I'm developing an mobile application using phonegap(2.9.0) and right now
i'm struggling with few android bugs related to select elements.
In advance, sorry for the poor paint "wireframes" haha
There's a form inside the relative positioned container. The select
elements were not opening the dropdown menu. After some research, this one
was solved setting the meta tag viewport with "user-scalable = yes".
Tested on Android 2.3.6: Samsung Galaxy Ace(GT-S5830C) and Motorola Defy
Mini(XT-320); Android 4.1.2: Motorola Razr D3(XT920). However, it's not
working on android 4.0.4: Samsung Galaxy S Duos(GT-S7562).
At this screen, there's a form inside the container inside the absolute
positioned div. The select elements are not working even with the meta tag
workaround. And this is driving me completely insane. At first, i thought
that the problem was the fact that i'm styling the select elements. After
removing EVERY style, it didn't work. The most close to a solution i've
got was doing it programmatically with JS, however, despite the fact that
only thinking about doing it make me want to cry, didn't work as expected,
because the dropdown menus sometimes opened, sometimes not. Sincerely, i
have no idea about why the hell is this happening. Tested on the same
devices as the screen above.
Can anyone please help me?? Thanks in advance
I'm developing an mobile application using phonegap(2.9.0) and right now
i'm struggling with few android bugs related to select elements.
In advance, sorry for the poor paint "wireframes" haha
There's a form inside the relative positioned container. The select
elements were not opening the dropdown menu. After some research, this one
was solved setting the meta tag viewport with "user-scalable = yes".
Tested on Android 2.3.6: Samsung Galaxy Ace(GT-S5830C) and Motorola Defy
Mini(XT-320); Android 4.1.2: Motorola Razr D3(XT920). However, it's not
working on android 4.0.4: Samsung Galaxy S Duos(GT-S7562).
At this screen, there's a form inside the container inside the absolute
positioned div. The select elements are not working even with the meta tag
workaround. And this is driving me completely insane. At first, i thought
that the problem was the fact that i'm styling the select elements. After
removing EVERY style, it didn't work. The most close to a solution i've
got was doing it programmatically with JS, however, despite the fact that
only thinking about doing it make me want to cry, didn't work as expected,
because the dropdown menus sometimes opened, sometimes not. Sincerely, i
have no idea about why the hell is this happening. Tested on the same
devices as the screen above.
Can anyone please help me?? Thanks in advance
Why can't I find a slash in indexOf with JavaScript?
Why can't I find a slash in indexOf with JavaScript?
mystring = "playlist/323";
if(mystring.indexOf('playlist/') == 1) {
alert("We got it");
} else {
alert("We don't");
}
I expect it to be show "we got it", but it doesn't.
See my fiddle http://jsfiddle.net/P2TcW/
mystring = "playlist/323";
if(mystring.indexOf('playlist/') == 1) {
alert("We got it");
} else {
alert("We don't");
}
I expect it to be show "we got it", but it doesn't.
See my fiddle http://jsfiddle.net/P2TcW/
C Programming: Linked Lists & Pointer Syntax errors
C Programming: Linked Lists & Pointer Syntax errors
This program simply takes a file with ASCII lines, puts it into a
linked-list stack, and then prints the reversed list to a new file in the
same ASCII format.
My struct Code:
typedef struct Node{
char info[15];
struct Node *ptr;
};
I'm getting the following errors on Main. Most have to do where I declare
the new Node Head... what's wrong with that syntax?:
Errors
strrev.c:28: error: 'Node' undeclared (first use in this function)
strrev.c:28: error: (Each undeclared identifier is reported only once
strrev.c:28: error: for each function it appears in.)
strrev.c:28: error: 'head' undeclared (first use in this function)
strrev.c:34: warning: passing argument 1 of 'strcpy' from incompatible
pointer type
/usr/include/string.h:128: note: expected 'char * __restrict__' but
argument is of type 'char **'
Main Code:
int main(int argc, char *argv[])
{
if (argc != 3) {
fprintf(stderr, "usage: intrev <input file> <output file>\n");
exit(1);
}
FILE *fp = fopen(argv[1], "r");
assert(fp != NULL);
Node *head = malloc(sizeof(Node));
head->ptr=NULL;
char str[15];
while (fgets(str, 15, fp) != NULL){
struct Node *currNode = malloc(sizeof(Node));
strcpy(currNode->info, str);
currNode->ptr = head;
head=currNode;
}
char *outfile = argv[2];
FILE *outfilestr = fopen(outfile, "w");
assert(fp != NULL);
while (head->ptr != NULL){
fprintf(outfilestr, "%s\n", head->info);
head = head->ptr;
}
fclose(fp);
fclose(outfilestr);
return 0;
}
This program simply takes a file with ASCII lines, puts it into a
linked-list stack, and then prints the reversed list to a new file in the
same ASCII format.
My struct Code:
typedef struct Node{
char info[15];
struct Node *ptr;
};
I'm getting the following errors on Main. Most have to do where I declare
the new Node Head... what's wrong with that syntax?:
Errors
strrev.c:28: error: 'Node' undeclared (first use in this function)
strrev.c:28: error: (Each undeclared identifier is reported only once
strrev.c:28: error: for each function it appears in.)
strrev.c:28: error: 'head' undeclared (first use in this function)
strrev.c:34: warning: passing argument 1 of 'strcpy' from incompatible
pointer type
/usr/include/string.h:128: note: expected 'char * __restrict__' but
argument is of type 'char **'
Main Code:
int main(int argc, char *argv[])
{
if (argc != 3) {
fprintf(stderr, "usage: intrev <input file> <output file>\n");
exit(1);
}
FILE *fp = fopen(argv[1], "r");
assert(fp != NULL);
Node *head = malloc(sizeof(Node));
head->ptr=NULL;
char str[15];
while (fgets(str, 15, fp) != NULL){
struct Node *currNode = malloc(sizeof(Node));
strcpy(currNode->info, str);
currNode->ptr = head;
head=currNode;
}
char *outfile = argv[2];
FILE *outfilestr = fopen(outfile, "w");
assert(fp != NULL);
while (head->ptr != NULL){
fprintf(outfilestr, "%s\n", head->info);
head = head->ptr;
}
fclose(fp);
fclose(outfilestr);
return 0;
}
Tuesday, October 1, 2013
Negative clockid when using clock_getcpuclockid()
Negative clockid when using clock_getcpuclockid()
I am trying to understand clock_getres() and clock_getcpuclockid(). I
wrote the example snippet below. I was expecting to get a clockid of 2
(CLOCK_PROCESS_CPUTIME_ID), based on the code in glibc:
https://github.com/lattera/glibc/blob/master/rt/clock_getcpuclockid.c .
However, the results printed out give a clockid of -6 (err is 0). ts.sec
is 0 and ts.nsec is 1, which seems reasonable. However, I don't understand
why the clockid is -6. What am I missing?
#include <time.h>
#include <iostream>
using namespace std;
int main(void)
{
struct timespec ts;
int clockid;
int err = clock_getcpuclockid(0, &clockid);
clock_getres(clockid, &ts);
cout << "err: " << err << endl;
cout << "clockid: " << clockid << " sec: " << ts.tv_sec
<< " nsec: " << ts.tv_nsec << endl;
return 0;
}
I am trying to understand clock_getres() and clock_getcpuclockid(). I
wrote the example snippet below. I was expecting to get a clockid of 2
(CLOCK_PROCESS_CPUTIME_ID), based on the code in glibc:
https://github.com/lattera/glibc/blob/master/rt/clock_getcpuclockid.c .
However, the results printed out give a clockid of -6 (err is 0). ts.sec
is 0 and ts.nsec is 1, which seems reasonable. However, I don't understand
why the clockid is -6. What am I missing?
#include <time.h>
#include <iostream>
using namespace std;
int main(void)
{
struct timespec ts;
int clockid;
int err = clock_getcpuclockid(0, &clockid);
clock_getres(clockid, &ts);
cout << "err: " << err << endl;
cout << "clockid: " << clockid << " sec: " << ts.tv_sec
<< " nsec: " << ts.tv_nsec << endl;
return 0;
}
How to fetch two different commits of the same project to different local folders using GIT
How to fetch two different commits of the same project to different local
folders using GIT
I am new to Git so please bear with me. I am trying to grab two different
commits of a same project, specifically a current commit and an old commit
with certain hash. I want them to clone it in separate folders (so that
they don't overwrite and I can open them as separate projects at same
time)? Is it possible?
Thanks in advance
folders using GIT
I am new to Git so please bear with me. I am trying to grab two different
commits of a same project, specifically a current commit and an old commit
with certain hash. I want them to clone it in separate folders (so that
they don't overwrite and I can open them as separate projects at same
time)? Is it possible?
Thanks in advance
What is the significance of limit points?
What is the significance of limit points?
When I had my first taste of topology a couple of years ago, our lecturer
emphasized the following notions.
closed set, closure, closure point
open set, interior, interior point
Of course, these are all basically different ways of talking about the
same thing. For example, from the family of closed sets of a space we can
obtain its closure operator, and the fixed points of the closure operator
are precisely the closed sets; the open sets are precisely the complements
of the closed sets, etc.
Anyway, the concepts were well-motivated from the viewpoint of continuous
functions between metric spaces. For example, it was demonstrated that if
$X$ and $Y$ are metric spaces and $f : X \rightarrow Y$ is a function,
then the following are equivalent
$f$ is continuous in the sense of $\epsilon$-$\delta$.
The preimage of a closed set under $f$ is closed.
The preimage of an open set under $f$ is open.
$f(\mathrm{cl} \,A)\subseteq\mathrm{cl}(f(A))$ for all $A \subseteq X$.
$\mathrm{cl}(f^{-1}(B)) \subseteq f^{-1}(\mathrm{cl} \,B)$ for all $B
\subseteq X$.
$f^{-1}( \mathrm{int} (B)) \subseteq \mathrm{int} ( f^{-1} ( B ) )$ for
all $B \subseteq Y$.
etc.
Anyway, on Wikipedia there's some related concept that weren't really
dealt with in the course I took, namely limit points and isolated points.
I understand the definitions (Wikipedia is clear enough), yet at the same
time I don't understand their significance. They just seem like closure
points, but less well-behaved.
For example, the set of all closure points of a set always includes the
original set. The same is true of the set of all limit points, so long as
the original set did not possess any isolated points, indeed we get the
same answer. The only time we get a different answer is when the original
set has at least one isolated point; but, in this case, the act of taking
the set of all limit points is no longer so well-behaved; indeed, it will
never include the original set.
So, its not clear to me the benefit of thinking in terms of limit points,
as opposed to closure points. In what circumstances are limit points the
right concept, and, more broadly, what is their significance?
When I had my first taste of topology a couple of years ago, our lecturer
emphasized the following notions.
closed set, closure, closure point
open set, interior, interior point
Of course, these are all basically different ways of talking about the
same thing. For example, from the family of closed sets of a space we can
obtain its closure operator, and the fixed points of the closure operator
are precisely the closed sets; the open sets are precisely the complements
of the closed sets, etc.
Anyway, the concepts were well-motivated from the viewpoint of continuous
functions between metric spaces. For example, it was demonstrated that if
$X$ and $Y$ are metric spaces and $f : X \rightarrow Y$ is a function,
then the following are equivalent
$f$ is continuous in the sense of $\epsilon$-$\delta$.
The preimage of a closed set under $f$ is closed.
The preimage of an open set under $f$ is open.
$f(\mathrm{cl} \,A)\subseteq\mathrm{cl}(f(A))$ for all $A \subseteq X$.
$\mathrm{cl}(f^{-1}(B)) \subseteq f^{-1}(\mathrm{cl} \,B)$ for all $B
\subseteq X$.
$f^{-1}( \mathrm{int} (B)) \subseteq \mathrm{int} ( f^{-1} ( B ) )$ for
all $B \subseteq Y$.
etc.
Anyway, on Wikipedia there's some related concept that weren't really
dealt with in the course I took, namely limit points and isolated points.
I understand the definitions (Wikipedia is clear enough), yet at the same
time I don't understand their significance. They just seem like closure
points, but less well-behaved.
For example, the set of all closure points of a set always includes the
original set. The same is true of the set of all limit points, so long as
the original set did not possess any isolated points, indeed we get the
same answer. The only time we get a different answer is when the original
set has at least one isolated point; but, in this case, the act of taking
the set of all limit points is no longer so well-behaved; indeed, it will
never include the original set.
So, its not clear to me the benefit of thinking in terms of limit points,
as opposed to closure points. In what circumstances are limit points the
right concept, and, more broadly, what is their significance?
Put swap on SSD or HDD?
Put swap on SSD or HDD?
New installation coming up. 120gb SSD for OS and HOME and 1tb HDD for
storage. 16gb of ram which means 16gb of swap if I recall correctly. SSD
space is too valuable for a swap partition right? If my thinking is
correct can someone guide me through or point me in the right direction
for putting a swap partition on a second hard drive? I have always
selected the automatic settings when installing ubuntu. Thanks!
New installation coming up. 120gb SSD for OS and HOME and 1tb HDD for
storage. 16gb of ram which means 16gb of swap if I recall correctly. SSD
space is too valuable for a swap partition right? If my thinking is
correct can someone guide me through or point me in the right direction
for putting a swap partition on a second hard drive? I have always
selected the automatic settings when installing ubuntu. Thanks!
Subscribe to:
Comments (Atom)