A strange "pattern" in the continued fraction convergents of pi?
From the simple continued fraction of $\pi$, one gets the convergents,
$$p_n = \frac{3}{1}, \frac{22}{7}, \frac{333}{106}, \frac{355}{113},
\frac{103993}{33102}, \frac{104348}{33215}, \frac{208341}{66317},
\frac{312689}{99532}, \frac{833719}{265381}, \frac{1146408}{364913},
\dots$$
starting with $n=1$, where the numerators and denominators are A002485 and
A002486, respectively. If you stare at it hard enough, a pattern will
emerge between three consecutive convergents. Define,
$$a_n,\,b_n,\,c_n = p_{n}-3,\;\; p_{n+1}-3,\;\; p_{n+2}-3$$
$$v_n=\text{Numerator}\,(a_n)\,\text{Numerator}\,(b_n)$$
then for even $n \ge 2$,
$$F(n) = \sqrt{\frac{a_n c_n}{a_n-c_n}-v_n}=\text{Integer}\, (often)$$
For example, for $n = 2$,
$$a_2,\,b_2,\,c_2, = \frac{22}{7}-3,\; \frac{333}{106}-3,\;
\frac{355}{113}-3$$
$$F(2) = 1$$
More generally,
$$\begin{array}{cc} n&F(n) \\ 2&1 \\ 4&16\\ 6&4703\\ 8&14093\\ 10&51669\\
12&122126\sqrt{2}\\ 14&7468474\\ 16&\frac{18549059}{\sqrt{2}}\\
\end{array}$$
and so on. For even $n<100$, I found half of the $F(n)$ were either
integer or half-integer. (And all the non-integers were of form
$N\sqrt{d}$ for some very small d.)
Some questions:
For $n<500$, $n<1000$, etc, how many $F(n)$ are integers or half-integers?
More importantly, why is $F(n)$ often an integer?
Monday, September 30, 2013
Screen fade to black after 10 minutes and never come back
Screen fade to black after 10 minutes and never come back
Im using Linaro Raring Server for Cubieboard A20 from here:
www.cubieforums.com/index.php?topic=807.0
After about 10 minutes, the screen goes to black, even I'm using keyboard
or mouse, so seems not be a screensaver to me, since not idle. Nothing I
can do to bring the screen back, only a reboot. My system still alive (my
TV shows signal is active).
I'm not using GUI, so answer in terminal commands.
I don't use GUI, but have a X11, because xbmc is installed on system. At
startup, xbmc starts without login.
Steps I've done:
1) Start system and XBMC. Auto login (root). Black screen after 10 min
even using keyboard/mouse.
2) Start without XBMC (and GUI). Auto login (root). Black screen after 10
min even using keyboard/mouse.
Tried this https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/1072531
and this How to stop screen going black after 10 min
I think i'ts a custom system configuration, since I don't have xset and
can't find xorg.conf.
There is a X11 in init folder.
Im using Linaro Raring Server for Cubieboard A20 from here:
www.cubieforums.com/index.php?topic=807.0
After about 10 minutes, the screen goes to black, even I'm using keyboard
or mouse, so seems not be a screensaver to me, since not idle. Nothing I
can do to bring the screen back, only a reboot. My system still alive (my
TV shows signal is active).
I'm not using GUI, so answer in terminal commands.
I don't use GUI, but have a X11, because xbmc is installed on system. At
startup, xbmc starts without login.
Steps I've done:
1) Start system and XBMC. Auto login (root). Black screen after 10 min
even using keyboard/mouse.
2) Start without XBMC (and GUI). Auto login (root). Black screen after 10
min even using keyboard/mouse.
Tried this https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/1072531
and this How to stop screen going black after 10 min
I think i'ts a custom system configuration, since I don't have xset and
can't find xorg.conf.
There is a X11 in init folder.
adding custom field to oData result
adding custom field to oData result
Calling an oData service from ajax I receive following object:
{"odata.metadata":"http://localhost:55878/odata/$metadata#Products","odata.count":"5",
"value":[
{
"ID":3,"Name":"Scarf","Price":"12","Category":"Apparel"
},
{
"ID":4,"Name":"Yo-yo","Price":"4.95","Category":"Toys"
}
],
"odata.nextLink":"[http://localhost:55878/odata/Products$inlinecount=allpages&$skip=4]"
}
notice I'm using pagging and that's why server return odata.nextLink url
in the odata object.
Now I want to add a custom field "odata.previousLink" in odata object.
where and how can I achive that ??
Calling an oData service from ajax I receive following object:
{"odata.metadata":"http://localhost:55878/odata/$metadata#Products","odata.count":"5",
"value":[
{
"ID":3,"Name":"Scarf","Price":"12","Category":"Apparel"
},
{
"ID":4,"Name":"Yo-yo","Price":"4.95","Category":"Toys"
}
],
"odata.nextLink":"[http://localhost:55878/odata/Products$inlinecount=allpages&$skip=4]"
}
notice I'm using pagging and that's why server return odata.nextLink url
in the odata object.
Now I want to add a custom field "odata.previousLink" in odata object.
where and how can I achive that ??
Execute Js code until the document is ready
Execute Js code until the document is ready
What's the best way to keep executing a JS code (each 100 ms in m case)
until the document is ready.
setInterval(function() {
xajax_updateLoader();
}, 100);
One the document is ready. The execution should stop.
What's the best way to keep executing a JS code (each 100 ms in m case)
until the document is ready.
setInterval(function() {
xajax_updateLoader();
}, 100);
One the document is ready. The execution should stop.
Sunday, September 29, 2013
Appending new XElement adds an entire XML to existing xml in stream
Appending new XElement adds an entire XML to existing xml in stream
I have an existing XML stored in the InternalFielStorage as..
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
<Books>
<Author name="Sam" />
</Books>
</Root>
I am trying to append a book node under the node but the when saved, I am
seeing a completly new xml added to the existing xml as..
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
<Books>
<Author name="Sam" />
</Books>
</Root>
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
<Books>
<Author name="Sam" />
<Title>Test</Title>
</Books>
</Root>
Code I am using for this..
using (IsolatedStorageFile myStore =
IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream myStream = new
IsolatedStorageFileStream(App.FileName, FileMode.Open,
FileAccess.ReadWrite, myStore))
{
XDocument _xDoc = XDocument.Load(myStream);
XElement srcTree = new XElement("Title", "test");
_xDoc.Element("Root").Element("Books").Add(new XElement(srcTree));
_xDoc.Save(myStream);
QUESTIONS:
1. How can I avoid the new XML from being appended to the existing one?
2. How can I make the tab to under the tag?
Thanks in advance.
I have an existing XML stored in the InternalFielStorage as..
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
<Books>
<Author name="Sam" />
</Books>
</Root>
I am trying to append a book node under the node but the when saved, I am
seeing a completly new xml added to the existing xml as..
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
<Books>
<Author name="Sam" />
</Books>
</Root>
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
<Books>
<Author name="Sam" />
<Title>Test</Title>
</Books>
</Root>
Code I am using for this..
using (IsolatedStorageFile myStore =
IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream myStream = new
IsolatedStorageFileStream(App.FileName, FileMode.Open,
FileAccess.ReadWrite, myStore))
{
XDocument _xDoc = XDocument.Load(myStream);
XElement srcTree = new XElement("Title", "test");
_xDoc.Element("Root").Element("Books").Add(new XElement(srcTree));
_xDoc.Save(myStream);
QUESTIONS:
1. How can I avoid the new XML from being appended to the existing one?
2. How can I make the tab to under the tag?
Thanks in advance.
Parsing XML to a Java object, clarification needed
Parsing XML to a Java object, clarification needed
What would be the best way to stick this XML into an object?
<root>
<data value=1>
<cell a='1' b='0'/>
<cell a='2' b='0'/>
<cell a='3' b='0'/>
</data>
<data value=2>
<cell a='2' b='0'/>
<cell a='4' b='1'/>
<cell a='3' b='0'/>
</data>
</root>
We can assume that
Each data value will be unique.
Actual numeric value assigned to it is important and needs to be captured
Is it possible to put this into Map<Integer, List<Cell>>, grouping cells
under the data value?
Ideally method signature would look as follows public static Map<Integer,
List<Cell>> parse(String pathToFile)
Would you provide an example please?
What would be the best way to stick this XML into an object?
<root>
<data value=1>
<cell a='1' b='0'/>
<cell a='2' b='0'/>
<cell a='3' b='0'/>
</data>
<data value=2>
<cell a='2' b='0'/>
<cell a='4' b='1'/>
<cell a='3' b='0'/>
</data>
</root>
We can assume that
Each data value will be unique.
Actual numeric value assigned to it is important and needs to be captured
Is it possible to put this into Map<Integer, List<Cell>>, grouping cells
under the data value?
Ideally method signature would look as follows public static Map<Integer,
List<Cell>> parse(String pathToFile)
Would you provide an example please?
How to adjust word-wrapped text's width when it exceed containers max-width ? (HTML)
How to adjust word-wrapped text's width when it exceed containers
max-width ? (HTML)
Im trying to put some text info on thumbnails, the info box is floating to
the left and should not exceed max-width:85%; (of the thumbnail).
Thumbnail area is marked light gray in the picture, text info area is
yellow.
When the text exceed the with, text holding element ocupies full 85% and
word wraps to next line. My problem is that there are extra white spaces
on the first line, which I would like gone.
In my project yellow area holds Thumbnail title, even though there are few
words in it, sometimes it just leaves big gaps on the first line which
look bad.
Is there any way to fix this or am I asking for too much ?
jsFiddle demo
HTML
<div id="main">
<div id="text">
<h3>Some text and line breaking words. Some text and line breaking words.
Soaaaaame text and line breaking words.<h3>
</div>
CSS
#main {
width:100%;
background-color:#ccc;
}
#text {
display:inline-block;
max-width:85%;
background-color:yellow;
}
max-width ? (HTML)
Im trying to put some text info on thumbnails, the info box is floating to
the left and should not exceed max-width:85%; (of the thumbnail).
Thumbnail area is marked light gray in the picture, text info area is
yellow.
When the text exceed the with, text holding element ocupies full 85% and
word wraps to next line. My problem is that there are extra white spaces
on the first line, which I would like gone.
In my project yellow area holds Thumbnail title, even though there are few
words in it, sometimes it just leaves big gaps on the first line which
look bad.
Is there any way to fix this or am I asking for too much ?
jsFiddle demo
HTML
<div id="main">
<div id="text">
<h3>Some text and line breaking words. Some text and line breaking words.
Soaaaaame text and line breaking words.<h3>
</div>
CSS
#main {
width:100%;
background-color:#ccc;
}
#text {
display:inline-block;
max-width:85%;
background-color:yellow;
}
Crypto provider in JDK
Crypto provider in JDK
Is it correctly understood that in order to do cryptography in Java using
eg. Cipher, I must choose an external provider to setup, that is, the JDK
does not come with and contains a "default" provider ?
Is it correctly understood that in order to do cryptography in Java using
eg. Cipher, I must choose an external provider to setup, that is, the JDK
does not come with and contains a "default" provider ?
Saturday, September 28, 2013
Transforming the measure in $CP^1$ mapping from Riemann sphere to $\mathbb{C}^2$-plane
Transforming the measure in $CP^1$ mapping from Riemann sphere to
$\mathbb{C}^2$-plane
I would like to know how the measure changes in $CP^1$ mapping from
Riemann sphere (2-sphere) to $\mathbb{C}^2$-plane.
Let a point on the 2-sphere is given by the vector
$\hat{n}(\mathbf{x})=(n^x(\mathbf{x}),n^y(\mathbf{x}),n^z(\mathbf{x}))$
with constraint $|\hat{n}|^2=1$. Now the $CP^1$ mapping is defined as
follows \begin{equation} n^\alpha(\mathbf{x}) = \mathbf{z}^\dagger
(\mathbf{x})\sigma^\alpha \mathbf{z}(\mathbf{x}), \quad \alpha=x,y,z
\end{equation} where
$\mathbf{z}(\mathbf{x})=[z_1(\mathbf{x}),z_2(\mathbf{x})]$ is a two
component spinor, $z_1, z_2\in \mathbb{C}$ are two complex numbers, and
$\sigma$ are Pauli matrices. The $CP^1$ mapping leads \begin{eqnarray} n^x
&=& z_1^\ast z_2 + z_2^\ast z_1= 2\Re \left( z_1^\ast z_2 \right)\\ n^y
&=& -iz_1^\ast z_2 + i z_2^\ast z_1=2\Im \left( z_1^\ast z_2 \right) \\
n^z &=&z_1^\ast z_1 - z_2^\ast z_2 \end{eqnarray} and \begin{equation}
|\hat{n}|= |\mathbf{z}|^2 = z_1^2 + z_2^2=1. \end{equation}
Now my question is how to find measure $dn^xdn^ydn^z$ in terms of complex
numbers $z_1$ and $z_2$ with appropriate normalization constant.
$\mathbb{C}^2$-plane
I would like to know how the measure changes in $CP^1$ mapping from
Riemann sphere (2-sphere) to $\mathbb{C}^2$-plane.
Let a point on the 2-sphere is given by the vector
$\hat{n}(\mathbf{x})=(n^x(\mathbf{x}),n^y(\mathbf{x}),n^z(\mathbf{x}))$
with constraint $|\hat{n}|^2=1$. Now the $CP^1$ mapping is defined as
follows \begin{equation} n^\alpha(\mathbf{x}) = \mathbf{z}^\dagger
(\mathbf{x})\sigma^\alpha \mathbf{z}(\mathbf{x}), \quad \alpha=x,y,z
\end{equation} where
$\mathbf{z}(\mathbf{x})=[z_1(\mathbf{x}),z_2(\mathbf{x})]$ is a two
component spinor, $z_1, z_2\in \mathbb{C}$ are two complex numbers, and
$\sigma$ are Pauli matrices. The $CP^1$ mapping leads \begin{eqnarray} n^x
&=& z_1^\ast z_2 + z_2^\ast z_1= 2\Re \left( z_1^\ast z_2 \right)\\ n^y
&=& -iz_1^\ast z_2 + i z_2^\ast z_1=2\Im \left( z_1^\ast z_2 \right) \\
n^z &=&z_1^\ast z_1 - z_2^\ast z_2 \end{eqnarray} and \begin{equation}
|\hat{n}|= |\mathbf{z}|^2 = z_1^2 + z_2^2=1. \end{equation}
Now my question is how to find measure $dn^xdn^ydn^z$ in terms of complex
numbers $z_1$ and $z_2$ with appropriate normalization constant.
need help understanding superposition principle..!
need help understanding superposition principle..!
if we have a function y=f(x) then in-order to prove linearity we try to
justify according to superposition principle as : let x1 and x2 be two
inputs then f(x1+x2)=f(x1)+f(x2) please correct me if i am wrong upto
here.. now what if we have more than two variables..let's say we have
three variables two independent and one dependent now we have function
z=g(x,y)..now in-order to prove linearity for function involving more than
two variables can i say this that for g(x,y) to be linear
g(x1+x2,y1+y2)=g(x1,y1)+g(x2,y2)..?? and if this isn't the correct way for
proving linearity in functions involving more than two variables..then
please justify the correct method along with examples.
if we have a function y=f(x) then in-order to prove linearity we try to
justify according to superposition principle as : let x1 and x2 be two
inputs then f(x1+x2)=f(x1)+f(x2) please correct me if i am wrong upto
here.. now what if we have more than two variables..let's say we have
three variables two independent and one dependent now we have function
z=g(x,y)..now in-order to prove linearity for function involving more than
two variables can i say this that for g(x,y) to be linear
g(x1+x2,y1+y2)=g(x1,y1)+g(x2,y2)..?? and if this isn't the correct way for
proving linearity in functions involving more than two variables..then
please justify the correct method along with examples.
Amazon EC2 Ubuntu Instance package installation problems
Amazon EC2 Ubuntu Instance package installation problems
I have an amazon EC2 installation of Ubuntu Precise 12.04, 64Bit
(ami-ce7b6fba)
I just don't seem to be able to install anything as you would normally
expect. When I run 'sudo apt-get update' I get the following issues;
W: GPG error: http://www.ubnt.com ubuntu Release: The following signatures
couldn't be verified because the public key is not available: NO_PUBKEY
06E85760C0A52C50
W: Failed to fetch
http://ppa.launchpad.net/andphe/php/ubuntu/dists/precise/main/source/Sources
404 Not Found
W: Failed to fetch
http://ppa.launchpad.net/andphe/php/ubuntu/dists/precise/main/binary-amd64/Packages
404 Not Found
W: Failed to fetch
http://ppa.launchpad.net/andphe/php/ubuntu/dists/precise/main/binary-i386/Packages
404 Not Found
E: Some index files failed to download. They have been ignored, or old
ones used instead.
Can anyone assist me in getting this fixed?
Thank you so much in advance
Stu
I have an amazon EC2 installation of Ubuntu Precise 12.04, 64Bit
(ami-ce7b6fba)
I just don't seem to be able to install anything as you would normally
expect. When I run 'sudo apt-get update' I get the following issues;
W: GPG error: http://www.ubnt.com ubuntu Release: The following signatures
couldn't be verified because the public key is not available: NO_PUBKEY
06E85760C0A52C50
W: Failed to fetch
http://ppa.launchpad.net/andphe/php/ubuntu/dists/precise/main/source/Sources
404 Not Found
W: Failed to fetch
http://ppa.launchpad.net/andphe/php/ubuntu/dists/precise/main/binary-amd64/Packages
404 Not Found
W: Failed to fetch
http://ppa.launchpad.net/andphe/php/ubuntu/dists/precise/main/binary-i386/Packages
404 Not Found
E: Some index files failed to download. They have been ignored, or old
ones used instead.
Can anyone assist me in getting this fixed?
Thank you so much in advance
Stu
Make the parent window controls accessible to the user which has a iframe element of border height and width being 100%
Make the parent window controls accessible to the user which has a iframe
element of border height and width being 100%
I have an iframe of height and width 100% i.e occupies entire height and
width of the main page. But the main page is an aspx page already, with
its own controls. On page load, this iframe occupies the entire page ,
hence lying above the main page controls, making them inaccessible. Now,
what i need is that this main page controls must be accessible. What do i
do for that. Can this be done using Uframes?? Please note that. the iframe
src links to an url which is basically a chat application, hence, there
can be as many chat windows which open in this frame based on the user,
hence the height and width of the iframe cannot be fixed. Please help me
out in finding a solution for this issue.
element of border height and width being 100%
I have an iframe of height and width 100% i.e occupies entire height and
width of the main page. But the main page is an aspx page already, with
its own controls. On page load, this iframe occupies the entire page ,
hence lying above the main page controls, making them inaccessible. Now,
what i need is that this main page controls must be accessible. What do i
do for that. Can this be done using Uframes?? Please note that. the iframe
src links to an url which is basically a chat application, hence, there
can be as many chat windows which open in this frame based on the user,
hence the height and width of the iframe cannot be fixed. Please help me
out in finding a solution for this issue.
Friday, September 27, 2013
How to store multiply check boxes in to database with PDO Connection
How to store multiply check boxes in to database with PDO Connection
I have the following problem which I can't resolve in which I've tried
everything and nothing is working. The problem is that I want to store
multiply checkboxes values into database, into one column one record
inside it. Here is the Form code which I am using:
<label for="newsletter1">PRIMARIA:</label>
<input type="checkbox" name="field021[]" value="1" /> 1
<input type="checkbox" name="field021[]" value="2" /> 2
<input type="checkbox" name="field021[]" value="3" /> 3
for the PHP I am using a class file with the following storring parameteres:
public function __construct( $data = array() ) {
if( isset( $data['field021'] ) ) $this->field021 = stripslashes(
strip_tags( $data['field021'] ) );
public function register() {
$correct = false;
try {
$con = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD );
$con->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$sql = "INSERT INTO users(field021) VALUES(:field021)";
$stmt = $con->prepare( $sql );
$stmt->bindValue( "field021", $this->field021, PDO::PARAM_STR );
$stmt->execute();
right now nothing is getting writen in the database in the cell field021 ,
what I want to do is, to be able to register there multiply checkboxes
devided by comma. If anyone can help, it will be much appreciated. Thanks
I have the following problem which I can't resolve in which I've tried
everything and nothing is working. The problem is that I want to store
multiply checkboxes values into database, into one column one record
inside it. Here is the Form code which I am using:
<label for="newsletter1">PRIMARIA:</label>
<input type="checkbox" name="field021[]" value="1" /> 1
<input type="checkbox" name="field021[]" value="2" /> 2
<input type="checkbox" name="field021[]" value="3" /> 3
for the PHP I am using a class file with the following storring parameteres:
public function __construct( $data = array() ) {
if( isset( $data['field021'] ) ) $this->field021 = stripslashes(
strip_tags( $data['field021'] ) );
public function register() {
$correct = false;
try {
$con = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD );
$con->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$sql = "INSERT INTO users(field021) VALUES(:field021)";
$stmt = $con->prepare( $sql );
$stmt->bindValue( "field021", $this->field021, PDO::PARAM_STR );
$stmt->execute();
right now nothing is getting writen in the database in the cell field021 ,
what I want to do is, to be able to register there multiply checkboxes
devided by comma. If anyone can help, it will be much appreciated. Thanks
Log into website using java
Log into website using java
I'm trying to use java to log into a website, but I'm having trouble doing
so, what am I missing?
Sending 'POST' request to URL : https://example.com/auth/
Post parameters : return_to=%2F&username=a&password=1&=Sign+In
I then called postParams on the HttpUrlConnectionExample object with url
and paragms, but I can't seem to log in, I get redirected back to the
login page. So I tried using only the paragrams: username=a&password=1 but
it still redirected me back to the login page. Any help to help me log in?
My credentials are 100% correct. Below is the form tag from the
https://example.com/auth/ page
<form id="loginForm" method="post" action="./do_login" name="loginForm">
<input type="hidden" name="return_to" value="/"/>
<div class="controlContainer">
<label for="username">User ID</label>
<input id="userid" class="field" type="text" value=""
maxlength="128" spellcheck="false" name="username"
autocomplete="off"
placeholder="User ID" tabindex="1"/>
<label for="password">Password</label>
<input id="password" class="field" type="password" value=""
maxlength="128" spellcheck="false" name="password"
placeholder="Password" autocomplete="off"tabindex="2"/>
<input id="submitButton" class="button" type="submit"
value="Sign In" tabindex="3"/>
</div>
</form>
I'm trying to use java to log into a website, but I'm having trouble doing
so, what am I missing?
Sending 'POST' request to URL : https://example.com/auth/
Post parameters : return_to=%2F&username=a&password=1&=Sign+In
I then called postParams on the HttpUrlConnectionExample object with url
and paragms, but I can't seem to log in, I get redirected back to the
login page. So I tried using only the paragrams: username=a&password=1 but
it still redirected me back to the login page. Any help to help me log in?
My credentials are 100% correct. Below is the form tag from the
https://example.com/auth/ page
<form id="loginForm" method="post" action="./do_login" name="loginForm">
<input type="hidden" name="return_to" value="/"/>
<div class="controlContainer">
<label for="username">User ID</label>
<input id="userid" class="field" type="text" value=""
maxlength="128" spellcheck="false" name="username"
autocomplete="off"
placeholder="User ID" tabindex="1"/>
<label for="password">Password</label>
<input id="password" class="field" type="password" value=""
maxlength="128" spellcheck="false" name="password"
placeholder="Password" autocomplete="off"tabindex="2"/>
<input id="submitButton" class="button" type="submit"
value="Sign In" tabindex="3"/>
</div>
</form>
Problems to get active directory guid current user in a windows service
Problems to get active directory guid current user in a windows service
When I've created a code to get a active directory guid by current user in
windows service
public static String getUserAdGuid(string userName) {
DirectorySearcher searcher = new DirectorySearcher();
searcher.Filter = "(&(objectClass=user)(sAMAccountName=" +
userName + "))";
SearchResult searchResult = searcher.FindOne();
DirectoryEntry entry = searchResult.GetDirectoryEntry();
Guid objectGuid = new Guid(entry.NativeGuid);
return objectGuid.ToString();
}</code> <br />
unfortunately not work rigth, I've checked and this result is not guid by
current active directory user.
Somebody can help me about this?
When I've created a code to get a active directory guid by current user in
windows service
public static String getUserAdGuid(string userName) {
DirectorySearcher searcher = new DirectorySearcher();
searcher.Filter = "(&(objectClass=user)(sAMAccountName=" +
userName + "))";
SearchResult searchResult = searcher.FindOne();
DirectoryEntry entry = searchResult.GetDirectoryEntry();
Guid objectGuid = new Guid(entry.NativeGuid);
return objectGuid.ToString();
}</code> <br />
unfortunately not work rigth, I've checked and this result is not guid by
current active directory user.
Somebody can help me about this?
Emacs: disable theme background color in terminal
Emacs: disable theme background color in terminal
I'd like to have emacs not to have a background color when I open a frame
in the terminal. I'm using a terminal with a translucent background, and
characters with a background color are not "see-through". TERM is set to
"xterm-256color".
How do I get emacs to use the default background color (no color at all),
when the frame is not graphical?
I'd like to have emacs not to have a background color when I open a frame
in the terminal. I'm using a terminal with a translucent background, and
characters with a background color are not "see-through". TERM is set to
"xterm-256color".
How do I get emacs to use the default background color (no color at all),
when the frame is not graphical?
Thursday, September 26, 2013
Database records not placing exactly continiously
Database records not placing exactly continiously
I have this code, My primary in my database is counter.
<input class="textbox1" tabIndex="8" maxLength="49" size="30"
name="n_counter" value='
<?php
$result = mysql_query("SELECT * FROM procurement WHERE counter != ' '");
while ( $row = mysql_fetch_array( $result ) ) {
$value = $row['counter'];
}
$i = "0";
while ( $i <= $value ) {
$i++;
}
$value2 = strlen( $i );
if ( $value2 == 1 ) {
echo "00000" . $i;
} else if ( $value2 == 2 ) {
echo "0000" . $i;
} else if ( $value2 == 3 ) {
echo "000" . $i;
} else if ( $value2 == 4) {
echo "00" . $i;
} else if ( $value2 == 5 ) {
echo "0" . $i;
} else {
echo $i;
}
?>'>
The looping statement works perfectly, but my problem is when I deleted
records from database.
When I deleted 000001 records and add another records, that records goes
next to 000000, what I want is 000010 should next to 000009. In my other
project that works perfectly. What is the problem?
I have this code, My primary in my database is counter.
<input class="textbox1" tabIndex="8" maxLength="49" size="30"
name="n_counter" value='
<?php
$result = mysql_query("SELECT * FROM procurement WHERE counter != ' '");
while ( $row = mysql_fetch_array( $result ) ) {
$value = $row['counter'];
}
$i = "0";
while ( $i <= $value ) {
$i++;
}
$value2 = strlen( $i );
if ( $value2 == 1 ) {
echo "00000" . $i;
} else if ( $value2 == 2 ) {
echo "0000" . $i;
} else if ( $value2 == 3 ) {
echo "000" . $i;
} else if ( $value2 == 4) {
echo "00" . $i;
} else if ( $value2 == 5 ) {
echo "0" . $i;
} else {
echo $i;
}
?>'>
The looping statement works perfectly, but my problem is when I deleted
records from database.
When I deleted 000001 records and add another records, that records goes
next to 000000, what I want is 000010 should next to 000009. In my other
project that works perfectly. What is the problem?
Wednesday, September 25, 2013
Android how to mange ads and ads free version
Android how to mange ads and ads free version
I developed an android app I want to release the ads and ad free version.
Kindly tell me how to do mange both and If some one want to purchase ad
free version from ad version he simple click on some button and he can
purchase add free version Thanks in Advance
I developed an android app I want to release the ads and ad free version.
Kindly tell me how to do mange both and If some one want to purchase ad
free version from ad version he simple click on some button and he can
purchase add free version Thanks in Advance
Thursday, September 19, 2013
Can we add locations to a given Google map temporary ?
Can we add locations to a given Google map temporary ?
Can we add locations to a given Google map temporary ?
Which means I have a simple web page with a Google map embedded into it. I
want to add 2 schools into that map once I click a button in that web page
(assume i have the GPS coordinates and necessary details of them).
I am not referring to the Markers in Google map.
Thanks,
Can we add locations to a given Google map temporary ?
Which means I have a simple web page with a Google map embedded into it. I
want to add 2 schools into that map once I click a button in that web page
(assume i have the GPS coordinates and necessary details of them).
I am not referring to the Markers in Google map.
Thanks,
Java Socket connected but no data is sent or received
Java Socket connected but no data is sent or received
I've created a simple socket server in Java which listens for connections
then establishes a socket with the client. Data is then read and written
over the socket.
The socket server is running in a Tomcat servlet container (Tomcat7) on an
Ubuntu server.
The problem I'm having is that when the client is on some wifi networks -
when a connection is made - the socket connects but no data is is received
from the client. The client automatically sends an initialization packet
when the connection is made, but the server is not receiving it.
This only happens on certain wifi networks - when the network is changed
then the connection works properly. I thought the issue might have to do
with the fact it's using a tcp6 socket - but after searching Google I
can't find any reason why that would matter?
netstat -tanp | grep 40
tcp6 0 0 :::4001 :::* LISTEN
13747/java
tcp6 0 0 :::4002 :::* LISTEN
13747/java
tcp6 0 0 :::4003 :::* LISTEN
13747/java
Example Code
// Listen for connections
SeverSocket m_cServerSocket = new ServerSocket(m_nPort);
Socket m_cSocket = m_cServerSocket.accept();
m_cServerSocket.close();
PrintWriter m_cSocketOut = new PrintWriter(m_cSocket.getOutputStream(),
true);
TBSockReader m_cSocketReader = new TBSockReader(m_cSocket,this);
// TBSockReader
String sReadLine;
BufferedReader in = new BufferedReader(new
InputStreamReader(m_isReadStream));
while ((sReadLine = in.readLine()) != null)
{
ManagerDataFromClient(sReadLine);
}
Also I don't think it's a firewall issue on the client side - as the
socket connects and stays connected until I close it. There is no firewall
on the server side.
Any help would be greatly appreciated!
Cheers
I've created a simple socket server in Java which listens for connections
then establishes a socket with the client. Data is then read and written
over the socket.
The socket server is running in a Tomcat servlet container (Tomcat7) on an
Ubuntu server.
The problem I'm having is that when the client is on some wifi networks -
when a connection is made - the socket connects but no data is is received
from the client. The client automatically sends an initialization packet
when the connection is made, but the server is not receiving it.
This only happens on certain wifi networks - when the network is changed
then the connection works properly. I thought the issue might have to do
with the fact it's using a tcp6 socket - but after searching Google I
can't find any reason why that would matter?
netstat -tanp | grep 40
tcp6 0 0 :::4001 :::* LISTEN
13747/java
tcp6 0 0 :::4002 :::* LISTEN
13747/java
tcp6 0 0 :::4003 :::* LISTEN
13747/java
Example Code
// Listen for connections
SeverSocket m_cServerSocket = new ServerSocket(m_nPort);
Socket m_cSocket = m_cServerSocket.accept();
m_cServerSocket.close();
PrintWriter m_cSocketOut = new PrintWriter(m_cSocket.getOutputStream(),
true);
TBSockReader m_cSocketReader = new TBSockReader(m_cSocket,this);
// TBSockReader
String sReadLine;
BufferedReader in = new BufferedReader(new
InputStreamReader(m_isReadStream));
while ((sReadLine = in.readLine()) != null)
{
ManagerDataFromClient(sReadLine);
}
Also I don't think it's a firewall issue on the client side - as the
socket connects and stays connected until I close it. There is no firewall
on the server side.
Any help would be greatly appreciated!
Cheers
how to debug "sql subquery returns more than 1 row" error
how to debug "sql subquery returns more than 1 row" error
We have a huge SQL script involving tens of tables, subqueries, hundreds
of attributes. It works perfectly in the test database but returns sql
subquery returns more than 1 row error when running in the production
database. The script was working perfectly up until now. The problem is,
all I get is a one-line error specified above with no clues whatsoever
which exact subquery causes the error which makes it near to impossible to
debug. The question is, how am I supposed to know which line of the SQL
causes the error? Is there any way to "debug" it line by line like you
would do it in a programming language? I am using TOAD with Oracle 11g.
We have a huge SQL script involving tens of tables, subqueries, hundreds
of attributes. It works perfectly in the test database but returns sql
subquery returns more than 1 row error when running in the production
database. The script was working perfectly up until now. The problem is,
all I get is a one-line error specified above with no clues whatsoever
which exact subquery causes the error which makes it near to impossible to
debug. The question is, how am I supposed to know which line of the SQL
causes the error? Is there any way to "debug" it line by line like you
would do it in a programming language? I am using TOAD with Oracle 11g.
Bootstrap 3 - weird floating issue with 3 column responsive layout
Bootstrap 3 - weird floating issue with 3 column responsive layout
I have a problem with a three column layout in bootstrap 3.
When in Full Desktop View, I have a standard 3 col layout, but on
responsive, I have the 3rd column placed underneath and full width.
The problem I'm getting is that, on responsive, the 3rd column is becoming
100% height and overlapping the other 2 columns above.
See screenshots below.
I've replicated a simple example below.
<div class="row">
<div class="col-sm-2 col-lg-2"></div>
<div class="col-sm-8 col-lg-8"></div>
<div class="col-sm-12 col-lg-2"></div><!--full with on responsive view-->
</div>
Is this a known issue with bootstrap3? Or is my markup wrong?
DESKTOP LAYOUT
RESPONSIVE LAYOUT (the blue column is appearing over the top the green and
red)
Cheers
I have a problem with a three column layout in bootstrap 3.
When in Full Desktop View, I have a standard 3 col layout, but on
responsive, I have the 3rd column placed underneath and full width.
The problem I'm getting is that, on responsive, the 3rd column is becoming
100% height and overlapping the other 2 columns above.
See screenshots below.
I've replicated a simple example below.
<div class="row">
<div class="col-sm-2 col-lg-2"></div>
<div class="col-sm-8 col-lg-8"></div>
<div class="col-sm-12 col-lg-2"></div><!--full with on responsive view-->
</div>
Is this a known issue with bootstrap3? Or is my markup wrong?
DESKTOP LAYOUT
RESPONSIVE LAYOUT (the blue column is appearing over the top the green and
red)
Cheers
Good reasons against leading commas in Javascript
Good reasons against leading commas in Javascript
I recently joined a project where leading commas are used as a standard.
While I understand the reason of this style ( safe commenting of lines ),
It's very inconvenient (To put it mildly).
I have a strong feeling that it's not only about taste, and I need better
reasons than 'I don't like it' to convince the team not to use this style
..
Can you help me ?
Thanks.
p.s. Sample code:
function cls(){
var prop = {
a:'a'
,b:'b'
,c:'c'
,d:'d'
};
var arr = [
11
,12
,13
,14
];
var x=1
,y=2
,z=3;
return {
f:function(){
alert(prop.a);
}
, g:function(){
alert(arr[0]);
}
, h: function(){
alert(x);
}
};
}
var test = cls();
test.f();test.g();test.h();
I recently joined a project where leading commas are used as a standard.
While I understand the reason of this style ( safe commenting of lines ),
It's very inconvenient (To put it mildly).
I have a strong feeling that it's not only about taste, and I need better
reasons than 'I don't like it' to convince the team not to use this style
..
Can you help me ?
Thanks.
p.s. Sample code:
function cls(){
var prop = {
a:'a'
,b:'b'
,c:'c'
,d:'d'
};
var arr = [
11
,12
,13
,14
];
var x=1
,y=2
,z=3;
return {
f:function(){
alert(prop.a);
}
, g:function(){
alert(arr[0]);
}
, h: function(){
alert(x);
}
};
}
var test = cls();
test.f();test.g();test.h();
remove all the nodes which have greater value on right(Linked list)
remove all the nodes which have greater value on right(Linked list)
Given a singly linked list, remove all the nodes which have a greater
value on right side.
e.g.
input:
2--->4--->2--->1--->3--->0
then the output should be
4--->3--->0.
input:
30--->40--->50--->60
then the output should be
60
Given a singly linked list, remove all the nodes which have a greater
value on right side.
e.g.
input:
2--->4--->2--->1--->3--->0
then the output should be
4--->3--->0.
input:
30--->40--->50--->60
then the output should be
60
How to get asset images id in android
How to get asset images id in android
I need to set a list of images in ViewPager. I have a list of images in my
asset folder. I grouped the images in seperate folders inside asset like
assets/images; assets/images1,...... Now I need to get the id of the
images (say images1 alone) in int[] array. I got the name of the
images(images1) in String[] array. How to get the id of the images in
string[] using their names.
I need to set a list of images in ViewPager. I have a list of images in my
asset folder. I grouped the images in seperate folders inside asset like
assets/images; assets/images1,...... Now I need to get the id of the
images (say images1 alone) in int[] array. I got the name of the
images(images1) in String[] array. How to get the id of the images in
string[] using their names.
Wednesday, September 18, 2013
C - separating strings in the input stream
C - separating strings in the input stream
My program is supposed to be able to create new structures and store them
in an array, however, the commands for storing and displaying pose
difficulty.
To create a new variable struct in the array, the user inputs "set varname
varcontents
To display the contents of a variable, the user inputs "set varname"
To display all variables, the user inputs "set"
I can't quite figure out how to check if there are multiple strings ("set"
"varname" "varcontents") or if there is only "set"
char command[2][5] = { "set", "clear"};
printf("prompt> ");
scanf("%s",inputString);
if(strncmp(inputString,command[0],5) == 0 )
{
//code to create new struct, display structs etc...
}
else if(strncmp(inputString,command[1],5) == 0 )
{
//code to clear struct
}
Right now the if loop only passes if the user inputs "set". I could
probably take the comparison of the first few letters, and then take the
full comparison and subtract the first few characters to generate the name
of the new struct, but this seems too complicated, there must be an easier
solution.
Any help is appreciated!
My program is supposed to be able to create new structures and store them
in an array, however, the commands for storing and displaying pose
difficulty.
To create a new variable struct in the array, the user inputs "set varname
varcontents
To display the contents of a variable, the user inputs "set varname"
To display all variables, the user inputs "set"
I can't quite figure out how to check if there are multiple strings ("set"
"varname" "varcontents") or if there is only "set"
char command[2][5] = { "set", "clear"};
printf("prompt> ");
scanf("%s",inputString);
if(strncmp(inputString,command[0],5) == 0 )
{
//code to create new struct, display structs etc...
}
else if(strncmp(inputString,command[1],5) == 0 )
{
//code to clear struct
}
Right now the if loop only passes if the user inputs "set". I could
probably take the comparison of the first few letters, and then take the
full comparison and subtract the first few characters to generate the name
of the new struct, but this seems too complicated, there must be an easier
solution.
Any help is appreciated!
Making iPhone apps have transparent backgrounds
Making iPhone apps have transparent backgrounds
I'm having trouble making a iPhone icon, and can not get them to be
transparent. They either turn out black where the transparent part is
(Such as when you double tap the home button to see running apps) or have
a black glow to them. Another thing, what is this editing program? Because
I'm using notepad. http://i.stack.imgur.com/jYtCh.png
I'm having trouble making a iPhone icon, and can not get them to be
transparent. They either turn out black where the transparent part is
(Such as when you double tap the home button to see running apps) or have
a black glow to them. Another thing, what is this editing program? Because
I'm using notepad. http://i.stack.imgur.com/jYtCh.png
Add post variable to form with jQuery
Add post variable to form with jQuery
I have the below code which adds the value of the parameter to my form by
default. This works well but if you set the form to post then it no longer
works. What is the best approach to setting this value?
var request = {};
var pairs = location.search.substring(1).split('&');
for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i].split('=');
request[pair[0]] = pair[1];
}
var getfirstname = document.getElementById('firstname');
var firstname = request['firstname'];
getfirstname.setAttribute('value', firstname);
<form method="get" action="search">
<input type="text" name="firstname" id="firstname" />
<input type="submit" alt="Go" value="Go" border="0" />
</form>
www.example.com?firstname=john
<form method="get" action="search">
<input type="text" name="firstname" id="firstname" value="John" />
<input type="submit" alt="Go" value="Go" border="0" />
</form>
I have the below code which adds the value of the parameter to my form by
default. This works well but if you set the form to post then it no longer
works. What is the best approach to setting this value?
var request = {};
var pairs = location.search.substring(1).split('&');
for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i].split('=');
request[pair[0]] = pair[1];
}
var getfirstname = document.getElementById('firstname');
var firstname = request['firstname'];
getfirstname.setAttribute('value', firstname);
<form method="get" action="search">
<input type="text" name="firstname" id="firstname" />
<input type="submit" alt="Go" value="Go" border="0" />
</form>
www.example.com?firstname=john
<form method="get" action="search">
<input type="text" name="firstname" id="firstname" value="John" />
<input type="submit" alt="Go" value="Go" border="0" />
</form>
printing from an array struct by refrence
printing from an array struct by refrence
I used 6 functions. Three of them (read) are for scanning, and the other
ones are for printing (write).I checked the read funtions works correctlly
and the problem is mainly in one of the write funtions. the problem that I
scan integers from the user,and store them in a array of structers but
when it comes to printing them, i get only the last integers entred
#include<stdio.h>
#include<string.h>
typedef struct
{
char month[20];
int day;
int year;
} date_t;
typedef struct{
int hours;
int minutes;
int seconds;
}time_t;
typedef struct
{
char event[20];
time_t tm;
date_t dt;
}event_t;
int wr_event(const event_t*);
int wr_date(const event_t*);
int wr_time(const event_t*);
int rd_event(event_t*);
int rd_date(event_t*);
int rd_time(event_t*);
int main()
{
int i,j=0,temp=1;
event_t ev[5];
while(temp!=0&&j!=5)
{
rd_event(&ev[j]);
temp=strcmp(ev[j].event,"exit");
j++;
}
if(temp==0)j=j-1;
for(i=0;i<j;i++){
wr_event(&ev[i]);
}
}
int rd_time(event_t *ev)
{
printf("hours->");
scanf("%d",&ev->tm.hours);
printf("minutes->");
scanf("%d",&ev->tm.minutes);
printf("secondes->");
scanf("%d",&ev->tm.seconds);
}
int rd_date(event_t *ev)
{
printf("day-> ");
scanf("%d",&ev->dt.day);
fflush(stdin);
printf("month->");
gets(ev->dt.month);
printf("year->");
scanf("%d",&ev->dt.year);
}
int rd_event(event_t *ev)
{
printf("\nevent name->");
fflush(stdin);
gets(ev->event);
if(strcmp(ev->event,"exit")!=0){
rd_time(&ev);
rd_date(&ev);
}
}
int wr_time(const event_t *ev)
{
printf("this is the time of the event->%d %d
%d\n\n",ev->tm.hours,ev->tm.minutes,ev->tm.seconds);
}
int wr_date(const event_t *ev)
{
printf("this the date of the event-> %d %s
%d\n\n",ev->dt.day,ev->dt.month,ev->dt.year);
}
int wr_event(const event_t *ev)
{
printf("\nthis is your event-> %s\n\n",ev->event);
wr_time(&ev);
wr_date(&ev);
}
I used 6 functions. Three of them (read) are for scanning, and the other
ones are for printing (write).I checked the read funtions works correctlly
and the problem is mainly in one of the write funtions. the problem that I
scan integers from the user,and store them in a array of structers but
when it comes to printing them, i get only the last integers entred
#include<stdio.h>
#include<string.h>
typedef struct
{
char month[20];
int day;
int year;
} date_t;
typedef struct{
int hours;
int minutes;
int seconds;
}time_t;
typedef struct
{
char event[20];
time_t tm;
date_t dt;
}event_t;
int wr_event(const event_t*);
int wr_date(const event_t*);
int wr_time(const event_t*);
int rd_event(event_t*);
int rd_date(event_t*);
int rd_time(event_t*);
int main()
{
int i,j=0,temp=1;
event_t ev[5];
while(temp!=0&&j!=5)
{
rd_event(&ev[j]);
temp=strcmp(ev[j].event,"exit");
j++;
}
if(temp==0)j=j-1;
for(i=0;i<j;i++){
wr_event(&ev[i]);
}
}
int rd_time(event_t *ev)
{
printf("hours->");
scanf("%d",&ev->tm.hours);
printf("minutes->");
scanf("%d",&ev->tm.minutes);
printf("secondes->");
scanf("%d",&ev->tm.seconds);
}
int rd_date(event_t *ev)
{
printf("day-> ");
scanf("%d",&ev->dt.day);
fflush(stdin);
printf("month->");
gets(ev->dt.month);
printf("year->");
scanf("%d",&ev->dt.year);
}
int rd_event(event_t *ev)
{
printf("\nevent name->");
fflush(stdin);
gets(ev->event);
if(strcmp(ev->event,"exit")!=0){
rd_time(&ev);
rd_date(&ev);
}
}
int wr_time(const event_t *ev)
{
printf("this is the time of the event->%d %d
%d\n\n",ev->tm.hours,ev->tm.minutes,ev->tm.seconds);
}
int wr_date(const event_t *ev)
{
printf("this the date of the event-> %d %s
%d\n\n",ev->dt.day,ev->dt.month,ev->dt.year);
}
int wr_event(const event_t *ev)
{
printf("\nthis is your event-> %s\n\n",ev->event);
wr_time(&ev);
wr_date(&ev);
}
Azure Virtual machine is stuck at "starting"
Azure Virtual machine is stuck at "starting"
I'm testing Azure using my MSDN account. All went well, until I went over
my spending limit, after which my services were suspended.
After my account was re-enabled, I wanted to start my Virtual Machines
again. However they keep having status 'Starting'.
The user-interface of the Azure management portal seems to offer no
methods to remedy this situation.
Any ideas on how to reset these servers, or find a way to determine what
is keeping them from finishing the starting process?
I'm testing Azure using my MSDN account. All went well, until I went over
my spending limit, after which my services were suspended.
After my account was re-enabled, I wanted to start my Virtual Machines
again. However they keep having status 'Starting'.
The user-interface of the Azure management portal seems to offer no
methods to remedy this situation.
Any ideas on how to reset these servers, or find a way to determine what
is keeping them from finishing the starting process?
Programmatically enter text into input tag and programmatically "click" the submit button
Programmatically enter text into input tag and programmatically "click"
the submit button
How do I get user input and set that to the "giftcard #" and "access code"
fields at this website
I then want to extract this data.
To summarize, this app will get the text that the user wants to search,
fill it into the input value in the webpage, and finally retrieve the URL
that is the product of searching.
the submit button
How do I get user input and set that to the "giftcard #" and "access code"
fields at this website
I then want to extract this data.
To summarize, this app will get the text that the user wants to search,
fill it into the input value in the webpage, and finally retrieve the URL
that is the product of searching.
Try catch blocks in C++ dll's in MVS 2010
Try catch blocks in C++ dll's in MVS 2010
I have a code which imports a dll and calls its functions several times.
For certain inputs the dll function is throwing an exception, but for
others it works fine. After studying a bit about exceptions in dll here it
seems that the runtime exceptions are not handled in case of dll's in a
straightforward approach.
Here is my code
int main( void )
{
WORD_DATABASE wd=parse_data();
const char*
WorkingDirPath="C:\\Users\\Koustav\\Dropbox\\Project\\July07_PT
int UserID=1;
DEVICE_INFO_T test= TOP_LEFT;
HINSTANCE hinstLib;
// MYPROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
// Get a handle to the DLL module.
hinstLib = LoadLibrary(TEXT("Recog_Malayalam.dll"));
// If the handle is valid, try to get the function address.pppppp
if (hinstLib != NULL)
{
f_funci init = (f_funci)GetProcAddress(hinstLib,"abc");
f_funci1 reco = (f_funci1)GetProcAddress(hinstLib,"xyz");
// If the function address is valid, call the function.
int a = init(WorkingDirPath,1,(DEVICE_INFO_T)1);
for (int c3=0;c3<120;c3++)
{
try{
"<<wd.annotation_detail[c3].uni_val<<endl;
for (int c4=0;c4<wd.annotation_detail[c3].stroke_count;c4++)
{
log_cl<<wd.annotation_detail[c3].stroke_labels[c4]-1<<" ";
}
log_cl<<"Actual Values"<<endl;
cout<<endl;
//cout<<"Supplied stroke
label"<<wd.annotation_detail[c3].stroke_labels[0]<<endl;
int b=0;
try{
b =
reco(wd.word_db[c3],wd.annotation_detail[c3].stroke_count,PLAIN,0,'\0',1);
}
catch(exception e){
b=0;
cout<<"try_catch_success"<<endl;
}
//cout<<"Supplied stroke
label"<<wd.annotation_detail[c3].stroke_labels[0]<<endl;
cout<<endl;
}
catch(exception e){
cout<<"There is an exception"<<endl;
}
}
fFreeResult = FreeLibrary(hinstLib);
}
// If unable to call the DLL function, use an alternative.
if (! fRunTimeLinkSuccess)
getch();
return 0;
}
I have used try catch blocks in the dll as well. the error is coming from
the second function which is called multiple times.
I have changed the project properties as mentioned here and here. But I am
still getting this error. (I have changed the properties of the project
that creates the dll and also the one in which I call the dll)
Assuming I have no access to the dll , how can I fix this code? If
impossible, is it possible if I can access the dll?
Any help will be greatly appreciated
I have a code which imports a dll and calls its functions several times.
For certain inputs the dll function is throwing an exception, but for
others it works fine. After studying a bit about exceptions in dll here it
seems that the runtime exceptions are not handled in case of dll's in a
straightforward approach.
Here is my code
int main( void )
{
WORD_DATABASE wd=parse_data();
const char*
WorkingDirPath="C:\\Users\\Koustav\\Dropbox\\Project\\July07_PT
int UserID=1;
DEVICE_INFO_T test= TOP_LEFT;
HINSTANCE hinstLib;
// MYPROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
// Get a handle to the DLL module.
hinstLib = LoadLibrary(TEXT("Recog_Malayalam.dll"));
// If the handle is valid, try to get the function address.pppppp
if (hinstLib != NULL)
{
f_funci init = (f_funci)GetProcAddress(hinstLib,"abc");
f_funci1 reco = (f_funci1)GetProcAddress(hinstLib,"xyz");
// If the function address is valid, call the function.
int a = init(WorkingDirPath,1,(DEVICE_INFO_T)1);
for (int c3=0;c3<120;c3++)
{
try{
"<<wd.annotation_detail[c3].uni_val<<endl;
for (int c4=0;c4<wd.annotation_detail[c3].stroke_count;c4++)
{
log_cl<<wd.annotation_detail[c3].stroke_labels[c4]-1<<" ";
}
log_cl<<"Actual Values"<<endl;
cout<<endl;
//cout<<"Supplied stroke
label"<<wd.annotation_detail[c3].stroke_labels[0]<<endl;
int b=0;
try{
b =
reco(wd.word_db[c3],wd.annotation_detail[c3].stroke_count,PLAIN,0,'\0',1);
}
catch(exception e){
b=0;
cout<<"try_catch_success"<<endl;
}
//cout<<"Supplied stroke
label"<<wd.annotation_detail[c3].stroke_labels[0]<<endl;
cout<<endl;
}
catch(exception e){
cout<<"There is an exception"<<endl;
}
}
fFreeResult = FreeLibrary(hinstLib);
}
// If unable to call the DLL function, use an alternative.
if (! fRunTimeLinkSuccess)
getch();
return 0;
}
I have used try catch blocks in the dll as well. the error is coming from
the second function which is called multiple times.
I have changed the project properties as mentioned here and here. But I am
still getting this error. (I have changed the properties of the project
that creates the dll and also the one in which I call the dll)
Assuming I have no access to the dll , how can I fix this code? If
impossible, is it possible if I can access the dll?
Any help will be greatly appreciated
Adding the last element to string after array
Adding the last element to string after array
My storage string gives me all the digits in want besides the last, I know
its because the last digit has nothing to compare to the right. Can I add
the last digit to the end of my string somehow,
for(int i = 0;i < othercontent.length -1 ;i++ )
{
if(othercontent[i] != othercontent[i + 1])
{
storage = storage + othercontent[i];
}
}
My storage string gives me all the digits in want besides the last, I know
its because the last digit has nothing to compare to the right. Can I add
the last digit to the end of my string somehow,
for(int i = 0;i < othercontent.length -1 ;i++ )
{
if(othercontent[i] != othercontent[i + 1])
{
storage = storage + othercontent[i];
}
}
PHPExcel Reader Date Format Issue - rangeToArray
PHPExcel Reader Date Format Issue - rangeToArray
I am facing a Date format issue when reading excel using PHPExcel. Even I
used $objReader->setReadDataOnly(false); getting format of the cell but
not working for me. This how I am reading the data from Excel.
$get_excel_data =
$objPHPExcel->getActiveSheet()->rangeToArray("A1:".$highestColumn.$highestRow);
When I am trying to print date, it shows like 03/06/13, and I have tried
to convert in mysl date format using
date('Y-m-d',PHPExcel_Shared_Date::ExcelToPHP($val[1]))
But it is not working, Can anyone guide me to the issue ? The main problem
is I am not getting the date as number format ( Excel ), Instead of it
showing date as 03/06/13,
I am facing a Date format issue when reading excel using PHPExcel. Even I
used $objReader->setReadDataOnly(false); getting format of the cell but
not working for me. This how I am reading the data from Excel.
$get_excel_data =
$objPHPExcel->getActiveSheet()->rangeToArray("A1:".$highestColumn.$highestRow);
When I am trying to print date, it shows like 03/06/13, and I have tried
to convert in mysl date format using
date('Y-m-d',PHPExcel_Shared_Date::ExcelToPHP($val[1]))
But it is not working, Can anyone guide me to the issue ? The main problem
is I am not getting the date as number format ( Excel ), Instead of it
showing date as 03/06/13,
Tuesday, September 17, 2013
Event manager - this undefined in callback function
Event manager - this undefined in callback function
I am trying to create a custom javascript EventManager class and add some
callback functions. But when the callback function is called, the 'this'
object in the function is undefined. I looked at Custom Javascript
EventManager - please help me complete, but this doesn't answer my
questions completely.
Why is this and this.name undefined in this.onEvent? Please help, thank you.
Here is my jsfiddle: http://jsfiddle.net/Charissima/fswfv/3/
function arEventManager() {
this.callbacks = {};
this.addCallback = function(eventCategory, fn) {
if (!this.callbacks[eventCategory]) {
this.callbacks[eventCategory] = [];
}
if (fn instanceof Function) {
this.callbacks[eventCategory].push(fn);
}
return this;
}, // addCallback
this.dispatchEvent = function(eventCategory, params) {
// Callback-Funktion(en) ausloesen
for (var iC = 0, lC = this.callbacks[eventCategory].length; iC <
lC; iC++) {
console.log( this.callbacks[eventCategory][iC] );
this.callbacks[eventCategory][iC](params);
}
} // dispatchEvent
};
function arPerson() {
this.name;
this.setName = function(name) {
this.name = name;
},
this.getName = function() {
return (this.name);
},
this.onEvent = function(p2) {
alert('this.name = ' + this.name + ' / ' + 'p2.name = ' + p2.name);
}
};
var eventManager = new arEventManager;
var Thomas = new arPerson();
Thomas.setName('Thomas');
var Mike = new arPerson();
Mike.setName('Mike');
eventManager.addCallback("myEvent", Mike.onEvent);
function test() {
eventManager.dispatchEvent('myEvent', Thomas);
}
I am trying to create a custom javascript EventManager class and add some
callback functions. But when the callback function is called, the 'this'
object in the function is undefined. I looked at Custom Javascript
EventManager - please help me complete, but this doesn't answer my
questions completely.
Why is this and this.name undefined in this.onEvent? Please help, thank you.
Here is my jsfiddle: http://jsfiddle.net/Charissima/fswfv/3/
function arEventManager() {
this.callbacks = {};
this.addCallback = function(eventCategory, fn) {
if (!this.callbacks[eventCategory]) {
this.callbacks[eventCategory] = [];
}
if (fn instanceof Function) {
this.callbacks[eventCategory].push(fn);
}
return this;
}, // addCallback
this.dispatchEvent = function(eventCategory, params) {
// Callback-Funktion(en) ausloesen
for (var iC = 0, lC = this.callbacks[eventCategory].length; iC <
lC; iC++) {
console.log( this.callbacks[eventCategory][iC] );
this.callbacks[eventCategory][iC](params);
}
} // dispatchEvent
};
function arPerson() {
this.name;
this.setName = function(name) {
this.name = name;
},
this.getName = function() {
return (this.name);
},
this.onEvent = function(p2) {
alert('this.name = ' + this.name + ' / ' + 'p2.name = ' + p2.name);
}
};
var eventManager = new arEventManager;
var Thomas = new arPerson();
Thomas.setName('Thomas');
var Mike = new arPerson();
Mike.setName('Mike');
eventManager.addCallback("myEvent", Mike.onEvent);
function test() {
eventManager.dispatchEvent('myEvent', Thomas);
}
How to skip to next row w/o go through entire for..loop in vb.net
How to skip to next row w/o go through entire for..loop in vb.net
i want to skip to next row in below statement
For iRow = 0 To dsDiscnt.Tables(0).Rows.Count - 1
rowDiscnt = dsDiscnt.Tables(0).Rows(iRow)
If rowdiscnt.Item("x") = "S" Then
'skip to next row
Else
'continue loop
End If
'do something...
Next
how to skip to next row w/o go through the entire loop?
i want to skip to next row in below statement
For iRow = 0 To dsDiscnt.Tables(0).Rows.Count - 1
rowDiscnt = dsDiscnt.Tables(0).Rows(iRow)
If rowdiscnt.Item("x") = "S" Then
'skip to next row
Else
'continue loop
End If
'do something...
Next
how to skip to next row w/o go through the entire loop?
MVC Kendu UI - Script tag placement
MVC Kendu UI - Script tag placement
Can somebody please give me the exact way the scrips should be placed on
my layout page. no matter what way i do it I am getting diferent error or
some controls work and other dont or Im getting javascript errors.
My Layout page is like this:
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<title>Clients To Profits @ViewBag.Title</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Styles.Render("~/Content/kendo")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/kendo")
</head>
<body>
<header>
<div class="content-wrapper">
<div class="float-left">
<p class="site-title">@Html.ActionLink("your logo
here", "Index", "Home")</p>
</div>
<div class="float-right">
<section id="login">
@Html.Partial("_LoginPartial")
</section>
<nav>
<ul id="menu">
<li>@Html.ActionLink("User", "Index",
"UserView", new { area = "" }, null)</li>
<li>@Html.ActionLink("Home", "Index", "Home",
new { area = "" }, null)</li>
<li>@Html.ActionLink("API", "Index", "Help",
new { area = "" }, null)</li>
</ul>
</nav>
</div>
</div>
</header>
<div id="body">
@RenderSection("featured", required: false)
<section class="content-wrapper main-content clear-fix">
@RenderBody()
</section>
</div>
<footer>
<div class="content-wrapper">
<div class="float-left">
<p>© @DateTime.Now.Year - Pauper To President,
Inc.</p>
</div>
</div>
</footer>
@*@Scripts.Render("~/bundles/jquery")*@
@RenderSection("scripts", required: false)
</body>
all scripts being registered at the top. but none of the comboboxes are
being rendered correctly, but the date picker is being rendered correctly.
when I register the jquery bundle at the end right before the closing body
tag, none of the controls render correctly, and i get all these js errors:
**Uncaught ReferenceError: jQuery is not defined kendo.all.min.js:12
Uncaught TypeError: Cannot read property 'jQuery' of undefined
kendo.aspnetmvc.min.js:11
Uncaught ReferenceError: $ is not defined Create:61
Uncaught ReferenceError: jQuery is not defined Create:106
Uncaught ReferenceError: jQuery is not defined Create:116**
The kenduUI version is at 1.9.1, but I am actually registering jquery
2.0.3. When I try to use 1.9.1 and register it at the bottom I get these
errors:
GET http://localhost:7731/Scripts/kendo/2013.2.716/jquery.min.map 404 (Not
Found)
I have spent 2 days trying to figure out what the problem is, can somebody
please help, who has figured this out already.
Can somebody please give me the exact way the scrips should be placed on
my layout page. no matter what way i do it I am getting diferent error or
some controls work and other dont or Im getting javascript errors.
My Layout page is like this:
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<title>Clients To Profits @ViewBag.Title</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Styles.Render("~/Content/kendo")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/kendo")
</head>
<body>
<header>
<div class="content-wrapper">
<div class="float-left">
<p class="site-title">@Html.ActionLink("your logo
here", "Index", "Home")</p>
</div>
<div class="float-right">
<section id="login">
@Html.Partial("_LoginPartial")
</section>
<nav>
<ul id="menu">
<li>@Html.ActionLink("User", "Index",
"UserView", new { area = "" }, null)</li>
<li>@Html.ActionLink("Home", "Index", "Home",
new { area = "" }, null)</li>
<li>@Html.ActionLink("API", "Index", "Help",
new { area = "" }, null)</li>
</ul>
</nav>
</div>
</div>
</header>
<div id="body">
@RenderSection("featured", required: false)
<section class="content-wrapper main-content clear-fix">
@RenderBody()
</section>
</div>
<footer>
<div class="content-wrapper">
<div class="float-left">
<p>© @DateTime.Now.Year - Pauper To President,
Inc.</p>
</div>
</div>
</footer>
@*@Scripts.Render("~/bundles/jquery")*@
@RenderSection("scripts", required: false)
</body>
all scripts being registered at the top. but none of the comboboxes are
being rendered correctly, but the date picker is being rendered correctly.
when I register the jquery bundle at the end right before the closing body
tag, none of the controls render correctly, and i get all these js errors:
**Uncaught ReferenceError: jQuery is not defined kendo.all.min.js:12
Uncaught TypeError: Cannot read property 'jQuery' of undefined
kendo.aspnetmvc.min.js:11
Uncaught ReferenceError: $ is not defined Create:61
Uncaught ReferenceError: jQuery is not defined Create:106
Uncaught ReferenceError: jQuery is not defined Create:116**
The kenduUI version is at 1.9.1, but I am actually registering jquery
2.0.3. When I try to use 1.9.1 and register it at the bottom I get these
errors:
GET http://localhost:7731/Scripts/kendo/2013.2.716/jquery.min.map 404 (Not
Found)
I have spent 2 days trying to figure out what the problem is, can somebody
please help, who has figured this out already.
Combining matrices by alternating columns
Combining matrices by alternating columns
I'm looking for a general approach to combine two matrices so that the
columns from the two initial matrices alternate in the new matrix
col1m1...col1m2...col2m1...col2m2...col3m1...col3m2......
for example:
matrix.odd=matrix(c(rep(1,3),rep(3,3),rep(5,3)),nrow=3,ncol=3)
matrix.even=matrix(c(rep(2,3),rep(4,3),rep(6,3)),nrow=3,ncol=3)
# would look like
matrix.combined=matrix(c(rep(1,3),rep(2,3),rep(3,3),rep(4,3),rep(5,3),rep(6,3)),nrow=3,ncol=6)
I'm looking for a general approach because I will have matrix combinations
with more than just 3 columns. I've tried some for loops and some if
statements but it isn't really coming together for me. Searches on
combining matrices with shuffle and with alternation have not proven
fruitful either. Any thoughts?
I'm looking for a general approach to combine two matrices so that the
columns from the two initial matrices alternate in the new matrix
col1m1...col1m2...col2m1...col2m2...col3m1...col3m2......
for example:
matrix.odd=matrix(c(rep(1,3),rep(3,3),rep(5,3)),nrow=3,ncol=3)
matrix.even=matrix(c(rep(2,3),rep(4,3),rep(6,3)),nrow=3,ncol=3)
# would look like
matrix.combined=matrix(c(rep(1,3),rep(2,3),rep(3,3),rep(4,3),rep(5,3),rep(6,3)),nrow=3,ncol=6)
I'm looking for a general approach because I will have matrix combinations
with more than just 3 columns. I've tried some for loops and some if
statements but it isn't really coming together for me. Searches on
combining matrices with shuffle and with alternation have not proven
fruitful either. Any thoughts?
Python IF statement to see how long an input has been active
Python IF statement to see how long an input has been active
I am using a raspberry pi, a pi face and a python script to monitor
several home sensors. I want to add the sensing wire from the smoke
detectors to that list but I need a bit of help with the if statement.
I'm unsure how to tell the if statement to check how long the input has
detected the signal. Under 4 seconds disregard (low battery chirp), over 4
seconds (smoke detected) alert me..
Basically I need help writing the if statement below.
if piface.digital_read(0)==0 >= 4 seconds:
# do x
else:
# do y
Do I need a loop and can it be as easy as what I have above? (Coded
correctly of course!)
I am using a raspberry pi, a pi face and a python script to monitor
several home sensors. I want to add the sensing wire from the smoke
detectors to that list but I need a bit of help with the if statement.
I'm unsure how to tell the if statement to check how long the input has
detected the signal. Under 4 seconds disregard (low battery chirp), over 4
seconds (smoke detected) alert me..
Basically I need help writing the if statement below.
if piface.digital_read(0)==0 >= 4 seconds:
# do x
else:
# do y
Do I need a loop and can it be as easy as what I have above? (Coded
correctly of course!)
Unable to install joomla in localhost
Unable to install joomla in localhost
today i was trying to install joomla on localhost but with web installer
after filling configuration info when i click next nothing happens but
just an processing image is displayed as shown in image I tried with
different browsers but same problem is everywhere,I have left it for 15-20
minutes ,restarted server/laptop yet same problem.I knew there is no
problem with installation source as I have already installed it before.
Well I am using EasyPHP-DevServer-13.1VC11 Please help!! I have wordpress
installed in my computer and it have no issues..
today i was trying to install joomla on localhost but with web installer
after filling configuration info when i click next nothing happens but
just an processing image is displayed as shown in image I tried with
different browsers but same problem is everywhere,I have left it for 15-20
minutes ,restarted server/laptop yet same problem.I knew there is no
problem with installation source as I have already installed it before.
Well I am using EasyPHP-DevServer-13.1VC11 Please help!! I have wordpress
installed in my computer and it have no issues..
Sunday, September 15, 2013
Java : Custom Timestamp : verify format to microsec precision and verify value to min precison
Java : Custom Timestamp : verify format to microsec precision and verify
value to min precison
My Objective is to create a java class that can handle the below two
requirements
1. Verify if the format of a timestamp matches with expected format.
CCYY-MM-DD'T'hh:mm:ss'.0000000000+'uh:um"
Ex: the expected format is not static. It may be either of these
"2013-09-10T18:30:20.123456+10:00" or "2013-09-10T18:30:20.123+10:00".
I am not bothered about the precision and value. Only the format matters.
2. Verify if the timestamp is in a certain range.
Ex: Verify if the timestamp is in between "2013-09-10 18:27" and
"2013-09-10 18:33". (verification is only upto minute level precision)
(may be a delta of + or - 2min)
Based on analysis from various search results, below is my understanding :
Java (by default) does not parse/format Timestamp at microsecond level( I
used SimpleDateFormat)
If 6 digits are given in milliseconds place, it will re-calculate the
value into seconds and the dateformat will be updated and the new
dateformat will have 3 digits in milliseconds precision.
I have also seen a thread which suggests to use java.sql.Timestamp.
Tried this approach but not working.
I was not able to convert my strTimestamp 2013-09-10T18:30:20.123456+10:00
into Timestamp object. I used
Timestamp ts = Timestamp.valueOf(strTimestamp);
java.lang.IllegalArgumentException:
Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]
How can I convert my input format into Timestamp object ?
Workaround for first objective : Validate using regular expression :
2013-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])T(0[0-9]|1[0-9]|2[0-3]):(0[0-9]|[1-5][0-9]):(0[0-9]|[1-5][0-9]).[0-9][0-9][0-9][0-9][0-9][0-9]\+10:00
But I would like to know if there is any robust solution in java, which
can be self sufficient even if the expected format changes. Is there
something that can be in java to validate the format.
For the second objective : to verify the range:
String date = "2013-09-10T18:30:12.123456789+10:00"
SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMddHHmm");
date = date.substring(0,22)+"+10:00";
Date newDate = df.parse(date);
timestamp_value = df2.format(newDate);
timestamp_value is now 201309101830
Checked if timestamp_value is greater than 201309101827.
Checked if timestamp_value is lesser_ than 201309101833 This works fine.
however, i feel this i a crude way of achieving it, so I would like to
know if there is any better solution. If i could convert to Timestamp
object, i think .before and .after can help. Any suggestions ?
value to min precison
My Objective is to create a java class that can handle the below two
requirements
1. Verify if the format of a timestamp matches with expected format.
CCYY-MM-DD'T'hh:mm:ss'.0000000000+'uh:um"
Ex: the expected format is not static. It may be either of these
"2013-09-10T18:30:20.123456+10:00" or "2013-09-10T18:30:20.123+10:00".
I am not bothered about the precision and value. Only the format matters.
2. Verify if the timestamp is in a certain range.
Ex: Verify if the timestamp is in between "2013-09-10 18:27" and
"2013-09-10 18:33". (verification is only upto minute level precision)
(may be a delta of + or - 2min)
Based on analysis from various search results, below is my understanding :
Java (by default) does not parse/format Timestamp at microsecond level( I
used SimpleDateFormat)
If 6 digits are given in milliseconds place, it will re-calculate the
value into seconds and the dateformat will be updated and the new
dateformat will have 3 digits in milliseconds precision.
I have also seen a thread which suggests to use java.sql.Timestamp.
Tried this approach but not working.
I was not able to convert my strTimestamp 2013-09-10T18:30:20.123456+10:00
into Timestamp object. I used
Timestamp ts = Timestamp.valueOf(strTimestamp);
java.lang.IllegalArgumentException:
Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]
How can I convert my input format into Timestamp object ?
Workaround for first objective : Validate using regular expression :
2013-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])T(0[0-9]|1[0-9]|2[0-3]):(0[0-9]|[1-5][0-9]):(0[0-9]|[1-5][0-9]).[0-9][0-9][0-9][0-9][0-9][0-9]\+10:00
But I would like to know if there is any robust solution in java, which
can be self sufficient even if the expected format changes. Is there
something that can be in java to validate the format.
For the second objective : to verify the range:
String date = "2013-09-10T18:30:12.123456789+10:00"
SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMddHHmm");
date = date.substring(0,22)+"+10:00";
Date newDate = df.parse(date);
timestamp_value = df2.format(newDate);
timestamp_value is now 201309101830
Checked if timestamp_value is greater than 201309101827.
Checked if timestamp_value is lesser_ than 201309101833 This works fine.
however, i feel this i a crude way of achieving it, so I would like to
know if there is any better solution. If i could convert to Timestamp
object, i think .before and .after can help. Any suggestions ?
Illegal start of expression for static classes?
Illegal start of expression for static classes?
I'm new to Java. I want to display a Jframe with two buttons in it. Upon
clicking each button a different JOptionPane message should show. However
I'm getting the error Illegal start of expression on both the static class
declarations.
can anyone explain why? I've tried moving the static classes but still the
same error.
Here is my code...
import javax.swing.JOptionPane;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
public class main {
public main() {
}
public static void main(String[] args) {
String name = JOptionPane.showInputDialog(null,
"What's your name?", "Enter your name",
JOptionPane.PLAIN_MESSAGE);
System.out.println("\nWelcome, "+ name + ".");
System.out.print(terms);
JOptionPane.showMessageDialog(null, "Welcome to
SkyWhale, " + name + ".\n" + deets + "\n" + terms ,
"Welcome, " + name + ".", JOptionPane.PLAIN_MESSAGE);
JFrame control = new JFrame("SkyWhale");
control.setVisible(true);
control.setSize(500,200);
control.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
JButton chatbtn = new JButton("Live Chat");
JButton editorbtn = new JButton("Editor");
control.add(panel);
panel.add(chatbtn);
panel.add(editorbtn);
chatbtn.addActionListener(goToChat());
editorbtn.addActionListener(goToEdit());
static class goToEdit implements ActionListener {
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null, "Code goes
here...", "Editor",
JOptionPane.PLAIN_MESSAGE);
}
}
static class goToChat implements ActionListener {
public void actionPerformed (ActionEvent e)
{
JOptionPane.showMessageDialog(null,
"Conversation...", "Live Chat",
JOptionPane.PLAIN_MESSAGE);
}
}
}
}
}
I'm new to Java. I want to display a Jframe with two buttons in it. Upon
clicking each button a different JOptionPane message should show. However
I'm getting the error Illegal start of expression on both the static class
declarations.
can anyone explain why? I've tried moving the static classes but still the
same error.
Here is my code...
import javax.swing.JOptionPane;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
public class main {
public main() {
}
public static void main(String[] args) {
String name = JOptionPane.showInputDialog(null,
"What's your name?", "Enter your name",
JOptionPane.PLAIN_MESSAGE);
System.out.println("\nWelcome, "+ name + ".");
System.out.print(terms);
JOptionPane.showMessageDialog(null, "Welcome to
SkyWhale, " + name + ".\n" + deets + "\n" + terms ,
"Welcome, " + name + ".", JOptionPane.PLAIN_MESSAGE);
JFrame control = new JFrame("SkyWhale");
control.setVisible(true);
control.setSize(500,200);
control.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
JButton chatbtn = new JButton("Live Chat");
JButton editorbtn = new JButton("Editor");
control.add(panel);
panel.add(chatbtn);
panel.add(editorbtn);
chatbtn.addActionListener(goToChat());
editorbtn.addActionListener(goToEdit());
static class goToEdit implements ActionListener {
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null, "Code goes
here...", "Editor",
JOptionPane.PLAIN_MESSAGE);
}
}
static class goToChat implements ActionListener {
public void actionPerformed (ActionEvent e)
{
JOptionPane.showMessageDialog(null,
"Conversation...", "Live Chat",
JOptionPane.PLAIN_MESSAGE);
}
}
}
}
}
Select adjacent couples (or triads, etc ) from a list
Select adjacent couples (or triads, etc ) from a list
I can do it by making use of the list indexes ...
lst =[1,2,3,4,5,6]
[ [lst[i] , lst[i+1]] for i in range( len(lst) - 1 )]
or:
lst =[1,2,3,4,5,6]
for i in range(len(lst)-1):
entities.append([lst[i],lst[i+1]])
But is there a smarter way? Maybe using iterators? What about performance?
I can do it by making use of the list indexes ...
lst =[1,2,3,4,5,6]
[ [lst[i] , lst[i+1]] for i in range( len(lst) - 1 )]
or:
lst =[1,2,3,4,5,6]
for i in range(len(lst)-1):
entities.append([lst[i],lst[i+1]])
But is there a smarter way? Maybe using iterators? What about performance?
Media Player Control stretch to fit window size
Media Player Control stretch to fit window size
I have the following code to load media and display it using Media Player
Control:
MediaPlayer Player = new MediaPlayer();
Player.Open(new Uri(videoURI, UriKind.Absolute));
VideoDrawing aVideoDrawing = new VideoDrawing();
aVideoDrawing.Rect = new Rect(0, 0, 100, 100);
aVideoDrawing.Player = Player;
DrawingBrush brush = new DrawingBrush(aVideoDrawing);
this.Background = brush;
No matter what is the size of the movie I play, it stretches to 1920x1080
(the window size).
I want it to be in the original full size and if the height/width is less
then 1920/1080 it will center the video.
Since there's no physical control, I have no Idea how to do it...
Will appreciate your help.
I have the following code to load media and display it using Media Player
Control:
MediaPlayer Player = new MediaPlayer();
Player.Open(new Uri(videoURI, UriKind.Absolute));
VideoDrawing aVideoDrawing = new VideoDrawing();
aVideoDrawing.Rect = new Rect(0, 0, 100, 100);
aVideoDrawing.Player = Player;
DrawingBrush brush = new DrawingBrush(aVideoDrawing);
this.Background = brush;
No matter what is the size of the movie I play, it stretches to 1920x1080
(the window size).
I want it to be in the original full size and if the height/width is less
then 1920/1080 it will center the video.
Since there's no physical control, I have no Idea how to do it...
Will appreciate your help.
Concurrency issues in android sqlitehelper
Concurrency issues in android sqlitehelper
i'm developing an app that uses sqlite database in android, and recently
i'm having frequent crashes that i think are related with concurrent
database access, altough the db exception is does not mention it..
here is the error:
09-15 15:25:45.672 195-1476/system_process V/ActivityManager©s Record
#1 ActivityRecord{a52ecf58 u0 com.pauloslf.efatura/.MenuInicial}:
app=ProcessRecord{a5317d60 0:com.pauloslf.efatura/u0a10049}
09-15 15:25:45.672 195-1476/system_process I/ActivityManager©s
Removing activity ActivityRecord{a52ecf58 u0
com.pauloslf.efatura/.MenuInicial} from stack at 1: haveState=false
stateNotNeeded=false finishing=true state=PAUSING
java.lang.RuntimeException: here
at
com.android.server.am.ActivityStack.removeHistoryRecordsForAppLocked(ActivityStack.java:4249)
at
com.android.server.am.ActivityManagerService.handleAppDiedLocked(ActivityManagerService.java:3015)
at
com.android.server.am.ActivityManagerService.appDiedLocked(ActivityManagerService.java:3085)
at
com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied(ActivityManagerService.java:897)
at android.os.BinderProxy.sendDeathNotice(Binder.java:470)
at dalvik.system.NativeStart.run(Native Method)
09-15 15:25:45.672 195-490/system_process W/InputDispatcher©s channel
'a5239e68 com.pauloslf.efatura/com.pauloslf.efatura.MenuInicial (server)'
~ Consumer closed input channel or an error occurred. events=0x9
09-15 15:25:45.672 195-490/system_process E/InputDispatcher©s channel
'a5239e68 com.pauloslf.efatura/com.pauloslf.efatura.MenuInicial (server)'
~ Channel is unrecoverably broken and will be disposed!
09-15 15:25:45.672 195-1476/system_process V/ActivityManager©s No
result destination from ActivityRecord{a52ecf58 u0
com.pauloslf.efatura/.MenuInicial}
09-15 15:25:45.676 119-119/? D/Zygote©s Process 3287 terminated by
signal (11)
09-15 15:25:45.684 195-1915/system_process W/InputDispatcher©s
Attempted to unregister already unregistered input channel 'a5239e68
com.pauloslf.efatura/com.pauloslf.efatura.MenuInicial (server)'
I'm accessing the db class using a singleton:
private static FacturasDB faturasdb = null;
public static FacturasDB getInstance(Context context) {
if (faturasdb == null) {
faturasdb = new FacturasDB(context);
}
return faturasdb;
}
The most easy way for me to reproduce the issue is when the asynctask
started on the main activity (does db access on the background) is running
and i navigate to another activity that also uses the db..
Any idea why this issue happens ?
Thanks a lot in advance!
i'm developing an app that uses sqlite database in android, and recently
i'm having frequent crashes that i think are related with concurrent
database access, altough the db exception is does not mention it..
here is the error:
09-15 15:25:45.672 195-1476/system_process V/ActivityManager©s Record
#1 ActivityRecord{a52ecf58 u0 com.pauloslf.efatura/.MenuInicial}:
app=ProcessRecord{a5317d60 0:com.pauloslf.efatura/u0a10049}
09-15 15:25:45.672 195-1476/system_process I/ActivityManager©s
Removing activity ActivityRecord{a52ecf58 u0
com.pauloslf.efatura/.MenuInicial} from stack at 1: haveState=false
stateNotNeeded=false finishing=true state=PAUSING
java.lang.RuntimeException: here
at
com.android.server.am.ActivityStack.removeHistoryRecordsForAppLocked(ActivityStack.java:4249)
at
com.android.server.am.ActivityManagerService.handleAppDiedLocked(ActivityManagerService.java:3015)
at
com.android.server.am.ActivityManagerService.appDiedLocked(ActivityManagerService.java:3085)
at
com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied(ActivityManagerService.java:897)
at android.os.BinderProxy.sendDeathNotice(Binder.java:470)
at dalvik.system.NativeStart.run(Native Method)
09-15 15:25:45.672 195-490/system_process W/InputDispatcher©s channel
'a5239e68 com.pauloslf.efatura/com.pauloslf.efatura.MenuInicial (server)'
~ Consumer closed input channel or an error occurred. events=0x9
09-15 15:25:45.672 195-490/system_process E/InputDispatcher©s channel
'a5239e68 com.pauloslf.efatura/com.pauloslf.efatura.MenuInicial (server)'
~ Channel is unrecoverably broken and will be disposed!
09-15 15:25:45.672 195-1476/system_process V/ActivityManager©s No
result destination from ActivityRecord{a52ecf58 u0
com.pauloslf.efatura/.MenuInicial}
09-15 15:25:45.676 119-119/? D/Zygote©s Process 3287 terminated by
signal (11)
09-15 15:25:45.684 195-1915/system_process W/InputDispatcher©s
Attempted to unregister already unregistered input channel 'a5239e68
com.pauloslf.efatura/com.pauloslf.efatura.MenuInicial (server)'
I'm accessing the db class using a singleton:
private static FacturasDB faturasdb = null;
public static FacturasDB getInstance(Context context) {
if (faturasdb == null) {
faturasdb = new FacturasDB(context);
}
return faturasdb;
}
The most easy way for me to reproduce the issue is when the asynctask
started on the main activity (does db access on the background) is running
and i navigate to another activity that also uses the db..
Any idea why this issue happens ?
Thanks a lot in advance!
javascript regex for special characters
javascript regex for special characters
I'm trying to create a validation for a password field which allows only
the a-zA-Z0-9 characters and .!@#$%^&*()_+-=
I can't seem to get the hang of it.
What's the difference when using regex = /a-zA-Z0-9/g and regex =
/[a-zA-Z0-9]/ and which chars from .!@#$%^&*()_+-= are needed to be
escaped?
What I've tried up to now is:
var regex = /a-zA-Z0-9!@#\$%\^\&*\)\(+=._-/g
but with no success
I'm trying to create a validation for a password field which allows only
the a-zA-Z0-9 characters and .!@#$%^&*()_+-=
I can't seem to get the hang of it.
What's the difference when using regex = /a-zA-Z0-9/g and regex =
/[a-zA-Z0-9]/ and which chars from .!@#$%^&*()_+-= are needed to be
escaped?
What I've tried up to now is:
var regex = /a-zA-Z0-9!@#\$%\^\&*\)\(+=._-/g
but with no success
Share kit in iOS
Share kit in iOS
I have develop application which need to share application data with
facebook I add facebook share kit arc It work fine to open application but
when I enter facebook app key in shkconfig ad run app then with new
facebook I'd it display first screen whrn I press ok then it display white
screen which not close when I see facebook time line then post s not
generated After second time it display page you requested was not found I
try lots of time but it not work but with same style other application it
work so how to recover that issue
I have develop application which need to share application data with
facebook I add facebook share kit arc It work fine to open application but
when I enter facebook app key in shkconfig ad run app then with new
facebook I'd it display first screen whrn I press ok then it display white
screen which not close when I see facebook time line then post s not
generated After second time it display page you requested was not found I
try lots of time but it not work but with same style other application it
work so how to recover that issue
Saturday, September 14, 2013
edge detection of histogram - python
edge detection of histogram - python
Basically I have some data that I have mad a histogram from. No great
difficulty there, just use matplotlib.pyplot.hist(data,bins=num) However,
I want to do a kind-of Sobel edge detection where basically the ith
histogram bar/bin (whatever the jargon is) becomes
-2*(i-1)th+0*(i)th+2*(i+1)th I have worked out/found out that you can do
(my data is in columnated txt files)
import matplotlib.pyplot as plt
alldata = np.genfromtxt('filename', delimiter=' ')
data = alldata[:,18]
n,bins,patches = plt.hist(data,bins=30)
Which returns/gives
>>> n
array([3,0,3,3,6,1,...etc])
>>> bins
array([13.755,14.0298,14.3046,... etc])
>>> patches
<a list of 30 Patch objects>
Here I can perform my operation on n to get my sobel-filtered stuff, (Side
note: I just do this iteratively over the array is there an easier way
with something like a = [-2,0,2])
So, my question and problem! I have no idea how to then reconstruct the
result as a histogram or line-plot ... AND keep the same horizontal axis
bins
Basically I have some data that I have mad a histogram from. No great
difficulty there, just use matplotlib.pyplot.hist(data,bins=num) However,
I want to do a kind-of Sobel edge detection where basically the ith
histogram bar/bin (whatever the jargon is) becomes
-2*(i-1)th+0*(i)th+2*(i+1)th I have worked out/found out that you can do
(my data is in columnated txt files)
import matplotlib.pyplot as plt
alldata = np.genfromtxt('filename', delimiter=' ')
data = alldata[:,18]
n,bins,patches = plt.hist(data,bins=30)
Which returns/gives
>>> n
array([3,0,3,3,6,1,...etc])
>>> bins
array([13.755,14.0298,14.3046,... etc])
>>> patches
<a list of 30 Patch objects>
Here I can perform my operation on n to get my sobel-filtered stuff, (Side
note: I just do this iteratively over the array is there an easier way
with something like a = [-2,0,2])
So, my question and problem! I have no idea how to then reconstruct the
result as a histogram or line-plot ... AND keep the same horizontal axis
bins
Arrays.asList type conversion issue
Arrays.asList type conversion issue
I'm studying the book Thinking in java piece of code is as follows: My
question is why no type conversion exception the new Light() and new
Heavy() is Power type
List snow4 = Arrays.asList(new Light(), new Heavy());
package com.yanbit.collection.basic;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
class Snow {
}
class Powder extends Snow {
}
class Crusty extends Snow {
}
class Stush extends Snow {
}
class Light extends Powder{}
class Heavy extends Powder {
}
public class AsListInference {
public static void main(String[] args) {
// swith list<Snow>
List<Snow> snow1 = Arrays.asList(new Powder(), new Crusty(),
new Stush());
// List<Snow> snow2 = Arrays.asList(new Light(), new Heavy());
// type list<power>
List<Snow> snow3=new ArrayList<Snow>();
Collections.addAll(snow3, new Light(), new Heavy());// implict type
List<Snow> snow4 = Arrays.<Snow> asList(new Light(), new Heavy());
}
}
I'm studying the book Thinking in java piece of code is as follows: My
question is why no type conversion exception the new Light() and new
Heavy() is Power type
List snow4 = Arrays.asList(new Light(), new Heavy());
package com.yanbit.collection.basic;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
class Snow {
}
class Powder extends Snow {
}
class Crusty extends Snow {
}
class Stush extends Snow {
}
class Light extends Powder{}
class Heavy extends Powder {
}
public class AsListInference {
public static void main(String[] args) {
// swith list<Snow>
List<Snow> snow1 = Arrays.asList(new Powder(), new Crusty(),
new Stush());
// List<Snow> snow2 = Arrays.asList(new Light(), new Heavy());
// type list<power>
List<Snow> snow3=new ArrayList<Snow>();
Collections.addAll(snow3, new Light(), new Heavy());// implict type
List<Snow> snow4 = Arrays.<Snow> asList(new Light(), new Heavy());
}
}
File.createNewFile() failing in java (Ubuntu 12.04)
File.createNewFile() failing in java (Ubuntu 12.04)
I am trying to createNewFile() in java.I have written down the following
example.I have compiled it but am getting a run time error.
import java.io.File;
import java.io.IOException;
public class CreateFileExample
{
public static void main(String [] args)
{
try
{
File file = new File("home/karthik/newfile.txt");
if(file.createNewFile())
{
System.out.println("created new fle");
}else
{
System.out.println("could not create a new
file");
}
}catch(IOException e )
{
e.printStackTrace();
}
}
}
It is compiling OK.The run time error that I am getting is
java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:947)
at CreateFileExample.main(CreateFileExample.java:16)
I am trying to createNewFile() in java.I have written down the following
example.I have compiled it but am getting a run time error.
import java.io.File;
import java.io.IOException;
public class CreateFileExample
{
public static void main(String [] args)
{
try
{
File file = new File("home/karthik/newfile.txt");
if(file.createNewFile())
{
System.out.println("created new fle");
}else
{
System.out.println("could not create a new
file");
}
}catch(IOException e )
{
e.printStackTrace();
}
}
}
It is compiling OK.The run time error that I am getting is
java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:947)
at CreateFileExample.main(CreateFileExample.java:16)
Check if variable is set in function call
Check if variable is set in function call
I have a little issue:
<?=$this->bs_forms->text_input('last_name','Name', $user->last_name);?>
If the last variable $user, does not exist I currently get some PHP
errors. My solution was this:
<?=$this->bs_forms->text_input('last_name','Last Name', (isset($user))?
$user->last_name : NULL);?>
But that's seems a bit hacky. Is there a better way to do this?
I have a little issue:
<?=$this->bs_forms->text_input('last_name','Name', $user->last_name);?>
If the last variable $user, does not exist I currently get some PHP
errors. My solution was this:
<?=$this->bs_forms->text_input('last_name','Last Name', (isset($user))?
$user->last_name : NULL);?>
But that's seems a bit hacky. Is there a better way to do this?
SQL syntax error in trigger
SQL syntax error in trigger
Can someone tell me what this sql does not work? Where is the syntax error?
SET NEW.`modified` = CURTIME() WHERE `id` = NEW.id;
Error:
One or more errors have occured while processing your request: The
following query has failed: "CREATE DEFINER=root@localhost TRIGGER
event_name BEFORE UPDATE ON clients FOR EACH ROW SET NEW.modified =
CURTIME() WHERE id = NEW.id;" MySQL said: #1064 - You have an error in
your SQL syntax; check the manual that corresponds to your MariaDB server
version for the right syntax to use near 'WHERE id = NEW.id' at line 1
Image shows the error http://s23.postimg.org/rhsf2x1tn/screenshot.png
Can someone tell me what this sql does not work? Where is the syntax error?
SET NEW.`modified` = CURTIME() WHERE `id` = NEW.id;
Error:
One or more errors have occured while processing your request: The
following query has failed: "CREATE DEFINER=root@localhost TRIGGER
event_name BEFORE UPDATE ON clients FOR EACH ROW SET NEW.modified =
CURTIME() WHERE id = NEW.id;" MySQL said: #1064 - You have an error in
your SQL syntax; check the manual that corresponds to your MariaDB server
version for the right syntax to use near 'WHERE id = NEW.id' at line 1
Image shows the error http://s23.postimg.org/rhsf2x1tn/screenshot.png
Segmentation fault: 11; range-based for loop
Segmentation fault: 11; range-based for loop
I'm working on a small programming exercise in C++. Goal is to initiate an
array with the first 32 exponentations of 2 and to output them afterwards.
Using a normal for loop there's no problem but I tried to use the
range-based for loop introduced in the C++11 standard. During compilation
I get the warning "range-based for loop is a C++11 extension
[-Wc++11-extensions]". Running the program I get the error "Segmentation
fault: 11" without any further output.
I got already that the elem variable somehow is broken but I don't know
how. Hope you can help a n00b :)
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
const int LAENGE = 32;
long potenzen[LAENGE];
for(int elem : potenzen)
{
potenzen[elem] = pow(2.0, (double) (elem + 1));
}
for(int elem : potenzen)
{
cout << endl;
cout << potenzen[elem];
}
cout << endl;
return 0;
}
I'm working on a small programming exercise in C++. Goal is to initiate an
array with the first 32 exponentations of 2 and to output them afterwards.
Using a normal for loop there's no problem but I tried to use the
range-based for loop introduced in the C++11 standard. During compilation
I get the warning "range-based for loop is a C++11 extension
[-Wc++11-extensions]". Running the program I get the error "Segmentation
fault: 11" without any further output.
I got already that the elem variable somehow is broken but I don't know
how. Hope you can help a n00b :)
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
const int LAENGE = 32;
long potenzen[LAENGE];
for(int elem : potenzen)
{
potenzen[elem] = pow(2.0, (double) (elem + 1));
}
for(int elem : potenzen)
{
cout << endl;
cout << potenzen[elem];
}
cout << endl;
return 0;
}
How to define a different bold font in Android textview
How to define a different bold font in Android textview
I need to use a different font for the bold elements in HTML text rendered
in an Android textview.
I tried doing it this way, but it looks like the Typeface style argument
just sets the entire textview to normal or bold, rather than setting the
font for that style in the textview.
TextView tv = (TextView) dialogView.findViewById(R.id.textInstructions);
String instructions = "<b>Headline</b><br/>Regular Text";
tv.setText(Html.fromHtml(instructions));
Typeface font = Typeface.createFromAsset(BaseActivity.this.getAssets(),
"OpenSans-Regular.ttf");
Typeface bold = Typeface.createFromAsset(BaseActivity.this.getAssets(),
"OpenSans-Bold.ttf");
tv.setTypeface(font, Typeface.NORMAL);
tv.setTypeface(bold, Typeface.BOLD);
I need to use a different font for the bold elements in HTML text rendered
in an Android textview.
I tried doing it this way, but it looks like the Typeface style argument
just sets the entire textview to normal or bold, rather than setting the
font for that style in the textview.
TextView tv = (TextView) dialogView.findViewById(R.id.textInstructions);
String instructions = "<b>Headline</b><br/>Regular Text";
tv.setText(Html.fromHtml(instructions));
Typeface font = Typeface.createFromAsset(BaseActivity.this.getAssets(),
"OpenSans-Regular.ttf");
Typeface bold = Typeface.createFromAsset(BaseActivity.this.getAssets(),
"OpenSans-Bold.ttf");
tv.setTypeface(font, Typeface.NORMAL);
tv.setTypeface(bold, Typeface.BOLD);
CSS3 animated target selector
CSS3 animated target selector
http://codepen.io/mikethedj4/pen/cpbCk
I'm having a bit of trouble here. I want the div scale set to 0 and when
targeted to scale in, but when I tried it didn't work.
CSS
/* Content Area */
.content div {
width: 50%;
margin: 2em auto;
padding: 1em;
background: #333;
border: 1em solid #555;
color: #fff;
transform: scale(0);
-webkit-transform: scale(0);
-moz-transform: scale(0);
-o-transform: scale(0);
-ms-transform: scale(0);
transition:all 300ms ease-in-out;
-webkit-transition:all 300ms ease-in-out;
-moz-transition:all 300ms ease-in-out;
-o-transition:all 300ms ease-in-out;
-ms-transition:all 300ms ease-in-out;
}
/* hide unselected targets */
.content div:not(:target) {
display: none;
}
/* display selected target */
:target {
display: inherit;
transform: scale(1);
-webkit-transform: scale(1);
-moz-transform: scale(1);
-o-transform: scale(1);
-ms-transform: scale(1);
}
HTML
<article id="container">
<ul>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#services">Services</a></li>
</ul>
<div class="content">
<div id="about">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla
at feugiat odio. Proin sit amet eros ac diam tempus tempor.
Fusce gravida ut nisi in consectetur. Sed hendrerit sapien id
metus adipiscing, id vehicula lacus fermentum. Proin mollis
facilisis erat, eu sollicitudin diam scelerisque ut. Phasellus
non mollis nisl. Vestibulum ac mi quis metus mollis fermentum.
Donec pharetra consequat lacinia. Vestibulum porta tortor
purus, non fermentum turpis congue eget. Nulla varius augue
dolor, at pellentesque diam volutpat in. Vestibulum vitae
ligula eu eros tristique accumsan. Mauris sagittis iaculis
lorem id egestas. Suspendisse potenti. Cras faucibus dolor
turpis, ac ultrices dolor rhoncus a.
<p>Etiam aliquam magna vitae hendrerit accumsan. Nam venenatis
risus a tempor semper. Nullam ac est nec dolor pellentesque
laoreet ac ac nisi. Ut sit amet magna nunc. Vestibulum orci
ipsum, pretium nec venenatis vel, lacinia et magna. Proin
dignissim dui ligula, eget pretium nisl ultrices eu. Etiam sit
amet nunc non nisl scelerisque dignissim a sed sapien.</p>
<p>Quisque auctor sit amet mi sed porta. Fusce nec erat eros.
Suspendisse et diam sit amet quam pretium sollicitudin quis
nec enim. Nam fermentum risus dui, non volutpat dolor
pellentesque nec. Quisque interdum, neque eu feugiat
hendrerit, risus augue malesuada mauris, non vestibulum ante
erat quis purus. Nunc scelerisque sapien vel leo bibendum, vel
dapibus ipsum ultricies. Cras commodo lacus quis nunc eleifend
iaculis. Nam adipiscing ipsum non justo ultrices, sit amet
vestibulum urna vehicula. Praesent porttitor neque et dictum
euismod. Aliquam erat volutpat. Nam adipiscing, neque ut
dictum ultricies, dui odio aliquet dui, ac rhoncus neque nulla
a enim.</p>
</div>
<div id="contact">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut
purus leo, varius pellentesque vestibulum at, lobortis quis
est. Suspendisse mattis leo vel eros faucibus adipiscing.
Phasellus sed nisl eu lectus blandit dignissim vel id nibh.
Donec rutrum felis urna, sed elementum urna venenatis quis.
Praesent vel tortor sed felis sodales lobortis eget eget
nulla. Aliquam bibendum elit eu nunc facilisis, varius tempor
lectus mattis. Aenean sed aliquet orci. Aliquam viverra
molestie ultrices.
<p>Nullam luctus imperdiet risus, vel convallis massa interdum
id. In ultricies pulvinar libero vitae sodales. Fusce eleifend
varius tincidunt. Nulla sed blandit nibh. Ut sollicitudin,
metus et sagittis tincidunt, nisl felis ultricies ante, eu
dapibus massa odio sed nunc. Pellentesque semper eros dui, ac
mollis nunc dictum non. Quisque ultrices sapien at velit
pellentesque, at lacinia est commodo. Morbi commodo in neque
eu tempor. Curabitur eu mattis diam, eu tristique mauris.</p>
<p>Suspendisse sit amet lacus rutrum, faucibus augue vitae,
euismod nibh. Mauris aliquet nisi in nibh aliquam, et
ullamcorper turpis mattis. Vestibulum ut hendrerit libero, eu
ultricies odio. Etiam sodales vehicula dignissim. Vestibulum
libero tellus, luctus sed imperdiet quis, malesuada sed nunc.
In aliquet pellentesque erat pellentesque fringilla. Aenean
egestas ipsum eu nunc auctor, nec vestibulum est varius.
Integer convallis, orci sit amet sagittis hendrerit, purus
ligula dictum dolor, in lobortis ligula lacus pulvinar lorem.
Sed pulvinar porttitor egestas. Duis ac ante ipsum. Donec sem
odio, sollicitudin in fermentum egestas, gravida sed diam. Nam
condimentum augue ut ligula dapibus sodales. Donec blandit sem
non cursus aliquam.</p>
</div>
<div id="services">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Vivamus posuere porta suscipit. In ac purus quis lectus
blandit rutrum eu vitae nisi. Nunc vel ante at enim imperdiet
ultrices et non erat. Vestibulum sagittis facilisis nulla. Ut
quis turpis sit amet enim volutpat tincidunt. Vivamus vel
ornare neque. Class aptent taciti sociosqu ad litora torquent
per conubia nostra, per inceptos himenaeos. Duis tincidunt mi
et ipsum cursus, vitae tincidunt ipsum fringilla. Integer eu
mollis elit, in tincidunt neque.
<p>Maecenas ac est gravida, iaculis mauris vitae, tempus enim.
Mauris ut nisi dapibus, commodo massa sed, iaculis augue. Cras
sit amet leo libero. Mauris ac dui lorem. Aenean velit risus,
ornare molestie neque ac, feugiat cursus tellus. Duis commodo
lacinia felis, vitae aliquam mauris consectetur cursus. Donec
arcu orci, sollicitudin eu lacus id, ultricies sollicitudin
ligula. Vivamus ac egestas ipsum. Duis aliquam suscipit
tristique. Vestibulum aliquet bibendum arcu, in adipiscing
arcu sagittis ut. Aenean in leo risus. Morbi vitae nibh in
eros accumsan consequat in ac lacus. Maecenas pretium mattis
justo non euismod. Sed vel velit sollicitudin, posuere mi nec,
dictum lectus.</p>
<p>Nullam nisl nisi, dignissim ultrices cursus id, aliquet vel
purus. Praesent velit purus, pharetra id eros id, viverra
ultricies velit. Phasellus sed lacinia neque, at dictum odio.
Mauris eget accumsan augue, ac imperdiet magna. Proin commodo
sem id purus vulputate mollis. Nunc a dignissim urna. Nam
facilisis, lectus sit amet blandit egestas, velit tortor
imperdiet massa, eu elementum lorem dolor nec diam. Interdum
et malesuada fames ac ante ipsum primis in faucibus. Phasellus
sit amet nisl turpis. Nulla vel nulla ut odio feugiat
ultrices. Ut id consequat sem.</p>
</div>
</div>
</article>
http://codepen.io/mikethedj4/pen/cpbCk
I'm having a bit of trouble here. I want the div scale set to 0 and when
targeted to scale in, but when I tried it didn't work.
CSS
/* Content Area */
.content div {
width: 50%;
margin: 2em auto;
padding: 1em;
background: #333;
border: 1em solid #555;
color: #fff;
transform: scale(0);
-webkit-transform: scale(0);
-moz-transform: scale(0);
-o-transform: scale(0);
-ms-transform: scale(0);
transition:all 300ms ease-in-out;
-webkit-transition:all 300ms ease-in-out;
-moz-transition:all 300ms ease-in-out;
-o-transition:all 300ms ease-in-out;
-ms-transition:all 300ms ease-in-out;
}
/* hide unselected targets */
.content div:not(:target) {
display: none;
}
/* display selected target */
:target {
display: inherit;
transform: scale(1);
-webkit-transform: scale(1);
-moz-transform: scale(1);
-o-transform: scale(1);
-ms-transform: scale(1);
}
HTML
<article id="container">
<ul>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#services">Services</a></li>
</ul>
<div class="content">
<div id="about">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla
at feugiat odio. Proin sit amet eros ac diam tempus tempor.
Fusce gravida ut nisi in consectetur. Sed hendrerit sapien id
metus adipiscing, id vehicula lacus fermentum. Proin mollis
facilisis erat, eu sollicitudin diam scelerisque ut. Phasellus
non mollis nisl. Vestibulum ac mi quis metus mollis fermentum.
Donec pharetra consequat lacinia. Vestibulum porta tortor
purus, non fermentum turpis congue eget. Nulla varius augue
dolor, at pellentesque diam volutpat in. Vestibulum vitae
ligula eu eros tristique accumsan. Mauris sagittis iaculis
lorem id egestas. Suspendisse potenti. Cras faucibus dolor
turpis, ac ultrices dolor rhoncus a.
<p>Etiam aliquam magna vitae hendrerit accumsan. Nam venenatis
risus a tempor semper. Nullam ac est nec dolor pellentesque
laoreet ac ac nisi. Ut sit amet magna nunc. Vestibulum orci
ipsum, pretium nec venenatis vel, lacinia et magna. Proin
dignissim dui ligula, eget pretium nisl ultrices eu. Etiam sit
amet nunc non nisl scelerisque dignissim a sed sapien.</p>
<p>Quisque auctor sit amet mi sed porta. Fusce nec erat eros.
Suspendisse et diam sit amet quam pretium sollicitudin quis
nec enim. Nam fermentum risus dui, non volutpat dolor
pellentesque nec. Quisque interdum, neque eu feugiat
hendrerit, risus augue malesuada mauris, non vestibulum ante
erat quis purus. Nunc scelerisque sapien vel leo bibendum, vel
dapibus ipsum ultricies. Cras commodo lacus quis nunc eleifend
iaculis. Nam adipiscing ipsum non justo ultrices, sit amet
vestibulum urna vehicula. Praesent porttitor neque et dictum
euismod. Aliquam erat volutpat. Nam adipiscing, neque ut
dictum ultricies, dui odio aliquet dui, ac rhoncus neque nulla
a enim.</p>
</div>
<div id="contact">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut
purus leo, varius pellentesque vestibulum at, lobortis quis
est. Suspendisse mattis leo vel eros faucibus adipiscing.
Phasellus sed nisl eu lectus blandit dignissim vel id nibh.
Donec rutrum felis urna, sed elementum urna venenatis quis.
Praesent vel tortor sed felis sodales lobortis eget eget
nulla. Aliquam bibendum elit eu nunc facilisis, varius tempor
lectus mattis. Aenean sed aliquet orci. Aliquam viverra
molestie ultrices.
<p>Nullam luctus imperdiet risus, vel convallis massa interdum
id. In ultricies pulvinar libero vitae sodales. Fusce eleifend
varius tincidunt. Nulla sed blandit nibh. Ut sollicitudin,
metus et sagittis tincidunt, nisl felis ultricies ante, eu
dapibus massa odio sed nunc. Pellentesque semper eros dui, ac
mollis nunc dictum non. Quisque ultrices sapien at velit
pellentesque, at lacinia est commodo. Morbi commodo in neque
eu tempor. Curabitur eu mattis diam, eu tristique mauris.</p>
<p>Suspendisse sit amet lacus rutrum, faucibus augue vitae,
euismod nibh. Mauris aliquet nisi in nibh aliquam, et
ullamcorper turpis mattis. Vestibulum ut hendrerit libero, eu
ultricies odio. Etiam sodales vehicula dignissim. Vestibulum
libero tellus, luctus sed imperdiet quis, malesuada sed nunc.
In aliquet pellentesque erat pellentesque fringilla. Aenean
egestas ipsum eu nunc auctor, nec vestibulum est varius.
Integer convallis, orci sit amet sagittis hendrerit, purus
ligula dictum dolor, in lobortis ligula lacus pulvinar lorem.
Sed pulvinar porttitor egestas. Duis ac ante ipsum. Donec sem
odio, sollicitudin in fermentum egestas, gravida sed diam. Nam
condimentum augue ut ligula dapibus sodales. Donec blandit sem
non cursus aliquam.</p>
</div>
<div id="services">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Vivamus posuere porta suscipit. In ac purus quis lectus
blandit rutrum eu vitae nisi. Nunc vel ante at enim imperdiet
ultrices et non erat. Vestibulum sagittis facilisis nulla. Ut
quis turpis sit amet enim volutpat tincidunt. Vivamus vel
ornare neque. Class aptent taciti sociosqu ad litora torquent
per conubia nostra, per inceptos himenaeos. Duis tincidunt mi
et ipsum cursus, vitae tincidunt ipsum fringilla. Integer eu
mollis elit, in tincidunt neque.
<p>Maecenas ac est gravida, iaculis mauris vitae, tempus enim.
Mauris ut nisi dapibus, commodo massa sed, iaculis augue. Cras
sit amet leo libero. Mauris ac dui lorem. Aenean velit risus,
ornare molestie neque ac, feugiat cursus tellus. Duis commodo
lacinia felis, vitae aliquam mauris consectetur cursus. Donec
arcu orci, sollicitudin eu lacus id, ultricies sollicitudin
ligula. Vivamus ac egestas ipsum. Duis aliquam suscipit
tristique. Vestibulum aliquet bibendum arcu, in adipiscing
arcu sagittis ut. Aenean in leo risus. Morbi vitae nibh in
eros accumsan consequat in ac lacus. Maecenas pretium mattis
justo non euismod. Sed vel velit sollicitudin, posuere mi nec,
dictum lectus.</p>
<p>Nullam nisl nisi, dignissim ultrices cursus id, aliquet vel
purus. Praesent velit purus, pharetra id eros id, viverra
ultricies velit. Phasellus sed lacinia neque, at dictum odio.
Mauris eget accumsan augue, ac imperdiet magna. Proin commodo
sem id purus vulputate mollis. Nunc a dignissim urna. Nam
facilisis, lectus sit amet blandit egestas, velit tortor
imperdiet massa, eu elementum lorem dolor nec diam. Interdum
et malesuada fames ac ante ipsum primis in faucibus. Phasellus
sit amet nisl turpis. Nulla vel nulla ut odio feugiat
ultrices. Ut id consequat sem.</p>
</div>
</div>
</article>
Friday, September 13, 2013
Swing Graphics Not Working In My Line Algorithm?
Swing Graphics Not Working In My Line Algorithm?
I'm trying to utilize swing graphics in order to gauge Bresenham's
algorithm against a less polished solution (I haven't implemented the
timers yet). As things stand, there are no errors when compiling, and it
throws a NullPointer exception at basic, drawthoselines, and main. The
idea is that the lines will appear in the JFrame, but they don't. It's
just a blank frame. I know I have everything set to static, but I get a
lot of errors otherwise.
I'm a novice and I would be grateful to anyone who could provide a
solution and an explanation.
import java.awt.*;
import javax.swing.*;
public class lines extends JPanel {
static int deltaX;
static int deltaY;
static int DY2;
static int DX2;
static int Di;
public static void main (String[] args) {
JFrame f = new JFrame("Line vs Line");
f.pack();
f.setVisible(true);
f.setSize(300,300);
f.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
JPanel p = new JPanel();
f.getContentPane().add(p);
Graphics g = null;
drawthoselines(g);
}
public static void basic(int x1, int y1, int x2, int y2, Graphics g){
int deltaX = x2-x1;
int deltaY = y2-y1;
float m = (float)deltaY/(float)deltaX;
float c = y1 - (m*x1);
for (int x=x1; x<x2; x++){
float floatY = (m*x) + c;
int y = Math.round(floatY);
g.drawLine(x,y,x,y);
}
}
public static void brz(int x1, int y1, int x2, int y2, Graphics g){
deltaX = x2-x1;
deltaY = y2-y1;
DY2 = 2* deltaY;
DX2 = 2* deltaX;
Di = DY2 - deltaX;
int x = x1;
int y = y1;
int prevy;
while (x<x2) {
x++;
prevy = y;
if (Di > 0){
y++;
}
g.drawLine(x,y,x,y);
Di = Di + DY2 - (DX2 * (y - prevy));
}
}
public static void drawthoselines(Graphics g){
basic(10,10,40,30,g);
basic(10,10,40,90,g);
brz(50,50,150,60,g);
brz(50,50,150,120,g);
brz(50,50,150,140,g);
}
}
I'm trying to utilize swing graphics in order to gauge Bresenham's
algorithm against a less polished solution (I haven't implemented the
timers yet). As things stand, there are no errors when compiling, and it
throws a NullPointer exception at basic, drawthoselines, and main. The
idea is that the lines will appear in the JFrame, but they don't. It's
just a blank frame. I know I have everything set to static, but I get a
lot of errors otherwise.
I'm a novice and I would be grateful to anyone who could provide a
solution and an explanation.
import java.awt.*;
import javax.swing.*;
public class lines extends JPanel {
static int deltaX;
static int deltaY;
static int DY2;
static int DX2;
static int Di;
public static void main (String[] args) {
JFrame f = new JFrame("Line vs Line");
f.pack();
f.setVisible(true);
f.setSize(300,300);
f.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
JPanel p = new JPanel();
f.getContentPane().add(p);
Graphics g = null;
drawthoselines(g);
}
public static void basic(int x1, int y1, int x2, int y2, Graphics g){
int deltaX = x2-x1;
int deltaY = y2-y1;
float m = (float)deltaY/(float)deltaX;
float c = y1 - (m*x1);
for (int x=x1; x<x2; x++){
float floatY = (m*x) + c;
int y = Math.round(floatY);
g.drawLine(x,y,x,y);
}
}
public static void brz(int x1, int y1, int x2, int y2, Graphics g){
deltaX = x2-x1;
deltaY = y2-y1;
DY2 = 2* deltaY;
DX2 = 2* deltaX;
Di = DY2 - deltaX;
int x = x1;
int y = y1;
int prevy;
while (x<x2) {
x++;
prevy = y;
if (Di > 0){
y++;
}
g.drawLine(x,y,x,y);
Di = Di + DY2 - (DX2 * (y - prevy));
}
}
public static void drawthoselines(Graphics g){
basic(10,10,40,30,g);
basic(10,10,40,90,g);
brz(50,50,150,60,g);
brz(50,50,150,120,g);
brz(50,50,150,140,g);
}
}
What is the difference between a combinator and a higher order function?
What is the difference between a combinator and a higher order function?
I have always thought the definition of both of these were functions that
take other functions as arguments. I understand the domain of each is
different, but what are their defining characteristics?
I have always thought the definition of both of these were functions that
take other functions as arguments. I understand the domain of each is
different, but what are their defining characteristics?
When including JQERY mobile CSS my actions from D3 do not work
When including JQERY mobile CSS my actions from D3 do not work
here is my HTML:
<head>
<script type="text/javascript"
src="//chalk1up.net/climb/3rdparty/d3.v3.min.js"></script>
<script type="text/javascript" src="graph_functions.js"></script>
<title>Stats - Chalk1Up Mobile Trainer</title>
<? include 'head1.html'; ?>
<style>
</style>
<? include 'head2.html'; ?>
</head>
<body>
<script type="text/javascript"
src="//chalk1up.net/climb/3rdparty/d3.v3.min.js"></script>
<script type="text/javascript" src="graph_functions.js"></script>
<div data-role="page" id="home" data-theme="a">
<? include 'navbar.php'; ?>
<div data-role="content">
<div id="graph_avg" data-role="fieldcontain">
<label><input type="radio" name="dataset" value="bouldering"
checked> Bouldering</label>
<label><input type="radio" name="dataset" value="ropes">
Ropes</label>
</div>
<? include 'footer.html'; ?>
</div>
</body>
<!--<script type="text/javascript" src="pie.js"></script> -->
<script type="text/javascript" src="pie.js"></script>
Here is my D3 Code to create a Pie Chart:
var dataset = {
bouldering: [53, 28, 19, 24, 300, 22,55,33, 77, 32,
43,55,67,87,99,25,21, 0, 0, 0, 0, 0, 0, 0, 0, 0],
ropes: [5, 0, 10, 0, 0, 15, 0, 1, 9, 10, 11,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
};
var center_text = "Your Average Grade is: ";
var sentence_1 = "Out Of ";
var sentence_2 = " Sends, You Climb ";
var sentence_3 = " of the time!";
var rope = dataset.ropes;
var boulder = dataset.bouldering;
// console.log(emptyset);
var rope_isempty = false;
var boulder_isempty = false;
var index = 0;
var added = 0;
var bouldering_total = 0;
var most_climbed_index = 0;
var rope_total;
var tempmax_boulder = 0;
var evens_odds = 0;
var boulder_grade;
var div_string = "#graph_avg";
var boulder_color;
while(index < dataset.bouldering.length){
console.log(boulder[index]);
bouldering_total += boulder[index];
if (tempmax_boulder < boulder[index]){
tempmax_boulder = boulder[index];
most_climbed_index = index;
}
index ++;
}
//figure out the grade
switch(most_climbed_index){
case 0 : boulder_grade = "V0", boulder_color = "#1f77b4"
break;
case 1 : boulder_grade = "V1", boulder_color = "#aec7e8"
break;
case 2 : boulder_grade = "V2", boulder_color = "#ff7f0e"
break;
case 3 : boulder_grade = "V3", boulder_color = "#ffbb78"
break;
case 4 : boulder_grade = "V4", boulder_color = "#2ca02c"
break;
case 5 : boulder_grade = "V5", boulder_color = "#98df8a"
break;
case 6 : boulder_grade = "V6", boulder_color = "#d62728"
break;
case 7 : boulder_grade = "V7", boulder_color = "#ff9896"
break;
case 8 : boulder_grade = "V8", boulder_color = "#9467bd"
break;
case 9 : boulder_grade = "V9", boulder_color = "#c5b0d5"
break;
case 10 : boulder_grade = "V10", boulder_color = "#8c564b"
break;
case 11 : boulder_grade = "V11", boulder_color = "#c49c94"
break;
case 12 : boulder_grade = "V12", boulder_color = "#e377c2"
break;
case 13 : boulder_grade = "V13", boulder_color = "#f7b6d2"
break;
case 14 : boulder_grade = "V14", boulder_color = "#7f7f7f"
break;
case 15 : boulder_grade = "V15", boulder_color = "#c7c7c7"
break;
default: boulder_grade = "NONE", boulder_color = "#bcbd22"
break;
}
console.log(bouldering_total);
console.log(tempmax_boulder);
console.log(most_climbed_index);
var boulder_percentage = (tempmax_boulder / bouldering_total) * 100;
boulder_percentage = Math.round(boulder_percentage * 100) / 100;
//var boulder_string = "Your Average Grade is: " + boulder_grade;
console.log(boulder_percentage);
var max_boulder_string = tempmax_boulder.toString();
console.log(max_boulder_string);
index = 0;
while(rope_isempty == false && index < rope.length){
added += rope[index];
index += 1;
}
if (added == 0){
rope_isempty = true;
}
index = 0;
added = 0;
// console.log(rope_isempty);
while(boulder_isempty == false && index < boulder.length){
added += boulder[index];
index += 1;
}
if (added == 0){
boulder_isempty = true;
}
// var width = 960,
// height = 500,
// radius = Math.min(width, height) / 2;
var width = setWidthToWindow() - 20,
height = setHeightToWindow(),
radius = Math.min(width, height) / 2;
console.log("Width:" + width);
console.log("Height" + height);
var color = d3.scale.ordinal()
.range(["#33ff33", "#00ff00", "#00cc00", //
V0 - V2
"#ffff00","#cccc00","#999900", //
V3 - V5
"#ff0000","#cc0000","#800000", //
V6 - V8
"#666666","#999999","#ffffff", //
V9 - V11
"#ffffff","#ffffff","#ffffff","#ffffff", //
V12 - V15
"#6666ff","#3333ff","#0000ff","#000099", //
5.6 - 5.9
"#944d94","#751975","#5c005c","#470047", //
5.10's
"#94b8b8","#75a3a3","#5c8a8a","#476b6b", //
5.11's
"#ff7d1a","#ff6f00","#e66400","#cc5900", //
5.12's
"#94b8b8","#7B3F00","#8B5A2B","#926C44", //
5.13's
"#CCB091","#CCB091","#CCB091","#CCB091", //
5.14's
"#CCB091","#CCB091","#CCB091" //
5.15's
]);
var pie = d3.layout.pie()
.sort(null);
//based on origin values
var arc = d3.svg.arc()
.innerRadius(radius - 60)
.outerRadius(radius - 20);
var svg_pie = d3.select(div_string).append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width / 2.2 + "," + height / 2 +
")"); //defines where the origin is!
var text_center = drawText(svg_pie, sentence_1, -460, 400, 20,
"steelblue", FONT, TEXT_STROKE_WIDTH);
var path_pie = svg_pie.selectAll("path")
.data(pie(dataset.bouldering))
.enter().append("path")
.attr("fill", function(d, i) { return color(i); })
.attr("d", arc)
.each(function(d) { this._current = d; }); // store the initial values
d3.selectAll("input").on("change", change);
var timeout = setTimeout(function() {
d3.select("input[value=\"ropes\"]").property("checked", true).each(change);
//d3.select("button[id=\"ropes\"]").each(change);
}, 2000);
function change() {
clearTimeout(timeout);
path_pie = path_pie.data(pie(dataset[this.value])); // update the data
path_pie.transition().duration(1200).attrTween("d", arcTween); // redraw
the arcs
evens_odds += 1;
if((evens_odds % 2) == 0 ){
d3.select("#graph_avg").selectAll("text").remove();
var text_lower_1 = drawText(svg_pie, sentence_1, -270, -170, 20,
"steelblue", FONT, TEXT_STROKE_WIDTH);
var text_lower_2 = drawText(svg_pie, bouldering_total, -390, 240, 50,
RED, FONT, TEXT_STROKE_WIDTH);
var text_lower_3 = drawText(svg_pie, sentence_2, -200, 240, 15,
"steelblue", FONT, TEXT_STROKE_WIDTH);
var text_lower_4 = drawText(svg_pie,boulder_grade, 120, 240, 50,
boulder_color, FONT, TEXT_STROKE_WIDTH);
var text_lower_5 = drawText(svg_pie,boulder_percentage + "%", 220,
240, 50, ORANGE, FONT, TEXT_STROKE_WIDTH);
var text_lower_3 = drawText(svg_pie, sentence_3, 380, 240, 20,
"steelblue", FONT, TEXT_STROKE_WIDTH);
var text_center = drawText(svg_pie, center_text, -(width/4.933),
-(height/28.30), 15, "steelblue", FONT, TEXT_STROKE_WIDTH);
var grade = drawText(svg_pie,boulder_grade, -45, 50, 50,
boulder_color, FONT, TEXT_STROKE_WIDTH);
}else{
d3.select("#graph_avg").selectAll("text").remove();
var text_lower_1 = drawText(svg_pie, sentence_1, -170, 175, 15,
"steelblue", FONT, TEXT_STROKE_WIDTH);
var text_lower_2 = drawText(svg_pie, 1010, -170, 220, 40, RED, FONT,
TEXT_STROKE_WIDTH);
var text_lower_3 = drawText(svg_pie, sentence_2, -170, 240, 15,
"steelblue", FONT, TEXT_STROKE_WIDTH);
var text_lower_4 = drawText(svg_pie,"5.9", -(width/8.22), 220, 50,
boulder_color, FONT, TEXT_STROKE_WIDTH);
var text_lower_5 = drawText(svg_pie,"13.2%", 220, 240, 50, ORANGE,
FONT, TEXT_STROKE_WIDTH);
var text_lower_3 = drawText(svg_pie, sentence_3, 380, 240, 20,
"steelblue", FONT, TEXT_STROKE_WIDTH);
var text_center = drawText(svg_pie, center_text, -(width/4.933),
-(height/28.30), 15, "steelblue", FONT, TEXT_STROKE_WIDTH);
var grade = drawText(svg_pie, "5.9", -(width/8.22), height/11.32, 50,
boulder_color, FONT, TEXT_STROKE_WIDTH);
}
}
// Store the displayed angles in _current.
// Then, interpolate from _current to the new angles.
// During the transition, _current is updated in-place by d3.interpolate.
function arcTween(a) {
var i = d3.interpolate(this._current, a);
this._current = i(0);
return function(t) {
return arc(i(t));
};
}
For Some reason when I remove this line from the HTML:
<? include 'head1.html'; ?>
The
<label><input type="radio" name="dataset" value="bouldering"
checked> Bouldering</label>
<label><input type="radio" name="dataset" value="ropes">
Ropes</label>
"buttons" actually work, but if I include the JQUERY mobile CSS library,
Nothing happens when i click the buttons that are displayed.
From what I gather the head1.html contains a line to include the JQeury
Mobile CSS file which makes those lables look all nice and pretty, but it
seems to remove the ability to allow me to either d3.select them or I am
not allowing my function to change it correctly. Any ideas on how to
overwrite the CSS or to change my D3 code to select correctly?
here is my HTML:
<head>
<script type="text/javascript"
src="//chalk1up.net/climb/3rdparty/d3.v3.min.js"></script>
<script type="text/javascript" src="graph_functions.js"></script>
<title>Stats - Chalk1Up Mobile Trainer</title>
<? include 'head1.html'; ?>
<style>
</style>
<? include 'head2.html'; ?>
</head>
<body>
<script type="text/javascript"
src="//chalk1up.net/climb/3rdparty/d3.v3.min.js"></script>
<script type="text/javascript" src="graph_functions.js"></script>
<div data-role="page" id="home" data-theme="a">
<? include 'navbar.php'; ?>
<div data-role="content">
<div id="graph_avg" data-role="fieldcontain">
<label><input type="radio" name="dataset" value="bouldering"
checked> Bouldering</label>
<label><input type="radio" name="dataset" value="ropes">
Ropes</label>
</div>
<? include 'footer.html'; ?>
</div>
</body>
<!--<script type="text/javascript" src="pie.js"></script> -->
<script type="text/javascript" src="pie.js"></script>
Here is my D3 Code to create a Pie Chart:
var dataset = {
bouldering: [53, 28, 19, 24, 300, 22,55,33, 77, 32,
43,55,67,87,99,25,21, 0, 0, 0, 0, 0, 0, 0, 0, 0],
ropes: [5, 0, 10, 0, 0, 15, 0, 1, 9, 10, 11,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
};
var center_text = "Your Average Grade is: ";
var sentence_1 = "Out Of ";
var sentence_2 = " Sends, You Climb ";
var sentence_3 = " of the time!";
var rope = dataset.ropes;
var boulder = dataset.bouldering;
// console.log(emptyset);
var rope_isempty = false;
var boulder_isempty = false;
var index = 0;
var added = 0;
var bouldering_total = 0;
var most_climbed_index = 0;
var rope_total;
var tempmax_boulder = 0;
var evens_odds = 0;
var boulder_grade;
var div_string = "#graph_avg";
var boulder_color;
while(index < dataset.bouldering.length){
console.log(boulder[index]);
bouldering_total += boulder[index];
if (tempmax_boulder < boulder[index]){
tempmax_boulder = boulder[index];
most_climbed_index = index;
}
index ++;
}
//figure out the grade
switch(most_climbed_index){
case 0 : boulder_grade = "V0", boulder_color = "#1f77b4"
break;
case 1 : boulder_grade = "V1", boulder_color = "#aec7e8"
break;
case 2 : boulder_grade = "V2", boulder_color = "#ff7f0e"
break;
case 3 : boulder_grade = "V3", boulder_color = "#ffbb78"
break;
case 4 : boulder_grade = "V4", boulder_color = "#2ca02c"
break;
case 5 : boulder_grade = "V5", boulder_color = "#98df8a"
break;
case 6 : boulder_grade = "V6", boulder_color = "#d62728"
break;
case 7 : boulder_grade = "V7", boulder_color = "#ff9896"
break;
case 8 : boulder_grade = "V8", boulder_color = "#9467bd"
break;
case 9 : boulder_grade = "V9", boulder_color = "#c5b0d5"
break;
case 10 : boulder_grade = "V10", boulder_color = "#8c564b"
break;
case 11 : boulder_grade = "V11", boulder_color = "#c49c94"
break;
case 12 : boulder_grade = "V12", boulder_color = "#e377c2"
break;
case 13 : boulder_grade = "V13", boulder_color = "#f7b6d2"
break;
case 14 : boulder_grade = "V14", boulder_color = "#7f7f7f"
break;
case 15 : boulder_grade = "V15", boulder_color = "#c7c7c7"
break;
default: boulder_grade = "NONE", boulder_color = "#bcbd22"
break;
}
console.log(bouldering_total);
console.log(tempmax_boulder);
console.log(most_climbed_index);
var boulder_percentage = (tempmax_boulder / bouldering_total) * 100;
boulder_percentage = Math.round(boulder_percentage * 100) / 100;
//var boulder_string = "Your Average Grade is: " + boulder_grade;
console.log(boulder_percentage);
var max_boulder_string = tempmax_boulder.toString();
console.log(max_boulder_string);
index = 0;
while(rope_isempty == false && index < rope.length){
added += rope[index];
index += 1;
}
if (added == 0){
rope_isempty = true;
}
index = 0;
added = 0;
// console.log(rope_isempty);
while(boulder_isempty == false && index < boulder.length){
added += boulder[index];
index += 1;
}
if (added == 0){
boulder_isempty = true;
}
// var width = 960,
// height = 500,
// radius = Math.min(width, height) / 2;
var width = setWidthToWindow() - 20,
height = setHeightToWindow(),
radius = Math.min(width, height) / 2;
console.log("Width:" + width);
console.log("Height" + height);
var color = d3.scale.ordinal()
.range(["#33ff33", "#00ff00", "#00cc00", //
V0 - V2
"#ffff00","#cccc00","#999900", //
V3 - V5
"#ff0000","#cc0000","#800000", //
V6 - V8
"#666666","#999999","#ffffff", //
V9 - V11
"#ffffff","#ffffff","#ffffff","#ffffff", //
V12 - V15
"#6666ff","#3333ff","#0000ff","#000099", //
5.6 - 5.9
"#944d94","#751975","#5c005c","#470047", //
5.10's
"#94b8b8","#75a3a3","#5c8a8a","#476b6b", //
5.11's
"#ff7d1a","#ff6f00","#e66400","#cc5900", //
5.12's
"#94b8b8","#7B3F00","#8B5A2B","#926C44", //
5.13's
"#CCB091","#CCB091","#CCB091","#CCB091", //
5.14's
"#CCB091","#CCB091","#CCB091" //
5.15's
]);
var pie = d3.layout.pie()
.sort(null);
//based on origin values
var arc = d3.svg.arc()
.innerRadius(radius - 60)
.outerRadius(radius - 20);
var svg_pie = d3.select(div_string).append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width / 2.2 + "," + height / 2 +
")"); //defines where the origin is!
var text_center = drawText(svg_pie, sentence_1, -460, 400, 20,
"steelblue", FONT, TEXT_STROKE_WIDTH);
var path_pie = svg_pie.selectAll("path")
.data(pie(dataset.bouldering))
.enter().append("path")
.attr("fill", function(d, i) { return color(i); })
.attr("d", arc)
.each(function(d) { this._current = d; }); // store the initial values
d3.selectAll("input").on("change", change);
var timeout = setTimeout(function() {
d3.select("input[value=\"ropes\"]").property("checked", true).each(change);
//d3.select("button[id=\"ropes\"]").each(change);
}, 2000);
function change() {
clearTimeout(timeout);
path_pie = path_pie.data(pie(dataset[this.value])); // update the data
path_pie.transition().duration(1200).attrTween("d", arcTween); // redraw
the arcs
evens_odds += 1;
if((evens_odds % 2) == 0 ){
d3.select("#graph_avg").selectAll("text").remove();
var text_lower_1 = drawText(svg_pie, sentence_1, -270, -170, 20,
"steelblue", FONT, TEXT_STROKE_WIDTH);
var text_lower_2 = drawText(svg_pie, bouldering_total, -390, 240, 50,
RED, FONT, TEXT_STROKE_WIDTH);
var text_lower_3 = drawText(svg_pie, sentence_2, -200, 240, 15,
"steelblue", FONT, TEXT_STROKE_WIDTH);
var text_lower_4 = drawText(svg_pie,boulder_grade, 120, 240, 50,
boulder_color, FONT, TEXT_STROKE_WIDTH);
var text_lower_5 = drawText(svg_pie,boulder_percentage + "%", 220,
240, 50, ORANGE, FONT, TEXT_STROKE_WIDTH);
var text_lower_3 = drawText(svg_pie, sentence_3, 380, 240, 20,
"steelblue", FONT, TEXT_STROKE_WIDTH);
var text_center = drawText(svg_pie, center_text, -(width/4.933),
-(height/28.30), 15, "steelblue", FONT, TEXT_STROKE_WIDTH);
var grade = drawText(svg_pie,boulder_grade, -45, 50, 50,
boulder_color, FONT, TEXT_STROKE_WIDTH);
}else{
d3.select("#graph_avg").selectAll("text").remove();
var text_lower_1 = drawText(svg_pie, sentence_1, -170, 175, 15,
"steelblue", FONT, TEXT_STROKE_WIDTH);
var text_lower_2 = drawText(svg_pie, 1010, -170, 220, 40, RED, FONT,
TEXT_STROKE_WIDTH);
var text_lower_3 = drawText(svg_pie, sentence_2, -170, 240, 15,
"steelblue", FONT, TEXT_STROKE_WIDTH);
var text_lower_4 = drawText(svg_pie,"5.9", -(width/8.22), 220, 50,
boulder_color, FONT, TEXT_STROKE_WIDTH);
var text_lower_5 = drawText(svg_pie,"13.2%", 220, 240, 50, ORANGE,
FONT, TEXT_STROKE_WIDTH);
var text_lower_3 = drawText(svg_pie, sentence_3, 380, 240, 20,
"steelblue", FONT, TEXT_STROKE_WIDTH);
var text_center = drawText(svg_pie, center_text, -(width/4.933),
-(height/28.30), 15, "steelblue", FONT, TEXT_STROKE_WIDTH);
var grade = drawText(svg_pie, "5.9", -(width/8.22), height/11.32, 50,
boulder_color, FONT, TEXT_STROKE_WIDTH);
}
}
// Store the displayed angles in _current.
// Then, interpolate from _current to the new angles.
// During the transition, _current is updated in-place by d3.interpolate.
function arcTween(a) {
var i = d3.interpolate(this._current, a);
this._current = i(0);
return function(t) {
return arc(i(t));
};
}
For Some reason when I remove this line from the HTML:
<? include 'head1.html'; ?>
The
<label><input type="radio" name="dataset" value="bouldering"
checked> Bouldering</label>
<label><input type="radio" name="dataset" value="ropes">
Ropes</label>
"buttons" actually work, but if I include the JQUERY mobile CSS library,
Nothing happens when i click the buttons that are displayed.
From what I gather the head1.html contains a line to include the JQeury
Mobile CSS file which makes those lables look all nice and pretty, but it
seems to remove the ability to allow me to either d3.select them or I am
not allowing my function to change it correctly. Any ideas on how to
overwrite the CSS or to change my D3 code to select correctly?
Backbone URL Won't Update Using .navigate()
Backbone URL Won't Update Using .navigate()
When parameters are passed into my Backbone App, I grab them and save them
to local storage as options, and then the App starts auto-saving the
user's progress as they work. Now, I want to remove the parameters from
the URL, so if the User refreshes the page, they won't have to start all
over.
However, when I use the following code, the URL is not being updated. I
simply want to clear out all of the parameters. And I don't want to run
the Router function again so I've included trigger: false Why doesn't
Backbone allow me to do this?
var newURL = "editor"
App.Router.navigate(newURL, { replace: true, trigger: true });
My Router
routes: {
"" : "browser",
"editor" : "editor"
Sample URL
myapp.com/editor?param1=true¶m2=false
When parameters are passed into my Backbone App, I grab them and save them
to local storage as options, and then the App starts auto-saving the
user's progress as they work. Now, I want to remove the parameters from
the URL, so if the User refreshes the page, they won't have to start all
over.
However, when I use the following code, the URL is not being updated. I
simply want to clear out all of the parameters. And I don't want to run
the Router function again so I've included trigger: false Why doesn't
Backbone allow me to do this?
var newURL = "editor"
App.Router.navigate(newURL, { replace: true, trigger: true });
My Router
routes: {
"" : "browser",
"editor" : "editor"
Sample URL
myapp.com/editor?param1=true¶m2=false
to retrive a mysql data in php and echo the retrived data
to retrive a mysql data in php and echo the retrived data
<?php
$username = "root";
$password = "password";
$database = "meipolytechnic";
$link = mysql_connect("localhost", $username, $password);
$query = "SELECT rollno FROM users where username =
'".$_SESSION['MM_Username']."'";
mysql_select_db('meipolytechnic', $link);
$result = mysql_query($query) or die(mysql_error($link));
$num = mysql_num_rows($result);
mysql_close();
$rows = array();
$result = mysql_query($query) or die(mysql_error());
$rows = array();
while($r = mysql_fetch_row($result))
{
$rows[] = $r[0];
}
print_r($rows);
?>
This is my code i want to display the roll number of the currently logged
in user and when i run this code i get no database selected.
<?php
$username = "root";
$password = "password";
$database = "meipolytechnic";
$link = mysql_connect("localhost", $username, $password);
$query = "SELECT rollno FROM users where username =
'".$_SESSION['MM_Username']."'";
mysql_select_db('meipolytechnic', $link);
$result = mysql_query($query) or die(mysql_error($link));
$num = mysql_num_rows($result);
mysql_close();
$rows = array();
$result = mysql_query($query) or die(mysql_error());
$rows = array();
while($r = mysql_fetch_row($result))
{
$rows[] = $r[0];
}
print_r($rows);
?>
This is my code i want to display the roll number of the currently logged
in user and when i run this code i get no database selected.
Do I need putting flags into synchronized blocks?
Do I need putting flags into synchronized blocks?
I had a code like this:
if(!flag) {
synchronized(lock) {
lock.wait(1000);
}
}
if(!flag) { print("Error flag not set!"); }
And:
void f() {
flag = true;
synchronized(lock) {
lock.notify()
}
}
A friend of mine told me I should put flag = true inside the synchronized
block:
synchronized(lock) {
flag = true;
lock.notify()
}
I do not understand why. Is it some classic example? Could someone,
please, explain?
I had a code like this:
if(!flag) {
synchronized(lock) {
lock.wait(1000);
}
}
if(!flag) { print("Error flag not set!"); }
And:
void f() {
flag = true;
synchronized(lock) {
lock.notify()
}
}
A friend of mine told me I should put flag = true inside the synchronized
block:
synchronized(lock) {
flag = true;
lock.notify()
}
I do not understand why. Is it some classic example? Could someone,
please, explain?
Thursday, September 12, 2013
Just started LUA, unsure of why I'm getting this answer
Just started LUA, unsure of why I'm getting this answer
This is probably a laughable error as:
A: I am a big big big newbie
B: I need sleep
We were all there at some point though, weren't we?
The error I'm getting is
[string "function NameGen()..."]:14: attempt to compare nil with number
stack traceback:
[string "function NameGen()..."]:14: in function 'NameGen'
[string "function NameGen()..."]:23: in main chunk
[C]: ?
My code:
function NameGen()
preftest = math.random(100) ;
syltest = math.random(100) ;
sufftest = math.random(100) ;
pref1 = "New ";
_1syl1 = "Lon";
_2syl1 = "Don";
suff1 = " City";
prefchoice = pref1;
_1sylchoice = _1syl1;
_2sylchoice = _2syl;
suffchoice = suff1;
if preftest < 50 and _2syltest < 50 and sufftest < 50 then
cityname = prefchoice .. _1sylchoice .. _2sylchoice .. suffchoice;
elseif preftest < 50 and _2syltest < 50 then
cityname = prefchoice .. _1sylchoice .. _2sylchoice;
else
cityname = _1sylchoice;
end
end
NameGen();
print(cityname);
This is probably a laughable error as:
A: I am a big big big newbie
B: I need sleep
We were all there at some point though, weren't we?
The error I'm getting is
[string "function NameGen()..."]:14: attempt to compare nil with number
stack traceback:
[string "function NameGen()..."]:14: in function 'NameGen'
[string "function NameGen()..."]:23: in main chunk
[C]: ?
My code:
function NameGen()
preftest = math.random(100) ;
syltest = math.random(100) ;
sufftest = math.random(100) ;
pref1 = "New ";
_1syl1 = "Lon";
_2syl1 = "Don";
suff1 = " City";
prefchoice = pref1;
_1sylchoice = _1syl1;
_2sylchoice = _2syl;
suffchoice = suff1;
if preftest < 50 and _2syltest < 50 and sufftest < 50 then
cityname = prefchoice .. _1sylchoice .. _2sylchoice .. suffchoice;
elseif preftest < 50 and _2syltest < 50 then
cityname = prefchoice .. _1sylchoice .. _2sylchoice;
else
cityname = _1sylchoice;
end
end
NameGen();
print(cityname);
iOS Error: cannot init a class object
iOS Error: cannot init a class object
I am running some CloudCode (via Parse.com) in my iOS app. I am running
that code in objective-C with this snippet right here:
[PFCloud callFunctionInBackground:@"email"
withParameters:@{@"email" : @"chumbleya@gmail.com",
@"code" : @"TESTCODE"}
block:^(NSString *result, NSError *error) {
if (!error) {
NSLog(@"%@", result);
}
else {
NSLog(@"%@", result);
}
}];
However, I get this error when I run it:
*** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '*** +[NSMutableArray<0x3b6b4c00>
init]: cannot init a class object.'
If anyone has had similar experience, let me know! Thanks
I am running some CloudCode (via Parse.com) in my iOS app. I am running
that code in objective-C with this snippet right here:
[PFCloud callFunctionInBackground:@"email"
withParameters:@{@"email" : @"chumbleya@gmail.com",
@"code" : @"TESTCODE"}
block:^(NSString *result, NSError *error) {
if (!error) {
NSLog(@"%@", result);
}
else {
NSLog(@"%@", result);
}
}];
However, I get this error when I run it:
*** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '*** +[NSMutableArray<0x3b6b4c00>
init]: cannot init a class object.'
If anyone has had similar experience, let me know! Thanks
How do I call a paremeterless generic method from Powershell v3?
How do I call a paremeterless generic method from Powershell v3?
For example I have an object $m with the following method overloads:
PS C:\Users\Me> $m.GetBody
OverloadDefinitions
-------------------
T GetBody[T]()
T GetBody[T](System.Runtime.Serialization.XmlObjectSerializer serializer)
If I try to invoke the parameterless method I get:
PS C:\Users\Me> $m.GetBody()
Cannot find an overload for "GetBody" and the argument count: "0".
At line:1 char:1
+ $m.GetBody()
+ ~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
I understand PowerShell v3.0 is supposed to work more easily with
generics. Obviously I need to tell it somehow what type I want returned
but I cannot figure out the syntax.
For example I have an object $m with the following method overloads:
PS C:\Users\Me> $m.GetBody
OverloadDefinitions
-------------------
T GetBody[T]()
T GetBody[T](System.Runtime.Serialization.XmlObjectSerializer serializer)
If I try to invoke the parameterless method I get:
PS C:\Users\Me> $m.GetBody()
Cannot find an overload for "GetBody" and the argument count: "0".
At line:1 char:1
+ $m.GetBody()
+ ~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
I understand PowerShell v3.0 is supposed to work more easily with
generics. Obviously I need to tell it somehow what type I want returned
but I cannot figure out the syntax.
Implement twitter bootstrap modal window call html
Implement twitter bootstrap modal window call html
I need to call a html data inside a twitter modal window from a .php file.
How to call this function? This below script is inside a php file, i need
to call this inside a modal window once we click the link. I am able to
trigger the modal window but not the data.
<html xmlns=hhttp://www.w3.org/1999/xhtmlh>
<head>
<meta http-equiv=hContent-Typeh content=htext/html; charset=utf-8 />
<title><?php echo $post->post_title; ?></title>
<meta name=hrobotsh content=hnoindexh/>
</head>
<body>
<div style=h"><?php echo $image; ?></div>
<?php echo $post->post_title; ?></b>
<p style=hfloat: left;h>Testing</p>
</body>
</html>
I need to call a html data inside a twitter modal window from a .php file.
How to call this function? This below script is inside a php file, i need
to call this inside a modal window once we click the link. I am able to
trigger the modal window but not the data.
<html xmlns=hhttp://www.w3.org/1999/xhtmlh>
<head>
<meta http-equiv=hContent-Typeh content=htext/html; charset=utf-8 />
<title><?php echo $post->post_title; ?></title>
<meta name=hrobotsh content=hnoindexh/>
</head>
<body>
<div style=h"><?php echo $image; ?></div>
<?php echo $post->post_title; ?></b>
<p style=hfloat: left;h>Testing</p>
</body>
</html>
Hide Group Header insertion and editing mode - OpenERP7
Hide Group Header insertion and editing mode - OpenERP7
I wonder if there is any way to hide the items that I have in the header
of a form, I would like to see them in query mode only.
I know of the existence of CSS classes that allow openERP own show / hide
elements, as *oe_edit_only*, *oe_save_only*, there is also the
*oe_view_only* classes.
<form string="People" version="7.0">
<header class="oe_view_only">
<button string="Wait" name="button_assists" states="assigned"
type="object"/>
....
</header>
...
</from>
But I can not make it work in my case.
I appreciate any help.
I wonder if there is any way to hide the items that I have in the header
of a form, I would like to see them in query mode only.
I know of the existence of CSS classes that allow openERP own show / hide
elements, as *oe_edit_only*, *oe_save_only*, there is also the
*oe_view_only* classes.
<form string="People" version="7.0">
<header class="oe_view_only">
<button string="Wait" name="button_assists" states="assigned"
type="object"/>
....
</header>
...
</from>
But I can not make it work in my case.
I appreciate any help.
Mongodb scanAndOrder index unexpected behaviour
Mongodb scanAndOrder index unexpected behaviour
I'm not understanding this mongodb behaviour, my collection has the
following index (names are simplified for clarity sake) and consists of ~
50k documents.
{
"v" : 1,
"key" : {
"a" : 1,
"b" : -1
},
"ns" : "db.articles",
"name" : "a_1_b_-1",
"background" : false,
"dropDups" : false
}
The following query
db.articles.find({ a: {"$in": ["foo", "bar"] } }).sort({b:
-1}).limit(10).explain()
returns:
{
"cursor" : "BtreeCursor a_1_b_-1 multi",
"isMultiKey" : false,
"n" : 10,
"nscannedObjects" : 20,
"nscanned" : 21,
"nscannedObjectsAllPlans" : 68,
"nscannedAllPlans" : 105,
"scanAndOrder" : true,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 0,
"indexBounds" : {
"a" : [
[
"foo",
"foo"
],
[
"bar",
"bar"
]
],
"b" : [
[
{
"$maxElement" : 1
},
{
"$minElement" : 1
}
]
]
},
"server" : "localhost:27017"
}
"scanAndOrder" is true which means the order in the index can't be used to
sort the return set. This means that the query will choke when given an
offset (i.e. skip 10000) and subsequently will return "too much data for
sort() with no index. add an index or specify a smaller limit". When the
query is altered to only do a single equality check, the index is used as
expected:
db.articles.find({ a: "foo" }).sort({b: -1}).limit(10).explain()
The resultset order is now the order the documents have in the index:
"scanAndOrder" : false
So it seems to have to do with how the "$in" operator behaves with index
lookups?
I'm not understanding this mongodb behaviour, my collection has the
following index (names are simplified for clarity sake) and consists of ~
50k documents.
{
"v" : 1,
"key" : {
"a" : 1,
"b" : -1
},
"ns" : "db.articles",
"name" : "a_1_b_-1",
"background" : false,
"dropDups" : false
}
The following query
db.articles.find({ a: {"$in": ["foo", "bar"] } }).sort({b:
-1}).limit(10).explain()
returns:
{
"cursor" : "BtreeCursor a_1_b_-1 multi",
"isMultiKey" : false,
"n" : 10,
"nscannedObjects" : 20,
"nscanned" : 21,
"nscannedObjectsAllPlans" : 68,
"nscannedAllPlans" : 105,
"scanAndOrder" : true,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 0,
"indexBounds" : {
"a" : [
[
"foo",
"foo"
],
[
"bar",
"bar"
]
],
"b" : [
[
{
"$maxElement" : 1
},
{
"$minElement" : 1
}
]
]
},
"server" : "localhost:27017"
}
"scanAndOrder" is true which means the order in the index can't be used to
sort the return set. This means that the query will choke when given an
offset (i.e. skip 10000) and subsequently will return "too much data for
sort() with no index. add an index or specify a smaller limit". When the
query is altered to only do a single equality check, the index is used as
expected:
db.articles.find({ a: "foo" }).sort({b: -1}).limit(10).explain()
The resultset order is now the order the documents have in the index:
"scanAndOrder" : false
So it seems to have to do with how the "$in" operator behaves with index
lookups?
Detecting keyboard layout (QWERTY, Colemak, etc.) in ActionScript 3
Detecting keyboard layout (QWERTY, Colemak, etc.) in ActionScript 3
I'm developing a game in AS3 and would like to set the game to bind
movement to WASD if the player's keyboard is QWERTY, WARS if it's Colemak,
etc. Is this possible, and if so, what are some ways that I could
implement this?
I'm developing a game in AS3 and would like to set the game to bind
movement to WASD if the player's keyboard is QWERTY, WARS if it's Colemak,
etc. Is this possible, and if so, what are some ways that I could
implement this?
Zend_Http_Client_Adapter_Exception' with message 'Unable to Connect to ssl://api.twitter.com:443
Zend_Http_Client_Adapter_Exception' with message 'Unable to Connect to
ssl://api.twitter.com:443
I am a trying to get a twitter feed displayed on the home page of my Zend
application, so far I have my IndexController code:
// ---------------Twitter Feed
$token = new Zend_Oauth_Token_Access();
$token->setParams(array(
'oauth_token' => 'token',
'oauth_token_secret' => 'tokSecret',
));
$twitter = new Zend_Service_Twitter(array(
'username' => 'usrname',
'accessToken' => $token,
'oauthOptions' => array(
'consumerKey' => 'consKey',
'consumerSecret' => 'consSecret',
)
));
$options = array('accessToken' => $token);
$this->view->twitter_timeline = $twitter->statuses->userTimeline();
Which is giving me the error:
exception 'Zend_Http_Client_Adapter_Exception' with message 'Unable to
Connect to ssl://api.twitter.com:443. Error #-223657718: Unable to find
the socket transport "ssl" - did you forget to enable it when you
configured PHP?'
I can connect to the apit.twitter.com through my browser so it's not a
proxy issue..
ssl://api.twitter.com:443
I am a trying to get a twitter feed displayed on the home page of my Zend
application, so far I have my IndexController code:
// ---------------Twitter Feed
$token = new Zend_Oauth_Token_Access();
$token->setParams(array(
'oauth_token' => 'token',
'oauth_token_secret' => 'tokSecret',
));
$twitter = new Zend_Service_Twitter(array(
'username' => 'usrname',
'accessToken' => $token,
'oauthOptions' => array(
'consumerKey' => 'consKey',
'consumerSecret' => 'consSecret',
)
));
$options = array('accessToken' => $token);
$this->view->twitter_timeline = $twitter->statuses->userTimeline();
Which is giving me the error:
exception 'Zend_Http_Client_Adapter_Exception' with message 'Unable to
Connect to ssl://api.twitter.com:443. Error #-223657718: Unable to find
the socket transport "ssl" - did you forget to enable it when you
configured PHP?'
I can connect to the apit.twitter.com through my browser so it's not a
proxy issue..
JS: Show/hide text field depending on radio button issue
JS: Show/hide text field depending on radio button issue
I have a JS that shows a test field if "1" is selected from a radio
button. And hides if "0" is selected. It's working while the text field is
hidden from the beginning but not if I want the text field to be visible
as default if the value is "1" from the database.
JS
$(document).ready(function() {
$("#send_to_yes").hide();
$("input:radio[name=\'article\']").change(function() {
if(this.value == \'1\' && this.checked){
$("#send_to_yes").show();
}
else {
$("#send_to_yes").hide();
}
});
});
HTML
Yes <input type="radio" name="article" value="1">
No <input type="radio" name="article" value="0">
<div id="send_to_yes">
<b>Number</b> <br><input type="text" name="number"><br><br>
</div>
CSS
#send_to_yes {
display: none;
}
The "1" and "0" comes from a database. With this code I need to press
"Yes" and then the text field comes up. Even if "Yes" is checked I need to
press it. I want it to be visible if "1" (Yes) is checked as default.
I have a JS that shows a test field if "1" is selected from a radio
button. And hides if "0" is selected. It's working while the text field is
hidden from the beginning but not if I want the text field to be visible
as default if the value is "1" from the database.
JS
$(document).ready(function() {
$("#send_to_yes").hide();
$("input:radio[name=\'article\']").change(function() {
if(this.value == \'1\' && this.checked){
$("#send_to_yes").show();
}
else {
$("#send_to_yes").hide();
}
});
});
HTML
Yes <input type="radio" name="article" value="1">
No <input type="radio" name="article" value="0">
<div id="send_to_yes">
<b>Number</b> <br><input type="text" name="number"><br><br>
</div>
CSS
#send_to_yes {
display: none;
}
The "1" and "0" comes from a database. With this code I need to press
"Yes" and then the text field comes up. Even if "Yes" is checked I need to
press it. I want it to be visible if "1" (Yes) is checked as default.
Subscribe to:
Comments (Atom)