Best way to prevent someone reading the source code
there are some form which I want to hide it from being read by someone
else.. what do you think is the best way to doing that?
hiding the source code in mysql and use query select to view the form.
encrypt the page with encoder.
is there any other way?
Thursday, 3 October 2013
Wednesday, 2 October 2013
Is there a maximum value or output to BigIntegers?
Is there a maximum value or output to BigIntegers?
I have a simple loop that does n = n ^ 2, where n is a BigInteger. But,
after the 11th iteration of the loop (I currently have it set to not go
further because of this issue), the console goes blank, but filled with
spaces. Like there should be characters there but there aren't. This is
evident as it's highlight-able. My question is; is there a cap on
BigIntegers, a max displayable output, or am I just not giving my CPU
enough time do the calculation?
import java.math.*;
public class Main {
static BigInteger n = BigInteger.valueOf(123);
static int j = 11;
public static void main(String[] args) {
while(j != 0) {
System.out.println(n);
n = n.pow(2);
j--;
}
System.out.println("Done. ");
}
}
I have a simple loop that does n = n ^ 2, where n is a BigInteger. But,
after the 11th iteration of the loop (I currently have it set to not go
further because of this issue), the console goes blank, but filled with
spaces. Like there should be characters there but there aren't. This is
evident as it's highlight-able. My question is; is there a cap on
BigIntegers, a max displayable output, or am I just not giving my CPU
enough time do the calculation?
import java.math.*;
public class Main {
static BigInteger n = BigInteger.valueOf(123);
static int j = 11;
public static void main(String[] args) {
while(j != 0) {
System.out.println(n);
n = n.pow(2);
j--;
}
System.out.println("Done. ");
}
}
Excel VBA: OnAction and Listview - strange behavior
Excel VBA: OnAction and Listview - strange behavior
My worksheet (Excel 2003) has a problem in popup button that I did. The
.OnAction calls a function "Inicia" with parameters. It almost works.
Error occurs when funcion 'Inicia' calls a public function
'FormConsulta.Pesquisa2(string arg)' to search data from a sheet and to
fill to a listview. 'Pesquisa2' has a loop that passes only one time and
listview returns only one value (not always the first item found).
If I call 'FormConsulta.Pesquisa2(string arg)' anywhere, it works plenty,
but if my menu button calls it, it returns only 01 result. Here is my
code:
My Popup menu button:
With Application.CommandBars("Cell").Controls.Add(Type:=msoControlButton,
before:=1, temporary:=True)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "Inicia(" & Chr(34) &
CStr(celula) & Chr(34) & ")" 'celula = an excel Cell rightclicked (type
Variant)
'style, caption, images, etc..
End With
sub Inicia: (placed on same module)
Private Sub Inicia(Optional celula As Variant)
If IsMissing(celula) Then 'se a sub foi chamada sem clicar com o
botão direito, apenas exibe form
FormAberturaChamado.Show 'this works fine this form has a call to
FormConsulta.Pesquisa2(arg) thar works fine!!
Exit Sub
End If
'(...) problem lies down here VV
If FormConsulta.Pesquisa2(celula) > 0 Then FormConsulta.Show
'(...)
End Sub
And finally FormConsulta.Pesquisa2 code:
Public Function Pesquisa2(ByVal valor As String) As Long 'boolean
'Variáveis locais
Dim rng1 As Range, rngPesquisa As Range, linBD As Long, contEncontrado
As Long, firstAddress As String,
Dim liit As ListItem
With Me.lvConsulta 'lvConsulta is ListView
.ListItems.Clear
.ColumnHeaders.Clear
.Gridlines = True
.View = lvwReport
'headers
'(...)
.ColumnHeaders.Add , , "Nome Fantasia", Width:=150
.ColumnHeaders.Add , , "Razão Social", Width:=166
.ColumnHeaders.Add , , "Telefone", Width:=62
.ColumnHeaders.Add , , "Contato", Width:=76
'etc...
End With
contEncontrado = 0 'items found
Set rngPesquisa = Sheets(PLANBD).Range("A:A") 'range of search. It's a
sample, there are other ranges of search based on type of search
Set rng1 = rngPesquisa.Find(what:=valor, MatchCase:=False)
If Not rng1 Is Nothing Then 'found at least one item
firstAddress = rng1.Address
Do 'continue searching
linBD = rng1.Row 'actual line
Set liit = FormConsulta.lvConsulta.ListItems.Add(, ,
Sheets(PLANBD).Range("A" & linBD).Value) 'Nome Fanstasia
liit.SubItems(2) = Sheets(PLANBD).Range("D" & linBD).Value
'Razao Social col D
liit.SubItems(3) = Sheets(PLANBD).Range("G" & linBD).Value
'Telefone col G
liit.SubItems(4) = Sheets(PLANBD).Range("H" & linBD).Value
'Contato Col H
'(...)
rng1 = rngPesquisa.FindNext(rng1) 'find next item
contEncontrado = contEncontrado + 1 'add items found
Loop While Not rng1 Is Nothing And rng1.Address <> firstAddress
'MsgBox("found xxx items")
Else
Call MsgBox("Nothing found", vbExclamation + vbOKOnly)
End If
Pesquisa2 = contEncontrado 'returns number of items found
End Function
Here is Do Loop While that passes only one time when I click on my menu
button. However it works fine when I call it from another Form.
Debug does not work, except if I call 'Pesquisa2' from another Form.
Anyone can help me? thanx in advance
My worksheet (Excel 2003) has a problem in popup button that I did. The
.OnAction calls a function "Inicia" with parameters. It almost works.
Error occurs when funcion 'Inicia' calls a public function
'FormConsulta.Pesquisa2(string arg)' to search data from a sheet and to
fill to a listview. 'Pesquisa2' has a loop that passes only one time and
listview returns only one value (not always the first item found).
If I call 'FormConsulta.Pesquisa2(string arg)' anywhere, it works plenty,
but if my menu button calls it, it returns only 01 result. Here is my
code:
My Popup menu button:
With Application.CommandBars("Cell").Controls.Add(Type:=msoControlButton,
before:=1, temporary:=True)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "Inicia(" & Chr(34) &
CStr(celula) & Chr(34) & ")" 'celula = an excel Cell rightclicked (type
Variant)
'style, caption, images, etc..
End With
sub Inicia: (placed on same module)
Private Sub Inicia(Optional celula As Variant)
If IsMissing(celula) Then 'se a sub foi chamada sem clicar com o
botão direito, apenas exibe form
FormAberturaChamado.Show 'this works fine this form has a call to
FormConsulta.Pesquisa2(arg) thar works fine!!
Exit Sub
End If
'(...) problem lies down here VV
If FormConsulta.Pesquisa2(celula) > 0 Then FormConsulta.Show
'(...)
End Sub
And finally FormConsulta.Pesquisa2 code:
Public Function Pesquisa2(ByVal valor As String) As Long 'boolean
'Variáveis locais
Dim rng1 As Range, rngPesquisa As Range, linBD As Long, contEncontrado
As Long, firstAddress As String,
Dim liit As ListItem
With Me.lvConsulta 'lvConsulta is ListView
.ListItems.Clear
.ColumnHeaders.Clear
.Gridlines = True
.View = lvwReport
'headers
'(...)
.ColumnHeaders.Add , , "Nome Fantasia", Width:=150
.ColumnHeaders.Add , , "Razão Social", Width:=166
.ColumnHeaders.Add , , "Telefone", Width:=62
.ColumnHeaders.Add , , "Contato", Width:=76
'etc...
End With
contEncontrado = 0 'items found
Set rngPesquisa = Sheets(PLANBD).Range("A:A") 'range of search. It's a
sample, there are other ranges of search based on type of search
Set rng1 = rngPesquisa.Find(what:=valor, MatchCase:=False)
If Not rng1 Is Nothing Then 'found at least one item
firstAddress = rng1.Address
Do 'continue searching
linBD = rng1.Row 'actual line
Set liit = FormConsulta.lvConsulta.ListItems.Add(, ,
Sheets(PLANBD).Range("A" & linBD).Value) 'Nome Fanstasia
liit.SubItems(2) = Sheets(PLANBD).Range("D" & linBD).Value
'Razao Social col D
liit.SubItems(3) = Sheets(PLANBD).Range("G" & linBD).Value
'Telefone col G
liit.SubItems(4) = Sheets(PLANBD).Range("H" & linBD).Value
'Contato Col H
'(...)
rng1 = rngPesquisa.FindNext(rng1) 'find next item
contEncontrado = contEncontrado + 1 'add items found
Loop While Not rng1 Is Nothing And rng1.Address <> firstAddress
'MsgBox("found xxx items")
Else
Call MsgBox("Nothing found", vbExclamation + vbOKOnly)
End If
Pesquisa2 = contEncontrado 'returns number of items found
End Function
Here is Do Loop While that passes only one time when I click on my menu
button. However it works fine when I call it from another Form.
Debug does not work, except if I call 'Pesquisa2' from another Form.
Anyone can help me? thanx in advance
Internet LAN Line-connection was reset
Internet LAN Line-connection was reset
I have 12.04 LTS running on my machine. Since I have had Ubuntu installed
I have been unable to connect to the internet with my lan line. Whenever
firefox is opened the message appears, "This connection was reset, The
connection to the server was reset while the page was loading." This
happens with any website I attempt to visit.
When I run the command ifconfig the following appears:
hatch@hatch-MXC6300:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:30:64:0f:dd:7a
inet addr:10.7.32.113 Bcast:10.7.63.255 Mask:255.255.224.0
inet6 addr: fe80::230:64ff:fe0f:dd7a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:20242 errors:0 dropped:0 overruns:0 frame:0
TX packets:3724 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1794017 (1.7 MB) TX bytes:577696 (577.6 KB)
Interrupt:20 Memory:f7e00000-f7e20000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:325 errors:0 dropped:0 overruns:0 frame:0
TX packets:325 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:28145 (28.1 KB) TX bytes:28145 (28.1 KB)
Also the firewall has been disabled.
Any help is much appreciated, -Cat
I have 12.04 LTS running on my machine. Since I have had Ubuntu installed
I have been unable to connect to the internet with my lan line. Whenever
firefox is opened the message appears, "This connection was reset, The
connection to the server was reset while the page was loading." This
happens with any website I attempt to visit.
When I run the command ifconfig the following appears:
hatch@hatch-MXC6300:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:30:64:0f:dd:7a
inet addr:10.7.32.113 Bcast:10.7.63.255 Mask:255.255.224.0
inet6 addr: fe80::230:64ff:fe0f:dd7a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:20242 errors:0 dropped:0 overruns:0 frame:0
TX packets:3724 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1794017 (1.7 MB) TX bytes:577696 (577.6 KB)
Interrupt:20 Memory:f7e00000-f7e20000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:325 errors:0 dropped:0 overruns:0 frame:0
TX packets:325 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:28145 (28.1 KB) TX bytes:28145 (28.1 KB)
Also the firewall has been disabled.
Any help is much appreciated, -Cat
How to accept different data types from the user in java
How to accept different data types from the user in java
I'm a beginner in Java and I just wrote a program to get the user's name,
phone number and address. The problem is after reading the phone number
the program will not proceed to read the address, it's like if it's
skipping it. Here is my code:
public static void main(String [] arge){
Scanner sc = new Scanner(System.in);
System.out.println("Enter your name, phone number and address");
String name = sc.nextLine();
long phone = sc.nextLong();
String address = sc.nextLine();
System.out.println("\n *** Here is your info ***");
System.out.println("Name: "+name+"\nPhone number: "+phone+"\n Address:
"+address);
}
I'm a beginner in Java and I just wrote a program to get the user's name,
phone number and address. The problem is after reading the phone number
the program will not proceed to read the address, it's like if it's
skipping it. Here is my code:
public static void main(String [] arge){
Scanner sc = new Scanner(System.in);
System.out.println("Enter your name, phone number and address");
String name = sc.nextLine();
long phone = sc.nextLong();
String address = sc.nextLine();
System.out.println("\n *** Here is your info ***");
System.out.println("Name: "+name+"\nPhone number: "+phone+"\n Address:
"+address);
}
Tuesday, 1 October 2013
Accessing non-consecutive elements of a list in python
Accessing non-consecutive elements of a list in python
As far as I can tell, this is not officially not possible, but is there a
"trick" to access arbitrary non-sequential elements of a list by slicing?
For example:
>>> L = range(0,101,10)
>>> L
[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
Now I want to be able to do
a,b = L[2,5]
so that a == 20 and b == 50
One way besides two statements would be something silly like:
a,b = L[2:6:3][:2]
But that doesn't scale at all to irregular intervals.
Maybe with list comprehension using the indices I want?
[L[x] for x in [2,5]]
I would love to know what is recommended for this common problem.
As far as I can tell, this is not officially not possible, but is there a
"trick" to access arbitrary non-sequential elements of a list by slicing?
For example:
>>> L = range(0,101,10)
>>> L
[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
Now I want to be able to do
a,b = L[2,5]
so that a == 20 and b == 50
One way besides two statements would be something silly like:
a,b = L[2:6:3][:2]
But that doesn't scale at all to irregular intervals.
Maybe with list comprehension using the indices I want?
[L[x] for x in [2,5]]
I would love to know what is recommended for this common problem.
Does Github rate limit apply globally per IP address?
Does Github rate limit apply globally per IP address?
From the Github doc:
For requests using Basic Authentication or OAuth, you can make up to 5,000
requests per hour.
Is 5000 reqs/hour global or per IP address?
From the Github doc:
For requests using Basic Authentication or OAuth, you can make up to 5,000
requests per hour.
Is 5000 reqs/hour global or per IP address?
how to get quick expire of sudo auto password save?
how to get quick expire of sudo auto password save?
we all know that in Ubuntu sudo password will be auto saved for 15 minutes
and expires after that. But I want to make it for quick expire. I mean I
dont want to change any settings and when I ever I want , My system should
have to release the password with out storing for 15 min. I mean it should
store only 3 min or 4 min for example.
how can i do that ?
we all know that in Ubuntu sudo password will be auto saved for 15 minutes
and expires after that. But I want to make it for quick expire. I mean I
dont want to change any settings and when I ever I want , My system should
have to release the password with out storing for 15 min. I mean it should
store only 3 min or 4 min for example.
how can i do that ?
Solution for PDE
Solution for PDE
I have the following PDE: $$u_t+(1+\epsilon \sin x)u_x=0$$ where $\epsilon
\to 0$ and I want to find the explicit form of the solution including
terms up to $O(\epsilon)$ and as initial condition I have $x(0)=s$. Now, I
manage it to write down $dx/(1+\epsilon \sin x) = dt$ and then using
$1/(1+\epsilon \sin x) = 1 - \epsilon\sin x + O(\epsilon^2)$ I find out:
$$ x-s+\epsilon\bigl(\cos(x)-\cos(s)\bigr)=t \tag{$*$}$$
The problem is that my solution is $u=f(s)$ and therefore I need to
express $s$ as a function of $x$ and $t$ from $(*)$.
Any suggestions?
I have the following PDE: $$u_t+(1+\epsilon \sin x)u_x=0$$ where $\epsilon
\to 0$ and I want to find the explicit form of the solution including
terms up to $O(\epsilon)$ and as initial condition I have $x(0)=s$. Now, I
manage it to write down $dx/(1+\epsilon \sin x) = dt$ and then using
$1/(1+\epsilon \sin x) = 1 - \epsilon\sin x + O(\epsilon^2)$ I find out:
$$ x-s+\epsilon\bigl(\cos(x)-\cos(s)\bigr)=t \tag{$*$}$$
The problem is that my solution is $u=f(s)$ and therefore I need to
express $s$ as a function of $x$ and $t$ from $(*)$.
Any suggestions?
Monday, 30 September 2013
Extracting a zip file in my machne givs me CRC error?
Extracting a zip file in my machne givs me CRC error?
I have a large zip that contain hundreds of file. I've unzip'ed it in more
than one machine and didn't have any problem before. However, for this
particular machine (Ubuntu Server 12.04) I keep getting CRC error for some
of the files inside my zip. I've unzip'ed the same file it on anther
machine just to and its fine.
Any clue?
I have a large zip that contain hundreds of file. I've unzip'ed it in more
than one machine and didn't have any problem before. However, for this
particular machine (Ubuntu Server 12.04) I keep getting CRC error for some
of the files inside my zip. I've unzip'ed the same file it on anther
machine just to and its fine.
Any clue?
How should I detect whether any of a list of links resolves=?iso-8859-1?Q?=3F_=96_tridion.stackexchange.com?=
How should I detect whether any of a list of links resolves? –
tridion.stackexchange.com
I am making an ASP.NET control which displays a list of links embedded in
a containing <ul/>. Based on a taxonomy query, I'm going to add a list of
Tridion.ContentDelivery.Web.UI.ComponentLink …
tridion.stackexchange.com
I am making an ASP.NET control which displays a list of links embedded in
a containing <ul/>. Based on a taxonomy query, I'm going to add a list of
Tridion.ContentDelivery.Web.UI.ComponentLink …
How do I take input from an asp web form to a visual basic back end?
How do I take input from an asp web form to a visual basic back end?
Here's what I've come up with so far (from other research):
Dim strStudentEmail As String = If(Request.Form("StudentEmail"), "")
However when I check the output from this it comes out blank.
The input comes from this text box markup on an asp webpage:
Student Email Address:
<br />
<asp:TextBox ID="StudentEmail" runat="server"
AutoCompleteType="Email"></asp:TextBox>
<br />
P.S. I'm very new to asp & Visual Basic syntax.
Here's what I've come up with so far (from other research):
Dim strStudentEmail As String = If(Request.Form("StudentEmail"), "")
However when I check the output from this it comes out blank.
The input comes from this text box markup on an asp webpage:
Student Email Address:
<br />
<asp:TextBox ID="StudentEmail" runat="server"
AutoCompleteType="Email"></asp:TextBox>
<br />
P.S. I'm very new to asp & Visual Basic syntax.
delte row from MYSQL database based on variable ID using PHP button in FORM
delte row from MYSQL database based on variable ID using PHP button in FORM
I work on a website where you can add tags to a video. this screenshot
should give you an overview how the result should look like:
http://www.unistamp.ch/images/images.html
A video with comments is embeded and to the right there is an Iframe where
the detailed information for the comments on the timeline are accessed
from a MYSQL database. Here a screenshot of the video_comment table.
I want to delete a specific comment from the database based on his comment
ID. I tried this code but it doesnt work to pass the commentid by clicking
the X button:
<?php
include '../../../DB/MySql/connectVideoPhase.php';
//****** Delete Row in table
if(isset($_POST['X']))
{
$comment_id = $_POST['comment_id'];
//CHeck --> doesnt work
echo "<pre> commentid= ".$comment_id . "</pre> ";
$sql = "DELETE video_converted_comment ".
"WHERE commentid = \"".$comment_id."\" ;";
$retval = mysql_query( $sql);
if(! $retval )
{ die('Could not delete data: ' . mysql_error()); }
echo "Deleted data successfully\n";
}
//**************************************
//******* Get the comments
$video_id = $_REQUEST['VideoId'];
// for testing use a specific video ID
if (! $video_id) {
$video_id = '153fb143';
}
$sqlSelectComment = "Select * from
video_converted_comment WHERE videoid
='".$video_id."'";
$sqlComments = mysql_query($sqlSelectComment);
$i = mysql_num_rows($sqlSelectComment);
// *************************
//********* Fill Table
echo "
<table width=\"100\" border=\"1\" >
<tr>
<td width=\"25\"><b>start</b></td>
<td width=\"25\"><b>end</b></td>
<td width=\"75\"><b>Text</b></td>
<td width=\"5\"><b>X</b></td>
<td width=\"0\"><input type=\"hidden\"></td>
</tr>";
while ($comments = mysql_fetch_array($sqlComments))
{
echo "<tr><td>" .$comments['starttime'] ."</td>";
echo "<td>" .$comments['endtime'] ."</td>";
echo "<td>" .$comments['text'] ."</td>";
echo "<td> <form method=\"post\" action=\"".$_PHP_SELF ."\">
<input name=\"comment_id\" type=\"hidden\"
value=\"".$comments['id']."\">
<button name=\"X\" type=\"submit\"
value=\"".$comments['id']."\"> </td>
</form>";
}
echo "</table> ";
Any help on deleting/ adding comments to the DB based on a commentid using
PHP would be very appreciated! Would it be easier to do it with
javascript? The visualisation of the timeline below the video is done with
javascript.
I work on a website where you can add tags to a video. this screenshot
should give you an overview how the result should look like:
http://www.unistamp.ch/images/images.html
A video with comments is embeded and to the right there is an Iframe where
the detailed information for the comments on the timeline are accessed
from a MYSQL database. Here a screenshot of the video_comment table.
I want to delete a specific comment from the database based on his comment
ID. I tried this code but it doesnt work to pass the commentid by clicking
the X button:
<?php
include '../../../DB/MySql/connectVideoPhase.php';
//****** Delete Row in table
if(isset($_POST['X']))
{
$comment_id = $_POST['comment_id'];
//CHeck --> doesnt work
echo "<pre> commentid= ".$comment_id . "</pre> ";
$sql = "DELETE video_converted_comment ".
"WHERE commentid = \"".$comment_id."\" ;";
$retval = mysql_query( $sql);
if(! $retval )
{ die('Could not delete data: ' . mysql_error()); }
echo "Deleted data successfully\n";
}
//**************************************
//******* Get the comments
$video_id = $_REQUEST['VideoId'];
// for testing use a specific video ID
if (! $video_id) {
$video_id = '153fb143';
}
$sqlSelectComment = "Select * from
video_converted_comment WHERE videoid
='".$video_id."'";
$sqlComments = mysql_query($sqlSelectComment);
$i = mysql_num_rows($sqlSelectComment);
// *************************
//********* Fill Table
echo "
<table width=\"100\" border=\"1\" >
<tr>
<td width=\"25\"><b>start</b></td>
<td width=\"25\"><b>end</b></td>
<td width=\"75\"><b>Text</b></td>
<td width=\"5\"><b>X</b></td>
<td width=\"0\"><input type=\"hidden\"></td>
</tr>";
while ($comments = mysql_fetch_array($sqlComments))
{
echo "<tr><td>" .$comments['starttime'] ."</td>";
echo "<td>" .$comments['endtime'] ."</td>";
echo "<td>" .$comments['text'] ."</td>";
echo "<td> <form method=\"post\" action=\"".$_PHP_SELF ."\">
<input name=\"comment_id\" type=\"hidden\"
value=\"".$comments['id']."\">
<button name=\"X\" type=\"submit\"
value=\"".$comments['id']."\"> </td>
</form>";
}
echo "</table> ";
Any help on deleting/ adding comments to the DB based on a commentid using
PHP would be very appreciated! Would it be easier to do it with
javascript? The visualisation of the timeline below the video is done with
javascript.
Sunday, 29 September 2013
Lenovo Twist Touchpad Problems
Lenovo Twist Touchpad Problems
I have a Lenovo Twist (laptop that converts to a tablet) Win 8 with a
touchscreen. I've tried to load several versions of Linux and the problem
I run into is the touchpad is not recognized. The touchscreen works but
the touchpad isn't loaded when I go into control panel. I posted on a
different forum and was told I should do a insmod psmouse but that did't
work.
Any idea how I can load drivers for my touchpad?
I have a Lenovo Twist (laptop that converts to a tablet) Win 8 with a
touchscreen. I've tried to load several versions of Linux and the problem
I run into is the touchpad is not recognized. The touchscreen works but
the touchpad isn't loaded when I go into control panel. I posted on a
different forum and was told I should do a insmod psmouse but that did't
work.
Any idea how I can load drivers for my touchpad?
Restrict the scope of data when using withCriteria
Restrict the scope of data when using withCriteria
I currently have the following 3 domain classes :
User.groovy
class User {
...
static hasMany = [
...
]
static belongsTo = [
course : Course,
university : University
]
}
Course.groovy
class Course {
String title
static hasMany = [
universities : University,
users : User
]
static belongsTo = University
}
University.groovy
class University {
String name
static hasMany = [
courses : Course,
users : User
]
}
I gather all of the courses for a university with the following code :
def courses = Course.withCriteria {
universities {
eq('id', Long.parseLong(params.universityId))
}
}
render courses as JSON
With an example response like so :
[{
"class":"classifieds.Course",
"id":1,
"title":"Computer Science",
"universities":
[{"class":"University",
"id":1}],
"users":
[{"class":"User"
,"id":1}]
}]
My issue is that I want to restrict the scope of the response to not
include the users or universitiesthat are currently being returned, I only
what a list of courses to be returned in the JSON. How to I restrict this?
I currently have the following 3 domain classes :
User.groovy
class User {
...
static hasMany = [
...
]
static belongsTo = [
course : Course,
university : University
]
}
Course.groovy
class Course {
String title
static hasMany = [
universities : University,
users : User
]
static belongsTo = University
}
University.groovy
class University {
String name
static hasMany = [
courses : Course,
users : User
]
}
I gather all of the courses for a university with the following code :
def courses = Course.withCriteria {
universities {
eq('id', Long.parseLong(params.universityId))
}
}
render courses as JSON
With an example response like so :
[{
"class":"classifieds.Course",
"id":1,
"title":"Computer Science",
"universities":
[{"class":"University",
"id":1}],
"users":
[{"class":"User"
,"id":1}]
}]
My issue is that I want to restrict the scope of the response to not
include the users or universitiesthat are currently being returned, I only
what a list of courses to be returned in the JSON. How to I restrict this?
Mysql & Php SUM function, array
Mysql & Php SUM function, array
Tried to make a script that calculate all values from a column but instead
of getting the sum of values I get "Array"
$sql = "SELECT SUM(Money) FROM players";
$result = mysql_query($sql) or die (mysql_error());
$BaniTotal = mysql_fetch_assoc($result);
Tried to make a script that calculate all values from a column but instead
of getting the sum of values I get "Array"
$sql = "SELECT SUM(Money) FROM players";
$result = mysql_query($sql) or die (mysql_error());
$BaniTotal = mysql_fetch_assoc($result);
Testing In app purchase using IAB helper class
Testing In app purchase using IAB helper class
Hi Im trying to test in app purchase in my app. It seems that everything
has been setup properly but when im trying to purchase an item im getting
the following:
"error processing purchase df-ppa-40"
Has anyone encountered this issue?
Hi Im trying to test in app purchase in my app. It seems that everything
has been setup properly but when im trying to purchase an item im getting
the following:
"error processing purchase df-ppa-40"
Has anyone encountered this issue?
Saturday, 28 September 2013
How to save UIDatePicker Date and print it back out?
How to save UIDatePicker Date and print it back out?
I have a UIDatePicker on my ViewController, and When I click the save
button, I want it to save the date to a variable, allowing me to print the
content of the variable, which should be the date that it was set.
I have a model(Class) to save all info on my ViewController (UiTextField
text, etc...), I am just not sure how to save a date from the DatePicker
and print it out. Can anyone help me figure how to make it work?
This is my first app(Besides Hello World)
I have a UIDatePicker on my ViewController, and When I click the save
button, I want it to save the date to a variable, allowing me to print the
content of the variable, which should be the date that it was set.
I have a model(Class) to save all info on my ViewController (UiTextField
text, etc...), I am just not sure how to save a date from the DatePicker
and print it out. Can anyone help me figure how to make it work?
This is my first app(Besides Hello World)
How can I get my quotes to diplay corretly in PHP using MYSQL information and put them inside and onclick event?
How can I get my quotes to diplay corretly in PHP using MYSQL information
and put them inside and onclick event?
Paraphrasing...
OK i have information in a database it reads: This is random text with a
"random quote"
$var = 'This is random text with a "random quote"'
onClick="show(\''.$var.'\')
but when displayed (viewing source) it shows:
onclick="show('This is random text with a " random="" quote"')
I have tried mysqli_real_escape_string and str_replace, str_replace works
if i am removing the "
Any help, alterations or reworks I would be grateful its driving me nuts
right now.
and put them inside and onclick event?
Paraphrasing...
OK i have information in a database it reads: This is random text with a
"random quote"
$var = 'This is random text with a "random quote"'
onClick="show(\''.$var.'\')
but when displayed (viewing source) it shows:
onclick="show('This is random text with a " random="" quote"')
I have tried mysqli_real_escape_string and str_replace, str_replace works
if i am removing the "
Any help, alterations or reworks I would be grateful its driving me nuts
right now.
Queries on Maven
Queries on Maven
1) I created a java project using below command. mvn archetype:create
-DgroupId=your.simple.java.gid -DartifactId=maventest After project
creation I checked pom.xml file and only depedecy I found is Junit.So why
doe it download other libraries like asm, antlr, oro, xmlapis,Jdom etc.
2) After this I created a web project by command mvn archetype:generate
-DgroupId=com.mycompany.app -DartifactId=my-webapp
-DarchetypeArtifactId=maven-archetype-webapp. In pom.xml Junit dependecy
is available but in project there is no test folder. Why does not this
creates test folder?
3)If I go to .m2/repository folder there are multiple libary folder
available. For example if I go inside asm directory
.m2/repository/asm/asm/3.2 I found below files.
a)asm-3.2.jar
b)asm-3.2.jar.sha1
c)asm-3.2.pom
d)asm-3.2.pom.sha1
e)_maven.repositories
I am not sure about .pom .sha1 and .repositories files. What are they for?
1) I created a java project using below command. mvn archetype:create
-DgroupId=your.simple.java.gid -DartifactId=maventest After project
creation I checked pom.xml file and only depedecy I found is Junit.So why
doe it download other libraries like asm, antlr, oro, xmlapis,Jdom etc.
2) After this I created a web project by command mvn archetype:generate
-DgroupId=com.mycompany.app -DartifactId=my-webapp
-DarchetypeArtifactId=maven-archetype-webapp. In pom.xml Junit dependecy
is available but in project there is no test folder. Why does not this
creates test folder?
3)If I go to .m2/repository folder there are multiple libary folder
available. For example if I go inside asm directory
.m2/repository/asm/asm/3.2 I found below files.
a)asm-3.2.jar
b)asm-3.2.jar.sha1
c)asm-3.2.pom
d)asm-3.2.pom.sha1
e)_maven.repositories
I am not sure about .pom .sha1 and .repositories files. What are they for?
Netbeans binding
Netbeans binding
I'm trying to bind a table from my db in a Jtable in my desktop app. I had
follow the step in this guide:
https://netbeans.org/kb/docs/java/gui-binding.html and everything is fine,
but I can't change the query to show the data in a different order. If I
try to change the query the application does not work. Netbeans had create
the query so:
SELECT t FROM TbAzioni t
my table name is tb_azioni and I would like to have a query like this:
select * from tb_azioni order by azcodaz
but if I change the query nothing works. Thank you
I'm trying to bind a table from my db in a Jtable in my desktop app. I had
follow the step in this guide:
https://netbeans.org/kb/docs/java/gui-binding.html and everything is fine,
but I can't change the query to show the data in a different order. If I
try to change the query the application does not work. Netbeans had create
the query so:
SELECT t FROM TbAzioni t
my table name is tb_azioni and I would like to have a query like this:
select * from tb_azioni order by azcodaz
but if I change the query nothing works. Thank you
Friday, 27 September 2013
TinyMCE 4 not showing toolbar icons in IE9 (any mode)
TinyMCE 4 not showing toolbar icons in IE9 (any mode)
TinyMCE has this easy to use code, but I cannot see the toolbar icons in
IE9 (the imgs don't load it seems).
<html>
<head><!-- CDN hosted by Cachefly -->
<script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script>
<script> tinymce.init({selector:'textarea'});</script>
</head>
<body>
<textarea>Your content here.</textarea>
</body>
</html>
I've seen this similar post (tinymce icons in internet explorer), but the
advice made no difference for me.
I've tried putting the browser in different modes, nothing worked. The
only time I saw it work in IE was inside the EditPlus embedded browser,
but I don't know exactly what that is.
Works nicely in Chrome.
EDIT- does work in IE when the file is loaded directly, eg.
C:\inetpub\wwwroot\tiny.html
Thanks.
TinyMCE has this easy to use code, but I cannot see the toolbar icons in
IE9 (the imgs don't load it seems).
<html>
<head><!-- CDN hosted by Cachefly -->
<script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script>
<script> tinymce.init({selector:'textarea'});</script>
</head>
<body>
<textarea>Your content here.</textarea>
</body>
</html>
I've seen this similar post (tinymce icons in internet explorer), but the
advice made no difference for me.
I've tried putting the browser in different modes, nothing worked. The
only time I saw it work in IE was inside the EditPlus embedded browser,
but I don't know exactly what that is.
Works nicely in Chrome.
EDIT- does work in IE when the file is loaded directly, eg.
C:\inetpub\wwwroot\tiny.html
Thanks.
Make the exportation of data occur for a chosen date
Make the exportation of data occur for a chosen date
I have Excel code which gets into intranet:
sub TESTE()
Dim Data As Date
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
URL = "(URL address)"
ie.navigate (URL)
Data = Date - 1
ie.document.getElementById("ctl31_ctl04_ctl03_ddDropDownButton").Click '
Calendario
ie.document.getElementById("ctl31_ctl04_ctl03_txtValue").Value =
Format(Data, "dd/mm/yyyy") ' Data
ie.document.getElementById("ctl31_ctl04_ctl00").Click ' Exibir Relatório
URL = "(URL address)"
ie.navigate (URL)
End Sub
However, in the last line of the code, the exportation doesn´t occur by
the chosen date, it always considers today. What can I do to make the
exportation consider a chosen date?
I have Excel code which gets into intranet:
sub TESTE()
Dim Data As Date
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
URL = "(URL address)"
ie.navigate (URL)
Data = Date - 1
ie.document.getElementById("ctl31_ctl04_ctl03_ddDropDownButton").Click '
Calendario
ie.document.getElementById("ctl31_ctl04_ctl03_txtValue").Value =
Format(Data, "dd/mm/yyyy") ' Data
ie.document.getElementById("ctl31_ctl04_ctl00").Click ' Exibir Relatório
URL = "(URL address)"
ie.navigate (URL)
End Sub
However, in the last line of the code, the exportation doesn´t occur by
the chosen date, it always considers today. What can I do to make the
exportation consider a chosen date?
Fixing PHP undefined index errors
Fixing PHP undefined index errors
$id_cust = $_POST['id_cust'];
$username = $_POST['username'];
$sql = ("UPDATE customer SET username = '$username' WHERE id_cust =
'$id_cust'");
mysql_select_db('dbisupply');
$retval = mysql_query( $sql, $conn );
if(! $retval )
The error is undefined index in id_cust.
What is the problem with this code ? The query seems correct.
$id_cust = $_POST['id_cust'];
$username = $_POST['username'];
$sql = ("UPDATE customer SET username = '$username' WHERE id_cust =
'$id_cust'");
mysql_select_db('dbisupply');
$retval = mysql_query( $sql, $conn );
if(! $retval )
The error is undefined index in id_cust.
What is the problem with this code ? The query seems correct.
Change or increase the bitrate of mp3 in C#
Change or increase the bitrate of mp3 in C#
Is there anyway we can change the bitrate of the mp3 file using c# code? I
have used NAudio to create a mp3 mixer but what i want now is to increase
the bitrate to 320kbps for the resulting mp3 file after mixing 3 of the
different mp3 files into one. The bitrate currently shows 128kbps for the
output mp3 file.
Is there anyway we can change the bitrate of the mp3 file using c# code? I
have used NAudio to create a mp3 mixer but what i want now is to increase
the bitrate to 320kbps for the resulting mp3 file after mixing 3 of the
different mp3 files into one. The bitrate currently shows 128kbps for the
output mp3 file.
Send and receive JSON to REST WebService in Jersey Java
Send and receive JSON to REST WebService in Jersey Java
I am new to Jersey Java REST WebService framework. I am trying to write a
service method which consumes and produces JSON. My service code is below.
It is simplest code, just for studying purpose.
@Path("/myresource")
public class MyResource {
@Path("/sendReceiveJson")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String sendReceiveJson(String name)
{
System.out.println("Value in name: " + name);
return "{\"serviceName\": \"Mr.Server\"}";
}
}
And following is JerseyClient code.
public class Program {
public static void main(String[] args) throws Exception{
String
urlString="http://localhost:8080/MyWebService/webresources/myresource/sendReceiveJson";
URL url=new URL(urlString);
URLConnection connection=url.openConnection();
connection.setDoOutput(true);
OutputStreamWriter out = new
OutputStreamWriter(connection.getOutputStream());
out.write("{\"clientName\": \"Mr.Client\"}");
out.close();
BufferedReader in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
String decodedString;
while ((decodedString = in.readLine()) != null) {
System.out.println(decodedString);
}
in.close();
}
}
But when i run service and then client, i am unable to send/receive JSON
data. Please guide me, what needs to correct, or whether i am in wrong
direction.
I am new to Jersey Java REST WebService framework. I am trying to write a
service method which consumes and produces JSON. My service code is below.
It is simplest code, just for studying purpose.
@Path("/myresource")
public class MyResource {
@Path("/sendReceiveJson")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String sendReceiveJson(String name)
{
System.out.println("Value in name: " + name);
return "{\"serviceName\": \"Mr.Server\"}";
}
}
And following is JerseyClient code.
public class Program {
public static void main(String[] args) throws Exception{
String
urlString="http://localhost:8080/MyWebService/webresources/myresource/sendReceiveJson";
URL url=new URL(urlString);
URLConnection connection=url.openConnection();
connection.setDoOutput(true);
OutputStreamWriter out = new
OutputStreamWriter(connection.getOutputStream());
out.write("{\"clientName\": \"Mr.Client\"}");
out.close();
BufferedReader in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
String decodedString;
while ((decodedString = in.readLine()) != null) {
System.out.println(decodedString);
}
in.close();
}
}
But when i run service and then client, i am unable to send/receive JSON
data. Please guide me, what needs to correct, or whether i am in wrong
direction.
emacs : auto-complete and golevka : force file parsing
emacs : auto-complete and golevka : force file parsing
The question for some user's/devel's of that
https://github.com/auto-complete/auto-complete and
https://github.com/Golevka/emacs-clang-complete-async : How do I
explicitly force to parse the file ? ( and add the resulting tags into the
potential >> complete-tags database << ? I the clang-complete works well
when it comes to complete tags from active buffers, but it's no no , when
completing external libraries tags ( mine standard example is Ogre3d
library include headers ... ). With CEDET/semanatic the command was M-x
senator-force-tag-refresh for visting buffer ( I just opened this cmd to
all opened Ogre .h files ), however C./S. is to poor to parse complex
template trickery ...
The question for some user's/devel's of that
https://github.com/auto-complete/auto-complete and
https://github.com/Golevka/emacs-clang-complete-async : How do I
explicitly force to parse the file ? ( and add the resulting tags into the
potential >> complete-tags database << ? I the clang-complete works well
when it comes to complete tags from active buffers, but it's no no , when
completing external libraries tags ( mine standard example is Ogre3d
library include headers ... ). With CEDET/semanatic the command was M-x
senator-force-tag-refresh for visting buffer ( I just opened this cmd to
all opened Ogre .h files ), however C./S. is to poor to parse complex
template trickery ...
Thursday, 26 September 2013
Dependency property binding Issue WPF
Dependency property binding Issue WPF
Kindly Let me Know where I am wrong
Xaml --- Xaml of User Control where I use my child user control with
dependency property
ComboBox SelectedItem will Update SelectedEmployee, This SelectedEmployee
is further Binded with My child Control CardView:uEmployeeCard ViewModel
Property---
<ComboBox Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"
Style="{StaticResource UiComboBox}" ItemsSource="{Binding
TB_EMPLOYEEList}" SelectedItem="{Binding SelectedEmployee, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
SelectedValuePath="ID" SelectedValue="{Binding
CurrentTB_RECIEPT.REFRENCEID}"
ItemTemplate="{StaticResource
ComboEmployeeTemplate}"/>
<CardView:uEmployeeCard ViewModel="{Binding
Path=SelectedEmployee}" Grid.Row="1" Grid.Column="0"
Grid.ColumnSpan="2" Grid.RowSpan="3"
VerticalAlignment="Top"/>
------------Dependency Property Code , Code Behind file of uEmployeeCard ----
public uEmployeeCard()
{
InitializeComponent();
this.DataContext = this;
}
public static readonly DependencyProperty ViewModelProperty =
DependencyProperty.Register("ViewModel",
typeof(TB_EMPLOYEE), typeof(uEmployeeCard), new
FrameworkPropertyMetadata
{
BindsTwoWayByDefault = true,
DefaultUpdateSourceTrigger =
UpdateSourceTrigger.PropertyChanged
});
[Bindable(true)]
public TB_EMPLOYEE ViewModel
{
get { return (TB_EMPLOYEE)GetValue(ViewModelProperty); } //do
NOT modify anything in here
set { SetValue(ViewModelProperty, value); } //...or here
}
-------Xaml File of uEmployeeCard (Child User Control)-----
<StackPanel Grid.Column="0" Grid.Row="0" Orientation="Horizontal">
<TextBlock Style="{StaticResource UiTextBlock}"
Text="{Binding Path=ViewModel.TITLE}"/>
<TextBlock Style="{StaticResource UiTextBlock}"
Text="{Binding Path=ViewModel.FIRSTNAME}"/>
<TextBlock Style="{StaticResource UiTextBlock}"
Text="{Binding Path=ViewModel.FIRSTNAME}"/>
</StackPanel>
<StackPanel Grid.Column="0" Grid.Row="1"
Orientation="Vertical" Grid.RowSpan="2">
<TextBlock Style="{StaticResource UiTextBlock}"
Text="{Binding Path=ViewModel.NATNO}"/>
</StackPanel>
I put breakpoint to check whether the Dependency property get affected..on
update from Combo on parent user control. but not...
Kindly let me know where I am wrong, Thanks a lot.
Kindly Let me Know where I am wrong
Xaml --- Xaml of User Control where I use my child user control with
dependency property
ComboBox SelectedItem will Update SelectedEmployee, This SelectedEmployee
is further Binded with My child Control CardView:uEmployeeCard ViewModel
Property---
<ComboBox Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"
Style="{StaticResource UiComboBox}" ItemsSource="{Binding
TB_EMPLOYEEList}" SelectedItem="{Binding SelectedEmployee, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
SelectedValuePath="ID" SelectedValue="{Binding
CurrentTB_RECIEPT.REFRENCEID}"
ItemTemplate="{StaticResource
ComboEmployeeTemplate}"/>
<CardView:uEmployeeCard ViewModel="{Binding
Path=SelectedEmployee}" Grid.Row="1" Grid.Column="0"
Grid.ColumnSpan="2" Grid.RowSpan="3"
VerticalAlignment="Top"/>
------------Dependency Property Code , Code Behind file of uEmployeeCard ----
public uEmployeeCard()
{
InitializeComponent();
this.DataContext = this;
}
public static readonly DependencyProperty ViewModelProperty =
DependencyProperty.Register("ViewModel",
typeof(TB_EMPLOYEE), typeof(uEmployeeCard), new
FrameworkPropertyMetadata
{
BindsTwoWayByDefault = true,
DefaultUpdateSourceTrigger =
UpdateSourceTrigger.PropertyChanged
});
[Bindable(true)]
public TB_EMPLOYEE ViewModel
{
get { return (TB_EMPLOYEE)GetValue(ViewModelProperty); } //do
NOT modify anything in here
set { SetValue(ViewModelProperty, value); } //...or here
}
-------Xaml File of uEmployeeCard (Child User Control)-----
<StackPanel Grid.Column="0" Grid.Row="0" Orientation="Horizontal">
<TextBlock Style="{StaticResource UiTextBlock}"
Text="{Binding Path=ViewModel.TITLE}"/>
<TextBlock Style="{StaticResource UiTextBlock}"
Text="{Binding Path=ViewModel.FIRSTNAME}"/>
<TextBlock Style="{StaticResource UiTextBlock}"
Text="{Binding Path=ViewModel.FIRSTNAME}"/>
</StackPanel>
<StackPanel Grid.Column="0" Grid.Row="1"
Orientation="Vertical" Grid.RowSpan="2">
<TextBlock Style="{StaticResource UiTextBlock}"
Text="{Binding Path=ViewModel.NATNO}"/>
</StackPanel>
I put breakpoint to check whether the Dependency property get affected..on
update from Combo on parent user control. but not...
Kindly let me know where I am wrong, Thanks a lot.
Wednesday, 25 September 2013
How do I get composer to install my repo from Bitbucket?
How do I get composer to install my repo from Bitbucket?
My composer file looks like this:
{
"name": "mnbayazit/pdblog",
"description": "A simple blog",
"minimum-stability": "stable",
"authors": [
{
"name": "Mark Bayazit",
"email": "mnbayazit@gmail.com"
}
],
"require": {
"silex/silex": "1.*",
"twig/twig": ">=1.13.2,<2.0-dev",
"symfony/twig-bridge": "~2.3"
},
"repositories": [
{
"type": "hg",
"url": "ssh://hg@bitbucket.org/mnbayazit/pdoplus"
}
]
}
When I run composer.phar update it tells me:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
But never creates anything for pdoplus under the vendor/ folder.
Have I configured something wrong? The composer file in my other project
looks like this.
My composer file looks like this:
{
"name": "mnbayazit/pdblog",
"description": "A simple blog",
"minimum-stability": "stable",
"authors": [
{
"name": "Mark Bayazit",
"email": "mnbayazit@gmail.com"
}
],
"require": {
"silex/silex": "1.*",
"twig/twig": ">=1.13.2,<2.0-dev",
"symfony/twig-bridge": "~2.3"
},
"repositories": [
{
"type": "hg",
"url": "ssh://hg@bitbucket.org/mnbayazit/pdoplus"
}
]
}
When I run composer.phar update it tells me:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
But never creates anything for pdoplus under the vendor/ folder.
Have I configured something wrong? The composer file in my other project
looks like this.
Thursday, 19 September 2013
An web application to Update an one field (say id number) in the pdf each time when the user download the pdf form
An web application to Update an one field (say id number) in the pdf each
time when the user download the pdf form
I wanted to create an web application which allows the users to download
the pdf file with the with the value to the one of the field..and
incrementing this number for each download and i wanted to even to store
that number to the database.
Any idea how to start with?
time when the user download the pdf form
I wanted to create an web application which allows the users to download
the pdf file with the with the value to the one of the field..and
incrementing this number for each download and i wanted to even to store
that number to the database.
Any idea how to start with?
Using Rails with no models
Using Rails with no models
I have an application that utilizes web service calls from the controller
to attain its data. I have no models and don't need them (the app just
reads and displays data). However, when the app is deployed I get an
ActiveRecord::ConnectionNotEstablished error. How or Can I configure Rails
to ignore ActiveRecord functionality, basically ignore anything that's
associated with databases or models?
I'm using Rails 4. Thanks.
I have an application that utilizes web service calls from the controller
to attain its data. I have no models and don't need them (the app just
reads and displays data). However, when the app is deployed I get an
ActiveRecord::ConnectionNotEstablished error. How or Can I configure Rails
to ignore ActiveRecord functionality, basically ignore anything that's
associated with databases or models?
I'm using Rails 4. Thanks.
Navbar tintColor not respected on iOS 7 compatibility mode for iOS 6 app?
Navbar tintColor not respected on iOS 7 compatibility mode for iOS 6 app?
My app's navbar which is blue has suddenly changed to black/gray on iOS 7.
My app was not upgraded to iOS 7 yet nor recompiled using Xcode 5. I was
expecting to look exactly the same on iOS 7 with is compatibility mode for
older compiled iOS 6, but I guess I was wrong?
Is this a bug or that's the intended behaviour?
For your information I'm not using a UINavigationController. Just a simple
UIView in a nib with a navbar directly dragged from the Interface Builder.
My app's navbar which is blue has suddenly changed to black/gray on iOS 7.
My app was not upgraded to iOS 7 yet nor recompiled using Xcode 5. I was
expecting to look exactly the same on iOS 7 with is compatibility mode for
older compiled iOS 6, but I guess I was wrong?
Is this a bug or that's the intended behaviour?
For your information I'm not using a UINavigationController. Just a simple
UIView in a nib with a navbar directly dragged from the Interface Builder.
Plotting histogram with percentages in ggplot2
Plotting histogram with percentages in ggplot2
I am trying to plot a histogram using ggplot2 with percentage on the
y-axis and numerical values on the x-axis.
A sample of my data and script looks like this (below) and goes on for
about 100,000 rows (or more).
A B
0.2 x
1 y
0.995 x
0.5 x
0.5 x
0.2 y
ggplot(data, aes(A, colour=B)) + geom_bar() +stat_bin(breaks=seq(0,1,
by=0.05)) + scale_y_continuous(labels = percent)
I want to know the percentage of B values distributed in each bin of A
value, instead of the number of B values per A value.
The code as it is now gives me a y-axis with ymax as 15000. The y-axis is
supposed to be in percentages (0-100).
I am trying to plot a histogram using ggplot2 with percentage on the
y-axis and numerical values on the x-axis.
A sample of my data and script looks like this (below) and goes on for
about 100,000 rows (or more).
A B
0.2 x
1 y
0.995 x
0.5 x
0.5 x
0.2 y
ggplot(data, aes(A, colour=B)) + geom_bar() +stat_bin(breaks=seq(0,1,
by=0.05)) + scale_y_continuous(labels = percent)
I want to know the percentage of B values distributed in each bin of A
value, instead of the number of B values per A value.
The code as it is now gives me a y-axis with ymax as 15000. The y-axis is
supposed to be in percentages (0-100).
regex for combination of alphabets & numbers with Special characters for iOS
regex for combination of alphabets & numbers with Special characters for iOS
I want regex for iOS with following conditions,
1. there should be at-least one character or number in the string.
2. combination may contain special characters like !@#$%&* .
3. string length should be more than 7.
Eg.
test1234
test@1234
1234Test
Thanks in advance.
I want regex for iOS with following conditions,
1. there should be at-least one character or number in the string.
2. combination may contain special characters like !@#$%&* .
3. string length should be more than 7.
Eg.
test1234
test@1234
1234Test
Thanks in advance.
Returning results from array that contains two types of results
Returning results from array that contains two types of results
Hello I'm trying to retrun array type named ZverejnenyUcetType but the
issue is that this array might contain two types : StandartniUcetType and
NestandardniUcetType.
So the issue is when I try to return the array like this:
for (int x = 0; x <= 3; x++)
{
file2.WriteLine((((RozhraniWSDL.StandardniUcetType)(info.zverejneneUcty[x].Item)).cislo)
+ "-"
+
(((RozhraniWSDL.StandardniUcetType)(info.zverejneneUcty[x].Item)).cislo)
+ "/"
+
(((RozhraniWSDL.StandardniUcetType)(info.zverejneneUcty[x].Item)).kodBanky));
}
}
I get following exception: unable to cast object of type
RozhraniWSDL.NestandardniUcetType to type RozhraniWSDL.StandardniUcetType.
NestandardniUcetType contains only one item - cislo
StandartníUcetType have 3 items- predcislo, cislo, kod banky
Here is an image of the array:
I thought that the solution might be to determinate which of the result
are of type StandartniUcetType and which are NestandardniUcetType.
I would like to ask if this is possible to do?
I found this solution more common.
Thank you for your time.
Hello I'm trying to retrun array type named ZverejnenyUcetType but the
issue is that this array might contain two types : StandartniUcetType and
NestandardniUcetType.
So the issue is when I try to return the array like this:
for (int x = 0; x <= 3; x++)
{
file2.WriteLine((((RozhraniWSDL.StandardniUcetType)(info.zverejneneUcty[x].Item)).cislo)
+ "-"
+
(((RozhraniWSDL.StandardniUcetType)(info.zverejneneUcty[x].Item)).cislo)
+ "/"
+
(((RozhraniWSDL.StandardniUcetType)(info.zverejneneUcty[x].Item)).kodBanky));
}
}
I get following exception: unable to cast object of type
RozhraniWSDL.NestandardniUcetType to type RozhraniWSDL.StandardniUcetType.
NestandardniUcetType contains only one item - cislo
StandartníUcetType have 3 items- predcislo, cislo, kod banky
Here is an image of the array:
I thought that the solution might be to determinate which of the result
are of type StandartniUcetType and which are NestandardniUcetType.
I would like to ask if this is possible to do?
I found this solution more common.
Thank you for your time.
Fork call working
Fork call working
can anybody explain me working of fork in detail
#include<unistd.h>
#include<stdio.h>
int main ()
{
int i, b;
for (i = 0; i < 2; i++) {
fflush (stdout);
b = fork ();
if (b == -1) {
perror ("error forking");
}
else if (b > 0) //parent process
{
wait ();
printf ("\nparent %d", getpid ());
}
else
printf ("\nchild %d %d", getpid (), getppid ());
}
return 0;
}
its just i need to know that if fork have same code as parent then this
for loop should never stop creating child processes (every child will have
its own for loop)
can anybody explain me working of fork in detail
#include<unistd.h>
#include<stdio.h>
int main ()
{
int i, b;
for (i = 0; i < 2; i++) {
fflush (stdout);
b = fork ();
if (b == -1) {
perror ("error forking");
}
else if (b > 0) //parent process
{
wait ();
printf ("\nparent %d", getpid ());
}
else
printf ("\nchild %d %d", getpid (), getppid ());
}
return 0;
}
its just i need to know that if fork have same code as parent then this
for loop should never stop creating child processes (every child will have
its own for loop)
AdMob TEST_EMULATOR doesn't work alone
AdMob TEST_EMULATOR doesn't work alone
I'm trying to implement AdMob banners on an Android app.
Even if I'm using
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
in my code to run test banners in emulator, I still get the real banners.
Also LogCat is showing the message:
I/Ads(2364): To get test ads on this device, call
adRequest.addTestDevice("94**************************B664");
What's strange is the fact that the Device ID number has changed 3 times
today. I wasn't able to find how and when changed. So using those ID
numbers in my code, I can run test banners, until the number will change
again.
adRequest.addTestDevices(AdRequest.TEST_EMULATOR);
adRequest.addTestDevice("94**************************B664"); // My Eclipse
I have no Android device connected to my computer. All tests was done on
Eclipse.
Please help me to understand this. Why TEST_EMULATOR doesn't work ? Why
Eclipse / AVD has a Device ID ? And why Device ID is changing in this case
?
Thank you,
Paul.
I'm trying to implement AdMob banners on an Android app.
Even if I'm using
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
in my code to run test banners in emulator, I still get the real banners.
Also LogCat is showing the message:
I/Ads(2364): To get test ads on this device, call
adRequest.addTestDevice("94**************************B664");
What's strange is the fact that the Device ID number has changed 3 times
today. I wasn't able to find how and when changed. So using those ID
numbers in my code, I can run test banners, until the number will change
again.
adRequest.addTestDevices(AdRequest.TEST_EMULATOR);
adRequest.addTestDevice("94**************************B664"); // My Eclipse
I have no Android device connected to my computer. All tests was done on
Eclipse.
Please help me to understand this. Why TEST_EMULATOR doesn't work ? Why
Eclipse / AVD has a Device ID ? And why Device ID is changing in this case
?
Thank you,
Paul.
Wednesday, 18 September 2013
How to save One-to-Many Relationship in CoreData?
How to save One-to-Many Relationship in CoreData?
I have one tables looks like as below
I have one XML where detail of CLUB is available. Every tag has one value
but Images tag contain dynamic images.
After this my object looks like as below
ClubDetails.h
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "ClubDetailsImages.h"
@interface ClubDetails : NSManagedObject
@property (nonatomic, retain) NSString * clubarea;
@property (nonatomic, retain) NSString * clubdealhere;
@property (nonatomic, retain) NSString * clubdescription;
@property (nonatomic, retain) NSString * clubdistance;
@property (nonatomic, retain) NSString * clubemail;
@property (nonatomic, retain) NSString * clubfacility;
@property (nonatomic, retain) NSString * clubfav;
@property (nonatomic, retain) NSString * clubid;
@property (nonatomic, retain) NSString * clublat;
@property (nonatomic, retain) NSString * clublogopath;
@property (nonatomic, retain) NSString * clubname;
@property (nonatomic, retain) NSString * clubphone;
@property (nonatomic, retain) NSString * cluburl;
@property (nonatomic, retain) NSString * clubvenutype;
@property (nonatomic, retain) NSString * clublong;
@property (nonatomic, retain) NSSet *clubdetailsimages;
@end
@interface ClubDetails (CoreDataGeneratedAccessors)
- (void)addClubdetailsimagesObject:(ClubDetailsImages *)value;
- (void)removeClubdetailsimagesObject:(ClubDetailsImages *)value;
- (void)addClubdetailsimages:(NSSet *)value;
- (void)removeClubdetailsimages:(NSSet *)value;
Its .m files looks like as below
@implementation ClubDetails
@dynamic clubarea;
@dynamic clubdealhere;
@dynamic clubdescription;
@dynamic clubdistance;
@dynamic clubemail;
@dynamic clubfacility;
@dynamic clubfav;
@dynamic clubid;
@dynamic clublat;
@dynamic clublogopath;
@dynamic clubname;
@dynamic clubphone;
@dynamic cluburl;
@dynamic clubvenutype;
@dynamic clublong;
@dynamic clubdetailsimages;
- (void)addClubdetailsimagesObject:(ClubDetailsImages *)value {
NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value
count:1];
[self willChangeValueForKey:@"ClubDetailsImages"
withSetMutation:NSKeyValueUnionSetMutation
usingObjects:changedObjects];
[[self primitiveValueForKey:@"ClubDetailsImages"] addObject:value];
[self didChangeValueForKey:@"ClubDetailsImages"
withSetMutation:NSKeyValueUnionSetMutation
usingObjects:changedObjects];
}
- (void)removeClubdetailsimagesObject:(ClubDetailsImages *)value {
NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value
count:1];
[self willChangeValueForKey:@"ClubDetailsImages"
withSetMutation:NSKeyValueMinusSetMutation
usingObjects:changedObjects];
[[self primitiveValueForKey:@"ClubDetailsImages"]
removeObject:value];
[self didChangeValueForKey:@"ClubDetailsImages"
withSetMutation:NSKeyValueMinusSetMutation
usingObjects:changedObjects];
}
- (void)addClubdetailsimages:(NSSet *)value {
[self willChangeValueForKey:@"ClubDetailsImages"
withSetMutation:NSKeyValueUnionSetMutation usingObjects:value];
[[self primitiveValueForKey:@"ClubDetailsImages"] unionSet:value];
[self didChangeValueForKey:@"ClubDetailsImages"
withSetMutation:NSKeyValueUnionSetMutation usingObjects:value];
}
- (void)removeClubdetailsimages:(NSSet *)value {
[self willChangeValueForKey:@"ClubDetailsImages"
withSetMutation:NSKeyValueMinusSetMutation usingObjects:value];
[[self primitiveValueForKey:@"ClubDetailsImages"] minusSet:value];
[self didChangeValueForKey:@"ClubDetailsImages"
withSetMutation:NSKeyValueMinusSetMutation usingObjects:value];
}
***ClubDetailsImages.h*** looks like
@class ClubDetails;
@interface ClubDetailsImages : NSManagedObject
@property (nonatomic, retain) NSString * images;
@property (nonatomic, retain) ClubDetails *clubdetailed;
***ClubDetailsImages.m*** looks like
@implementation ClubDetailsImages
@dynamic images;
@dynamic clubdetailed;
For Saving, I wrote code like this
-(void)saveClubDetails:(NSMutableArray*)allClubs{
NSError *error;
NSManagedObjectContext *context = [self managedObjectContext];
NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:[NSEntityDescription
entityForName:@"ClubDetails" inManagedObjectContext:context]];
[fetchRequest setIncludesPropertyValues:NO]; //only fetch the
managedObjectID
NSArray *allObject = [context executeFetchRequest:fetchRequest
error:&error];
for (NSManagedObject * obj in allObject) {
[context deleteObject:obj];
}
NSError *saveError = nil;
[context save:&saveError]; // NO MORE VALUE IS DB
for (int x = 0; x<[allClubs count]; x++) {
ClubDetails *club = [NSEntityDescription
insertNewObjectForEntityForName:@"ClubDetails"
inManagedObjectContext:context];
ClubDetails2 *ob = (ClubDetails2*)[allClubs objectAtIndex:x];
club.clubarea = [NSString stringWithFormat:@"%@", ob.clubarea];
club.clubdealhere = [NSString stringWithFormat:@"%@",
ob.clubdealhere];
club.clubdescription = [NSString stringWithFormat:@"%@",
ob.clubdescription];
club.clubdistance = [NSString stringWithFormat:@"%@",
ob.clubdistance];
club.clubemail = [NSString stringWithFormat:@"%@", ob.clubemail];
club.clubfacility = [NSString stringWithFormat:@"%@",
ob.clubfacility];
club.clubfav = [NSString stringWithFormat:@"%@", ob.clubfav];
club.clubid = [NSString stringWithFormat:@"%@", ob.clubid];
club.clublat = [NSString stringWithFormat:@"%@", ob.clublat];
club.clublogopath = [NSString stringWithFormat:@"%@",
ob.clublogopath];
club.clubname = [NSString stringWithFormat:@"%@", ob.clubname];
club.clubphone = [NSString stringWithFormat:@"%@", ob.clubphone];
club.cluburl = [NSString stringWithFormat:@"%@", ob.cluburl];
club.clubvenutype = [NSString stringWithFormat:@"%@",
ob.clubvenutype];
club.clublong = [NSString stringWithFormat:@"%@", ob.clublong];
ClubDetailsImages *clubImages = [NSEntityDescription
insertNewObjectForEntityForName:@"ClubDetailsImages"
inManagedObjectContext:context];
clubImages.images = [NSString stringWithFormat:@"veer url image"];
[club addClubdetailsimagesObject:clubImages];
}
if (![context save:&error]) {
NSLog(@"Whoops, couldn't save: %@", [error localizedDescription]);
}
// NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Clubs"
inManagedObjectContext:context];
[fetchRequest setEntity:entity];
NSArray *fetchedArray = [context executeFetchRequest:fetchRequest
error:&error];
NSLog(@"COUNT of arary is %d", [fetchedArray count]);
for (Clubs *info in fetchedArray) {
NSLog(@" Duaan Name ~~~~ : %@", info.clubname);
}
}
I AM STUCK IN FOLLOWING POINTS
1. How to save such objects in CoreData where one club may be 3, 4, 5
images which are stored in Array?
2. How can I fetch that one-to-more relationship from CoreData?
I have one tables looks like as below
I have one XML where detail of CLUB is available. Every tag has one value
but Images tag contain dynamic images.
After this my object looks like as below
ClubDetails.h
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "ClubDetailsImages.h"
@interface ClubDetails : NSManagedObject
@property (nonatomic, retain) NSString * clubarea;
@property (nonatomic, retain) NSString * clubdealhere;
@property (nonatomic, retain) NSString * clubdescription;
@property (nonatomic, retain) NSString * clubdistance;
@property (nonatomic, retain) NSString * clubemail;
@property (nonatomic, retain) NSString * clubfacility;
@property (nonatomic, retain) NSString * clubfav;
@property (nonatomic, retain) NSString * clubid;
@property (nonatomic, retain) NSString * clublat;
@property (nonatomic, retain) NSString * clublogopath;
@property (nonatomic, retain) NSString * clubname;
@property (nonatomic, retain) NSString * clubphone;
@property (nonatomic, retain) NSString * cluburl;
@property (nonatomic, retain) NSString * clubvenutype;
@property (nonatomic, retain) NSString * clublong;
@property (nonatomic, retain) NSSet *clubdetailsimages;
@end
@interface ClubDetails (CoreDataGeneratedAccessors)
- (void)addClubdetailsimagesObject:(ClubDetailsImages *)value;
- (void)removeClubdetailsimagesObject:(ClubDetailsImages *)value;
- (void)addClubdetailsimages:(NSSet *)value;
- (void)removeClubdetailsimages:(NSSet *)value;
Its .m files looks like as below
@implementation ClubDetails
@dynamic clubarea;
@dynamic clubdealhere;
@dynamic clubdescription;
@dynamic clubdistance;
@dynamic clubemail;
@dynamic clubfacility;
@dynamic clubfav;
@dynamic clubid;
@dynamic clublat;
@dynamic clublogopath;
@dynamic clubname;
@dynamic clubphone;
@dynamic cluburl;
@dynamic clubvenutype;
@dynamic clublong;
@dynamic clubdetailsimages;
- (void)addClubdetailsimagesObject:(ClubDetailsImages *)value {
NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value
count:1];
[self willChangeValueForKey:@"ClubDetailsImages"
withSetMutation:NSKeyValueUnionSetMutation
usingObjects:changedObjects];
[[self primitiveValueForKey:@"ClubDetailsImages"] addObject:value];
[self didChangeValueForKey:@"ClubDetailsImages"
withSetMutation:NSKeyValueUnionSetMutation
usingObjects:changedObjects];
}
- (void)removeClubdetailsimagesObject:(ClubDetailsImages *)value {
NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value
count:1];
[self willChangeValueForKey:@"ClubDetailsImages"
withSetMutation:NSKeyValueMinusSetMutation
usingObjects:changedObjects];
[[self primitiveValueForKey:@"ClubDetailsImages"]
removeObject:value];
[self didChangeValueForKey:@"ClubDetailsImages"
withSetMutation:NSKeyValueMinusSetMutation
usingObjects:changedObjects];
}
- (void)addClubdetailsimages:(NSSet *)value {
[self willChangeValueForKey:@"ClubDetailsImages"
withSetMutation:NSKeyValueUnionSetMutation usingObjects:value];
[[self primitiveValueForKey:@"ClubDetailsImages"] unionSet:value];
[self didChangeValueForKey:@"ClubDetailsImages"
withSetMutation:NSKeyValueUnionSetMutation usingObjects:value];
}
- (void)removeClubdetailsimages:(NSSet *)value {
[self willChangeValueForKey:@"ClubDetailsImages"
withSetMutation:NSKeyValueMinusSetMutation usingObjects:value];
[[self primitiveValueForKey:@"ClubDetailsImages"] minusSet:value];
[self didChangeValueForKey:@"ClubDetailsImages"
withSetMutation:NSKeyValueMinusSetMutation usingObjects:value];
}
***ClubDetailsImages.h*** looks like
@class ClubDetails;
@interface ClubDetailsImages : NSManagedObject
@property (nonatomic, retain) NSString * images;
@property (nonatomic, retain) ClubDetails *clubdetailed;
***ClubDetailsImages.m*** looks like
@implementation ClubDetailsImages
@dynamic images;
@dynamic clubdetailed;
For Saving, I wrote code like this
-(void)saveClubDetails:(NSMutableArray*)allClubs{
NSError *error;
NSManagedObjectContext *context = [self managedObjectContext];
NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:[NSEntityDescription
entityForName:@"ClubDetails" inManagedObjectContext:context]];
[fetchRequest setIncludesPropertyValues:NO]; //only fetch the
managedObjectID
NSArray *allObject = [context executeFetchRequest:fetchRequest
error:&error];
for (NSManagedObject * obj in allObject) {
[context deleteObject:obj];
}
NSError *saveError = nil;
[context save:&saveError]; // NO MORE VALUE IS DB
for (int x = 0; x<[allClubs count]; x++) {
ClubDetails *club = [NSEntityDescription
insertNewObjectForEntityForName:@"ClubDetails"
inManagedObjectContext:context];
ClubDetails2 *ob = (ClubDetails2*)[allClubs objectAtIndex:x];
club.clubarea = [NSString stringWithFormat:@"%@", ob.clubarea];
club.clubdealhere = [NSString stringWithFormat:@"%@",
ob.clubdealhere];
club.clubdescription = [NSString stringWithFormat:@"%@",
ob.clubdescription];
club.clubdistance = [NSString stringWithFormat:@"%@",
ob.clubdistance];
club.clubemail = [NSString stringWithFormat:@"%@", ob.clubemail];
club.clubfacility = [NSString stringWithFormat:@"%@",
ob.clubfacility];
club.clubfav = [NSString stringWithFormat:@"%@", ob.clubfav];
club.clubid = [NSString stringWithFormat:@"%@", ob.clubid];
club.clublat = [NSString stringWithFormat:@"%@", ob.clublat];
club.clublogopath = [NSString stringWithFormat:@"%@",
ob.clublogopath];
club.clubname = [NSString stringWithFormat:@"%@", ob.clubname];
club.clubphone = [NSString stringWithFormat:@"%@", ob.clubphone];
club.cluburl = [NSString stringWithFormat:@"%@", ob.cluburl];
club.clubvenutype = [NSString stringWithFormat:@"%@",
ob.clubvenutype];
club.clublong = [NSString stringWithFormat:@"%@", ob.clublong];
ClubDetailsImages *clubImages = [NSEntityDescription
insertNewObjectForEntityForName:@"ClubDetailsImages"
inManagedObjectContext:context];
clubImages.images = [NSString stringWithFormat:@"veer url image"];
[club addClubdetailsimagesObject:clubImages];
}
if (![context save:&error]) {
NSLog(@"Whoops, couldn't save: %@", [error localizedDescription]);
}
// NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Clubs"
inManagedObjectContext:context];
[fetchRequest setEntity:entity];
NSArray *fetchedArray = [context executeFetchRequest:fetchRequest
error:&error];
NSLog(@"COUNT of arary is %d", [fetchedArray count]);
for (Clubs *info in fetchedArray) {
NSLog(@" Duaan Name ~~~~ : %@", info.clubname);
}
}
I AM STUCK IN FOLLOWING POINTS
1. How to save such objects in CoreData where one club may be 3, 4, 5
images which are stored in Array?
2. How can I fetch that one-to-more relationship from CoreData?
PHP--an Array in an Array? Not sure, using ajilion MySQLidb Class need to get value of raw Query
PHP--an Array in an Array? Not sure, using ajilion MySQLidb Class need to
get value of raw Query
(PHP newb here--can read code somewhat well, working on writing)
I think I have an array in an array. using this for MySQL calls:
https://github.com/ajillion/PHP-MySQLi-Database-Class
my call:
$params = array($mta_name);
$mta_uid = $db->rawQuery("SELECT mta_uid FROM mtas WHERE mta_name = ?",
$params);
echo print_r($mta_uid);
ends up with this:
Array ( [0] => Array ( [uid] => 1 ) ) 1
I just want the '1' . Have tried mta_name['0'] and ['1'] and ['0']['1'] /
['1']['0'] / ['1']['2'] etc.
Whenever I have issues always find you guys and usually solves. First time
posting.
Many thanks!
get value of raw Query
(PHP newb here--can read code somewhat well, working on writing)
I think I have an array in an array. using this for MySQL calls:
https://github.com/ajillion/PHP-MySQLi-Database-Class
my call:
$params = array($mta_name);
$mta_uid = $db->rawQuery("SELECT mta_uid FROM mtas WHERE mta_name = ?",
$params);
echo print_r($mta_uid);
ends up with this:
Array ( [0] => Array ( [uid] => 1 ) ) 1
I just want the '1' . Have tried mta_name['0'] and ['1'] and ['0']['1'] /
['1']['0'] / ['1']['2'] etc.
Whenever I have issues always find you guys and usually solves. First time
posting.
Many thanks!
php mysql store procedure, Parse error: syntax error, unexpected T_STRING
php mysql store procedure, Parse error: syntax error, unexpected T_STRING
i've got this code
{ <?php
include 'koneksi.php';
$idAgent = $_GET["rqid"];
$ipAgent = $_SERVER['REMOTE_ADDR'];
$app = $_GET["app"];
$action = $_GET["action"];
$org = $_GET["org"];
$des = $_GET["des"];
$trainNo = $_GET["train_no"];
$depDate = $_GET["dep_date"];
$query = "SELECT cekRQID('$idAgent','$ipAgent') as jml;";
//echo($query);
$hasil = mysql_query($query);
$data = mysql_fetch_array($hasil);
$channelOK = $data['jml'];
if ($channelOK == "1") {
if ($app == "information" && $action == "get_seat_map") {
$query="SELECT 0 as err_code, '$org' as org, '$des' as des,
'$trainNo' as train_no, $depDate as dep_date ";
$hasil1 = mysql_query($query);
$rows1 = array();
while ($r1 = mysql_fetch_assoc($hasil1)){
$rows1 = $r1;
}
$tglnya = date('Ymd',$depDate); //STR_TO_DATE('$depDate','%Y%m%d')
$query = mysql_query("CALL
GET_SEAT_MAP('$org','$des','$trainNo',STR_TO_DATE('$depDate','%Y%m%d'),@TEST);")
or die mysql_error();
$query = mysql_query("SELECT @TEST;") or die mysql_error();
//echo($query);
while($row = mysql_fetch_row($query))
{
$query = $row[0];
}
$hasil = mysql_query($query);
//echo($query);
$rows = array();
$index= 0;
$bufk0 = "";
$body = 0;
while ($r = mysql_fetch_row($hasil)){
$curfk0 = $r[0].$r[1];
if( $bufk0 != $curfk0 ){
$head[$curfk0] = array ( $r[0],$r[1]);
$out2[$curfk0][] = array(
$r[2],$r[3],$r[4],$r[5],$r[6],$r[7] );
} else {
$out2[$curfk0][] = array(
$r[2],$r[3],$r[4],$r[5],$r[6],$r[7] );
}
$bufk0 = $r[0].$r[1];
$bufindex = $index;
$headindex = $head ;
$index++;
}
}
if (is_array($values)){
foreach ($head as $key => $val ){
$final['seat_map'][] = array( $val[0],$val[1], $out2[$key] );
}
}
header('Content-type: application/json');
echo json_encode($rows1+$final);
}
?>
}
when i'm run this code, i've got some error message : Parse error: syntax
error, unexpected T_STRING in /var/www/html/sgetseatmap.php on line 37
which is in code :
$query = mysql_query("CALL
GET_SEAT_MAP('$org','$des','$trainNo',STR_TO_DATE('$depDate','%Y%m%d'),@TEST);")
or die mysql_error();
I just can't figure out why its happening here, any help is greatly
appreciated.
i've got this code
{ <?php
include 'koneksi.php';
$idAgent = $_GET["rqid"];
$ipAgent = $_SERVER['REMOTE_ADDR'];
$app = $_GET["app"];
$action = $_GET["action"];
$org = $_GET["org"];
$des = $_GET["des"];
$trainNo = $_GET["train_no"];
$depDate = $_GET["dep_date"];
$query = "SELECT cekRQID('$idAgent','$ipAgent') as jml;";
//echo($query);
$hasil = mysql_query($query);
$data = mysql_fetch_array($hasil);
$channelOK = $data['jml'];
if ($channelOK == "1") {
if ($app == "information" && $action == "get_seat_map") {
$query="SELECT 0 as err_code, '$org' as org, '$des' as des,
'$trainNo' as train_no, $depDate as dep_date ";
$hasil1 = mysql_query($query);
$rows1 = array();
while ($r1 = mysql_fetch_assoc($hasil1)){
$rows1 = $r1;
}
$tglnya = date('Ymd',$depDate); //STR_TO_DATE('$depDate','%Y%m%d')
$query = mysql_query("CALL
GET_SEAT_MAP('$org','$des','$trainNo',STR_TO_DATE('$depDate','%Y%m%d'),@TEST);")
or die mysql_error();
$query = mysql_query("SELECT @TEST;") or die mysql_error();
//echo($query);
while($row = mysql_fetch_row($query))
{
$query = $row[0];
}
$hasil = mysql_query($query);
//echo($query);
$rows = array();
$index= 0;
$bufk0 = "";
$body = 0;
while ($r = mysql_fetch_row($hasil)){
$curfk0 = $r[0].$r[1];
if( $bufk0 != $curfk0 ){
$head[$curfk0] = array ( $r[0],$r[1]);
$out2[$curfk0][] = array(
$r[2],$r[3],$r[4],$r[5],$r[6],$r[7] );
} else {
$out2[$curfk0][] = array(
$r[2],$r[3],$r[4],$r[5],$r[6],$r[7] );
}
$bufk0 = $r[0].$r[1];
$bufindex = $index;
$headindex = $head ;
$index++;
}
}
if (is_array($values)){
foreach ($head as $key => $val ){
$final['seat_map'][] = array( $val[0],$val[1], $out2[$key] );
}
}
header('Content-type: application/json');
echo json_encode($rows1+$final);
}
?>
}
when i'm run this code, i've got some error message : Parse error: syntax
error, unexpected T_STRING in /var/www/html/sgetseatmap.php on line 37
which is in code :
$query = mysql_query("CALL
GET_SEAT_MAP('$org','$des','$trainNo',STR_TO_DATE('$depDate','%Y%m%d'),@TEST);")
or die mysql_error();
I just can't figure out why its happening here, any help is greatly
appreciated.
Polygon(), Polygons(), SpatialPolygons(), and SpationPolygonsDataFrame()....{spdep}
Polygon(), Polygons(), SpatialPolygons(), and
SpationPolygonsDataFrame()....{spdep}
I am new to R programming. I am currently working on a research project
that can improve mstree() in spdep package. I have a question on how to
make Polygon(), Polygons(), SpatialPolygons(), and
SpationPolygonsDataFrame() to work. Below are the codes I tried:
library("spdep")
library("sp")
require(maptools)
Dmat<-matrix(nrow=1,ncol=2)
rownames(Dmat)<-c("s1")
Dfram<-data.frame(Dmat)
#diabetesNum is a dataset that I artificially made
nrows<-nrow(diabetesNum)
x1matrix<-data.matrix(diabetesNum)
x1Frame<-data.frame(diabetesNum)
x1Frame4<-as(x1Frame,"S4")
x1X<-prcomp(x1Frame)$x
#Use the first two principal components for coordinates of the points
xycoordinates<-data.frame(x1X[,1:2])
row1<-xycoordinates[1,]
row1M<-data.frame(row1)
xycoordinates[nrows+1,]<-c(row1M)
xycoordinatesF<-data.frame(xycoordinates)
xycoordinatesM<-data.matrix(xycoordinatesF)
pl<-Polygon(xycoordinatesM)
pls<-Polygons(list(pl), ID="1")
Sr<-SpatialPolygons(list(pls))
bho.nb<-poly2nb(list(Sr))
Error in sp$mbxv[i]:(n * 2) : argument of length 0
...and ERROR! what is the wrong with my code above? I searched and
searched on the internet to find out the proper way to use Polygon(),
Polygons(), SpatialPolygons(), SpatialPolygonsDataFrame(), and poly2nb()
yet I just don't know how to make these functions work! I already have
gone through R manual but it is not so much of helpl...... one interesting
thing though is that when I view the Polygons object, the Polygons slot is
empty; when I view Sr, similarly, the SpatialPolygons slot and Polygons
slot are empty. thanks,
SpationPolygonsDataFrame()....{spdep}
I am new to R programming. I am currently working on a research project
that can improve mstree() in spdep package. I have a question on how to
make Polygon(), Polygons(), SpatialPolygons(), and
SpationPolygonsDataFrame() to work. Below are the codes I tried:
library("spdep")
library("sp")
require(maptools)
Dmat<-matrix(nrow=1,ncol=2)
rownames(Dmat)<-c("s1")
Dfram<-data.frame(Dmat)
#diabetesNum is a dataset that I artificially made
nrows<-nrow(diabetesNum)
x1matrix<-data.matrix(diabetesNum)
x1Frame<-data.frame(diabetesNum)
x1Frame4<-as(x1Frame,"S4")
x1X<-prcomp(x1Frame)$x
#Use the first two principal components for coordinates of the points
xycoordinates<-data.frame(x1X[,1:2])
row1<-xycoordinates[1,]
row1M<-data.frame(row1)
xycoordinates[nrows+1,]<-c(row1M)
xycoordinatesF<-data.frame(xycoordinates)
xycoordinatesM<-data.matrix(xycoordinatesF)
pl<-Polygon(xycoordinatesM)
pls<-Polygons(list(pl), ID="1")
Sr<-SpatialPolygons(list(pls))
bho.nb<-poly2nb(list(Sr))
Error in sp$mbxv[i]:(n * 2) : argument of length 0
...and ERROR! what is the wrong with my code above? I searched and
searched on the internet to find out the proper way to use Polygon(),
Polygons(), SpatialPolygons(), SpatialPolygonsDataFrame(), and poly2nb()
yet I just don't know how to make these functions work! I already have
gone through R manual but it is not so much of helpl...... one interesting
thing though is that when I view the Polygons object, the Polygons slot is
empty; when I view Sr, similarly, the SpatialPolygons slot and Polygons
slot are empty. thanks,
convert jquery toggleclass code to pure javascript code
convert jquery toggleclass code to pure javascript code
Im looking for a way to convert this jquery code (which is used in
responsive menu section) to pure javascript code.
if its hard to implement its ok to use other javascript frameworks.
$('.btn-navbar').click(function()
{
$('.container-fluid:first').toggleClass('menu-hidden');
$('#menu').toggleClass('hidden-phone');
if (typeof masonryGallery != 'undefined')
masonryGallery();
});
thanks in advance
Im looking for a way to convert this jquery code (which is used in
responsive menu section) to pure javascript code.
if its hard to implement its ok to use other javascript frameworks.
$('.btn-navbar').click(function()
{
$('.container-fluid:first').toggleClass('menu-hidden');
$('#menu').toggleClass('hidden-phone');
if (typeof masonryGallery != 'undefined')
masonryGallery();
});
thanks in advance
Django: Create a multipage JQuery dialog
Django: Create a multipage JQuery dialog
I am trying to create some sort of multipage modal dialog with
Django/Python and JQuery. I didn't found yet in the web something similar
to what i have in mind.
My idea is to show a popup dialog when a user press a button in a webpage,
then that user can choose from 3 possible choices that immediately - when
pressed - bring him to the next page in the dialog. Here the user can
choose one element in a list and then the dialog will close and will show
the original webpage with the informations submitted by the user.
I already try to put togheter some code blocks, but till now i didn't
obtain good results.
Could someone - at least - tell me the correct process?
I am trying to create some sort of multipage modal dialog with
Django/Python and JQuery. I didn't found yet in the web something similar
to what i have in mind.
My idea is to show a popup dialog when a user press a button in a webpage,
then that user can choose from 3 possible choices that immediately - when
pressed - bring him to the next page in the dialog. Here the user can
choose one element in a list and then the dialog will close and will show
the original webpage with the informations submitted by the user.
I already try to put togheter some code blocks, but till now i didn't
obtain good results.
Could someone - at least - tell me the correct process?
store value fetched from an arraylist into an int variable
store value fetched from an arraylist into an int variable
<%-- JSTL foreach tag example to loop an array in jsp --%>
<c:forEach var="window" items="${listOFSchools}">
<c:out value='${window.school_id }'/>
<%
SchoolDisplayService CDS = new SchoolDisplayService();
List<Schooltable> list = CDS.getSchools(window.school_id );
%>
I want to pass the school_id fetched from the array list "listOFSchools"
to the method getSchools(). How can i do this?
<%-- JSTL foreach tag example to loop an array in jsp --%>
<c:forEach var="window" items="${listOFSchools}">
<c:out value='${window.school_id }'/>
<%
SchoolDisplayService CDS = new SchoolDisplayService();
List<Schooltable> list = CDS.getSchools(window.school_id );
%>
I want to pass the school_id fetched from the array list "listOFSchools"
to the method getSchools(). How can i do this?
Can't add a menu item on ExtJS 3.4
Can't add a menu item on ExtJS 3.4
I'm trying the following code to add a menu item at runtime but I can't
get it to work, the ExtJS documentation has samples only to create the
entire menu along with the menu item. Any help is much appreciated.
var menuItem = Ext.create('Ext.menu.Item', { text: 'menu item'});
Error:
TypeError: b[e] is not a constructor
Ext.ComponentMgr.create()ext.axd?v=31893 (line 7)
()debugg...al code (line 2)
...;if(a.getMonth()==G.getMonth()&&a.getFullYear()==G.getFullYear()){this.cells.rem...
I'm trying the following code to add a menu item at runtime but I can't
get it to work, the ExtJS documentation has samples only to create the
entire menu along with the menu item. Any help is much appreciated.
var menuItem = Ext.create('Ext.menu.Item', { text: 'menu item'});
Error:
TypeError: b[e] is not a constructor
Ext.ComponentMgr.create()ext.axd?v=31893 (line 7)
()debugg...al code (line 2)
...;if(a.getMonth()==G.getMonth()&&a.getFullYear()==G.getFullYear()){this.cells.rem...
testing mobile apps - best and worst browser- differences
testing mobile apps - best and worst browser- differences
Heyy Friends - I am just curious to know about Mobile application Testing.
1) What browsers are the worst for mobile web applications and are to be
tested by the tester (Just like IE 6, 7 for ordinary web apps)
2) What browsers support mobile web applications and tester does not need
much testing 3) What is the difference between testing a normal web
application and mobile web application?
Please help
Heyy Friends - I am just curious to know about Mobile application Testing.
1) What browsers are the worst for mobile web applications and are to be
tested by the tester (Just like IE 6, 7 for ordinary web apps)
2) What browsers support mobile web applications and tester does not need
much testing 3) What is the difference between testing a normal web
application and mobile web application?
Please help
Tuesday, 17 September 2013
Pdf Join Cat wrong
Pdf Join Cat wrong
shell_exec('pdftk offerletter/'.$_GET['id'].'.pdf LAMPIRAN_A.pdf cat
output offerletter2/'.$_GET['id'].'.pdf dont_ask');
header('location:offerletter2/'.$_GET['id'].'.pdf');
situation : example : $_GET['id']=123456789;
student will download offerletter name 123456789, which it will save under
folder offerletter. And in offerletter folder, have LAMPIRAN_A.pdf that
will join with the student offerletter, and after join, it will output to
another folder, which name offerletter2
error : cannot find offerletter2/123456789.pdf
shell_exec('pdftk offerletter/'.$_GET['id'].'.pdf LAMPIRAN_A.pdf cat
output offerletter2/'.$_GET['id'].'.pdf dont_ask');
header('location:offerletter2/'.$_GET['id'].'.pdf');
situation : example : $_GET['id']=123456789;
student will download offerletter name 123456789, which it will save under
folder offerletter. And in offerletter folder, have LAMPIRAN_A.pdf that
will join with the student offerletter, and after join, it will output to
another folder, which name offerletter2
error : cannot find offerletter2/123456789.pdf
CSS or JavaScript Div Blur magic
CSS or JavaScript Div Blur magic
Okay, so a new version of the iCloud website is out. It has what appears
to be some crazy voodoo Apple magic going on. They were able to blur the
background icons behind the login screen, and I can't figure out how they
did it. It's not a static image, as the icons change size if you resize
the browser.
Would someone please explain?
https://www.icloud.com/
Okay, so a new version of the iCloud website is out. It has what appears
to be some crazy voodoo Apple magic going on. They were able to blur the
background icons behind the login screen, and I can't figure out how they
did it. It's not a static image, as the icons change size if you resize
the browser.
Would someone please explain?
https://www.icloud.com/
Can't parse specific HTML page with BeautifulSoup
Can't parse specific HTML page with BeautifulSoup
I'm having trouble parsing this with BeautifulSoup. I think the problem is
that most of the content is loaded through a script, so that if you view
the source code, something like "Current Average Recommendation" is not
there.
I can instead try to parse
http://www.quotemedia.com/results.php&action=showDetailedQuote&webmasterId=500&targetsym=BCE">this
page, which looks like it contains the underlying content, but the page
seems to be a mess and will not parse cleanly.
Am I missing something obvious here?
I'm having trouble parsing this with BeautifulSoup. I think the problem is
that most of the content is loaded through a script, so that if you view
the source code, something like "Current Average Recommendation" is not
there.
I can instead try to parse
http://www.quotemedia.com/results.php&action=showDetailedQuote&webmasterId=500&targetsym=BCE">this
page, which looks like it contains the underlying content, but the page
seems to be a mess and will not parse cleanly.
Am I missing something obvious here?
WordPress/WooCommerce: Cannot Specify Product Category In WP_Query
WordPress/WooCommerce: Cannot Specify Product Category In WP_Query
I'm trying to set up a custom loop that cycles through products assigned
to a product category, but it doesn't seem to be working.
My category setup:
Factory Direct - FD1 - FD2 - FD3
I want my loop to display products that fall into ANY CHILDREN CATEGORIES
of Factory Direct which has an ID of 84.
My attempt at coding this in my template: http://paste.laravel.com/RYK
I have tried changing the ID from 84 to a specific category (example FD1
which has an ID of 24), but it still isn't working.
Any ideas/suggestions?
It loops through products if I remove the cat argument in WP_Query, but I
can't specify my loop.
Thanks!
I'm trying to set up a custom loop that cycles through products assigned
to a product category, but it doesn't seem to be working.
My category setup:
Factory Direct - FD1 - FD2 - FD3
I want my loop to display products that fall into ANY CHILDREN CATEGORIES
of Factory Direct which has an ID of 84.
My attempt at coding this in my template: http://paste.laravel.com/RYK
I have tried changing the ID from 84 to a specific category (example FD1
which has an ID of 24), but it still isn't working.
Any ideas/suggestions?
It loops through products if I remove the cat argument in WP_Query, but I
can't specify my loop.
Thanks!
javascript scope issue causing infinite loop
javascript scope issue causing infinite loop
I am trying to make and ajax call 30 times but this is resulting in an
infinite loop. It is certainly a scope issue relating to the data array
but cant seem to track it down.
var data = [], totalPoints = 30;
function getData() {
var value = 0.0;
if (data.length > 0)
data = data.slice(1);
url = "some/url"
while (data.length < totalPoints) {
$.getJSON(url, {metric_name : "someMetric"})
.done(function(json ) {
value = json;
console.log(value);
data.push(value.metricValue);
});
}
}
I am trying to make and ajax call 30 times but this is resulting in an
infinite loop. It is certainly a scope issue relating to the data array
but cant seem to track it down.
var data = [], totalPoints = 30;
function getData() {
var value = 0.0;
if (data.length > 0)
data = data.slice(1);
url = "some/url"
while (data.length < totalPoints) {
$.getJSON(url, {metric_name : "someMetric"})
.done(function(json ) {
value = json;
console.log(value);
data.push(value.metricValue);
});
}
}
Find occurrences of objects in list
Find occurrences of objects in list
I've this class:
public class FileInformation
{
public string Category { get; set; }
public string Message { get; set; }
}
Then, I add data to:
List<FileInformation> theConfigFiles = new List<FileInformation>();
....
theConfigFiles.Add(new FileInformation() { Category= xxx, Message = yyyy});
Question:
How can I get the occurrences of "OK" in Message? I need to count the
number of "OK" in Message.
I've this class:
public class FileInformation
{
public string Category { get; set; }
public string Message { get; set; }
}
Then, I add data to:
List<FileInformation> theConfigFiles = new List<FileInformation>();
....
theConfigFiles.Add(new FileInformation() { Category= xxx, Message = yyyy});
Question:
How can I get the occurrences of "OK" in Message? I need to count the
number of "OK" in Message.
Build App like Shazam but for devotional songs
Build App like Shazam but for devotional songs
Just realized Shazam App which recognizes the song, I was wondering if I
can build app which can recognize the devotional songs as well, what API
have they used? If so, then how would I go on doing that?
Just realized Shazam App which recognizes the song, I was wondering if I
can build app which can recognize the devotional songs as well, what API
have they used? If so, then how would I go on doing that?
Sunday, 15 September 2013
How to check a execute file is 64 bit in linux?
How to check a execute file is 64 bit in linux?
I like understand a execute file is 64 bit or no. I want to understand a
run process in Linux is 64 bit or 32 bit with c++. I do not want to use
"file" command. for example: File -L bash
I like understand a execute file is 64 bit or no. I want to understand a
run process in Linux is 64 bit or 32 bit with c++. I do not want to use
"file" command. for example: File -L bash
Rails migration not seeming to work? Accidentally named a column "type", ran a migration but receiving error
Rails migration not seeming to work? Accidentally named a column "type",
ran a migration but receiving error
So I accidentally named a column in my Item model "type" and I wrote a
migration to rename it.
class RenameTypeToTagged < ActiveRecord::Migration
def up rename_column :items, :type, :tagged end
def down end end
When I restart the server, and rake db:migrate it still spits back "Can't
mass-assign protected attributes: type". I've renamed the attr_accesible
in the Item model by hand but it doesn't seem to resolve. any ideas?
thanks
ran a migration but receiving error
So I accidentally named a column in my Item model "type" and I wrote a
migration to rename it.
class RenameTypeToTagged < ActiveRecord::Migration
def up rename_column :items, :type, :tagged end
def down end end
When I restart the server, and rake db:migrate it still spits back "Can't
mass-assign protected attributes: type". I've renamed the attr_accesible
in the Item model by hand but it doesn't seem to resolve. any ideas?
thanks
How can I create a data base management system?
How can I create a data base management system?
I have to create a data base management system as a project for the school
but I don't know how to. It doesn't have to be very sophisticated. Is
there any tutorial that shows how to do it? And, what would be the most
appropriate language to do that?
I have to create a data base management system as a project for the school
but I don't know how to. It doesn't have to be very sophisticated. Is
there any tutorial that shows how to do it? And, what would be the most
appropriate language to do that?
How to open camera in winJs
How to open camera in winJs
i am working for a face detection mechanism in winJs starting from the
basic. What is the mechanism to open a Camera in winJs and in which tag to
show the video.
This is the code i know till now
var Capture = Windows.Media.Capture;
var mediaCapture = new Capture.MediaCapture();
mediaCapture.initializeAsync();
How to show in a Div the same.
i am working for a face detection mechanism in winJs starting from the
basic. What is the mechanism to open a Camera in winJs and in which tag to
show the video.
This is the code i know till now
var Capture = Windows.Media.Capture;
var mediaCapture = new Capture.MediaCapture();
mediaCapture.initializeAsync();
How to show in a Div the same.
Replace word tag to entire file content
Replace word tag to entire file content
Assume that we have a content xml-file:
<field name="id" id="1" type="number" default="" />
Assume that we have template file with tag:
INCLUDE_XML
We need to replace INCLUDE_XML tag to entire content from xml-file. We can
try.
tpl_content=$(<tpl.xml)
xml_content=$(<cnt.xml)
xml_content="$(echo "$tpl_content" | sed "s/INCLUDE_XML/"$xml_content"/g")"
echo "$xml_content" > out.xml
The problem is unterminated 's' command cause xml-file has lot of bless
characters (quotes, slashes, etc). How we can do the replacement without
this care about the characters in content xml-file?
Assume that we have a content xml-file:
<field name="id" id="1" type="number" default="" />
Assume that we have template file with tag:
INCLUDE_XML
We need to replace INCLUDE_XML tag to entire content from xml-file. We can
try.
tpl_content=$(<tpl.xml)
xml_content=$(<cnt.xml)
xml_content="$(echo "$tpl_content" | sed "s/INCLUDE_XML/"$xml_content"/g")"
echo "$xml_content" > out.xml
The problem is unterminated 's' command cause xml-file has lot of bless
characters (quotes, slashes, etc). How we can do the replacement without
this care about the characters in content xml-file?
Pascal - Declare unknown amount of variables
Pascal - Declare unknown amount of variables
I'm working with this excercise: make a program that gives the number of
consecutive letters of a word -ex: if i enter aaafdseergftth the program
returns a = 3, e=2, t=2-.
I've come up with a couple of solutions, like define a string and then use
an array to get the characters and compare then with a while loop, but
here's the issue: i can't use arrays, string, sunbfunctions to solve this
excersise, and explicitely says i have to look for another solution.
Now here is my second idea without using strings or arrays: Define an
unknown amounts of char variables and enter each one until Intro is
entered with a while loop like While not (Eoln) do (...). And that's the
only thing i can come up right now to solve it, but when i was looking for
a way to define an unknown amount of variables i found nothing but a
solution with an array that i should resize to enter new variables. How
can i define an unknown amount of variables without using arrays? -is it
even possible?-, and if can't be done, how could i get every character of
a word without using arrays nor strings?.
I'm working with this excercise: make a program that gives the number of
consecutive letters of a word -ex: if i enter aaafdseergftth the program
returns a = 3, e=2, t=2-.
I've come up with a couple of solutions, like define a string and then use
an array to get the characters and compare then with a while loop, but
here's the issue: i can't use arrays, string, sunbfunctions to solve this
excersise, and explicitely says i have to look for another solution.
Now here is my second idea without using strings or arrays: Define an
unknown amounts of char variables and enter each one until Intro is
entered with a while loop like While not (Eoln) do (...). And that's the
only thing i can come up right now to solve it, but when i was looking for
a way to define an unknown amount of variables i found nothing but a
solution with an array that i should resize to enter new variables. How
can i define an unknown amount of variables without using arrays? -is it
even possible?-, and if can't be done, how could i get every character of
a word without using arrays nor strings?.
Is there a way to set underline to mnemonic character in native look and feel under Win 7?
Is there a way to set underline to mnemonic character in native look and
feel under Win 7?
My code:
fileMenu = new JMenu("File");
fileMenu.setMnemonic(KeyEvent.VK_F);
fileMenu.setDisplayedMnemonicIndex(0);
Javadocs for AbstractButton.setDisplayedMnemonicIndex() say that
Not all look and feels may support this.
I set my look and feel to UIManager.getSystemLookAndFeelClassName()
And I don't see underline on mnemonic even when the index is explicitely
set by setDisplayedMnemonicIndex() - under Windows 7.
It works however if I do not set the look & feel and leave just default
java theme.
Is there a way to achieve this? Is it caused by the settings of Windows ?
feel under Win 7?
My code:
fileMenu = new JMenu("File");
fileMenu.setMnemonic(KeyEvent.VK_F);
fileMenu.setDisplayedMnemonicIndex(0);
Javadocs for AbstractButton.setDisplayedMnemonicIndex() say that
Not all look and feels may support this.
I set my look and feel to UIManager.getSystemLookAndFeelClassName()
And I don't see underline on mnemonic even when the index is explicitely
set by setDisplayedMnemonicIndex() - under Windows 7.
It works however if I do not set the look & feel and leave just default
java theme.
Is there a way to achieve this? Is it caused by the settings of Windows ?
Saturday, 14 September 2013
Call Activity from BaseGameActirity
Call Activity from BaseGameActirity
I am developing a game using andengine so I am extending my main activity
from BaseGameActivity. I have also implemented SceneManager. now from
within scenemanager, I want to call a class that extends 'Activity' (not
BaseGameActivity) I am using following code to call the class from my
SceneManager
activity.startActivity(new Intent(activity, FbConnect.class)); //
Error line
activity.finish();
where 'activity' is an object of my MainActivity class which extends
BaseGameActivity.
now my problem is that I am getting a nullpointerexception on the above
mentioned line (see commented code).
following is my logcat output commented line in above code is line# 118 in
SceneManager.
09-14 22:52:32.035: E/AndroidRuntime(22385): FATAL EXCEPTION: UpdateThread
09-14 22:52:32.035: E/AndroidRuntime(22385): java.lang.NullPointerException
09-14 22:52:32.035: E/AndroidRuntime(22385): at
android.content.ComponentName.<init>(ComponentName.java:75)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
android.content.Intent.<init>(Intent.java:2857)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
com.sohi.tech.rollball.SceneManager.showFbActivity(SceneManager.java:118)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
com.sohi.tech.rollball.MainMenuScene.onMenuItemClicked(MainMenuScene.java:93)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.entity.scene.menu.MenuScene.onAreaTouched(MenuScene.java:139)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.entity.scene.Scene.onAreaTouchEvent(Scene.java:413)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.entity.scene.Scene.onSceneTouchEvent(Scene.java:357)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.entity.scene.CameraScene.onSceneTouchEvent(CameraScene.java:64)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.entity.scene.Scene.onChildSceneTouchEvent(Scene.java:420)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.entity.scene.Scene.onSceneTouchEvent(Scene.java:338)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.engine.Engine.onTouchScene(Engine.java:452)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.engine.Engine.onTouchEvent(Engine.java:438)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.input.touch.controller.BaseTouchController$TouchEventRunnablePoolItem.run(BaseTouchController.java:102)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.util.adt.pool.RunnablePoolUpdateHandler.onHandlePoolItem(RunnablePoolUpdateHandler.java:54)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.util.adt.pool.RunnablePoolUpdateHandler.onHandlePoolItem(RunnablePoolUpdateHandler.java:1)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.util.adt.pool.PoolUpdateHandler.onUpdate(PoolUpdateHandler.java:88)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.input.touch.controller.BaseTouchController.onUpdate(BaseTouchController.java:62)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.engine.Engine.onUpdate(Engine.java:584)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.engine.LimitedFPSEngine.onUpdate(LimitedFPSEngine.java:56)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.engine.Engine.onTickUpdate(Engine.java:548)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.engine.Engine$UpdateThread.run(Engine.java:820)
I am developing a game using andengine so I am extending my main activity
from BaseGameActivity. I have also implemented SceneManager. now from
within scenemanager, I want to call a class that extends 'Activity' (not
BaseGameActivity) I am using following code to call the class from my
SceneManager
activity.startActivity(new Intent(activity, FbConnect.class)); //
Error line
activity.finish();
where 'activity' is an object of my MainActivity class which extends
BaseGameActivity.
now my problem is that I am getting a nullpointerexception on the above
mentioned line (see commented code).
following is my logcat output commented line in above code is line# 118 in
SceneManager.
09-14 22:52:32.035: E/AndroidRuntime(22385): FATAL EXCEPTION: UpdateThread
09-14 22:52:32.035: E/AndroidRuntime(22385): java.lang.NullPointerException
09-14 22:52:32.035: E/AndroidRuntime(22385): at
android.content.ComponentName.<init>(ComponentName.java:75)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
android.content.Intent.<init>(Intent.java:2857)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
com.sohi.tech.rollball.SceneManager.showFbActivity(SceneManager.java:118)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
com.sohi.tech.rollball.MainMenuScene.onMenuItemClicked(MainMenuScene.java:93)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.entity.scene.menu.MenuScene.onAreaTouched(MenuScene.java:139)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.entity.scene.Scene.onAreaTouchEvent(Scene.java:413)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.entity.scene.Scene.onSceneTouchEvent(Scene.java:357)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.entity.scene.CameraScene.onSceneTouchEvent(CameraScene.java:64)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.entity.scene.Scene.onChildSceneTouchEvent(Scene.java:420)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.entity.scene.Scene.onSceneTouchEvent(Scene.java:338)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.engine.Engine.onTouchScene(Engine.java:452)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.engine.Engine.onTouchEvent(Engine.java:438)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.input.touch.controller.BaseTouchController$TouchEventRunnablePoolItem.run(BaseTouchController.java:102)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.util.adt.pool.RunnablePoolUpdateHandler.onHandlePoolItem(RunnablePoolUpdateHandler.java:54)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.util.adt.pool.RunnablePoolUpdateHandler.onHandlePoolItem(RunnablePoolUpdateHandler.java:1)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.util.adt.pool.PoolUpdateHandler.onUpdate(PoolUpdateHandler.java:88)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.input.touch.controller.BaseTouchController.onUpdate(BaseTouchController.java:62)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.engine.Engine.onUpdate(Engine.java:584)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.engine.LimitedFPSEngine.onUpdate(LimitedFPSEngine.java:56)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.engine.Engine.onTickUpdate(Engine.java:548)
09-14 22:52:32.035: E/AndroidRuntime(22385): at
org.andengine.engine.Engine$UpdateThread.run(Engine.java:820)
Apache ActiveMQ Camel transacted rollback
Apache ActiveMQ Camel transacted rollback
In an attempt to understand ActiveMQ and Camel better I am writing a unit
test for transaction rollback. It seems to not be working for me which
means I am doing something wrong! Here is the code:
public class MyTest extends CamelTestSupport {
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry reg = super.createRegistry();
DataSourceTransactionManager txMgr = new DataSourceTransactionManager();
SpringTransactionPolicy txPolicy = new SpringTransactionPolicy();
txPolicy.setTransactionManager(txMgr);
txPolicy.setPropagationBehaviorName("PROPAGATION_REQUIRED");
reg.bind("required", txPolicy);
return reg;
}
@Before
public void setUp() throws Exception {
super.setUp();
}
@After
public void tearDown() throws Exception {
super.tearDown();
}
@Test
public void testTransaction() throws Exception {
ConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
context.addComponent("jms",
JmsComponent.jmsComponentTransacted(connectionFactory));
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("jms:queue:in")
.transacted("required")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws
Exception {
System.out.println("Expected failure");
throw new RuntimeException("Expected failure");
}
})
.to("mock:result");
}
});
context.start();
MockEndpoint result = context.getEndpoint("mock:result",
MockEndpoint.class);
result.expectedMessageCount(0);
NotifyBuilder notifyBuilder = new
NotifyBuilder(context).whenDone(1).create();
context.createProducerTemplate().sendBody("jms:queue:in", "Test");
boolean matches = notifyBuilder.matches(5, TimeUnit.SECONDS);
assertTrue(matches);
Thread.sleep(1000);
assertMockEndpointsSatisfied();
BrowsableEndpoint in = context.getEndpoint("jms:queue:in",
BrowsableEndpoint.class);
List<Exchange> list = in.getExchanges();
assertEquals(1, list.size());
String body = list.get(0).getIn().getBody(String.class);
assertEquals("Test", body);
context.stop();
}
}
It fails on the assertion that the list.size() is 1, which should pass if
the rollback was successful. What am I doing wrong? Thanks in advance!
In an attempt to understand ActiveMQ and Camel better I am writing a unit
test for transaction rollback. It seems to not be working for me which
means I am doing something wrong! Here is the code:
public class MyTest extends CamelTestSupport {
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry reg = super.createRegistry();
DataSourceTransactionManager txMgr = new DataSourceTransactionManager();
SpringTransactionPolicy txPolicy = new SpringTransactionPolicy();
txPolicy.setTransactionManager(txMgr);
txPolicy.setPropagationBehaviorName("PROPAGATION_REQUIRED");
reg.bind("required", txPolicy);
return reg;
}
@Before
public void setUp() throws Exception {
super.setUp();
}
@After
public void tearDown() throws Exception {
super.tearDown();
}
@Test
public void testTransaction() throws Exception {
ConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
context.addComponent("jms",
JmsComponent.jmsComponentTransacted(connectionFactory));
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("jms:queue:in")
.transacted("required")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws
Exception {
System.out.println("Expected failure");
throw new RuntimeException("Expected failure");
}
})
.to("mock:result");
}
});
context.start();
MockEndpoint result = context.getEndpoint("mock:result",
MockEndpoint.class);
result.expectedMessageCount(0);
NotifyBuilder notifyBuilder = new
NotifyBuilder(context).whenDone(1).create();
context.createProducerTemplate().sendBody("jms:queue:in", "Test");
boolean matches = notifyBuilder.matches(5, TimeUnit.SECONDS);
assertTrue(matches);
Thread.sleep(1000);
assertMockEndpointsSatisfied();
BrowsableEndpoint in = context.getEndpoint("jms:queue:in",
BrowsableEndpoint.class);
List<Exchange> list = in.getExchanges();
assertEquals(1, list.size());
String body = list.get(0).getIn().getBody(String.class);
assertEquals("Test", body);
context.stop();
}
}
It fails on the assertion that the list.size() is 1, which should pass if
the rollback was successful. What am I doing wrong? Thanks in advance!
Difference between Bootstrap 3 'default' and 'customized' download versions?
Difference between Bootstrap 3 'default' and 'customized' download versions?
I have recently started using Bootstrap3 on my projects. I would like to
understand what is the difference between: Bootstrap 3 'default' and
'customized' download versions? (Particularly related to how to
use/customize LESS in both the cases)
I am attaching the snapshots of the folder structures of the downloaded
folders in both the cases.
Case 1: Default Download: Has a lot of folders. Q: can i customize LESS
variables here and then use all that in my project?
Case 2: Customized Download: Has only 3 folders. Contains only the CSS and
JS and Fonts. No other folders. And also there is the additional
'bootstrap-theme.css' (under assets/css folder), but it is not in the
default version..is it included by default in it?
PS- My reason for asking is so that i can decide when to use the default
and when to use the customized version, and do i actually need the
customized version?
Thanks.
I have recently started using Bootstrap3 on my projects. I would like to
understand what is the difference between: Bootstrap 3 'default' and
'customized' download versions? (Particularly related to how to
use/customize LESS in both the cases)
I am attaching the snapshots of the folder structures of the downloaded
folders in both the cases.
Case 1: Default Download: Has a lot of folders. Q: can i customize LESS
variables here and then use all that in my project?
Case 2: Customized Download: Has only 3 folders. Contains only the CSS and
JS and Fonts. No other folders. And also there is the additional
'bootstrap-theme.css' (under assets/css folder), but it is not in the
default version..is it included by default in it?
PS- My reason for asking is so that i can decide when to use the default
and when to use the customized version, and do i actually need the
customized version?
Thanks.
Indy Redirect results in 404
Indy Redirect results in 404
When I set hoTreat302Like303 and login in Gmail it results in:
First chance exception at $76F3C41F. Exception class
EIdHTTPProtocolException with message 'HTTP/1.1 404 Not Found'
Which is a problem because if I remove it then I cannot login in to
Facebook. I am quite sure this is a bug in Indy 10. I am using the latest
SVN.
When I set hoTreat302Like303 and login in Gmail it results in:
First chance exception at $76F3C41F. Exception class
EIdHTTPProtocolException with message 'HTTP/1.1 404 Not Found'
Which is a problem because if I remove it then I cannot login in to
Facebook. I am quite sure this is a bug in Indy 10. I am using the latest
SVN.
Python: Strange output when calculate md5
Python: Strange output when calculate md5
When i calculate MD5 for a file in Python i get a strange output. My
function :
def md5_for_file(self, fname, block_size=2**20):
f = open(fname)
data = f.read()
m = md5.new()
if len(data)>0:
m.update(data)
f.close()
return m.digest()
Output :
I need to convert that to utf8 or what?!
When i calculate MD5 for a file in Python i get a strange output. My
function :
def md5_for_file(self, fname, block_size=2**20):
f = open(fname)
data = f.read()
m = md5.new()
if len(data)>0:
m.update(data)
f.close()
return m.digest()
Output :
I need to convert that to utf8 or what?!
Making jQuery plugin exhibit jQuery's on() quality
Making jQuery plugin exhibit jQuery's on() quality
I just created a jQuery plugin http://jsbin.com/aCoboQo/2 which applies a
tooltip to the selected elements. To apply it to all elements of class
"myElement", one would simply use the following script:
$('.myElement').toolTip();
All is good until I wish to add another element. The newly added element
never had the plugin applied to it, so it will obviously not have a
tooltip. Yes, I know I can apply the tooltip to the newly added element
after adding, but I would rather not make the user need to.
How do I make my jQuery plugin exhibit jQuery's on() quality? I am okay
with either modifying the plugin or changing how I apply pluging.
Again, a live demo is at http://jsbin.com/aCoboQo/2 and the script is
duplicated below.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1" />
<title>screenshot</title>
<script src="http://code.jquery.com/jquery-latest.js"
type="text/javascript"></script>
<style type="text/css">
.myElement{margin:100px;}
.toolToolActive{color:blue;}
.myTooTip {
border:1px solid #CECECE;
background:white;
padding:10px;
display:none;
color:black;
font-size:11px;-moz-border-radius:4px;
box-shadow: 3px 1px 6px #505050;
-khtml-border-radius:4px;
-webkit-border-radius:4px;
border-radius:4px;
}
</style>
<script type="text/javascript">
(function($){
var defaults = {
'class' : '', // Css class(es) to add to tooltip (along with
standardToolTip).
'mouseMove': true, // A flag indicating whether to move tooltip
with mouse.
'speed' : 'fast', // The speed at which to fade in the tool tip.
'delay' : 250, // Delay (in ms) before opening the popup.
'xOffset' : 20,
'yOffset' : 10
};
var methods = {
init : function (options) {
// Create settings using the defaults extended with any
options provided.
var settings = $.extend(defaults, options || {});
return this.each(function () {
var title,
timeoutID,
$t,
toolTip;
// Wrap the content of the current element in a span.
$t = $(this).wrapInner('<span />');
$t.children('span').hover(function(e) {
if(!$t.hasClass('toolToolActive')) {
title = $t.attr('title');
$t.attr('title',''); // Remove the title so that
it doesn't show on hover.
timeoutID = window.setTimeout(function () {
// Create a div to be the tooltip pop up, add
the styling as well as
// the html (from the display function) to it
and then fade the element in
// using the speed specified in the settings.
toolTip = $('<div />')
.addClass('standardToolTip ' + settings['class'])
.html(title)
.css('top', (e.pageY - settings.yOffset) + 'px')
.css('left', (e.pageX + settings.xOffset) + 'px')
.css('position', 'absolute')
.appendTo('body')
.fadeIn(settings.speed);
$t.addClass('toolToolActive');
}, settings.delay);
}
},
function () {
window.clearTimeout(timeoutID);
$t.attr('title', title);
if ($t.hasClass('toolToolActive')) {
toolTip.remove();
$t.removeClass('toolToolActive');
}
});
$t.mousemove(function (e) {
if (settings.mouseMove &&
$t.hasClass('toolToolActive')) {
toolTip.css('top', (e.pageY - settings.yOffset) +
'px')
.css('left', (e.pageX + settings.xOffset) + 'px');
}
});
});
},
destroy : function () {
return this.each(function () {
var $e = $(this);
$e.html($e.children('span').html());
});
}
};
$.fn.toolTip = function(method) {
if (methods[method]) {
return methods[method].apply(this,
Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || ! method) {
return methods.init.apply(this, arguments);
} else {
$.error('Method ' + method + ' does not exist on
jQuery.toolTip');
}
};
}(jQuery));
$(function(){
$('.myElement').toolTip({
'class':'myTooTip'
});
$('.add').click(function(){$('#myDiv').append('<p
class="myElement" data-id="4" title="Popup for New
Doe">New Doe</p>');});
});
</script>
</head>
<body>
<div id="myDiv">
<p class="myElement" data-id="1" title="Popup for John Doe">John
Doe</p>
<p class="myElement" data-id="2" title="Popup for Jane Doe">Jane
Doe</p>
<p class="myElement" data-id="3" title="Popup for Baby Doe">Baby
Doe</p>
</div>
<p class="add">Add</p>
</body>
</html>
I just created a jQuery plugin http://jsbin.com/aCoboQo/2 which applies a
tooltip to the selected elements. To apply it to all elements of class
"myElement", one would simply use the following script:
$('.myElement').toolTip();
All is good until I wish to add another element. The newly added element
never had the plugin applied to it, so it will obviously not have a
tooltip. Yes, I know I can apply the tooltip to the newly added element
after adding, but I would rather not make the user need to.
How do I make my jQuery plugin exhibit jQuery's on() quality? I am okay
with either modifying the plugin or changing how I apply pluging.
Again, a live demo is at http://jsbin.com/aCoboQo/2 and the script is
duplicated below.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1" />
<title>screenshot</title>
<script src="http://code.jquery.com/jquery-latest.js"
type="text/javascript"></script>
<style type="text/css">
.myElement{margin:100px;}
.toolToolActive{color:blue;}
.myTooTip {
border:1px solid #CECECE;
background:white;
padding:10px;
display:none;
color:black;
font-size:11px;-moz-border-radius:4px;
box-shadow: 3px 1px 6px #505050;
-khtml-border-radius:4px;
-webkit-border-radius:4px;
border-radius:4px;
}
</style>
<script type="text/javascript">
(function($){
var defaults = {
'class' : '', // Css class(es) to add to tooltip (along with
standardToolTip).
'mouseMove': true, // A flag indicating whether to move tooltip
with mouse.
'speed' : 'fast', // The speed at which to fade in the tool tip.
'delay' : 250, // Delay (in ms) before opening the popup.
'xOffset' : 20,
'yOffset' : 10
};
var methods = {
init : function (options) {
// Create settings using the defaults extended with any
options provided.
var settings = $.extend(defaults, options || {});
return this.each(function () {
var title,
timeoutID,
$t,
toolTip;
// Wrap the content of the current element in a span.
$t = $(this).wrapInner('<span />');
$t.children('span').hover(function(e) {
if(!$t.hasClass('toolToolActive')) {
title = $t.attr('title');
$t.attr('title',''); // Remove the title so that
it doesn't show on hover.
timeoutID = window.setTimeout(function () {
// Create a div to be the tooltip pop up, add
the styling as well as
// the html (from the display function) to it
and then fade the element in
// using the speed specified in the settings.
toolTip = $('<div />')
.addClass('standardToolTip ' + settings['class'])
.html(title)
.css('top', (e.pageY - settings.yOffset) + 'px')
.css('left', (e.pageX + settings.xOffset) + 'px')
.css('position', 'absolute')
.appendTo('body')
.fadeIn(settings.speed);
$t.addClass('toolToolActive');
}, settings.delay);
}
},
function () {
window.clearTimeout(timeoutID);
$t.attr('title', title);
if ($t.hasClass('toolToolActive')) {
toolTip.remove();
$t.removeClass('toolToolActive');
}
});
$t.mousemove(function (e) {
if (settings.mouseMove &&
$t.hasClass('toolToolActive')) {
toolTip.css('top', (e.pageY - settings.yOffset) +
'px')
.css('left', (e.pageX + settings.xOffset) + 'px');
}
});
});
},
destroy : function () {
return this.each(function () {
var $e = $(this);
$e.html($e.children('span').html());
});
}
};
$.fn.toolTip = function(method) {
if (methods[method]) {
return methods[method].apply(this,
Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || ! method) {
return methods.init.apply(this, arguments);
} else {
$.error('Method ' + method + ' does not exist on
jQuery.toolTip');
}
};
}(jQuery));
$(function(){
$('.myElement').toolTip({
'class':'myTooTip'
});
$('.add').click(function(){$('#myDiv').append('<p
class="myElement" data-id="4" title="Popup for New
Doe">New Doe</p>');});
});
</script>
</head>
<body>
<div id="myDiv">
<p class="myElement" data-id="1" title="Popup for John Doe">John
Doe</p>
<p class="myElement" data-id="2" title="Popup for Jane Doe">Jane
Doe</p>
<p class="myElement" data-id="3" title="Popup for Baby Doe">Baby
Doe</p>
</div>
<p class="add">Add</p>
</body>
</html>
How can I make my activity have a transparent background?
How can I make my activity have a transparent background?
I don't want to use
android:theme="@android:style/Theme.Translucent.NoTitleBar" because the
progressbar come out in black in an old outdated style. so I took what's
inside this theme and put ito my own style with Holo Light as parent.
<style name="noTitleTransparentBackground" parent="android:Theme.Holo.Light">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
But this made the background not transparent anymore.
What am i doing wrong?
I don't want to use
android:theme="@android:style/Theme.Translucent.NoTitleBar" because the
progressbar come out in black in an old outdated style. so I took what's
inside this theme and put ito my own style with Holo Light as parent.
<style name="noTitleTransparentBackground" parent="android:Theme.Holo.Light">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
But this made the background not transparent anymore.
What am i doing wrong?
Hold a selected value of dropdown box after action calling in JSP and struts2
Hold a selected value of dropdown box after action calling in JSP and struts2
Hi I am very unaware of JAVASCRIPT and AJAX ... I have drop down box that
is populated dynamically When a user selects an option he press submit and
that will go to action class after coming back to JSP I want to populate
the option the he selected previously... Please provide me The code ..
Thanks In advance
Hi I am very unaware of JAVASCRIPT and AJAX ... I have drop down box that
is populated dynamically When a user selects an option he press submit and
that will go to action class after coming back to JSP I want to populate
the option the he selected previously... Please provide me The code ..
Thanks In advance
Friday, 13 September 2013
PageView slideshow
PageView slideshow
I'm new here and could use some help, i'm making an ios app for the ipad
and want to be able to animate the transition of pages in a pageview with
custom and/or stock transitions.
What is the correct way to animate through various pages (PageView) each
having full screen photos in them? Similar to in apples photos app. I'd
like to be able to set up a basic slideshow and transition through them.
All Help is appreciated.
Thank You
I'm new here and could use some help, i'm making an ios app for the ipad
and want to be able to animate the transition of pages in a pageview with
custom and/or stock transitions.
What is the correct way to animate through various pages (PageView) each
having full screen photos in them? Similar to in apples photos app. I'd
like to be able to set up a basic slideshow and transition through them.
All Help is appreciated.
Thank You
How to evaluate a reciprocal function
How to evaluate a reciprocal function
I am building a basic jQuery calculator. Everything was going good, until
I tried doing the reciprocal function. I have it bound to a click event.
The code looks like this
// inverse is $(".row li.inverse")
inverse.on("click", function () {
// textBox is $("input#result")
var val = textBox.val(),
text = parseFloat(val),
recip = eval(1/text);
textBox.val(recip);
});
So on the click of the button with the class inverse, it should get the
value of what is in the input, and turn it into a number. It should then
eval the number as 1 divided by the number, and set the textbox value
equal to the answer. But when I click the button, the value stays the
same. However, when I put the code into firebug without the click handler,
it works just fine. Where am I going wrong?
Fiddle
I am building a basic jQuery calculator. Everything was going good, until
I tried doing the reciprocal function. I have it bound to a click event.
The code looks like this
// inverse is $(".row li.inverse")
inverse.on("click", function () {
// textBox is $("input#result")
var val = textBox.val(),
text = parseFloat(val),
recip = eval(1/text);
textBox.val(recip);
});
So on the click of the button with the class inverse, it should get the
value of what is in the input, and turn it into a number. It should then
eval the number as 1 divided by the number, and set the textbox value
equal to the answer. But when I click the button, the value stays the
same. However, when I put the code into firebug without the click handler,
it works just fine. Where am I going wrong?
Fiddle
Extract body text from Outlook
Extract body text from Outlook
I am working on a vba macro to extract the text contained in an email that
is sent to me every day at a specified email address I want to generate a
vba macro that triggers when this arrives. The text needs to be saved to a
text file "c:\temp\email.txt"
I have collated various bits of code, but nothing really works.
Can anyone advise a simple vba method to do this?
I am working on a vba macro to extract the text contained in an email that
is sent to me every day at a specified email address I want to generate a
vba macro that triggers when this arrives. The text needs to be saved to a
text file "c:\temp\email.txt"
I have collated various bits of code, but nothing really works.
Can anyone advise a simple vba method to do this?
how to bound searchLookupEdit to PictureEdit
how to bound searchLookupEdit to PictureEdit
Please edit this code
i am trying this code but there is error
this.PicboxEmployee.Image =
System.Drawing.Image.FromStream(this.searchLookUpEdit1.Properties.View.GetFocusedRowCellValue("Emp_Pic_ImageData").ToString());
Please edit this code
i am trying this code but there is error
this.PicboxEmployee.Image =
System.Drawing.Image.FromStream(this.searchLookUpEdit1.Properties.View.GetFocusedRowCellValue("Emp_Pic_ImageData").ToString());
Jquery 1.9.1 integration with SharePoint 2010
Jquery 1.9.1 integration with SharePoint 2010
I am using SharePoint 2010 and included the JQuery Library as discussed in
the MSDN blog
'http://blogs.msdn.com/b/yojoshi/archive/2010/06/17/using-jquery-with-sharepoint-2010.aspx?'
This looks successful. However, I am not able to run the following JQuery
in a webpart.
I have the JQuery, HTML and CSS in 'http://jsfiddle.net/8HEd9/1/' Below is
the JQuery code that looks to have a problem.
function init()
{
// Grab the tab links and content divs from the page
var tabListItems = $('#tabs li');
// loop through all tab li tags
$('#tabs li').each(function (i, ele) {
// Assign click/focus events to the tab anchor/links
var tabLink = $(this).find('a').on('click', showTab).on('focus',
function () { $(this).blur(); });
var tabBody = $($(tabLink).attr('href'));
// highlight the first tab
if (i == 0) $(tabLink).addClass('selected');
// hide all the content divs but the first
if (i != 0) $(tabBody).hide();
});
//auto-rotate every 4 seconds
setInterval(function () {
var selectedTab = $('#tabs').find('li.on');
var index = $(selectedTab).index();
if (index < $('#tabs').find('li').length - 1)
index++;
else
index = 0;
$('#tabs').find('li:eq(' + index + ') a').click();
}, 4000);
}
This JQuery function in the fiddle is to render the html ul elements into
tabs and auto-toggle between them every 4 seconds.
This works well on static with the css. But, seems to not running all the
JQuery code. I do not see the effect of 'SetInterval' function when
deployed into SharePoint.
Kindly help me understand what I am missing. Thanks
I am using SharePoint 2010 and included the JQuery Library as discussed in
the MSDN blog
'http://blogs.msdn.com/b/yojoshi/archive/2010/06/17/using-jquery-with-sharepoint-2010.aspx?'
This looks successful. However, I am not able to run the following JQuery
in a webpart.
I have the JQuery, HTML and CSS in 'http://jsfiddle.net/8HEd9/1/' Below is
the JQuery code that looks to have a problem.
function init()
{
// Grab the tab links and content divs from the page
var tabListItems = $('#tabs li');
// loop through all tab li tags
$('#tabs li').each(function (i, ele) {
// Assign click/focus events to the tab anchor/links
var tabLink = $(this).find('a').on('click', showTab).on('focus',
function () { $(this).blur(); });
var tabBody = $($(tabLink).attr('href'));
// highlight the first tab
if (i == 0) $(tabLink).addClass('selected');
// hide all the content divs but the first
if (i != 0) $(tabBody).hide();
});
//auto-rotate every 4 seconds
setInterval(function () {
var selectedTab = $('#tabs').find('li.on');
var index = $(selectedTab).index();
if (index < $('#tabs').find('li').length - 1)
index++;
else
index = 0;
$('#tabs').find('li:eq(' + index + ') a').click();
}, 4000);
}
This JQuery function in the fiddle is to render the html ul elements into
tabs and auto-toggle between them every 4 seconds.
This works well on static with the css. But, seems to not running all the
JQuery code. I do not see the effect of 'SetInterval' function when
deployed into SharePoint.
Kindly help me understand what I am missing. Thanks
call another class from java program
call another class from java program
I have 2 classes one is a simple one
Sample.java
public class Sample {
public static void main(String args[]) {
System.out.println("Hello World!!!!!");
}
}
Other one is something like this
Main.java
public class Main
{
public static void main(String[] args) throws Exception
{
Runtime.getRuntime().exec("java Sample");
}
}
I am basically trying to run the Main.java program to call Sample.java in
a new command prompt...that is a new cmd that should open and print the
output of Sample.java...how should I do this...???
I have 2 classes one is a simple one
Sample.java
public class Sample {
public static void main(String args[]) {
System.out.println("Hello World!!!!!");
}
}
Other one is something like this
Main.java
public class Main
{
public static void main(String[] args) throws Exception
{
Runtime.getRuntime().exec("java Sample");
}
}
I am basically trying to run the Main.java program to call Sample.java in
a new command prompt...that is a new cmd that should open and print the
output of Sample.java...how should I do this...???
Thursday, 12 September 2013
Subtract DateTimes in IQueryable query
Subtract DateTimes in IQueryable query
Hello I'm trying to subtract two DateTimes in my query and compare
defference with timeInterval,but I get exeption:
<Message>An error has occurred.</Message>
<ExceptionMessage>System.TimeSpan
Subtract(System.DateTime)</ExceptionMessage>
<ExceptionType>System.NotSupportedException</ExceptionType>
C# code:
producerRelations = producerRelationRepository.Query().Fetch(c => c.Order).
Where(c => c.Order.CreatedBy == login).
Where(c=>currentDate.Subtract(c.RouteUnit.DtStart.Value).TotalMinutes<timeInterval);
How I can subtract dates in my code?
Hello I'm trying to subtract two DateTimes in my query and compare
defference with timeInterval,but I get exeption:
<Message>An error has occurred.</Message>
<ExceptionMessage>System.TimeSpan
Subtract(System.DateTime)</ExceptionMessage>
<ExceptionType>System.NotSupportedException</ExceptionType>
C# code:
producerRelations = producerRelationRepository.Query().Fetch(c => c.Order).
Where(c => c.Order.CreatedBy == login).
Where(c=>currentDate.Subtract(c.RouteUnit.DtStart.Value).TotalMinutes<timeInterval);
How I can subtract dates in my code?
Next function doesn't work for Magnific popup
Next function doesn't work for Magnific popup
I have tried to apply Magnific Popup to a content gallery. Each link will
open an individual popup from different gallery. However, I bump into this
issue that when the popup open, I click Next and all popups disappear.
Meanwhile, if I click Previous, it still loads the previous popup.
Here is my code
http://codepen.io/anon/pen/EbDwJ
How can I fix the Next function here?
I have tried to apply Magnific Popup to a content gallery. Each link will
open an individual popup from different gallery. However, I bump into this
issue that when the popup open, I click Next and all popups disappear.
Meanwhile, if I click Previous, it still loads the previous popup.
Here is my code
http://codepen.io/anon/pen/EbDwJ
How can I fix the Next function here?
Retrieve child records ordered by another parent
Retrieve child records ordered by another parent
This associations worked OK in Rails 3, so for a User I could get
UserQuest ordered by Quest.status. I can't find how to get this in Rails
4. Thanks for the help.
class Quest < ActiveRecord::Base
has_many :user_quests
end
class UserQuest < ActiveRecord::Base
belongs_to :user
belongs_to :quest
end
class User < ActiveRecord::Base
has_many :user_quests, :include => :quest, :order => "Quest.status
DESC", :dependent => :delete_all
end
This associations worked OK in Rails 3, so for a User I could get
UserQuest ordered by Quest.status. I can't find how to get this in Rails
4. Thanks for the help.
class Quest < ActiveRecord::Base
has_many :user_quests
end
class UserQuest < ActiveRecord::Base
belongs_to :user
belongs_to :quest
end
class User < ActiveRecord::Base
has_many :user_quests, :include => :quest, :order => "Quest.status
DESC", :dependent => :delete_all
end
Verifying exception messages with GoogleTest
Verifying exception messages with GoogleTest
Is it possible to verify the message thrown by an exception? Currently one
can do:
ASSERT_THROW(statement, exception_type)
which is all fine and good but no where can I find a way to test e.what()
is really what I am looking for. Is this not possible via google test?
Is it possible to verify the message thrown by an exception? Currently one
can do:
ASSERT_THROW(statement, exception_type)
which is all fine and good but no where can I find a way to test e.what()
is really what I am looking for. Is this not possible via google test?
Windows Batch: How to create and use generated code
Windows Batch: How to create and use generated code
I need help creating a for loop that generates the following example code
below depending on the %count% variable and then execute it:
So if %count%=4 it would output the following:
IF %M%==1 set %variable%
IF %M%==2 set %variable%
IF %M%==3 set %variable%
IF %M%==4 EXIT
If %count%= 7 output would be:
IF %M%==1 set %variable%
IF %M%==2 set %variable%
IF %M%==3 set %variable%
IF %M%==4 set %variable%
IF %M%==5 set %variable%
IF %M%==6 set %variable%
IF %M%==7 EXIT
I was thinking of echoing the for loop into a new batch file and then
execute it, not sure if thats the best approach?
Ex:
for /l %%a in (1,1,%count%) do (
echo IF %M%==%count% set %variable% > new.bat
)
call new.bat
I need help creating a for loop that generates the following example code
below depending on the %count% variable and then execute it:
So if %count%=4 it would output the following:
IF %M%==1 set %variable%
IF %M%==2 set %variable%
IF %M%==3 set %variable%
IF %M%==4 EXIT
If %count%= 7 output would be:
IF %M%==1 set %variable%
IF %M%==2 set %variable%
IF %M%==3 set %variable%
IF %M%==4 set %variable%
IF %M%==5 set %variable%
IF %M%==6 set %variable%
IF %M%==7 EXIT
I was thinking of echoing the for loop into a new batch file and then
execute it, not sure if thats the best approach?
Ex:
for /l %%a in (1,1,%count%) do (
echo IF %M%==%count% set %variable% > new.bat
)
call new.bat
Run-Time check failure #2 - Stack around the variable 'str' was corrupted. ERROR? How to correct?
Run-Time check failure #2 - Stack around the variable 'str' was corrupted.
ERROR? How to correct?
Below program gives desired output(Counts Words of 3 consecutive lines)
but it gives "Run-Time check failure #2 - Stack around the variable 'str'
was corrupted" and hangs. I tried but I could not find the solution.
Thanks
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
int i,count=0;
int main(void){
char str[3][1000];
char *ptr;
//Get user input
puts("Enter three lines:");
for (i = 0; i < 3; i++)
{
gets(&str[i][1000]);
}
for (i = 0; i < 3; i++)
{
ptr=strtok(&str[i][1000]," ");
count++;
while (ptr!=NULL)
{
ptr=strtok(NULL, " ");
if (ptr!=NULL)
{
count++;
}
}
}
printf("%d words", count);
getch();
}
ERROR? How to correct?
Below program gives desired output(Counts Words of 3 consecutive lines)
but it gives "Run-Time check failure #2 - Stack around the variable 'str'
was corrupted" and hangs. I tried but I could not find the solution.
Thanks
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
int i,count=0;
int main(void){
char str[3][1000];
char *ptr;
//Get user input
puts("Enter three lines:");
for (i = 0; i < 3; i++)
{
gets(&str[i][1000]);
}
for (i = 0; i < 3; i++)
{
ptr=strtok(&str[i][1000]," ");
count++;
while (ptr!=NULL)
{
ptr=strtok(NULL, " ");
if (ptr!=NULL)
{
count++;
}
}
}
printf("%d words", count);
getch();
}
How can i update the ids field with this rethinkdb document structure?
How can i update the ids field with this rethinkdb document structure?
Having trouble trying to update the ids field in the document structure:
[
[0] {
"rank" => nil,
"profile_id" => 3,
"daily_providers" => [
[0] {
"relationships" => [
[0] {
"relationship_type" => "friend",
"count" => 0
},
[1] {
"relationship_type" => "acquaintance",
"ids" => [],
"count" => 0
}
],
"provider_name" => "foo",
"date" => 20130912
},
[1] {
"provider_name" => "bar"
}
]
}
]
Having trouble trying to update the ids field in the document structure:
[
[0] {
"rank" => nil,
"profile_id" => 3,
"daily_providers" => [
[0] {
"relationships" => [
[0] {
"relationship_type" => "friend",
"count" => 0
},
[1] {
"relationship_type" => "acquaintance",
"ids" => [],
"count" => 0
}
],
"provider_name" => "foo",
"date" => 20130912
},
[1] {
"provider_name" => "bar"
}
]
}
]
Wednesday, 11 September 2013
reducing size of a stringstream
reducing size of a stringstream
As an easy way to store several status logs etc. I have chosen a
std::stringstream. In case of an error I can simply dump .rdbuf() into a
file to be able to reproduce what my program has been doing before it
crashed.
My problem now is, that this stringstream grows in size indefinitely. I
have tried several things to ensure that I only keep the last 1MiB or so
of the stream but have not been successful.
.rdbuf()->pubseekoff(...)
.ignore(...)
getline(...)
ss.str() = ss.str().substr(...)
Apparently the underlying buffer object always only increases in size - no
matter whether some of the data has already been read or not.
Is there any way to reduce the size / hold it at some constant (preferably
without regular deep copies)? A circular buffer as an underlying buffer
object would be perfect - is that possible? Esp. does that already exist?
As an easy way to store several status logs etc. I have chosen a
std::stringstream. In case of an error I can simply dump .rdbuf() into a
file to be able to reproduce what my program has been doing before it
crashed.
My problem now is, that this stringstream grows in size indefinitely. I
have tried several things to ensure that I only keep the last 1MiB or so
of the stream but have not been successful.
.rdbuf()->pubseekoff(...)
.ignore(...)
getline(...)
ss.str() = ss.str().substr(...)
Apparently the underlying buffer object always only increases in size - no
matter whether some of the data has already been read or not.
Is there any way to reduce the size / hold it at some constant (preferably
without regular deep copies)? A circular buffer as an underlying buffer
object would be perfect - is that possible? Esp. does that already exist?
MySql Error: 1364 Field 'display_name' doesnt have default value
MySql Error: 1364 Field 'display_name' doesnt have default value
I have just switched from a MAMP installation to a native Apache, MySql
and PHP installation. I have got everything working, but I hve started
using my web app in the new environment and suddenly any INSERT commands
are resulting in the following error:
SQLSTATE[HY000]: General error: 1364 Field 'display_name' doesn't have a
default value
It seems the I am unable to leave a field blank now where I was able to
before. I am using MySql version 5.6.13
Is there a way to change this setting in MySql?
I have just switched from a MAMP installation to a native Apache, MySql
and PHP installation. I have got everything working, but I hve started
using my web app in the new environment and suddenly any INSERT commands
are resulting in the following error:
SQLSTATE[HY000]: General error: 1364 Field 'display_name' doesn't have a
default value
It seems the I am unable to leave a field blank now where I was able to
before. I am using MySql version 5.6.13
Is there a way to change this setting in MySql?
Is thread sleep necessary when reading from a socket stream?
Is thread sleep necessary when reading from a socket stream?
I am reading from a socket input stream like this
BufferedReader in = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
String line;
while((line = in.readLine()) != null){
// do something
Thread.sleep(10); // for example 10ms
}
Now, the read method of an input stream blocks until data is available.
In this case is cooling-down the thread a good idea? After 10ms it will be
blocking anyway.
Please do not tell me about non-blocking IO, I know about that.
I am just curious whether it helps performance/CPU in anyway.
I am reading from a socket input stream like this
BufferedReader in = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
String line;
while((line = in.readLine()) != null){
// do something
Thread.sleep(10); // for example 10ms
}
Now, the read method of an input stream blocks until data is available.
In this case is cooling-down the thread a good idea? After 10ms it will be
blocking anyway.
Please do not tell me about non-blocking IO, I know about that.
I am just curious whether it helps performance/CPU in anyway.
Error in Httpresponse
Error in Httpresponse
the following is HttpResponse,
Result:{"basicDetailsList":[{"imageUrl":"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","response":"success"}]}
I'm using the following code,
JSONObject objResponse=new JSONObject(retResult); final String
strResponse=objResponse.getString("response"); if(strResponse!=null &&
strResponse.equalsIgnoreCase("success")){ //it get inside the loop-->
final String image=objResponse.getString("imageUrl"); }
I,m getting the error,
org.json.JSONException: No value for imageUrl
Any Help would be appreciated,,
the following is HttpResponse,
Result:{"basicDetailsList":[{"imageUrl":"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","response":"success"}]}
I'm using the following code,
JSONObject objResponse=new JSONObject(retResult); final String
strResponse=objResponse.getString("response"); if(strResponse!=null &&
strResponse.equalsIgnoreCase("success")){ //it get inside the loop-->
final String image=objResponse.getString("imageUrl"); }
I,m getting the error,
org.json.JSONException: No value for imageUrl
Any Help would be appreciated,,
Animating object inside UIPageViewController
Animating object inside UIPageViewController
I have a button inside UIPageViewController. I added animation to it
(hide/show)
Once I go to another controller by clicking other buttons then I go back
to the the view controller with animating button, I couldn't click any
button anymore.
I tried to remove the animation on the button and everything works fine
again so I'm guessing it's the animation that I'm having a problem with.
Here's my code for the button's animation:
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"];
theAnimation.duration=1.0;
theAnimation.repeatCount=3;
theAnimation.autoreverses=YES;
theAnimation.fromValue=[NSNumber numberWithFloat:1.0];
theAnimation.toValue=[NSNumber numberWithFloat:0.0];
[helloGuestButton.layer addAnimation:theAnimation
forKey:@"animateOpacity"];
I have a button inside UIPageViewController. I added animation to it
(hide/show)
Once I go to another controller by clicking other buttons then I go back
to the the view controller with animating button, I couldn't click any
button anymore.
I tried to remove the animation on the button and everything works fine
again so I'm guessing it's the animation that I'm having a problem with.
Here's my code for the button's animation:
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"];
theAnimation.duration=1.0;
theAnimation.repeatCount=3;
theAnimation.autoreverses=YES;
theAnimation.fromValue=[NSNumber numberWithFloat:1.0];
theAnimation.toValue=[NSNumber numberWithFloat:0.0];
[helloGuestButton.layer addAnimation:theAnimation
forKey:@"animateOpacity"];
Excel formula not working
Excel formula not working
=IF(F5=0,[E5-E5*$H$1],[F5-F5*$H$1])
I have 2 columns of data that can be used and I want the calculation to
take data from the first column only when the second column is blank (I
didn't know how to add blank in so have opted for =0) and then perform the
calculation referring to a fixed reference cell.
So if F5 is blank then take EF into the calculation referring to H1 as the
fixed reference (5% is in H1). Information in columns E&F are manually
input prices, E column is normal retail price and a figure only appears in
F column if the item is selling at a reduced price.
I want one calculation in column G that takes the most current price and
works out -5%.
=IF(F5=0,[E5-E5*$H$1],[F5-F5*$H$1])
I have 2 columns of data that can be used and I want the calculation to
take data from the first column only when the second column is blank (I
didn't know how to add blank in so have opted for =0) and then perform the
calculation referring to a fixed reference cell.
So if F5 is blank then take EF into the calculation referring to H1 as the
fixed reference (5% is in H1). Information in columns E&F are manually
input prices, E column is normal retail price and a figure only appears in
F column if the item is selling at a reduced price.
I want one calculation in column G that takes the most current price and
works out -5%.
Tuesday, 10 September 2013
Add Integer into LInked List
Add Integer into LInked List
I am trying to re-study several subjects on data structure inlcuding
Linked List. Because it's been too long since my last class works,
unfortunately, I am not sure what I am doing wrong with my code. Please
give me some advice how to resolve this problem as shown below.
LinkedList.java
package my.linked.list;
public class LinkedList<E> {
private Listnode<E> items;
private Listnode<E> lastNode;
int numItems;
public LinkedList() {
items = new Listnode<E>(null);
lastNode = new Listnode<E>(null);
numItems = 0;
}
public void add(E d) {
//Listnode<E> temp = new Listnode<E>(d);
//lastNode.setNext(temp);
lastNode.setNext(new Listnode<E>(d));
lastNode = lastNode.getNext();
numItems++;
}
//public void add(int pos){
//
//}
public void remove(Listnode<E> n) {
Listnode<E> temp = items;
if (items == n) {
items = n.getNext();
}
while (temp.getNext() != n) {
temp = temp.getNext();
}
temp.setNext((n.getNext()));
numItems--;
}
//public void remove(int pos) {
//
//}
public boolean isEmpty() {
boolean ans = false;
if (numItems == 0) {
ans = true;
}
return ans;
}
public boolean contains() {
return false;
}
public int size() {
return numItems;
}
}
MyLinkedListTest.java
package my.linked.list;
import java.io.*;
public class MyLinkedListTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
LinkedList myTest = new LinkedList();
// check whether the linkedlist is empty or not
boolean ans = false;
ans = myTest.isEmpty();
if (ans = true) {
System.out.println("This Linked List is empty");
} else {
System.out.println("This Linked List is not empty");
}
// add operation
for (int i=0; i<5; i++){
myTest.add(i);
System.out.println(myTest);
}
System.out.println("Current size of myList : " + myTest.size());
}
}
When I run this code, I receive messages below.
This Linked List is empty
my.linked.list.LinkedList@667262b6
my.linked.list.LinkedList@667262b6
my.linked.list.LinkedList@667262b6
my.linked.list.LinkedList@667262b6
my.linked.list.LinkedList@667262b6
Current size of myList : 5
It looks like that my code doesn't add integer values into the linkedlist
data type. Please let me know how to resolve this problem. Thanks so much
in advance.
I am trying to re-study several subjects on data structure inlcuding
Linked List. Because it's been too long since my last class works,
unfortunately, I am not sure what I am doing wrong with my code. Please
give me some advice how to resolve this problem as shown below.
LinkedList.java
package my.linked.list;
public class LinkedList<E> {
private Listnode<E> items;
private Listnode<E> lastNode;
int numItems;
public LinkedList() {
items = new Listnode<E>(null);
lastNode = new Listnode<E>(null);
numItems = 0;
}
public void add(E d) {
//Listnode<E> temp = new Listnode<E>(d);
//lastNode.setNext(temp);
lastNode.setNext(new Listnode<E>(d));
lastNode = lastNode.getNext();
numItems++;
}
//public void add(int pos){
//
//}
public void remove(Listnode<E> n) {
Listnode<E> temp = items;
if (items == n) {
items = n.getNext();
}
while (temp.getNext() != n) {
temp = temp.getNext();
}
temp.setNext((n.getNext()));
numItems--;
}
//public void remove(int pos) {
//
//}
public boolean isEmpty() {
boolean ans = false;
if (numItems == 0) {
ans = true;
}
return ans;
}
public boolean contains() {
return false;
}
public int size() {
return numItems;
}
}
MyLinkedListTest.java
package my.linked.list;
import java.io.*;
public class MyLinkedListTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
LinkedList myTest = new LinkedList();
// check whether the linkedlist is empty or not
boolean ans = false;
ans = myTest.isEmpty();
if (ans = true) {
System.out.println("This Linked List is empty");
} else {
System.out.println("This Linked List is not empty");
}
// add operation
for (int i=0; i<5; i++){
myTest.add(i);
System.out.println(myTest);
}
System.out.println("Current size of myList : " + myTest.size());
}
}
When I run this code, I receive messages below.
This Linked List is empty
my.linked.list.LinkedList@667262b6
my.linked.list.LinkedList@667262b6
my.linked.list.LinkedList@667262b6
my.linked.list.LinkedList@667262b6
my.linked.list.LinkedList@667262b6
Current size of myList : 5
It looks like that my code doesn't add integer values into the linkedlist
data type. Please let me know how to resolve this problem. Thanks so much
in advance.
Subscribe to:
Comments (Atom)