Inserting Specific function within a Block. Scripting
Consider you have a file test.cpp with below lines
Test(func_class,func1)
{
Test_Func1();
Test_Func2();
Test_Func3();
}
Test(func_class,func3)
{
Test_Func1();
Test_Func9();
Test_Func3();
}
Test(func_class,func2)
{
Test_Func6();
Test_Func7();
Test_Func3();
}
Now i want to insert a new line in between the curly braces for e:g in
Test(func_class,func1/2/3) after inserting will be like
Test(func_class,func1)
{
Test_Func1();
Test_newFunc6();
Test_Func2();
Test_Func3();
}
Test(func_class,func3)
{
Test_Func1();
Test_newFunc6();
Test_Func9();
Test_Func3();
}
Test(func_class,func2)
{
Test_Func6();
Test_newFunc6();
Test_Func7();
Test_Func3();
}
this can be done using scripting . can anyone please suggest shell script
or perl python to do this,
Thursday, October 3, 2013
Wednesday, October 2, 2013
has_many / belongs_to associations in RoR
has_many / belongs_to associations in RoR
I've read the guide on associations but I feel like I'm still not
completely comprehending so I want to ask a couple of questions just to be
sure. Let's say I am making an app that will, among other things, list
large cities all over the world. I would plan on having a view that starts
at continent level and can be filtered down. So I would start with a
Continent model. And then a Country model. Now, within the Continent model
I would define an association as has_many :countries. And in the Country
model I would use belongs_to :continents. That much I grasp. So my next
model would be a model for states / province. Let's just call it Province
since that is more common throughout the world. So now I have my Province
model, and I would use belongs_to :country. And likewise Countries would
have has_many :provinces. My first question is, how do I describe the
association between Province and Continent? Has_many through describes
associations where both models have many. A Province only has one
Continent. Has_one through describes a relationship between objects that
have a one to one relationship via a third object. Again, this isn't the
case because a Continent will have many Provinces. So that is my primary
question.. how to describe relationships that exist in a one to many
through context. My second question would be just asking for tips on
writing the migrations for this in a situation where I add another layer,
say County, later on. But the main problem is just understand how to
express the relationships I described. Or if they even need to be
expressed.
I've read the guide on associations but I feel like I'm still not
completely comprehending so I want to ask a couple of questions just to be
sure. Let's say I am making an app that will, among other things, list
large cities all over the world. I would plan on having a view that starts
at continent level and can be filtered down. So I would start with a
Continent model. And then a Country model. Now, within the Continent model
I would define an association as has_many :countries. And in the Country
model I would use belongs_to :continents. That much I grasp. So my next
model would be a model for states / province. Let's just call it Province
since that is more common throughout the world. So now I have my Province
model, and I would use belongs_to :country. And likewise Countries would
have has_many :provinces. My first question is, how do I describe the
association between Province and Continent? Has_many through describes
associations where both models have many. A Province only has one
Continent. Has_one through describes a relationship between objects that
have a one to one relationship via a third object. Again, this isn't the
case because a Continent will have many Provinces. So that is my primary
question.. how to describe relationships that exist in a one to many
through context. My second question would be just asking for tips on
writing the migrations for this in a situation where I add another layer,
say County, later on. But the main problem is just understand how to
express the relationships I described. Or if they even need to be
expressed.
Getting back urls while loading multiple urls with YQL
Getting back urls while loading multiple urls with YQL
I'm using YQL to fetch a bunch of pages, some of which could be offline
(obviously I don't know which ones). I'm using this query:
SELECT * FROM html WHERE url IN ("http://www.whooma.net",
"http://www.dfdsfsdgsfagdffgd.com", "http://www.cnn.com")
Where the first and the last one are actual sites, while the second one
obviously doesn't exist. Two results are actually returned but the url
from where they were loaded doesn't appear anywhere. So what would be the
way to find out which html page belongs to which url, if not every page in
the query is loaded?
Thank you very much indeed!
Matteo
I'm using YQL to fetch a bunch of pages, some of which could be offline
(obviously I don't know which ones). I'm using this query:
SELECT * FROM html WHERE url IN ("http://www.whooma.net",
"http://www.dfdsfsdgsfagdffgd.com", "http://www.cnn.com")
Where the first and the last one are actual sites, while the second one
obviously doesn't exist. Two results are actually returned but the url
from where they were loaded doesn't appear anywhere. So what would be the
way to find out which html page belongs to which url, if not every page in
the query is loaded?
Thank you very much indeed!
Matteo
Formatting the output of a String in C#
Formatting the output of a String in C#
I am new to C#. I am studying it in a module in college. We have been
given an assignment which involves us having to create a simple booking
application using the various components included in the toolbox in Visual
Studio.
The UI has a ListBox which enables the user to select multiple names of
people that will attend the event. The selected items are concatenated to
a String and output in a Label when the user confirms the selection.
This is the code where I get the values from the ListBox
protected void btnRequest_Click(object sender, EventArgs e)
{
//Update the summary label with the details of the booking.
n = name.Text;
en = eventName.Text;
r = room.SelectedItem.ToString();
d = cal.SelectedDate.ToShortDateString();
foreach (ListItem li in attendees.Items)
{
if (li.Selected)
{
people += li.Text + " ";
}
}
confirmation.Text = r + " has been booked on " + d + " by " + n + "
for " + en + ". " + people + " will be attending.";
}
Below is my entire code:
public partial class _Default : System.Web.UI.Page
{
//Variables
public TextBox name;
public TextBox eventName;
public Label confirmation;
public DropDownList room;
public Calendar cal;
public Button btn;
public ListBox attendees;
//Booking variables - store all information relating to booking in
these variables
public String n; //name of person placing booking
public String en; //name of event
public String r; //room it will take place
public List<String> att; //list of people attending
public String d; //date it will be held on
public String people;
protected void Page_Load(object sender, EventArgs e)
{
//Get references to components
name = txtName;
eventName = txtEvent;
room = droplistRooms;
attendees = attendeelist;
cal = Calendar1;
btn = btnRequest;
confirmation = lblSummary;
}
protected void btnRequest_Click(object sender, EventArgs e)
{
//Update the summary label with the details of the booking.
n = name.Text;
en = eventName.Text;
r = room.SelectedItem.ToString();
d = cal.SelectedDate.ToShortDateString();
foreach (ListItem li in attendees.Items)
{
if (li.Selected)
{
people += li.Text + " ";
}
}
confirmation.Text = r + " has been booked on " + d + " by " + n +
" for " + en + ". " + people + " will be attending.";
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
d = cal.SelectedDate.ToShortDateString();
}
The output is this:
Room 2 has been booked on 08/10/2013 by Jason Manford for Comedy Gig. Jack
Coldrick Bill Gates Larry Page Jimmy Wales will be attending.
However I would like to add an and to the last name of the person
attending the event. How would I go about doing this. Would I have to use
a List?
Many Thanks...
I am new to C#. I am studying it in a module in college. We have been
given an assignment which involves us having to create a simple booking
application using the various components included in the toolbox in Visual
Studio.
The UI has a ListBox which enables the user to select multiple names of
people that will attend the event. The selected items are concatenated to
a String and output in a Label when the user confirms the selection.
This is the code where I get the values from the ListBox
protected void btnRequest_Click(object sender, EventArgs e)
{
//Update the summary label with the details of the booking.
n = name.Text;
en = eventName.Text;
r = room.SelectedItem.ToString();
d = cal.SelectedDate.ToShortDateString();
foreach (ListItem li in attendees.Items)
{
if (li.Selected)
{
people += li.Text + " ";
}
}
confirmation.Text = r + " has been booked on " + d + " by " + n + "
for " + en + ". " + people + " will be attending.";
}
Below is my entire code:
public partial class _Default : System.Web.UI.Page
{
//Variables
public TextBox name;
public TextBox eventName;
public Label confirmation;
public DropDownList room;
public Calendar cal;
public Button btn;
public ListBox attendees;
//Booking variables - store all information relating to booking in
these variables
public String n; //name of person placing booking
public String en; //name of event
public String r; //room it will take place
public List<String> att; //list of people attending
public String d; //date it will be held on
public String people;
protected void Page_Load(object sender, EventArgs e)
{
//Get references to components
name = txtName;
eventName = txtEvent;
room = droplistRooms;
attendees = attendeelist;
cal = Calendar1;
btn = btnRequest;
confirmation = lblSummary;
}
protected void btnRequest_Click(object sender, EventArgs e)
{
//Update the summary label with the details of the booking.
n = name.Text;
en = eventName.Text;
r = room.SelectedItem.ToString();
d = cal.SelectedDate.ToShortDateString();
foreach (ListItem li in attendees.Items)
{
if (li.Selected)
{
people += li.Text + " ";
}
}
confirmation.Text = r + " has been booked on " + d + " by " + n +
" for " + en + ". " + people + " will be attending.";
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
d = cal.SelectedDate.ToShortDateString();
}
The output is this:
Room 2 has been booked on 08/10/2013 by Jason Manford for Comedy Gig. Jack
Coldrick Bill Gates Larry Page Jimmy Wales will be attending.
However I would like to add an and to the last name of the person
attending the event. How would I go about doing this. Would I have to use
a List?
Many Thanks...
Tuesday, October 1, 2013
Does it matter that I update the gcc 4.6 to 4.7 or higher in Ubuntu 12.04(LTS)
Does it matter that I update the gcc 4.6 to 4.7 or higher in Ubuntu
12.04(LTS)
I found that more and more open source libraries will use C++11 features,
and my Ubuntu Desktop 12.04 just has gcc 4.6, I want to use the
update-alternatives to change the default gcc version into 4.7 or 4.8. I
wonder that, if the libraries in the /usr/local/lib compiled by gcc 4.6
will need to be recompiled by the new gcc 4.7/4.8. In my opinion, if the
dependency libraries are still in the system, there is no need to
recompile. But, If one dependency library compiled by the new gcc 4.7, is
the dependency among libraries still right? Sorry for my poor English.
Thanks.
12.04(LTS)
I found that more and more open source libraries will use C++11 features,
and my Ubuntu Desktop 12.04 just has gcc 4.6, I want to use the
update-alternatives to change the default gcc version into 4.7 or 4.8. I
wonder that, if the libraries in the /usr/local/lib compiled by gcc 4.6
will need to be recompiled by the new gcc 4.7/4.8. In my opinion, if the
dependency libraries are still in the system, there is no need to
recompile. But, If one dependency library compiled by the new gcc 4.7, is
the dependency among libraries still right? Sorry for my poor English.
Thanks.
What is wrong with getchar (as program is exiting without a check at do while loop)?
What is wrong with getchar (as program is exiting without a check at do
while loop)?
In this in the main function the usage of getchar in do while loop is
creating problem (as per what i m figuring out) and using getch resolves
it..plz help why so..
#include <iostream>
#include <cstring>
#include <stdio.h>
using namespace std;
const int size = 10;
int main()
{
int stack[size];
int top = -1;
char ch;
char chh;
do {
cout << "what you want to do? 1:Push,2:Pop,3:Display \n";
cin >> ch;
if (ch == '1')
{
int a;
cout << "enter element to be entered";
a = getchar();
int r = push(stack, &top, a);
if (r == -1) cout << "array already full \n";
}
if (ch == '2')
{
pop(stack, &top);
}
if (ch == '3')
{
display(stack, &top);
}
cout << "enter y to continue";
chh = getchar();
} while (chh == 'y');
return 0;
}
while loop)?
In this in the main function the usage of getchar in do while loop is
creating problem (as per what i m figuring out) and using getch resolves
it..plz help why so..
#include <iostream>
#include <cstring>
#include <stdio.h>
using namespace std;
const int size = 10;
int main()
{
int stack[size];
int top = -1;
char ch;
char chh;
do {
cout << "what you want to do? 1:Push,2:Pop,3:Display \n";
cin >> ch;
if (ch == '1')
{
int a;
cout << "enter element to be entered";
a = getchar();
int r = push(stack, &top, a);
if (r == -1) cout << "array already full \n";
}
if (ch == '2')
{
pop(stack, &top);
}
if (ch == '3')
{
display(stack, &top);
}
cout << "enter y to continue";
chh = getchar();
} while (chh == 'y');
return 0;
}
About the generating function of the sum of roll dice values.
About the generating function of the sum of roll dice values.
I thought this exercise would be fairly easy, but it seems i can't find a
proper approach to it.
I have to prove that $f(x) = (1-x-x^2-x^3-x^4-x^5-x^6)^{-1}$ is the
function that generates the number of forms we can get a number $n$ as the
sum of the values given rolling a dice -as many times as is needed-.
My first excerpt is to note that $f(x) =
\displaystyle\frac{1}{1-(\sum_{i=1}^6x^i)}=\displaystyle\sum_{k=0}^{\infty}(x+\dots+x^6)^k$.
Now i would like to work from 'the other side' and see how many forms are
to write a number $n$ as the sum of numbers from 1 to 6. I have in mind
two steps:
(1) If i need to find the number of solution -without the restriction from
1 to 6- i'd have to find how many solutions are for each of the following
equations $x_1=n$; $x_1+x_2=n$, $\dots$; $x_1+\dots+x_n=n$. Then i found
out that for each $m$ there are $\sum_{k=0}^{m-1}\binom{m-1}{k}=2^{m-1}$.
(2) Now i woud like to know how many solutions are if i consider the
restriction $1\leq x_i \leq 6$. I'm not sure how to go from here, but i've
been thinking about the principle of inclusion and exclusion and maybe it
may goes as follows:
(2.1) There's only one sol. for $x_1=n$
(2.2) For $x_1+x_2=n$ with $0\leq x_i \leq 6$.
There are $\binom{2+n-1}{n}=\binom{1+n}{n}$ solutions with $x_i\leq 0$ Let
say that $x_1,x_2$ is a solution that sastisfies the condition $c_i$ if
$x_i>6$. The answer should be $N(\bar{c_1},\bar{c_2}).$ By symmetry
$N(c_1)=N(c_2)$. Now i'm looking the integer solutions for $x_1+x_2=n-7$
then $N(c_i)=\binom{2+(n-7)+1}{n-7}=\binom{n-4}{n-7}$, also $N(c_ic_j) =
\binom{2+(n-14)-1}{n-14}=\binom{n-11}{n-14}$.
Then $N(\bar{c_1},\bar{c_2})=
\binom{n+1}{n}-\binom{2}{1}\binom{n-4}{n-7}+\binom{2}{2}\binom{n-11}{n-14}$
gives the numer of solutions which satisfies $x_i\leq 6$?.
But how can i get rid of the solutions that involve $x_i = 0$?
Would be a good idea keep trying with this or there is an easier way?. I
thought that if i get the number of solutions for $x_1+\dots+x_n=n$ with
the restriction given i could find the generating function, but looking at
the $f(x)$ given i'm not sure if what i did may help somehow.
Any hints?.
I thought this exercise would be fairly easy, but it seems i can't find a
proper approach to it.
I have to prove that $f(x) = (1-x-x^2-x^3-x^4-x^5-x^6)^{-1}$ is the
function that generates the number of forms we can get a number $n$ as the
sum of the values given rolling a dice -as many times as is needed-.
My first excerpt is to note that $f(x) =
\displaystyle\frac{1}{1-(\sum_{i=1}^6x^i)}=\displaystyle\sum_{k=0}^{\infty}(x+\dots+x^6)^k$.
Now i would like to work from 'the other side' and see how many forms are
to write a number $n$ as the sum of numbers from 1 to 6. I have in mind
two steps:
(1) If i need to find the number of solution -without the restriction from
1 to 6- i'd have to find how many solutions are for each of the following
equations $x_1=n$; $x_1+x_2=n$, $\dots$; $x_1+\dots+x_n=n$. Then i found
out that for each $m$ there are $\sum_{k=0}^{m-1}\binom{m-1}{k}=2^{m-1}$.
(2) Now i woud like to know how many solutions are if i consider the
restriction $1\leq x_i \leq 6$. I'm not sure how to go from here, but i've
been thinking about the principle of inclusion and exclusion and maybe it
may goes as follows:
(2.1) There's only one sol. for $x_1=n$
(2.2) For $x_1+x_2=n$ with $0\leq x_i \leq 6$.
There are $\binom{2+n-1}{n}=\binom{1+n}{n}$ solutions with $x_i\leq 0$ Let
say that $x_1,x_2$ is a solution that sastisfies the condition $c_i$ if
$x_i>6$. The answer should be $N(\bar{c_1},\bar{c_2}).$ By symmetry
$N(c_1)=N(c_2)$. Now i'm looking the integer solutions for $x_1+x_2=n-7$
then $N(c_i)=\binom{2+(n-7)+1}{n-7}=\binom{n-4}{n-7}$, also $N(c_ic_j) =
\binom{2+(n-14)-1}{n-14}=\binom{n-11}{n-14}$.
Then $N(\bar{c_1},\bar{c_2})=
\binom{n+1}{n}-\binom{2}{1}\binom{n-4}{n-7}+\binom{2}{2}\binom{n-11}{n-14}$
gives the numer of solutions which satisfies $x_i\leq 6$?.
But how can i get rid of the solutions that involve $x_i = 0$?
Would be a good idea keep trying with this or there is an easier way?. I
thought that if i get the number of solutions for $x_1+\dots+x_n=n$ with
the restriction given i could find the generating function, but looking at
the $f(x)$ given i'm not sure if what i did may help somehow.
Any hints?.
Prove modular inequalities $ab + ac\le a(b+ac)$ and $(a+b)(a+c)\ge a+b(a+c)$
Prove modular inequalities $ab + ac\le a(b+ac)$ and $(a+b)(a+c)\ge a+b(a+c)$
How to prove
$$(a\cdot b)+(a\cdot c)\le a\cdot\big(b+(a\cdot c)\big)$$
and
$$(a+b)\cdot(a+c)\ge a+\big(b\cdot(a+c)\big)\;?$$
I have tried this. Using distributive property, I think we can get
$$a+(b\cdot c) \le (a+b)\cdot(a+c)$$
and
$$a\cdot(b+c) \ge (a\cdot b) + (a\cdot c)\;.$$
Now what should I do?
How to prove
$$(a\cdot b)+(a\cdot c)\le a\cdot\big(b+(a\cdot c)\big)$$
and
$$(a+b)\cdot(a+c)\ge a+\big(b\cdot(a+c)\big)\;?$$
I have tried this. Using distributive property, I think we can get
$$a+(b\cdot c) \le (a+b)\cdot(a+c)$$
and
$$a\cdot(b+c) \ge (a\cdot b) + (a\cdot c)\;.$$
Now what should I do?
Monday, September 30, 2013
Configuring Dialout with the Cisco 2500 router
Configuring Dialout with the Cisco 2500 router
I'm working on configuring dialout with a Cisco 2511 router and external
modems. The end point is a dial-in server, which will create a ppp
connection. I use this guide as a reference but it only work with async1
port, when I switch to async2 and ping the server, the router doesn't dial
the server.
Config: client computer==(ethernet)router==(async
port)modems----pstn----modem==dial-in server(s)
Can someone help me out of this? A detail answer or document will help me
much since I'm new with this things.
Update: the result of sho run
!
version 11.2
no service password-encryption
no service udp-small-servers
no service tcp-small-servers
!
hostname Cisco
!
!
chat-script dialnum ABORT ERROR ABORT BUSY "" "ATD\T" TIMEOUT 180 CONNECT
chat-script DialOut ABORT ERROR ABORT BUSY "" "ATD\T" TIMEOUT 120 CONNECT
modemcap entry Zyxelsetup:MSC=&FS0=1&K4&N70
modemcap entry hayes:MSC=&FS0=1&K4&N70
modemcap entry Mosetup MSC=&FS0=1+MS=11,1,19200,19200
!
interface Ethernet0
description !!----- LAN interface -----!!
ip address 192.185.10.254 255.255.255.0
ip access-group 100 in
ip access-group 100 out
no ip mroute-cache
!
interface Serial0
no ip address
shutdown
no fair-queue
!
interface Serial1
no ip address
shutdown
!
interface Async1
no ip address
encapsulation ppp
async mode dedicated
dialer in-band
dialer rotary-group 0
!
interface Async2
no ip address
encapsulation ppp
async mode dedicated
dialer in-band
dialer rotary-group 1
!
interface Dialer0
ip address 192.184.10.254 255.255.255.0
encapsulation ppp
dialer in-band
dialer idle-timeout 180
dialer string xxxxxxx
dialer-group 1
ppp chap hostname CISCO1
ppp chap password 7 0010161510
!
interface Dialer1
ip address 192.184.9.254 255.255.255.0
encapsulation ppp
dialer in-band
dialer idle-timeout 60
dialer string xxxxxxxx
dialer-group 1
ppp chap hostname CISCO2
ppp chap password 7 110A11001419
!
ip classless
ip route 192.184.9.0 255.255.255.0 Dialer1
ip route 192.184.10.0 255.255.255.255 Dialer0
access-list 100 permit tcp any any
access-list 100 permit icmp any any
access-list 100 permit ip any any
!
dialer-list 1 protocol ip list 100
!
line con 0
line 1 16
script dialer DialOut
modem InOut
modem autoconfigure discovery
speed 115200
flowcontrol hardware
line aux 0
line vty 0 4
login
!
end
Thank you!
I'm working on configuring dialout with a Cisco 2511 router and external
modems. The end point is a dial-in server, which will create a ppp
connection. I use this guide as a reference but it only work with async1
port, when I switch to async2 and ping the server, the router doesn't dial
the server.
Config: client computer==(ethernet)router==(async
port)modems----pstn----modem==dial-in server(s)
Can someone help me out of this? A detail answer or document will help me
much since I'm new with this things.
Update: the result of sho run
!
version 11.2
no service password-encryption
no service udp-small-servers
no service tcp-small-servers
!
hostname Cisco
!
!
chat-script dialnum ABORT ERROR ABORT BUSY "" "ATD\T" TIMEOUT 180 CONNECT
chat-script DialOut ABORT ERROR ABORT BUSY "" "ATD\T" TIMEOUT 120 CONNECT
modemcap entry Zyxelsetup:MSC=&FS0=1&K4&N70
modemcap entry hayes:MSC=&FS0=1&K4&N70
modemcap entry Mosetup MSC=&FS0=1+MS=11,1,19200,19200
!
interface Ethernet0
description !!----- LAN interface -----!!
ip address 192.185.10.254 255.255.255.0
ip access-group 100 in
ip access-group 100 out
no ip mroute-cache
!
interface Serial0
no ip address
shutdown
no fair-queue
!
interface Serial1
no ip address
shutdown
!
interface Async1
no ip address
encapsulation ppp
async mode dedicated
dialer in-band
dialer rotary-group 0
!
interface Async2
no ip address
encapsulation ppp
async mode dedicated
dialer in-band
dialer rotary-group 1
!
interface Dialer0
ip address 192.184.10.254 255.255.255.0
encapsulation ppp
dialer in-band
dialer idle-timeout 180
dialer string xxxxxxx
dialer-group 1
ppp chap hostname CISCO1
ppp chap password 7 0010161510
!
interface Dialer1
ip address 192.184.9.254 255.255.255.0
encapsulation ppp
dialer in-band
dialer idle-timeout 60
dialer string xxxxxxxx
dialer-group 1
ppp chap hostname CISCO2
ppp chap password 7 110A11001419
!
ip classless
ip route 192.184.9.0 255.255.255.0 Dialer1
ip route 192.184.10.0 255.255.255.255 Dialer0
access-list 100 permit tcp any any
access-list 100 permit icmp any any
access-list 100 permit ip any any
!
dialer-list 1 protocol ip list 100
!
line con 0
line 1 16
script dialer DialOut
modem InOut
modem autoconfigure discovery
speed 115200
flowcontrol hardware
line aux 0
line vty 0 4
login
!
end
Thank you!
Derivative of a parametric function [on hold]
Derivative of a parametric function [on hold]
pI have the following parametric function: \begin{align} x amp;= A_1
\sin(deg(t) F_1 + P_1) \exp(-D_1 t) + A_2 \sin(deg(t) F_2 + P_2) \exp(-D_2
t)\\ y amp;= A_3 \sin(deg(t) F_3 + P_3) \exp(-D_3 t) + A_4 \sin(deg(t) F_4
+ P_4) \exp(-D_4 t)\\ z amp;= A_1 \sin(deg(t) F_5 + P_5) \exp(-D_5 t) +
A_6 \sin(deg(t) F_6 + P_6) \exp(-D_6 t) \end{align}/p pWhat is the
derivative? Thanks!/p pI'm trying to plot something called a Harmonograph,
and would like to enclose the curve within a tube. For that I need the
derivative and tangents./p pI tried using the a
href=http://www.derivative-calculator.net/ rel=nofollowOnline Derivative
Calculator/a but became confused./p pThanks!/p
pI have the following parametric function: \begin{align} x amp;= A_1
\sin(deg(t) F_1 + P_1) \exp(-D_1 t) + A_2 \sin(deg(t) F_2 + P_2) \exp(-D_2
t)\\ y amp;= A_3 \sin(deg(t) F_3 + P_3) \exp(-D_3 t) + A_4 \sin(deg(t) F_4
+ P_4) \exp(-D_4 t)\\ z amp;= A_1 \sin(deg(t) F_5 + P_5) \exp(-D_5 t) +
A_6 \sin(deg(t) F_6 + P_6) \exp(-D_6 t) \end{align}/p pWhat is the
derivative? Thanks!/p pI'm trying to plot something called a Harmonograph,
and would like to enclose the curve within a tube. For that I need the
derivative and tangents./p pI tried using the a
href=http://www.derivative-calculator.net/ rel=nofollowOnline Derivative
Calculator/a but became confused./p pThanks!/p
What does "L", "[" and ";" mean in smali code?
What does "L", "[" and ";" mean in smali code?
I'm trying to get a deep understanding of smali language. I found a page
talking about opcodes online, but it never talks about these special
symbols, which is L, ; and [, e.g
invoke-static {v2, v3},
Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
So, what does these symbols mean here? e.g [Ljava/lang/Object; and
Ljava/lang/String;
I'm trying to get a deep understanding of smali language. I found a page
talking about opcodes online, but it never talks about these special
symbols, which is L, ; and [, e.g
invoke-static {v2, v3},
Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
So, what does these symbols mean here? e.g [Ljava/lang/Object; and
Ljava/lang/String;
Creating a dynamic text field that changes content depending on select list choice?
Creating a dynamic text field that changes content depending on select
list choice?
Me and my colleague are in the process of starting up our own company that
handles exam results and school data. I am currently in the process of
setting up the webpage (I am completely new with PHP and Dreamweaver CC)
where the end-user can access and edit the database in the extent that
they need to.
But I shall get to the point of my problem. At the moment I am trying to
build a data edit page where all relevant data is shown once the user has
logged in (In this case it's an admin-kind of person, so he/she needs to
see which teacher teaches which classes). On this page I want to build a
drop-down list of all the possible Classes (done this with the recordset,
sorted alphabetically and working) and linking to that, a dynamic text
field that changes value depending on the option picked in the select
list.
Example:
There are four classes, and four corresponding teachers as followed:
Class - Teacher
English - Bob
Spanish - Juan
Math - Jenny
Geography - William
What I'm basically after is that if you choose the Class 'English' in the
drop-down select list, the text field should display 'Bob' (and similarly
for all the other classes). So far I've not managed to work out how to do
that in Dreamweaver CC.
Help is much appreciated!
list choice?
Me and my colleague are in the process of starting up our own company that
handles exam results and school data. I am currently in the process of
setting up the webpage (I am completely new with PHP and Dreamweaver CC)
where the end-user can access and edit the database in the extent that
they need to.
But I shall get to the point of my problem. At the moment I am trying to
build a data edit page where all relevant data is shown once the user has
logged in (In this case it's an admin-kind of person, so he/she needs to
see which teacher teaches which classes). On this page I want to build a
drop-down list of all the possible Classes (done this with the recordset,
sorted alphabetically and working) and linking to that, a dynamic text
field that changes value depending on the option picked in the select
list.
Example:
There are four classes, and four corresponding teachers as followed:
Class - Teacher
English - Bob
Spanish - Juan
Math - Jenny
Geography - William
What I'm basically after is that if you choose the Class 'English' in the
drop-down select list, the text field should display 'Bob' (and similarly
for all the other classes). So far I've not managed to work out how to do
that in Dreamweaver CC.
Help is much appreciated!
Sunday, September 29, 2013
Display jQuery Datepicker calculated date elsewhere on page
Display jQuery Datepicker calculated date elsewhere on page
Currently I'm using jQuery ui Datepicker. I'm using the calendar to allow
customers to choose delivery dates in one area of the page and it's set up
with a minDate of 4 days, excluding weekends and holidays. I wondered if
it's possible to display the final calculated minDate elsewhere on my
page? I want to display the "Earliest possible Delivery Date" in the
product description. Very, very new at jQuery and javascript.
Thanks in advance for your answers!
Currently I'm using jQuery ui Datepicker. I'm using the calendar to allow
customers to choose delivery dates in one area of the page and it's set up
with a minDate of 4 days, excluding weekends and holidays. I wondered if
it's possible to display the final calculated minDate elsewhere on my
page? I want to display the "Earliest possible Delivery Date" in the
product description. Very, very new at jQuery and javascript.
Thanks in advance for your answers!
Connect to database from another file class
Connect to database from another file class
I am trying to connect to a database PDO, but am having problems doing so.
I have tried to putt the connection inside the class.acl.php
The error is Fatal error: Call to a member function prepare() on a
non-object in.... class.acl.php
Connect.php:
$config = array(
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'lar'
);
$db = new PDO('mysql:host=' . $config['host'] . ';dbname=' .
$config['dbname'], $config['username'], $config['password']);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
class.acl.php:
class ACL{
private $db;
function __constructor($userID=''){
if ($userID != ''){
$this->userID = floatval($userID);
}else{
$this->userID = floatval($_SESSION['userID']);
}
$this->userRoles = $this->getUserRoles('ids');
$this->buildACL();
}
function ACL($userID=''){
$this->__constructor($userID);
}
function database($database){
$this->db = $database;
}
function getPermKeyFromID($permID){
Code....
return $permID
}
}
index.php:
require 'class.acl.php';
$userID=$_SESSION['ID'];
$ACL = new ACL($userID);
$ACL->database($db);
echo $ACL->getPermKeyFromID('1');
I am trying to connect to a database PDO, but am having problems doing so.
I have tried to putt the connection inside the class.acl.php
The error is Fatal error: Call to a member function prepare() on a
non-object in.... class.acl.php
Connect.php:
$config = array(
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'lar'
);
$db = new PDO('mysql:host=' . $config['host'] . ';dbname=' .
$config['dbname'], $config['username'], $config['password']);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
class.acl.php:
class ACL{
private $db;
function __constructor($userID=''){
if ($userID != ''){
$this->userID = floatval($userID);
}else{
$this->userID = floatval($_SESSION['userID']);
}
$this->userRoles = $this->getUserRoles('ids');
$this->buildACL();
}
function ACL($userID=''){
$this->__constructor($userID);
}
function database($database){
$this->db = $database;
}
function getPermKeyFromID($permID){
Code....
return $permID
}
}
index.php:
require 'class.acl.php';
$userID=$_SESSION['ID'];
$ACL = new ACL($userID);
$ACL->database($db);
echo $ACL->getPermKeyFromID('1');
Andengine: Version not supported by gl2
Andengine: Version not supported by gl2
I am new to gaming and when I tried to use Andengine GL ES 2.0 on the
emulator or bluestacks it errors out, saying that version not supported on
the gl2.
I'm using API Level 15, and the latest revision of the SDK (18), on
Windows XP professional, 32 bit I have GPU Emulation set to "yes".
My CPU is: Intel Core TM2 Duo Processor T7300, and I have a Intel 965/963
Graphics Media Accelerator
Also i have updated by OpenGl verion to 2.0 in my system
Any ideas? Should it be working? If so, how do I make it work?
Pls help me regarding this issue
I am new to gaming and when I tried to use Andengine GL ES 2.0 on the
emulator or bluestacks it errors out, saying that version not supported on
the gl2.
I'm using API Level 15, and the latest revision of the SDK (18), on
Windows XP professional, 32 bit I have GPU Emulation set to "yes".
My CPU is: Intel Core TM2 Duo Processor T7300, and I have a Intel 965/963
Graphics Media Accelerator
Also i have updated by OpenGl verion to 2.0 in my system
Any ideas? Should it be working? If so, how do I make it work?
Pls help me regarding this issue
Preventing Sql Injection in php (codeigniter)
Preventing Sql Injection in php (codeigniter)
How do I prevent sql injection in codeigniter for additional security?
Does Codeigniter do that itself or do I have to make my own? I want my
pages to be heavily secure.
How do I prevent sql injection in codeigniter for additional security?
Does Codeigniter do that itself or do I have to make my own? I want my
pages to be heavily secure.
Saturday, September 28, 2013
Canvas toDataURL() giving blank image
Canvas toDataURL() giving blank image
I'm a complete beginner to JS and I'm just playing around with HTML5.
While experimenting, I came across this issue. I have something like this:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
function graph() {
// ...stuff that draws to canvas, verified "working"...
var downloadLink =
document.getElementById("myCanvas").toDataURL();
$("#dlLink").attr("href", downloadLink);
}
$(window).load(function() {
graph();
});
</script>
</head>
<body>
<div class="container">
<h1 style = ";padding-bottom:30px;"><a href="#">Tool</a></h1>
<canvas id="myCanvas" width="400" height="400"></canvas>
<a href="#" id="dlLink">Download</a>
</div>
</body>
</html>
When I click the download link with the base64 encoding, I get a blank
image. Can anyone bring to light why this is happening? It seems like the
link is generated before the canvas has anything on it, but I can't be
sure.
I'm a complete beginner to JS and I'm just playing around with HTML5.
While experimenting, I came across this issue. I have something like this:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
function graph() {
// ...stuff that draws to canvas, verified "working"...
var downloadLink =
document.getElementById("myCanvas").toDataURL();
$("#dlLink").attr("href", downloadLink);
}
$(window).load(function() {
graph();
});
</script>
</head>
<body>
<div class="container">
<h1 style = ";padding-bottom:30px;"><a href="#">Tool</a></h1>
<canvas id="myCanvas" width="400" height="400"></canvas>
<a href="#" id="dlLink">Download</a>
</div>
</body>
</html>
When I click the download link with the base64 encoding, I get a blank
image. Can anyone bring to light why this is happening? It seems like the
link is generated before the canvas has anything on it, but I can't be
sure.
Why do I keep getting NoSuchMethodError on LocationAwareLogger?
Why do I keep getting NoSuchMethodError on LocationAwareLogger?
I'm trying to embed Jetty server into my automated tests so I've added the
following dependency in my project:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>7.6.13.v20130916</version>
<scope>test</scope>
</dependency>
I'm using Jetty 7 because the Web app uses Java 6, Servlet 2.5.
However when I try to start embedded Jetty server, I get:
java.lang.NoSuchMethodError:
org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
at
org.eclipse.jetty.util.log.JettyAwareLogger.log(JettyAwareLogger.java:607)
at
org.eclipse.jetty.util.log.JettyAwareLogger.warn(JettyAwareLogger.java:431)
at org.eclipse.jetty.util.log.Slf4jLog.warn(Slf4jLog.java:69)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.setFailed(AbstractLifeCycle.java:204)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:74)
I've been trying to figure out what's wrong but none of the steps I've
taken so far addresses the issue. Here's a list of what I've done so far:
Trace transitive dependencies to search for incompatible versions of
slf4j-api
Try out different versions of slf4j-api (1.5.11, 1.6.1, 1.6.4, 1.7.5)
Looked into the some sources of Jetty 7 particularly the pom.xml and found
that there's a dependency to slf4j 1.6.1
Looked into this similar question and got null when trying to print
org.slf4j.spi.LocationAwareLogger, and org.slf4j.Marker
I hope someone can offer a fresh insight into this issue. Thanks.
I'm trying to embed Jetty server into my automated tests so I've added the
following dependency in my project:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>7.6.13.v20130916</version>
<scope>test</scope>
</dependency>
I'm using Jetty 7 because the Web app uses Java 6, Servlet 2.5.
However when I try to start embedded Jetty server, I get:
java.lang.NoSuchMethodError:
org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
at
org.eclipse.jetty.util.log.JettyAwareLogger.log(JettyAwareLogger.java:607)
at
org.eclipse.jetty.util.log.JettyAwareLogger.warn(JettyAwareLogger.java:431)
at org.eclipse.jetty.util.log.Slf4jLog.warn(Slf4jLog.java:69)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.setFailed(AbstractLifeCycle.java:204)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:74)
I've been trying to figure out what's wrong but none of the steps I've
taken so far addresses the issue. Here's a list of what I've done so far:
Trace transitive dependencies to search for incompatible versions of
slf4j-api
Try out different versions of slf4j-api (1.5.11, 1.6.1, 1.6.4, 1.7.5)
Looked into the some sources of Jetty 7 particularly the pom.xml and found
that there's a dependency to slf4j 1.6.1
Looked into this similar question and got null when trying to print
org.slf4j.spi.LocationAwareLogger, and org.slf4j.Marker
I hope someone can offer a fresh insight into this issue. Thanks.
Alert hello world not working
Alert hello world not working
I have created a webservice to alert hello world using javacript. But no
results come. Even no error. I couldnot figure out where I do the mistake.
I just host the wsdl in locally. What have I missed?
Here is my code
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="Site.master.cs" Inherits="SiteMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<title></title>
<link href="~/css/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/NetWebsite/js/jquery-1.10.2.js"
></script>
<script type="text/javascript" src="/NetWebsite/js/script.js" ></script>
<script language="JavaScript">
var iCallID;
function InitializeService(){
service.useService(http://localhost:5431/WebSite1/WebService.asmx?WSDL,"HelloWorldService");
service.HelloWorldService.callService("HellowWorld");
}
function ShowResult(){
alert(event.result.value);
}
</script>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>
<body onload="InitializeService()" id="service"
style="behavior:url(webservice.htc)" onresult="ShowResult()">
<form runat="server">
<div class="page">
<div class="main">
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
</div>
<div class="clear">
</div>
</div>
<div class="footer">
</div>
</form>
</body>
</html>
I have created a webservice to alert hello world using javacript. But no
results come. Even no error. I couldnot figure out where I do the mistake.
I just host the wsdl in locally. What have I missed?
Here is my code
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="Site.master.cs" Inherits="SiteMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<title></title>
<link href="~/css/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/NetWebsite/js/jquery-1.10.2.js"
></script>
<script type="text/javascript" src="/NetWebsite/js/script.js" ></script>
<script language="JavaScript">
var iCallID;
function InitializeService(){
service.useService(http://localhost:5431/WebSite1/WebService.asmx?WSDL,"HelloWorldService");
service.HelloWorldService.callService("HellowWorld");
}
function ShowResult(){
alert(event.result.value);
}
</script>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>
<body onload="InitializeService()" id="service"
style="behavior:url(webservice.htc)" onresult="ShowResult()">
<form runat="server">
<div class="page">
<div class="main">
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
</div>
<div class="clear">
</div>
</div>
<div class="footer">
</div>
</form>
</body>
</html>
Bash doesn't quit on syntax error
Bash doesn't quit on syntax error
I have a bash code in which I have made a function which is called in the
program. I forgot to put a quotation mark in one of the statement because
of which the script threw a syntax error.Following is the code :
#function
write_errors()
{
#writes RIGHT TRUNCATION errors in bcp import
temp_file=$1
error_file=$2
stepName=$3
error_count=`fgrep -c "right truncation" ${error_file} "` #here is the
extra quotation mark
...
}
#start of script
date
...
write_errors #syntax error happens here
...
date #these lines are executed
rm -f ${temp}
rm -f ${error_file}
...
I have a bash code in which I have made a function which is called in the
program. I forgot to put a quotation mark in one of the statement because
of which the script threw a syntax error.Following is the code :
#function
write_errors()
{
#writes RIGHT TRUNCATION errors in bcp import
temp_file=$1
error_file=$2
stepName=$3
error_count=`fgrep -c "right truncation" ${error_file} "` #here is the
extra quotation mark
...
}
#start of script
date
...
write_errors #syntax error happens here
...
date #these lines are executed
rm -f ${temp}
rm -f ${error_file}
...
Subscribe to:
Posts (Atom)