Main Domain is SSL and need to add multiple non-SSL domains to subfolders,
.htaccess help needed
My main domain is red dot com it comes up with ssl as https www dot red
dot com I need to add multiple domains to the subfolders. For instance red
dot co dot uk would point to folder /var/www/html/uk or red dot tv would
point to folder /var/www/html/tv and so on.
My dns servers are pointing right, and I added virtual servers for each
domain but nothing worked so far because the .htaccess is not configured
properly, can someone give me an idea how to configure the virtual server
and .htaccess?
I also wanted to mention that I have 2 seperate ip addresses both pointing
to main domain
my existing .htaccess file looks like this
# BEGIN WordPress
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.red.com/$1 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
This is my config file http://pastebin.com/QWF5a4r7
and this is ssl config file http://pastebin.com/bZpP153d
Monday, 30 September 2013
Squid url_rewrite_program is not working
Squid url_rewrite_program is not working
I'm writing a url_rewrite module for squid in python (OS: Ubuntu 13). For
now the code is just a test which should print the received stdin to a
file:
#!/usr/bin/python
import sys,os
url = sys.stdin.read()
os.system('echo "%s" >> log.txt' % url)
sys.stdout.write(url)
sys.stdout.flush()
When I start squid and launch a request from my browser connected to the
proxy it doesn't work and checking the logs I can see some related errors:
syslog:
squid3: The redirector helpers are crashing too rapidly, need help!
cache.log
2013/09/30 14:51:44| WARNING: redirector #1 (FD 7) exited
2013/09/30 14:51:44| WARNING: redirector #2 (FD 9) exited
2013/09/30 14:51:44| WARNING: redirector #3 (FD 11) exited
2013/09/30 14:51:44| WARNING: redirector #4 (FD 13) exited
2013/09/30 14:51:44| Too few redirector processes are running
2013/09/30 14:51:44| storeDirWriteCleanLogs: Starting...
2013/09/30 14:51:44| Finished. Wrote 0 entries.
2013/09/30 14:51:44| Took 0.00 seconds ( 0.00 entries/sec).
FATAL: The redirector helpers are crashing too rapidly, need help!
Did anyone faced this issue and can figure out how to solve it? Regards.
I'm writing a url_rewrite module for squid in python (OS: Ubuntu 13). For
now the code is just a test which should print the received stdin to a
file:
#!/usr/bin/python
import sys,os
url = sys.stdin.read()
os.system('echo "%s" >> log.txt' % url)
sys.stdout.write(url)
sys.stdout.flush()
When I start squid and launch a request from my browser connected to the
proxy it doesn't work and checking the logs I can see some related errors:
syslog:
squid3: The redirector helpers are crashing too rapidly, need help!
cache.log
2013/09/30 14:51:44| WARNING: redirector #1 (FD 7) exited
2013/09/30 14:51:44| WARNING: redirector #2 (FD 9) exited
2013/09/30 14:51:44| WARNING: redirector #3 (FD 11) exited
2013/09/30 14:51:44| WARNING: redirector #4 (FD 13) exited
2013/09/30 14:51:44| Too few redirector processes are running
2013/09/30 14:51:44| storeDirWriteCleanLogs: Starting...
2013/09/30 14:51:44| Finished. Wrote 0 entries.
2013/09/30 14:51:44| Took 0.00 seconds ( 0.00 entries/sec).
FATAL: The redirector helpers are crashing too rapidly, need help!
Did anyone faced this issue and can figure out how to solve it? Regards.
PHP string comparasion
PHP string comparasion
I have a variable and its type is string. var_dump() shows:
var_dump() output is below:
string(14)
//this is my code..
$game_cat = "Some text"; // some text mean actually it is one of below
Category 1,2,3,4 ...
if ( $game_cat === "Category 1" ) {
$cid = 1;
}
if ( $game_cat === "Category 2" ) {
$cid = 2;
}
if ( $game_cat === "Category 3" ) {
$cid = 0;
}
else{
$cid = 999999;
}
For example when I change $game_cat to Category 1 like $game_cat =
"Category 1"; $cid must 1 but output is 999999.
Why?
I have a variable and its type is string. var_dump() shows:
var_dump() output is below:
string(14)
//this is my code..
$game_cat = "Some text"; // some text mean actually it is one of below
Category 1,2,3,4 ...
if ( $game_cat === "Category 1" ) {
$cid = 1;
}
if ( $game_cat === "Category 2" ) {
$cid = 2;
}
if ( $game_cat === "Category 3" ) {
$cid = 0;
}
else{
$cid = 999999;
}
For example when I change $game_cat to Category 1 like $game_cat =
"Category 1"; $cid must 1 but output is 999999.
Why?
GIT: should force ever be used?
GIT: should force ever be used?
Git has --force flag in a lot of operations but when I use them I feel a
bit strange. Like ignoring warning messages in my code.
For example I just wanted to unstage a file and did this:
git rm --cached myfile.ext
git complained error:
the following file has staged content different from both the file and the
HEAD
I really don't care about this error and it seems not to be an issue - I
just want to leave my code as it is, but unstage the file. --force flag
simply solved this issue.
My question is about best practices as I was unable to find any
information about this issue - should one use force flags in git commands
or is it a bad practice?
Git has --force flag in a lot of operations but when I use them I feel a
bit strange. Like ignoring warning messages in my code.
For example I just wanted to unstage a file and did this:
git rm --cached myfile.ext
git complained error:
the following file has staged content different from both the file and the
HEAD
I really don't care about this error and it seems not to be an issue - I
just want to leave my code as it is, but unstage the file. --force flag
simply solved this issue.
My question is about best practices as I was unable to find any
information about this issue - should one use force flags in git commands
or is it a bad practice?
Sunday, 29 September 2013
double border around a container
double border around a container
I wanted to create an effect like this around my border, basically a
double sided border. Currently I am using an image as a background-image,
but the issue comes when I want to make the site responsive. So I want to
re-create this using CSS. Is this even possible?
I wanted to create an effect like this around my border, basically a
double sided border. Currently I am using an image as a background-image,
but the issue comes when I want to make the site responsive. So I want to
re-create this using CSS. Is this even possible?
fade a page in with jquery after a button is clicked
fade a page in with jquery after a button is clicked
with this jquery i can fade the page in after it loads:
<script type="text/javascript">
$(function() {
$('body').hide().fadeIn(1000);
});
</script>
now what i want to do is have it that function happen after a button is
clicked. for example, when the user goes to the page, there would be a
window with a clickable button. after the button was clicked then it would
do that fade in jquery loading the page with a fade in. i was thinking
that it would be some kind of form, but the problem is it needs to hide
the body when the page is loaded, and then fade in to the body after the
button is clicked.
with this jquery i can fade the page in after it loads:
<script type="text/javascript">
$(function() {
$('body').hide().fadeIn(1000);
});
</script>
now what i want to do is have it that function happen after a button is
clicked. for example, when the user goes to the page, there would be a
window with a clickable button. after the button was clicked then it would
do that fade in jquery loading the page with a fade in. i was thinking
that it would be some kind of form, but the problem is it needs to hide
the body when the page is loaded, and then fade in to the body after the
button is clicked.
Can std::async call std::function objects?
Can std::async call std::function objects?
Is it possible to call function objects created with std::bind using
std::async. The following code fails to compile:
#include <iostream>
#include <future>
#include <functional>
using namespace std;
class Adder {
public:
int add(int x, int y) {
return x + y;
}
};
int main(int argc, const char * argv[])
{
Adder a;
function<int(int, int)> sumFunc = bind(&Adder::add, &a, 1, 2);
auto future = async(launch::async, sumFunc); // ERROR HERE
cout << future.get();
return 0;
}
The error is:
No matching function for call to 'async': Candidate template ignored:
substitution failure [with Fp = std::_1::function &, Args = <>]: no type
named 'type' in 'std::_1::__invoke_of, >
Is it just not possible to use async with std::function objects or am I
doing something wrong?
(This is being compiled using Xcode 5 with the Apple LLVM 5.0 compiler)
Is it possible to call function objects created with std::bind using
std::async. The following code fails to compile:
#include <iostream>
#include <future>
#include <functional>
using namespace std;
class Adder {
public:
int add(int x, int y) {
return x + y;
}
};
int main(int argc, const char * argv[])
{
Adder a;
function<int(int, int)> sumFunc = bind(&Adder::add, &a, 1, 2);
auto future = async(launch::async, sumFunc); // ERROR HERE
cout << future.get();
return 0;
}
The error is:
No matching function for call to 'async': Candidate template ignored:
substitution failure [with Fp = std::_1::function &, Args = <>]: no type
named 'type' in 'std::_1::__invoke_of, >
Is it just not possible to use async with std::function objects or am I
doing something wrong?
(This is being compiled using Xcode 5 with the Apple LLVM 5.0 compiler)
Prevent website from resizing
Prevent website from resizing
On the website I'm currently fixing there are two divs displayed Inline.
On resizing the browser window, the div on the right automatically aligns
to fit under the first div instead of staying inline. My question is on
how to prevent this resize and to keep it standard on all screen sizes.
To display this issue, I've attached two screenshots.
Another issue: The screen is vertically scrollable which should not be the
case as the height of html, body or any of the div are not more than 100%
My CSS for the two main divs is as follows:
#menu{
position:absolute;
width:15%;
height:600px;
float:left;
margin-top: 10px;
margin-left: 40px;
}
#content{
position: absolute;
height:600px;
width:73%;
float:left;
margin-top: 10px;
margin-left: 290px;
}
The CSS for the inner 4 divs are as follows
.gallery-image-rest{
background: url('../images/thumbs/rest.jpg');
position: relative;
height:600px;
width:24%;
float: left;
margin-left: 15px;
/*display: inline-block;*/
text-align: center;
}
.gallery-image-replenish{
background: url('../images/thumbs/Replenish.jpg');
position: relative;
height:600px;
width:24%;
float: left;
margin-left:3px;
/*display: inline-block;*/
text-align: center;
}
.gallery-image-rejuvenate{
background: url('../images/thumbs/Rejuvenate.jpg');
position: relative;
height:600px;
width:24%;
float: left;
margin-left:3px;
/*display: inline-block;*/
text-align: center;
}
.gallery-image-reunite{
background: url('../images/thumbs/reunite.jpg');
position: relative;
height:600px;
width:24%;
float:left;
margin-left:3px;
/*display: inline-block;*/
text-align: center;
}
The code has a lot of redundancies but that is second priority as the
client needs the display to be correct before anything else.
Thanks guys.
On the website I'm currently fixing there are two divs displayed Inline.
On resizing the browser window, the div on the right automatically aligns
to fit under the first div instead of staying inline. My question is on
how to prevent this resize and to keep it standard on all screen sizes.
To display this issue, I've attached two screenshots.
Another issue: The screen is vertically scrollable which should not be the
case as the height of html, body or any of the div are not more than 100%
My CSS for the two main divs is as follows:
#menu{
position:absolute;
width:15%;
height:600px;
float:left;
margin-top: 10px;
margin-left: 40px;
}
#content{
position: absolute;
height:600px;
width:73%;
float:left;
margin-top: 10px;
margin-left: 290px;
}
The CSS for the inner 4 divs are as follows
.gallery-image-rest{
background: url('../images/thumbs/rest.jpg');
position: relative;
height:600px;
width:24%;
float: left;
margin-left: 15px;
/*display: inline-block;*/
text-align: center;
}
.gallery-image-replenish{
background: url('../images/thumbs/Replenish.jpg');
position: relative;
height:600px;
width:24%;
float: left;
margin-left:3px;
/*display: inline-block;*/
text-align: center;
}
.gallery-image-rejuvenate{
background: url('../images/thumbs/Rejuvenate.jpg');
position: relative;
height:600px;
width:24%;
float: left;
margin-left:3px;
/*display: inline-block;*/
text-align: center;
}
.gallery-image-reunite{
background: url('../images/thumbs/reunite.jpg');
position: relative;
height:600px;
width:24%;
float:left;
margin-left:3px;
/*display: inline-block;*/
text-align: center;
}
The code has a lot of redundancies but that is second priority as the
client needs the display to be correct before anything else.
Thanks guys.
Saturday, 28 September 2013
Cookie Setting Issue when logging into gmail with http post in android
Cookie Setting Issue when logging into gmail with http post in android
I'm trying to implement the following code. It works as a java code but I
get the following message when I implement it in an android application.
I'm new to this field, so I don't know where exactly I'm going wrong.
Please suggest
http://www.mkyong.com/java/how-to-automate-login-a-website-java-example/
I'm trying to implement the following code. It works as a java code but I
get the following message when I implement it in an android application.
I'm new to this field, so I don't know where exactly I'm going wrong.
Please suggest
http://www.mkyong.com/java/how-to-automate-login-a-website-java-example/
Why isn't the onDraw() method of my custom view being called when the size of the view is set larger than the screen (it is inside a scroll...
Why isn't the onDraw() method of my custom view being called when the size
of the view is set larger than the screen (it is inside a scroll...
Inside a method of my Fragment, I do the following in order to add a
custom calendar to a container:
container.addView(calView = new CalendarView(x, y, z));
calView.setMinimumHeight(height);
If "height" is large enough that container is expanded to larger than the
scrollview, the scroll bar appears as it should, but the calendar is not
drawn (the onDraw() method is never called).
of the view is set larger than the screen (it is inside a scroll...
Inside a method of my Fragment, I do the following in order to add a
custom calendar to a container:
container.addView(calView = new CalendarView(x, y, z));
calView.setMinimumHeight(height);
If "height" is large enough that container is expanded to larger than the
scrollview, the scroll bar appears as it should, but the calendar is not
drawn (the onDraw() method is never called).
Error with putting voids into one another (& compiler no getting to code)
Error with putting voids into one another (& compiler no getting to code)
so I've been trying to do some simple coding: Moving a blue square with
the WASD keys,
public static void main (String args[])
{
new MoveWASD();
}
public MoveWASD()
{
super("Use-WASD-to-Move");
setSize(800, 450);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void paint(Graphics g)
{
g.setColor(Color.WHITE);
g.fillRect(0, 0, 800, 450);
g.setColor(Color.BLUE);
g.fillRect(Location[0], Location[1], 20, 20);
System.out.println("PRINTEDs");
}
public class MoveDetection extends Thread implements KeyListener
{
@Override
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub
}
@Override
public void keyTyped(KeyEvent e) {
// TODO Auto-generated method stub
}
public void keyPressed(KeyEvent arg0)
{
public void run()
{
while(true)
{
try
{
if(event.getKeyChar() == 'w')
{
Location[1] = Location[1] - 20;
Repeat = true;
}
else if(event.getKeyChar() == 'd')
{
Location[0] = Location[0] + 20;
}
else if(event.getKeyChar() == 's')
{
Location[1] = Location[1] + 20;
}
else if (event.getKeyChar() == 'a')
{
Location[0] = Location[0] - 20;
}
else
{
Location[0] = Location[0];
}
Thread.sleep(75);
}
catch(Exception e)
{
break;
}
}
}
}
}
However, a get an error when putting to static voids one into the other,
the arrow (up above) points to my two errors: one under run which says:
Syntax error on token "void", @ expected and another under the end
parenthasis in run() which says: Syntax error, insert "EnumBody" to
complete BlockStatements Also, when I put a "System.out.write() under any
"void" under my movedetection class it does not display, which probably
means it isn't getting to it... As I have just begun coding, I have no
idea what this means, any help?
so I've been trying to do some simple coding: Moving a blue square with
the WASD keys,
public static void main (String args[])
{
new MoveWASD();
}
public MoveWASD()
{
super("Use-WASD-to-Move");
setSize(800, 450);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void paint(Graphics g)
{
g.setColor(Color.WHITE);
g.fillRect(0, 0, 800, 450);
g.setColor(Color.BLUE);
g.fillRect(Location[0], Location[1], 20, 20);
System.out.println("PRINTEDs");
}
public class MoveDetection extends Thread implements KeyListener
{
@Override
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub
}
@Override
public void keyTyped(KeyEvent e) {
// TODO Auto-generated method stub
}
public void keyPressed(KeyEvent arg0)
{
public void run()
{
while(true)
{
try
{
if(event.getKeyChar() == 'w')
{
Location[1] = Location[1] - 20;
Repeat = true;
}
else if(event.getKeyChar() == 'd')
{
Location[0] = Location[0] + 20;
}
else if(event.getKeyChar() == 's')
{
Location[1] = Location[1] + 20;
}
else if (event.getKeyChar() == 'a')
{
Location[0] = Location[0] - 20;
}
else
{
Location[0] = Location[0];
}
Thread.sleep(75);
}
catch(Exception e)
{
break;
}
}
}
}
}
However, a get an error when putting to static voids one into the other,
the arrow (up above) points to my two errors: one under run which says:
Syntax error on token "void", @ expected and another under the end
parenthasis in run() which says: Syntax error, insert "EnumBody" to
complete BlockStatements Also, when I put a "System.out.write() under any
"void" under my movedetection class it does not display, which probably
means it isn't getting to it... As I have just begun coding, I have no
idea what this means, any help?
how can i change the arrow cursor image to hand image for my web page
how can i change the arrow cursor image to hand image for my web page
I want to change the image of my cursor,instead of it I want the hand
image ,when I will take the cursor on the side bar menu than cursor image
should be hand.
I want to change the image of my cursor,instead of it I want the hand
image ,when I will take the cursor on the side bar menu than cursor image
should be hand.
Friday, 27 September 2013
threads to show progress in java
threads to show progress in java
Here's the situation: My code downloads a file from the internet, also
displays its size and filename.
The problem is that when I'm downloading that file, nothing appears in
that JTextArea and the frame is like "frozen" until the download is
complete.
I even tried to put a progress bar using swingworker class (i asked some
days ago requesting information and I didn't understand how to "integrate"
the swingworker methods you gave me before in my code. I was told that
using Matisse is not recommendable at all in that sort of cases. So I'm
not able to use swingworker.
I've been researching, and I think that the suitable way for me is using a
thread. With, or without a progress bar. Just looking for simple code, I'm
a beginner, thanks
Here's the situation: My code downloads a file from the internet, also
displays its size and filename.
The problem is that when I'm downloading that file, nothing appears in
that JTextArea and the frame is like "frozen" until the download is
complete.
I even tried to put a progress bar using swingworker class (i asked some
days ago requesting information and I didn't understand how to "integrate"
the swingworker methods you gave me before in my code. I was told that
using Matisse is not recommendable at all in that sort of cases. So I'm
not able to use swingworker.
I've been researching, and I think that the suitable way for me is using a
thread. With, or without a progress bar. Just looking for simple code, I'm
a beginner, thanks
C# how to deal with sessions left open
C# how to deal with sessions left open
I have a ConcurrentDictionary on server side holding on to all the
<SessionId, UserSessions> pairs.
When a new connection is established a cookie is assigned to a client
browser, perm or temp depending on the RememberMe option.
When clients call the LogOut function it removes the session from the
dictionary.
However, when the client browser is simply closed or crashed, and cookie
was per session or expired or deleted, the server side session object in
memory is remained in dictionary and becomes a ghost. Over time these
ghosts will stack up.
My question is, how to improve the design so that the dead sessions can be
cleaned up after they are expired?
I thought about making a timer service running a cleaning schedule, but it
feels not elegent. Is there a simpler way to do this without depending on
an external service?
My setup is .NET 4.5 and IIS8
I have a ConcurrentDictionary on server side holding on to all the
<SessionId, UserSessions> pairs.
When a new connection is established a cookie is assigned to a client
browser, perm or temp depending on the RememberMe option.
When clients call the LogOut function it removes the session from the
dictionary.
However, when the client browser is simply closed or crashed, and cookie
was per session or expired or deleted, the server side session object in
memory is remained in dictionary and becomes a ghost. Over time these
ghosts will stack up.
My question is, how to improve the design so that the dead sessions can be
cleaned up after they are expired?
I thought about making a timer service running a cleaning schedule, but it
feels not elegent. Is there a simpler way to do this without depending on
an external service?
My setup is .NET 4.5 and IIS8
Trouble runing a c++ project on Windows (Was coded on Linux)
Trouble runing a c++ project on Windows (Was coded on Linux)
Ok guys, I've been using Ubuntu for a while, so I've been coding all my
projects using NetBeans on ubuntu. Now, due to external causes I need to
code on Visual Studio/Windows. I know migrating projects from one OS to
another may be problematic so I made a new c++ project on Visual and
included all the .cpp files from my project. I'm having the next issues
when I run it, this is the output:
'proyecto01datosWIN.exe': Loaded 'C:\WINDOWS\SysWOW64\ntdll.dll', Cannot
find or open the PDB file
'proyecto01datosWIN.exe': Loaded 'C:\WINDOWS\SysWOW64\kernel32.dll',
Cannot find or open the PDB file
'proyecto01datosWIN.exe': Loaded 'C:\WINDOWS\SysWOW64\KernelBase.dll',
Cannot find or open the PDB file
'proyecto01datosWIN.exe': Loaded 'C:\WINDOWS\SysWOW64\msvcp100d.dll',
Symbols loaded.
'proyecto01datosWIN.exe': Loaded 'C:\WINDOWS\SysWOW64\msvcr100d.dll',
Symbols loaded.
I know it may be caused by some library, these are the libraries I'm using
in different files: iostream, fstream, sstream, vector, cstdlib, string,
algorithm,
The program reads a .txt and generates a list of objects. I'll been trying
to figure it out but haven't been able to fix it! Thanks for your time!
Ok guys, I've been using Ubuntu for a while, so I've been coding all my
projects using NetBeans on ubuntu. Now, due to external causes I need to
code on Visual Studio/Windows. I know migrating projects from one OS to
another may be problematic so I made a new c++ project on Visual and
included all the .cpp files from my project. I'm having the next issues
when I run it, this is the output:
'proyecto01datosWIN.exe': Loaded 'C:\WINDOWS\SysWOW64\ntdll.dll', Cannot
find or open the PDB file
'proyecto01datosWIN.exe': Loaded 'C:\WINDOWS\SysWOW64\kernel32.dll',
Cannot find or open the PDB file
'proyecto01datosWIN.exe': Loaded 'C:\WINDOWS\SysWOW64\KernelBase.dll',
Cannot find or open the PDB file
'proyecto01datosWIN.exe': Loaded 'C:\WINDOWS\SysWOW64\msvcp100d.dll',
Symbols loaded.
'proyecto01datosWIN.exe': Loaded 'C:\WINDOWS\SysWOW64\msvcr100d.dll',
Symbols loaded.
I know it may be caused by some library, these are the libraries I'm using
in different files: iostream, fstream, sstream, vector, cstdlib, string,
algorithm,
The program reads a .txt and generates a list of objects. I'll been trying
to figure it out but haven't been able to fix it! Thanks for your time!
Questions about sentinels? Beginner Java Programming
Questions about sentinels? Beginner Java Programming
I have this program that uses user input to find sum of number entered,
aswell as the smallest numbers and how many integers have been entered by
the users.
public static void main(String args[])
{
int numOfints = 0;
int numberin;
int sum = 0;
int small;
Scanner input = new Scanner(System.in);
System.out.print("Please enter the numbers; <-999 to stop>: ");
System.out.print("Please enter the first number: ");
numberin = input.nextInt();
small = numberin;
while(numin!=-999)
{
numOfints++;
sum+=numin;
}
if (numin >0)
{
System.out.println("Total number of numbers inputted was" +numOfints);
System.out.println("The sum of these numbers is " + sum);
System.out.println("The smallest number in the set is" + small);
}
else
System.out.println("The number set is empty, therefore no calculations can
be performed.");
}
}
However when I run the program the only thing that appears is
c:\jwork>java lab7a
Please enter the numbers; <-999 to stop>: Please enter the first number: 1
_
and it does not allow for anymore inputs from the user. Why won't the
program continue?
I have this program that uses user input to find sum of number entered,
aswell as the smallest numbers and how many integers have been entered by
the users.
public static void main(String args[])
{
int numOfints = 0;
int numberin;
int sum = 0;
int small;
Scanner input = new Scanner(System.in);
System.out.print("Please enter the numbers; <-999 to stop>: ");
System.out.print("Please enter the first number: ");
numberin = input.nextInt();
small = numberin;
while(numin!=-999)
{
numOfints++;
sum+=numin;
}
if (numin >0)
{
System.out.println("Total number of numbers inputted was" +numOfints);
System.out.println("The sum of these numbers is " + sum);
System.out.println("The smallest number in the set is" + small);
}
else
System.out.println("The number set is empty, therefore no calculations can
be performed.");
}
}
However when I run the program the only thing that appears is
c:\jwork>java lab7a
Please enter the numbers; <-999 to stop>: Please enter the first number: 1
_
and it does not allow for anymore inputs from the user. Why won't the
program continue?
Vague kernel exception on D3D11DeviceContext Update Subresource
Vague kernel exception on D3D11DeviceContext Update Subresource
I am developing a class for displaying 10-bit video streams using D3D11.
The solution I went for was to render each frame as a texture to a quad.
As such I have a function for updating the frame/texture from a YUV
surface:
void tenBitDisplay::SetTextureData(short int *yuvData) {
unsigned int size = m_width * m_height, chromaSize;
short int y1, y2, y3, y4, u, v, r, g, b;
DWORD *data;
chromaSize = size * 0.25;
data = new DWORD[size];
for(unsigned int k = 0, j = 0; k < size; k += 2, j++) {
y1 = yuvData[k];
y2 = yuvData[k + 1];
y3 = yuvData[k + m_width];
y4 = yuvData[k + m_width + 1];
u = yuvData[size + j];
v = yuvData[size + chromaSize + j];
convertYUV(y1, u, v, &r, &g, &b);
packRGB(data, r, g, b, k);
convertYUV(y2, u, v, &r, &g, &b);
packRGB(data, r, g, b, k + 1);
convertYUV(y3, u, v, &r, &g, &b);
packRGB(data, r, g, b, k + m_width);
convertYUV(y4, u, v, &r, &g, &b);
packRGB(data, r, g, b, k + m_width + 1);
if (k!=0 && (k+2) % m_width == 0)
k += m_width;
}
if (m_pTexture2D != NULL) {
m_pImmediateContext->UpdateSubresource(m_pTexture2D, 0, NULL,
data, m_width * 4, 0);
}
free(data);
}
Everything executes fine up until it reaches the
m_pImmediateContext->UpdateSubresource(m_pTexture2D, 0, NULL, data,
m_width * 4, 0); call. At some point during execution of this method, the
following exception is thrown:
First-chance exception at 0x751EC41F (KernelBase.dll) in app.exe:
0x0000087D (parameters: 0x00000000, 0x0273D328, 0x0273C760).
If there is a handler for this exception, the program may be safely
continued.
I am guessing this is a problem with the heap, stack or something else to
do with memory. I just can't figure out what precisely, and I have never
encountered such an issue and don't really have much knowledge about where
to start with debugging it. I have checked the preceding loop to make sure
there is no overrun on the buffer and everything is fine.
I am developing a class for displaying 10-bit video streams using D3D11.
The solution I went for was to render each frame as a texture to a quad.
As such I have a function for updating the frame/texture from a YUV
surface:
void tenBitDisplay::SetTextureData(short int *yuvData) {
unsigned int size = m_width * m_height, chromaSize;
short int y1, y2, y3, y4, u, v, r, g, b;
DWORD *data;
chromaSize = size * 0.25;
data = new DWORD[size];
for(unsigned int k = 0, j = 0; k < size; k += 2, j++) {
y1 = yuvData[k];
y2 = yuvData[k + 1];
y3 = yuvData[k + m_width];
y4 = yuvData[k + m_width + 1];
u = yuvData[size + j];
v = yuvData[size + chromaSize + j];
convertYUV(y1, u, v, &r, &g, &b);
packRGB(data, r, g, b, k);
convertYUV(y2, u, v, &r, &g, &b);
packRGB(data, r, g, b, k + 1);
convertYUV(y3, u, v, &r, &g, &b);
packRGB(data, r, g, b, k + m_width);
convertYUV(y4, u, v, &r, &g, &b);
packRGB(data, r, g, b, k + m_width + 1);
if (k!=0 && (k+2) % m_width == 0)
k += m_width;
}
if (m_pTexture2D != NULL) {
m_pImmediateContext->UpdateSubresource(m_pTexture2D, 0, NULL,
data, m_width * 4, 0);
}
free(data);
}
Everything executes fine up until it reaches the
m_pImmediateContext->UpdateSubresource(m_pTexture2D, 0, NULL, data,
m_width * 4, 0); call. At some point during execution of this method, the
following exception is thrown:
First-chance exception at 0x751EC41F (KernelBase.dll) in app.exe:
0x0000087D (parameters: 0x00000000, 0x0273D328, 0x0273C760).
If there is a handler for this exception, the program may be safely
continued.
I am guessing this is a problem with the heap, stack or something else to
do with memory. I just can't figure out what precisely, and I have never
encountered such an issue and don't really have much knowledge about where
to start with debugging it. I have checked the preceding loop to make sure
there is no overrun on the buffer and everything is fine.
Is there another way to retrieve data in url rather than URI->SEGMENT?
Is there another way to retrieve data in url rather than URI->SEGMENT?
Example:
...scms/contracts/set_pm/3/Monthly
this is the URL and i want to get the word monthly...I cant use
uri->segment in my view so I'm asking if there's other way
Example:
...scms/contracts/set_pm/3/Monthly
this is the URL and i want to get the word monthly...I cant use
uri->segment in my view so I'm asking if there's other way
Applying outer layer that wrapping two select statement
Applying outer layer that wrapping two select statement
I have two query which has successfully inner join
select t1.countResult, t2.sumResult from (
select
count(column) as countResult
from tableA join tableB
on tableA.id = tableB.id
group by name
)t1 inner join (
select
sum(column) as sumResult
from tableA
join tableB
on tableA.id = tableB.id
group by name
)t2
on t1.name= t2.name
The above query will return me the name and the corresponding number of
count and the sum. I need to do a comparison between the count and sum. If
the count doesnt match the sum, it will return 0, else 1. And so my idea
was implementing another outer layer to wrap them up and use CASE WHEN.
However, I've failed to apply an outer layer just to wrap them up? This is
what I've tried:
select * from(
select t1.countResult, t2.sumResult from (
select
count(column) as countResult
from tableA join tableB
on tableA.id = tableB.id
group by name
)t1 inner join (
select
sum(column) as sumResult
from tableA
join tableB
on tableA.id = tableB.id
group by name
)t2
on t1.name= t2.name
)
I have two query which has successfully inner join
select t1.countResult, t2.sumResult from (
select
count(column) as countResult
from tableA join tableB
on tableA.id = tableB.id
group by name
)t1 inner join (
select
sum(column) as sumResult
from tableA
join tableB
on tableA.id = tableB.id
group by name
)t2
on t1.name= t2.name
The above query will return me the name and the corresponding number of
count and the sum. I need to do a comparison between the count and sum. If
the count doesnt match the sum, it will return 0, else 1. And so my idea
was implementing another outer layer to wrap them up and use CASE WHEN.
However, I've failed to apply an outer layer just to wrap them up? This is
what I've tried:
select * from(
select t1.countResult, t2.sumResult from (
select
count(column) as countResult
from tableA join tableB
on tableA.id = tableB.id
group by name
)t1 inner join (
select
sum(column) as sumResult
from tableA
join tableB
on tableA.id = tableB.id
group by name
)t2
on t1.name= t2.name
)
Thursday, 26 September 2013
hyperlink in openerp tree view
hyperlink in openerp tree view
I want to add a link with ftp url in my tree view. i tested with adding
widget="url" in my xml ,but its not working. Please help my code is
<tree string="File Names" >
<field name="time_created" string="Time Created"/>
<field name="size" string="Size"/>
<field name="file_name"/>
<field name="file_path" widget="url"/>
</tree>
class filedata(osv.osv):
_name = 'filedata'
_log_access = False
_columns = {
'file_name' : fields.char('Name'),
'file_path' : fields.char('File Path'),
'time_created' : fields.datetime('Date Time'),
'size' : fields.char('Size')
}
I want to add a link with ftp url in my tree view. i tested with adding
widget="url" in my xml ,but its not working. Please help my code is
<tree string="File Names" >
<field name="time_created" string="Time Created"/>
<field name="size" string="Size"/>
<field name="file_name"/>
<field name="file_path" widget="url"/>
</tree>
class filedata(osv.osv):
_name = 'filedata'
_log_access = False
_columns = {
'file_name' : fields.char('Name'),
'file_path' : fields.char('File Path'),
'time_created' : fields.datetime('Date Time'),
'size' : fields.char('Size')
}
Wednesday, 25 September 2013
How to get parameter in new google map street view url
How to get parameter in new google map street view url
The old street view I can obtain the parameter of ll= for lat and lng,
cbp= for getting heading and pitch from the Share URL such as below
https://maps.google.com/maps?q=London+Borough+of+Hillingdon,+United+Kingdom&hl=en&ll=51.544098,-0.474593&spn=0.0014,0.003484&sll=52.209371,0.117255&sspn=0.005516,0.013937&oq=london&hq=London+Borough+of+Hillingdon,+United+Kingdom&t=m&z=19&layer=c&cbll=51.544098,-0.474593&panoid=p3rE-jwzNFukt6tfwRCm8Q&cbp=12,244.19,,0,0.97
But the new streetview url changes to shorter and different way.
https://www.google.com/maps/preview#!data=!1m8!1m3!1d3!2d-0.474593!3d51.544098!2m2!1f244.19!2f89.03!4f75!2m4!1e1!2m2!1sp3rE-jwzNFukt6tfwRCm8Q!2e0
Both of this link open same street view with same camera view.
So is there any method I can get the ll= and cbp from new url?
The old street view I can obtain the parameter of ll= for lat and lng,
cbp= for getting heading and pitch from the Share URL such as below
https://maps.google.com/maps?q=London+Borough+of+Hillingdon,+United+Kingdom&hl=en&ll=51.544098,-0.474593&spn=0.0014,0.003484&sll=52.209371,0.117255&sspn=0.005516,0.013937&oq=london&hq=London+Borough+of+Hillingdon,+United+Kingdom&t=m&z=19&layer=c&cbll=51.544098,-0.474593&panoid=p3rE-jwzNFukt6tfwRCm8Q&cbp=12,244.19,,0,0.97
But the new streetview url changes to shorter and different way.
https://www.google.com/maps/preview#!data=!1m8!1m3!1d3!2d-0.474593!3d51.544098!2m2!1f244.19!2f89.03!4f75!2m4!1e1!2m2!1sp3rE-jwzNFukt6tfwRCm8Q!2e0
Both of this link open same street view with same camera view.
So is there any method I can get the ll= and cbp from new url?
Thursday, 19 September 2013
split some variables into one variable c#
split some variables into one variable c#
i have a some variables like this
string cond;
if(cond1){
cond += "name=@name";
}
if(cond2){
cond += "age=@age";
}
if(cond3){
cond += "city=@city";
}
query="select * from students where"+string.Join(" and ",cond);
i want to do this
query="select * from students where if exists cond1 (cond) and if exists
cond2 (cond)";
i want split all conds into one variable with cond(and) .
i have a some variables like this
string cond;
if(cond1){
cond += "name=@name";
}
if(cond2){
cond += "age=@age";
}
if(cond3){
cond += "city=@city";
}
query="select * from students where"+string.Join(" and ",cond);
i want to do this
query="select * from students where if exists cond1 (cond) and if exists
cond2 (cond)";
i want split all conds into one variable with cond(and) .
Testing multiple scenarios under one Unit Test
Testing multiple scenarios under one Unit Test
This is how I am doing my unit test in groovy.
public void testSomeMethod() {
doSomething(1,2,3,4); //this is first test
doSomething(11,22,33,44); //this is second test
}
private void doSomething(a, b, c, d) {
assertEquals(a, actual)
}
Basically I am calling doSomething 2 times with different values under
same test. It might not be a good way to test But I just want to try it
out.
So, the problem is, if the first test fails second does't get executed.
Is there a way I can force it to print fail message and move on to next one?
This is how I am doing my unit test in groovy.
public void testSomeMethod() {
doSomething(1,2,3,4); //this is first test
doSomething(11,22,33,44); //this is second test
}
private void doSomething(a, b, c, d) {
assertEquals(a, actual)
}
Basically I am calling doSomething 2 times with different values under
same test. It might not be a good way to test But I just want to try it
out.
So, the problem is, if the first test fails second does't get executed.
Is there a way I can force it to print fail message and move on to next one?
Hibernate-Mapping of one object type in two sets is not working
Hibernate-Mapping of one object type in two sets is not working
I have a class A and class B as shown below. The problem I have is, that
looking in my database the mapping table has the three columns "A_id",
"setOne_id" and "setTwo_id".
"A_id" and "setOne_id" are also the primary key.
public class A implements Serializable{
public A(){
setOne = new HashSet<B>();
setTwo = new HashSet<B>();
}
@Id @GeneratedValue(strategy = GenerationType.AUTO) @Column
private long id;
@OneToMany(cascade=CascadeType.ALL, fetch = FetchType.EAGER)
@ElementCollection(targetClass=B.class)
@Column(nullable=true,columnDefinition="bigint(20) default NULL")
private Set<B> setOne;
@OneToMany(cascade=CascadeType.ALL, fetch = FetchType.EAGER)
@ElementCollection(targetClass=B.class)
@Column(nullable=true,columnDefinition="bigint(20) default NULL")
private Set<B> setTwo;
// Getter and Setter
}
public class B implements Serializeable{
@Id @GeneratedValue(strategy = GenerationType.AUTO) @Column
private long id;
private String data;
// Getter and Setter
}
Trying to save an A Object with an added B object in setOne or setTwo end
up with this exeption:
Exception in thread "main" org.hibernate.exception.GenericJDBCException:
could not execute statement
at
org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
at
org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at
org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at
org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:136)
at
org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:58)
at
org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1256)
at
org.hibernate.action.internal.CollectionRecreateAction.execute(CollectionRecreateAction.java:58)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:377)
at
org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:369)
at
org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:292)
at
org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:339)
at
org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1234)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:404)
at
org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
at
org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
at com.cgi.liebichs.bachelorarbeit.server.App.main(App.java:131)
Caused by: java.sql.SQLException: Field 'setTwo_id' doesn't have a default
value
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4187)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4119)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2815)
at
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458)
at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2375)
at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2359)
at
org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:133)
... 13 more
How can I make this thing work?
I have a class A and class B as shown below. The problem I have is, that
looking in my database the mapping table has the three columns "A_id",
"setOne_id" and "setTwo_id".
"A_id" and "setOne_id" are also the primary key.
public class A implements Serializable{
public A(){
setOne = new HashSet<B>();
setTwo = new HashSet<B>();
}
@Id @GeneratedValue(strategy = GenerationType.AUTO) @Column
private long id;
@OneToMany(cascade=CascadeType.ALL, fetch = FetchType.EAGER)
@ElementCollection(targetClass=B.class)
@Column(nullable=true,columnDefinition="bigint(20) default NULL")
private Set<B> setOne;
@OneToMany(cascade=CascadeType.ALL, fetch = FetchType.EAGER)
@ElementCollection(targetClass=B.class)
@Column(nullable=true,columnDefinition="bigint(20) default NULL")
private Set<B> setTwo;
// Getter and Setter
}
public class B implements Serializeable{
@Id @GeneratedValue(strategy = GenerationType.AUTO) @Column
private long id;
private String data;
// Getter and Setter
}
Trying to save an A Object with an added B object in setOne or setTwo end
up with this exeption:
Exception in thread "main" org.hibernate.exception.GenericJDBCException:
could not execute statement
at
org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
at
org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at
org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at
org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:136)
at
org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:58)
at
org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1256)
at
org.hibernate.action.internal.CollectionRecreateAction.execute(CollectionRecreateAction.java:58)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:377)
at
org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:369)
at
org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:292)
at
org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:339)
at
org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1234)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:404)
at
org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
at
org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
at com.cgi.liebichs.bachelorarbeit.server.App.main(App.java:131)
Caused by: java.sql.SQLException: Field 'setTwo_id' doesn't have a default
value
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4187)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4119)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2815)
at
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458)
at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2375)
at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2359)
at
org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:133)
... 13 more
How can I make this thing work?
Is there a way to add a Javascript-based Signature Pad to a Google Form to capture a responder's signature?
Is there a way to add a Javascript-based Signature Pad to a Google Form to
capture a responder's signature?
Is there a way to add in Thomas Bradley's Signature Pad plugin so that
someone who is filling out the Google Form would be able to sign the form?
Would it be possible to use the HTML Service option to create a custom
HTML form web app that can then still upload the responses into a Google
Spreadsheet?
The project I've been asked to look into involves an individual being able
to fill out a form but they would also like to be able to capture a
signature (essentially a web form replacing paper forms) and they would
like to do it all with Google since it is their preferred service. They
also prefer to use Google Spreadsheets.
I'm very new to Google App Scripts and have a beginner's understanding of
Javascript so I may very well misunderstand the uses and potential of
Google App Scripts. Any help or advice is much appreciated.
capture a responder's signature?
Is there a way to add in Thomas Bradley's Signature Pad plugin so that
someone who is filling out the Google Form would be able to sign the form?
Would it be possible to use the HTML Service option to create a custom
HTML form web app that can then still upload the responses into a Google
Spreadsheet?
The project I've been asked to look into involves an individual being able
to fill out a form but they would also like to be able to capture a
signature (essentially a web form replacing paper forms) and they would
like to do it all with Google since it is their preferred service. They
also prefer to use Google Spreadsheets.
I'm very new to Google App Scripts and have a beginner's understanding of
Javascript so I may very well misunderstand the uses and potential of
Google App Scripts. Any help or advice is much appreciated.
Google Search Api Couldn't get Result More Than 4?
Google Search Api Couldn't get Result More Than 4?
Here is my code that Search Result From Google.somewhere is written that i
have to set 'start' to '0' but as i'm a very Newbee in java i really don't
khow what should i do.so any help will appreciate.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.demo.GoogleSearch"%>
<%@page import="java.util.List"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%@include file="SearchGoogle.jsp" %>
<%
String word=request.getParameter("searchWord");
List<String>urls=GoogleSearch.searchWord(word);
%>
<table>
<%
int b = urls.size();
for(int i=0;i<b;i++){
//if (i < b)
%>
<tr><td><%=urls.get(i) %></td></tr>
<%} %>
</table>
</body>
</html>
And Here is the page for Sesrch:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="SearchResults.jsp">
<table>
<tr><td>
Enter Search Word:</td><td>
<input type="text" name="searchWord"/></td></tr>
<tr><td colspan="2">
<input type="submit" value="search">
</td></tr>
</table>
</form>
</body>
</html>
Here is my code that Search Result From Google.somewhere is written that i
have to set 'start' to '0' but as i'm a very Newbee in java i really don't
khow what should i do.so any help will appreciate.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.demo.GoogleSearch"%>
<%@page import="java.util.List"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%@include file="SearchGoogle.jsp" %>
<%
String word=request.getParameter("searchWord");
List<String>urls=GoogleSearch.searchWord(word);
%>
<table>
<%
int b = urls.size();
for(int i=0;i<b;i++){
//if (i < b)
%>
<tr><td><%=urls.get(i) %></td></tr>
<%} %>
</table>
</body>
</html>
And Here is the page for Sesrch:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="SearchResults.jsp">
<table>
<tr><td>
Enter Search Word:</td><td>
<input type="text" name="searchWord"/></td></tr>
<tr><td colspan="2">
<input type="submit" value="search">
</td></tr>
</table>
</form>
</body>
</html>
Add view class defined in external lbrary project
Add view class defined in external lbrary project
I have created a new GLView component to be aded to different projects.
After building the library correctly I am trying to add it to a xml layout
in my test app, but it doesn't seem to work as it throws a classnotfound
exception.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lib="http://schemas.android.com/apk/res-auto"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@android:color/darker_gray">
<com.exapmple.library.CustomView
android:id="@+id/glsurfaceview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
And the class inside the external project is:
public class CustomView extends GLSurfaceView
I have created a new GLView component to be aded to different projects.
After building the library correctly I am trying to add it to a xml layout
in my test app, but it doesn't seem to work as it throws a classnotfound
exception.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lib="http://schemas.android.com/apk/res-auto"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@android:color/darker_gray">
<com.exapmple.library.CustomView
android:id="@+id/glsurfaceview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
And the class inside the external project is:
public class CustomView extends GLSurfaceView
How can I populate array of tuples from array?
How can I populate array of tuples from array?
I have to populate array of tuples from array:
My array is = [1,0.004,5,0.03]
It should be moved to array of tuples Tuple<int,double>
(1, 0.004), (5, 0.03)
I m workin with c#. Could you please help me?
I have to populate array of tuples from array:
My array is = [1,0.004,5,0.03]
It should be moved to array of tuples Tuple<int,double>
(1, 0.004), (5, 0.03)
I m workin with c#. Could you please help me?
Wednesday, 18 September 2013
How to get first letter from string using jquery
How to get first letter from string using jquery
I am poor knowledge in jquery. I have mentioned the script below
var header = $('.time'+col).text();
alert(header);
I got string as "109:00AM" from that how to get first letter such as 1.
Could you please help me.
I am poor knowledge in jquery. I have mentioned the script below
var header = $('.time'+col).text();
alert(header);
I got string as "109:00AM" from that how to get first letter such as 1.
Could you please help me.
Hide platform from detection
Hide platform from detection
I have sites with Joomla & Drupal and I dont wont that others can view
platform (cms) of my sites from Extensions like Wappalyzers or similar to
it. I've heard that has to do with meta tags but I'm not sure.
Please help me how to hide me cms.
This is an image: http://i43.tinypic.com/2evc6qo.png
I have sites with Joomla & Drupal and I dont wont that others can view
platform (cms) of my sites from Extensions like Wappalyzers or similar to
it. I've heard that has to do with meta tags but I'm not sure.
Please help me how to hide me cms.
This is an image: http://i43.tinypic.com/2evc6qo.png
Unable to locate the model you have specified - CodeIgniter Issue
Unable to locate the model you have specified - CodeIgniter Issue
I'm getting an unable to locate model error.
$this->load->model('1/Gift_model');
My model file name is gift_model.php within /models/1/.
I declare the model the following way.
class Gift_model extends CI_Model {
According to CodeIgniter's documentation I'm doing it the correct way. Any
suggestions? I have 5 other models named exactly the same way and they're
all loading fine.
I'm getting an unable to locate model error.
$this->load->model('1/Gift_model');
My model file name is gift_model.php within /models/1/.
I declare the model the following way.
class Gift_model extends CI_Model {
According to CodeIgniter's documentation I'm doing it the correct way. Any
suggestions? I have 5 other models named exactly the same way and they're
all loading fine.
How to get value from another table and count it
How to get value from another table and count it
This is like a voting system, lets says i have 2 mysql tables,
firsttable
Name Gold
Rafael 1
Fabio 1
Rooney 1
secondtable
Club Golds
Manutd 0
Madrid 0
Barcelona 0
what the sql query to update madrid golds with rafael's gold, so rafael's
gold will be 0 and madrid's golds will be 1. And then if fabio and rooney
give their gold to madrid also, madrid's gold will be 3. please help.
This is like a voting system, lets says i have 2 mysql tables,
firsttable
Name Gold
Rafael 1
Fabio 1
Rooney 1
secondtable
Club Golds
Manutd 0
Madrid 0
Barcelona 0
what the sql query to update madrid golds with rafael's gold, so rafael's
gold will be 0 and madrid's golds will be 1. And then if fabio and rooney
give their gold to madrid also, madrid's gold will be 3. please help.
slides turn blank during viewing the slides
slides turn blank during viewing the slides
my application views HTML5 slides in webViewDidFinishLoad i use this code
but still flashing white space
(void)webViewDidFinishLoad:(UIWebView *)webView{
webView.delegate=self; if (![[webView.request.URL absoluteString]
isEqualToString:@"about:blank"]) {
if ([[webView
stringByEvaluatingJavaScriptFromString:@"document.readyState"]
isEqualToString:@"complete"]) {
if (webView == ((SlideView *) swipeView.currentItemView).webView) {
int index = swipeView.currentItemIndex;
[self performSelector:@selector(hideImage:) withObject:[NSNumber
numberWithInt:index] afterDelay:0.0];
my application views HTML5 slides in webViewDidFinishLoad i use this code
but still flashing white space
(void)webViewDidFinishLoad:(UIWebView *)webView{
webView.delegate=self; if (![[webView.request.URL absoluteString]
isEqualToString:@"about:blank"]) {
if ([[webView
stringByEvaluatingJavaScriptFromString:@"document.readyState"]
isEqualToString:@"complete"]) {
if (webView == ((SlideView *) swipeView.currentItemView).webView) {
int index = swipeView.currentItemIndex;
[self performSelector:@selector(hideImage:) withObject:[NSNumber
numberWithInt:index] afterDelay:0.0];
Program that works in all version of excel
Program that works in all version of excel
Recently i have developed a windows form application which has several
datagrids ,client needs to export the data into excel, they are using diff
version of excel(like 2003,2007,2010,2013), but i'm using office 2013. so
i have used excel 2013 references
(Microsoft excel 15.0 object library)
in my program ,client recently reported to me that the export option not
worked. then i had a investigation and my application working fine those
who are using office 2013 not working for 2010,2007 version
Is there any way to do work my application in all version of excel ?
Recently i have developed a windows form application which has several
datagrids ,client needs to export the data into excel, they are using diff
version of excel(like 2003,2007,2010,2013), but i'm using office 2013. so
i have used excel 2013 references
(Microsoft excel 15.0 object library)
in my program ,client recently reported to me that the export option not
worked. then i had a investigation and my application working fine those
who are using office 2013 not working for 2010,2007 version
Is there any way to do work my application in all version of excel ?
Sending/uploading xml file in POST method of RestAPI using Ruby
Sending/uploading xml file in POST method of RestAPI using Ruby
I have used HTTPClient for authentication of Rest API and then used file
upload method for uploading file
Code:
require 'HTTPClient'
clnt = HTTPClient.new(path)
clnt.set_auth(path, 'username', 'password')
File.open('E:\Project_Groundwork\RestAPI\RestAPI Docs\postHost.xml') do
|file|
body = [{ 'Content-Type' => 'application/xml; charset=UTF-8',
:content => '<hosts><host hostName="host100"
description="First of my servers" monitorStatus="UP"
appType="NAGIOS" deviceIdentification="172.28.112.13"
monitorServer="localhost" deviceDisplayName="Device-50"
><properties><property name="Latency" value="125"
/></properties></host></hosts>' },
{ 'Content-Type' => 'application/xml',
'Content-Transfer-Encoding' => 'binary',
:content => file }]
io = clnt.post(path, body)
Above code authenticates successfully but after that returns '415
Unsupported Media type' error message. This error is returned when xml has
incorrect format. Though when I am sending xml data using 'RestClient'
Firefox Addon, then everything works fine.It means that my xml is correct.
Can anyone tell what am I doing wrong here.
I have used HTTPClient for authentication of Rest API and then used file
upload method for uploading file
Code:
require 'HTTPClient'
clnt = HTTPClient.new(path)
clnt.set_auth(path, 'username', 'password')
File.open('E:\Project_Groundwork\RestAPI\RestAPI Docs\postHost.xml') do
|file|
body = [{ 'Content-Type' => 'application/xml; charset=UTF-8',
:content => '<hosts><host hostName="host100"
description="First of my servers" monitorStatus="UP"
appType="NAGIOS" deviceIdentification="172.28.112.13"
monitorServer="localhost" deviceDisplayName="Device-50"
><properties><property name="Latency" value="125"
/></properties></host></hosts>' },
{ 'Content-Type' => 'application/xml',
'Content-Transfer-Encoding' => 'binary',
:content => file }]
io = clnt.post(path, body)
Above code authenticates successfully but after that returns '415
Unsupported Media type' error message. This error is returned when xml has
incorrect format. Though when I am sending xml data using 'RestClient'
Firefox Addon, then everything works fine.It means that my xml is correct.
Can anyone tell what am I doing wrong here.
C++ Copy Constructor to Copy Grade
C++ Copy Constructor to Copy Grade
im busy with writing a piece of code. The function of the code is the
following: I have a class Student. I want to copy the grade from freshman
to freshman2. Then I delete freshman, but freshman2 should still hold the
grade from freshman. I want/need to do this with a copy constructor. Im
not that familiar with a copy constructor, however. This is what I have
uptil now. Can someone please help me with this?
#include <iostream>
using namespace std;
class Student
{
public:
int *grades;
int size;
Student (unsigned int n) {grades = new int[n]; size = n;}
Student(const int& other);
~Student() {delete[] grades;}
Student(Student &old_student) {}
};
int main()
{
Student *freshman = new Student(1);
freshman -> grades[0] = 8;
Student *freshman2 = new Student(*freshman);
delete freshman;
cout << freshman2 -> grades[0] << endl;
}
Thanks in advance guys:)
im busy with writing a piece of code. The function of the code is the
following: I have a class Student. I want to copy the grade from freshman
to freshman2. Then I delete freshman, but freshman2 should still hold the
grade from freshman. I want/need to do this with a copy constructor. Im
not that familiar with a copy constructor, however. This is what I have
uptil now. Can someone please help me with this?
#include <iostream>
using namespace std;
class Student
{
public:
int *grades;
int size;
Student (unsigned int n) {grades = new int[n]; size = n;}
Student(const int& other);
~Student() {delete[] grades;}
Student(Student &old_student) {}
};
int main()
{
Student *freshman = new Student(1);
freshman -> grades[0] = 8;
Student *freshman2 = new Student(*freshman);
delete freshman;
cout << freshman2 -> grades[0] << endl;
}
Thanks in advance guys:)
Tuesday, 17 September 2013
Right definition of HashMap for static variables
Right definition of HashMap for static variables
I have trouble with logical definition of the HashMap.
For example I create the following class to store some mandatory data, I
just wanna know that is it good implementation or not? I used static
HashMap because I need these HashMaps all over the time since my
application is alive.
public abstract class DataTable {
private static HashMap<String, String[]> mainData = new
HashMap<String, String[]>();
public static void putData(String[] data) {
// put some data
}
public static String[] getData(String alias) {
// return entered data with the given alias
}
}
Any suggestion would be appreciated...
I have trouble with logical definition of the HashMap.
For example I create the following class to store some mandatory data, I
just wanna know that is it good implementation or not? I used static
HashMap because I need these HashMaps all over the time since my
application is alive.
public abstract class DataTable {
private static HashMap<String, String[]> mainData = new
HashMap<String, String[]>();
public static void putData(String[] data) {
// put some data
}
public static String[] getData(String alias) {
// return entered data with the given alias
}
}
Any suggestion would be appreciated...
My mysql table carshes and I can't find the reason
My mysql table carshes and I can't find the reason
I have an online game site, and I get this error on my site:
Warning: mysql_query(): Unable to save result set in
/home/fravianx/public_html/tx25/GameEngine/Database/db_MYSQL.php on line
2750
and here is the part of code that makes the error :
function getTrainingList() { $q = "SELECT * FROM " . TB_PREFIX . "training
where vref != '' AND eachtime<=(1000*(".time()."-commence))"; $result =
mysql_query($q, $this->connection); return
$this->mysql_fetch_all($result); }
the code itself looks fine (well, at least to me) but somehow it makes the
"training" table in mysql database to crash (doesn't do what it supposed
to be doing, which is creating troops on players accounts)
I have tried everything I could find online but still couldn't fix this :(
can you help me with this?
I have an online game site, and I get this error on my site:
Warning: mysql_query(): Unable to save result set in
/home/fravianx/public_html/tx25/GameEngine/Database/db_MYSQL.php on line
2750
and here is the part of code that makes the error :
function getTrainingList() { $q = "SELECT * FROM " . TB_PREFIX . "training
where vref != '' AND eachtime<=(1000*(".time()."-commence))"; $result =
mysql_query($q, $this->connection); return
$this->mysql_fetch_all($result); }
the code itself looks fine (well, at least to me) but somehow it makes the
"training" table in mysql database to crash (doesn't do what it supposed
to be doing, which is creating troops on players accounts)
I have tried everything I could find online but still couldn't fix this :(
can you help me with this?
Sqrt function errors incorporating
Sqrt function errors incorporating
How would I incorporate the equation into my program? Basically adding a
new column of info when it compiles:
relative_error_per_cent = 100 *((my_sqrt_1(n) – sqrt(n)) / sqrt(n)
I know that it is suppose to go inside the for loop but what else is
missing? Im getting errors. Been trying at this for a while
#include <iostream>
#include <math.h>
using namespace std;
double my_sqrt_1(double n)
{
double x = 1;
for(int i = 1; i < 10; ++i)
x = (x+n/x)/2;
return x;
}
int main()
{
for(auto k : { -100,-10,-1,0,1,10,100})
{
double relative_error_per_cent = 100*((my_sqrt_1(n) – sqrt(n)) / sqrt(n))
double n=3.14159 * pow (10.0,k);
cout << n << sqrt(n) << my_sqrt_1(n) << relative_error_per_cent;
}
return 0;
}
How would I incorporate the equation into my program? Basically adding a
new column of info when it compiles:
relative_error_per_cent = 100 *((my_sqrt_1(n) – sqrt(n)) / sqrt(n)
I know that it is suppose to go inside the for loop but what else is
missing? Im getting errors. Been trying at this for a while
#include <iostream>
#include <math.h>
using namespace std;
double my_sqrt_1(double n)
{
double x = 1;
for(int i = 1; i < 10; ++i)
x = (x+n/x)/2;
return x;
}
int main()
{
for(auto k : { -100,-10,-1,0,1,10,100})
{
double relative_error_per_cent = 100*((my_sqrt_1(n) – sqrt(n)) / sqrt(n))
double n=3.14159 * pow (10.0,k);
cout << n << sqrt(n) << my_sqrt_1(n) << relative_error_per_cent;
}
return 0;
}
Android - YouTube AdSense does not render on an Android WebView
Android - YouTube AdSense does not render on an Android WebView
I have a WebView in Android, and most things render fine. My Youtube
videos render fine, but the ads on them do not show up. I checked and
JavaScript is enabled. So I am not sure why the ads do not render.
Here is the code that I use:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
webview = new WebView(this);
setContentView(webview);
webview.getSettings().setAppCacheEnabled(false);
webview.getSettings().setJavaScriptEnabled(true);
webview.setInitialScale(1);
webview.getSettings().setPluginState(PluginState.ON);
WebSettings webSettings = webview.getSettings();
webSettings.setLoadsImagesAutomatically(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setUseWideViewPort(true);
webview.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
});
webview.setWebChromeClient(new WebChromeClient(){});
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setAppCacheEnabled(true);
webSettings.setAppCachePath(getApplicationContext().getFilesDir().getAbsolutePath()
+ "/cache");
webSettings.setDatabaseEnabled(true);
webSettings.setDatabasePath(getApplicationContext().getFilesDir().getAbsolutePath()
+ "/databases");
webview.loadUrl("http://javatester.org/javascript.html");
}
Would anyone know why the AdSense ads do not render, and how I can make it
render?
Thanks!
I have a WebView in Android, and most things render fine. My Youtube
videos render fine, but the ads on them do not show up. I checked and
JavaScript is enabled. So I am not sure why the ads do not render.
Here is the code that I use:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
webview = new WebView(this);
setContentView(webview);
webview.getSettings().setAppCacheEnabled(false);
webview.getSettings().setJavaScriptEnabled(true);
webview.setInitialScale(1);
webview.getSettings().setPluginState(PluginState.ON);
WebSettings webSettings = webview.getSettings();
webSettings.setLoadsImagesAutomatically(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setUseWideViewPort(true);
webview.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
});
webview.setWebChromeClient(new WebChromeClient(){});
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setAppCacheEnabled(true);
webSettings.setAppCachePath(getApplicationContext().getFilesDir().getAbsolutePath()
+ "/cache");
webSettings.setDatabaseEnabled(true);
webSettings.setDatabasePath(getApplicationContext().getFilesDir().getAbsolutePath()
+ "/databases");
webview.loadUrl("http://javatester.org/javascript.html");
}
Would anyone know why the AdSense ads do not render, and how I can make it
render?
Thanks!
How to start a radiobutton checked = true in a WPF MVVM application
How to start a radiobutton checked = true in a WPF MVVM application
Hi Basically I have a WPF application using the MVVM pattern.
This is my ViewModel:
namespace enLoja.WPF.ViewModel.Relatórios
{
public class SEL_PG_C_ALIViewModel : ViewModelBase
{
private readonly ICAD_EF_C_ALIService _cadEfCAliService;
//Commands
public RelayCommand OnLoaded { get; set; }
public RelayCommand Gerar { get; set; }
public SEL_PG_C_ALIViewModel(ICAD_EF_C_ALIService cadEfCAliService)
{
_cadEfCAliService = cadEfCAliService;
IsDataLoaded = false;
OnLoaded = new RelayCommand(OnLoadedExecute);
Gerar = new RelayCommand(GerarExecute, GerarCanExecute);
}
public async void Load()
{
await Task.Factory.StartNew(() =>
{
IsDataLoaded = true;
RaisePropertyChanged("IsDataLoaded");
});
}
public bool CodigoChecked { get; set; }
public bool DescricaoChecked { get; set; }
public bool IsDataLoaded { get; set; }
#region Commands Execute
public void OnLoadedExecute()
{
Load();
}
public void GerarExecute()
{
var parameters = new Dictionary<string, string>();
if (CodigoChecked)
{
parameters.Add("Order", "Código");
}
if (DescricaoChecked)
{
parameters.Add("Order", "Descrição");
}
IEnumerable<CAD_EF_C_ALI> query =
_cadEfCAliService.GetCAD_EF_C_ALI();
var empresaSelecionada = new List<CAD_EF_C_PAR> {
((App)Application.Current).EmpresaSelecionada };
var reportWindow = new REL_PG_C_ALI(query.ToList(),
parameters, empresaSelecionada);
reportWindow.ShowDialog();
}
public bool GerarCanExecute()
{
return (IsDataLoaded);
}
Hi Basically I have a WPF application using the MVVM pattern.
This is my ViewModel:
namespace enLoja.WPF.ViewModel.Relatórios
{
public class SEL_PG_C_ALIViewModel : ViewModelBase
{
private readonly ICAD_EF_C_ALIService _cadEfCAliService;
//Commands
public RelayCommand OnLoaded { get; set; }
public RelayCommand Gerar { get; set; }
public SEL_PG_C_ALIViewModel(ICAD_EF_C_ALIService cadEfCAliService)
{
_cadEfCAliService = cadEfCAliService;
IsDataLoaded = false;
OnLoaded = new RelayCommand(OnLoadedExecute);
Gerar = new RelayCommand(GerarExecute, GerarCanExecute);
}
public async void Load()
{
await Task.Factory.StartNew(() =>
{
IsDataLoaded = true;
RaisePropertyChanged("IsDataLoaded");
});
}
public bool CodigoChecked { get; set; }
public bool DescricaoChecked { get; set; }
public bool IsDataLoaded { get; set; }
#region Commands Execute
public void OnLoadedExecute()
{
Load();
}
public void GerarExecute()
{
var parameters = new Dictionary<string, string>();
if (CodigoChecked)
{
parameters.Add("Order", "Código");
}
if (DescricaoChecked)
{
parameters.Add("Order", "Descrição");
}
IEnumerable<CAD_EF_C_ALI> query =
_cadEfCAliService.GetCAD_EF_C_ALI();
var empresaSelecionada = new List<CAD_EF_C_PAR> {
((App)Application.Current).EmpresaSelecionada };
var reportWindow = new REL_PG_C_ALI(query.ToList(),
parameters, empresaSelecionada);
reportWindow.ShowDialog();
}
public bool GerarCanExecute()
{
return (IsDataLoaded);
}
Sunday, 15 September 2013
How do I read a two part input in Java?
How do I read a two part input in Java?
I'm writing a program that reads a user input in feet inches and
converting it into inches and centimeters. I can't figure out how to do a
two part input. Can someone help me out?
I'm writing a program that reads a user input in feet inches and
converting it into inches and centimeters. I can't figure out how to do a
two part input. Can someone help me out?
android external storage encryption keys
android external storage encryption keys
Any one knows where android is keeping private keys for external storage
encryption? There is such option (ext storage enc) in some versions of
android 4.1+ (at least in samsung series).
The thing is that it warns you before encryption that if your phone breaks
you wont be able to recover data. I assume it is because as always
encryption keys are encrypted with user password. So user password alone
is useless and the keys are kept somewhere in tge internal memory.
Any one knows where android is keeping private keys for external storage
encryption? There is such option (ext storage enc) in some versions of
android 4.1+ (at least in samsung series).
The thing is that it warns you before encryption that if your phone breaks
you wont be able to recover data. I assume it is because as always
encryption keys are encrypted with user password. So user password alone
is useless and the keys are kept somewhere in tge internal memory.
Is it hardcoding to type out values in a formula?
Is it hardcoding to type out values in a formula?
I am working on a class assignment and one of the things covered in this
weeks text is hardcoding and how it is frowned upon.
My question is if I physically put in a value that is part of the formula,
is that considered hardcoding?
example: the volume of a sphere is (4/3) * PI * r^3 should I declare (4/3)
as variable in the beginning of my block code? or should I take it a step
further and declare the whole formula?
I hope what I am asking makes sense to everyone, and for a little extra
information here is the my code:
package area_volume_surfacearea;
/**
* Area_Volume_SurfaceArea (Assignment number 9)
* For CSCI 111
* last modified sept 15 12 p.m.
* @author Jeffrey Quinn
*/
//import Scanner class
import java.util.Scanner;
public class Area_Volume_SurfaceArea
{
/**
* This method finds the Area, Volume and Surface Area of geometric
shapes
based off a value that the user inputs (in inches)
*/
public static void main(String[] args)
{
double distance; //the distance the users inputs to be used in the
formulas (raidus or side)
double areaCircle; //the area of the circle
double areaSquare; //the area of the square
double volumeSphere; //the volume of the sphere
double volumeCube; //the volume of the cube
double surfaceAreaSphere; // the surface area of the sphere
double surfaceAreaCube; //the surface area of the cube
//declare an instance of Scanner class to read the datastream from
the keyboard
Scanner keyboard = new Scanner(System.in);
//get the value of the radius of the circle (in inches)
System.out.println("Please enter a distance (in inches) to be
used:");
distance = keyboard.nextDouble();
//calculate area of a circle (in inches)
areaCircle = Math.PI * Math.pow(distance,2);
//calculate area of a square (in inches)
areaSquare = Math.pow(distance,2);
//calculate volume of a sphere (in inches)
volumeSphere = (4/3) * Math.PI * Math.pow(distance,3);
//calculate volume of a cube (in inches)
volumeCube = Math.pow(distance,3);
// calulate surface area of a sphere (in inches)
surfaceAreaSphere = 4 * Math.PI * Math.pow(distance,2);
//calculate surface area of a cube (in inches)
surfaceAreaCube = 6 * Math.pow(distance,2);
//results
System.out.println(" The area of a circle with the radius of " +
distance + "in, is " + areaCircle);
System.out.println(" The area of a square whos sides measures " +
distance+ "in, is " + areaSquare);
System.out.println(" The volume of a sphere with the radius of " +
distance + "in, is " + volumeSphere);
System.out.println(" The volume of a cube whos sides measures " +
distance + "in, is " + volumeCube);
System.out.println(" The surface area of a sphere with the radius
of " + distance + "in, is " + surfaceAreaSphere);
System.out.println(" The surface area of a cube whos sides
measures " + distance + "in, is " + surfaceAreaCube);
} //end main()
}// end class Area_Volume_SurfaceArea
I am working on a class assignment and one of the things covered in this
weeks text is hardcoding and how it is frowned upon.
My question is if I physically put in a value that is part of the formula,
is that considered hardcoding?
example: the volume of a sphere is (4/3) * PI * r^3 should I declare (4/3)
as variable in the beginning of my block code? or should I take it a step
further and declare the whole formula?
I hope what I am asking makes sense to everyone, and for a little extra
information here is the my code:
package area_volume_surfacearea;
/**
* Area_Volume_SurfaceArea (Assignment number 9)
* For CSCI 111
* last modified sept 15 12 p.m.
* @author Jeffrey Quinn
*/
//import Scanner class
import java.util.Scanner;
public class Area_Volume_SurfaceArea
{
/**
* This method finds the Area, Volume and Surface Area of geometric
shapes
based off a value that the user inputs (in inches)
*/
public static void main(String[] args)
{
double distance; //the distance the users inputs to be used in the
formulas (raidus or side)
double areaCircle; //the area of the circle
double areaSquare; //the area of the square
double volumeSphere; //the volume of the sphere
double volumeCube; //the volume of the cube
double surfaceAreaSphere; // the surface area of the sphere
double surfaceAreaCube; //the surface area of the cube
//declare an instance of Scanner class to read the datastream from
the keyboard
Scanner keyboard = new Scanner(System.in);
//get the value of the radius of the circle (in inches)
System.out.println("Please enter a distance (in inches) to be
used:");
distance = keyboard.nextDouble();
//calculate area of a circle (in inches)
areaCircle = Math.PI * Math.pow(distance,2);
//calculate area of a square (in inches)
areaSquare = Math.pow(distance,2);
//calculate volume of a sphere (in inches)
volumeSphere = (4/3) * Math.PI * Math.pow(distance,3);
//calculate volume of a cube (in inches)
volumeCube = Math.pow(distance,3);
// calulate surface area of a sphere (in inches)
surfaceAreaSphere = 4 * Math.PI * Math.pow(distance,2);
//calculate surface area of a cube (in inches)
surfaceAreaCube = 6 * Math.pow(distance,2);
//results
System.out.println(" The area of a circle with the radius of " +
distance + "in, is " + areaCircle);
System.out.println(" The area of a square whos sides measures " +
distance+ "in, is " + areaSquare);
System.out.println(" The volume of a sphere with the radius of " +
distance + "in, is " + volumeSphere);
System.out.println(" The volume of a cube whos sides measures " +
distance + "in, is " + volumeCube);
System.out.println(" The surface area of a sphere with the radius
of " + distance + "in, is " + surfaceAreaSphere);
System.out.println(" The surface area of a cube whos sides
measures " + distance + "in, is " + surfaceAreaCube);
} //end main()
}// end class Area_Volume_SurfaceArea
Pattern (Neighbor) choices in mpptest
Pattern (Neighbor) choices in mpptest
I am experimenting with mpptest and I am wandering what is the difference
between -nbrring and -nbrdbl?
I am experimenting with mpptest and I am wandering what is the difference
between -nbrring and -nbrdbl?
php send email using gmail smtp
php send email using gmail smtp
I am trying to send email by using Gmail (maybe even Yahoo SMTP ) , I have
the following code
require("class.phpmailer.php");
//ini_set("SMTP","smtp.google.com" );
$smtp=$_GET["smtp"];
$youremail= $_GET["youremail"];
$emailpassword=$_GET["emailpassword"];
$companyemail=$_GET["companyemail"];
$messagetitle= $_GET["messagetitle"];
$messagetext=$_GET["messagetext"];
echo "_GET variables dump" ;
var_dump($smtp);
var_dump($youremail);
var_dump($emailpassword);
var_dump($companyemail);
var_dump($messagetitle);
var_dump($messagetext);
//this is a path to PHP mailer class you have dowloaded
//include("class.phpmailer.php");
$emailChunks = explode(",", $companyemail);
for($i = 0; $i < count($emailChunks); $i++){
// echo "Piece $i = <br />";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1; // errors and messages
//$mail->SMTPSecure = "tls"; // sets the prefix to the
servier
$mail->SMTPSecure = "ssl";
$mail->Port = 587;
$mail->Host = $smtp;
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = $youremail; // SMTP username
$mail->Password = $emailpassword; // SMTP password
$mail->From = $youremail; //do NOT fake header.
$mail->FromName = $youremail;
$adr=$emailChunks[$i];
$mail->AddAddress($adr); // Email on which you want to send mail
$mail->AddReplyTo($emailpassword, "Reply to"); //optional
$mail->IsHTML(true);
$mail->Subject = $messagetitle;
$mail->Body = $messagetext;
echo "mail variable dump" ;
var_dump($mail);
if(!$mail->Send())
{
echo $mail->ErrorInfo;
}else{
echo "email was sent";
}
}
When I call the code - I use var_dump for debugging purpose I get
ALL EMAIL MESSAGES HAVE BEEN WITH STATUS :_GET variables dumpstring(14)
"smtp.gmail.com"
string(18) "me@gmail.com"
string(8) "mypass"
string(18) "sendTo@yahoo.com"
string(2) "message subject"
string(6) "message"
Invalid address: mypassmail variable dumpobject(PHPMailer)#1 (53) {
["Priority"]=>
int(3)
["CharSet"]=>
string(10) "iso-8859-1"
["ContentType"]=>
string(9) "text/html"
["Encoding"]=>
string(4) "8bit"
["ErrorInfo"]=>
string(25) "Invalid address: mypass"
["From"]=>
string(18) "me@gmail.com"
["FromName"]=>
string(18) "me@gmail.com"
["Sender"]=>
string(0) ""
["Subject"]=>
string(2) "ja"
["Body"]=>
string(6) "message"
["AltBody"]=>
string(0) ""
["WordWrap"]=>
int(0)
["Mailer"]=>
string(4) "smtp"
["Sendmail"]=>
string(18) "/usr/sbin/sendmail"
["PluginDir"]=>
string(0) ""
["ConfirmReadingTo"]=>
string(0) ""
["Hostname"]=>
string(0) ""
["MessageID"]=>
string(0) ""
["Host"]=>
string(14) "smtp.gmail.com"
["Port"]=>
int(587)
["Helo"]=>
string(0) ""
["SMTPSecure"]=>
string(3) "ssl"
["SMTPAuth"]=>
bool(true)
["Username"]=>
string(18) "me@gmail.com"
["Password"]=>
string(8) "mypass"
["Timeout"]=>
int(10)
["SMTPDebug"]=>
int(1)
["SMTPKeepAlive"]=>
bool(false)
["SingleTo"]=>
bool(false)
["SingleToArray"]=>
array(0) {
}
["LE"]=>
string(1) "
"
["DKIM_selector"]=>
string(9) "phpmailer"
["DKIM_identity"]=>
string(0) ""
["DKIM_domain"]=>
string(0) ""
["DKIM_private"]=>
string(0) ""
["action_function"]=>
string(0) ""
["Version"]=>
string(3) "5.1"
["smtp:private"]=>
NULL
["to:private"]=>
array(1) {
[0]=>
array(2) {
[0]=>
string(18) "sendTo@yahoo.com"
[1]=>
string(0) ""
}
}
["cc:private"]=>
array(0) {
}
["bcc:private"]=>
array(0) {
}
["ReplyTo:private"]=>
array(0) {
}
["all_recipients:private"]=>
array(1) {
["sendTo@yahoo.com"]=>
bool(true)
}
["attachment:private"]=>
array(0) {
}
["CustomHeader:private"]=>
array(0) {
}
["message_type:private"]=>
string(0) ""
["boundary:private"]=>
array(0) {
}
["language:protected"]=>
array(17) {
["provide_address"]=>
string(54) "You must provide at least one recipient email address."
["mailer_not_supported"]=>
string(25) " mailer is not supported."
["execute"]=>
string(19) "Could not execute: "
["instantiate"]=>
string(36) "Could not instantiate mail function."
["authenticate"]=>
string(35) "SMTP Error: Could not authenticate."
["from_failed"]=>
string(35) "The following From address failed: "
["recipients_failed"]=>
string(45) "SMTP Error: The following recipients failed: "
["data_not_accepted"]=>
string(30) "SMTP Error: Data not accepted."
["connect_host"]=>
string(43) "SMTP Error: Could not connect to SMTP host."
["file_access"]=>
string(23) "Could not access file: "
["file_open"]=>
string(33) "File Error: Could not open file: "
["encoding"]=>
string(18) "Unknown encoding: "
["signing"]=>
string(15) "Signing Error: "
["smtp_error"]=>
string(19) "SMTP server error: "
["empty_message"]=>
string(18) "Message body empty"
["invalid_address"]=>
string(15) "Invalid address"
["variable_set"]=>
string(30) "Cannot set or reset variable: "
}
["error_count:private"]=>
int(1)
["sign_cert_file:private"]=>
string(0) ""
["sign_key_file:private"]=>
string(0) ""
["sign_key_pass:private"]=>
string(0) ""
["exceptions:private"]=>
bool(false)
}
SMTP -> ERROR: Failed to connect to server: Connection timed out (110)
<br />SMTP Error: Could not connect to SMTP host.
SMTP Error: Could not connect to SMTP host.
And the email send fails !
I am trying to send email by using Gmail (maybe even Yahoo SMTP ) , I have
the following code
require("class.phpmailer.php");
//ini_set("SMTP","smtp.google.com" );
$smtp=$_GET["smtp"];
$youremail= $_GET["youremail"];
$emailpassword=$_GET["emailpassword"];
$companyemail=$_GET["companyemail"];
$messagetitle= $_GET["messagetitle"];
$messagetext=$_GET["messagetext"];
echo "_GET variables dump" ;
var_dump($smtp);
var_dump($youremail);
var_dump($emailpassword);
var_dump($companyemail);
var_dump($messagetitle);
var_dump($messagetext);
//this is a path to PHP mailer class you have dowloaded
//include("class.phpmailer.php");
$emailChunks = explode(",", $companyemail);
for($i = 0; $i < count($emailChunks); $i++){
// echo "Piece $i = <br />";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1; // errors and messages
//$mail->SMTPSecure = "tls"; // sets the prefix to the
servier
$mail->SMTPSecure = "ssl";
$mail->Port = 587;
$mail->Host = $smtp;
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = $youremail; // SMTP username
$mail->Password = $emailpassword; // SMTP password
$mail->From = $youremail; //do NOT fake header.
$mail->FromName = $youremail;
$adr=$emailChunks[$i];
$mail->AddAddress($adr); // Email on which you want to send mail
$mail->AddReplyTo($emailpassword, "Reply to"); //optional
$mail->IsHTML(true);
$mail->Subject = $messagetitle;
$mail->Body = $messagetext;
echo "mail variable dump" ;
var_dump($mail);
if(!$mail->Send())
{
echo $mail->ErrorInfo;
}else{
echo "email was sent";
}
}
When I call the code - I use var_dump for debugging purpose I get
ALL EMAIL MESSAGES HAVE BEEN WITH STATUS :_GET variables dumpstring(14)
"smtp.gmail.com"
string(18) "me@gmail.com"
string(8) "mypass"
string(18) "sendTo@yahoo.com"
string(2) "message subject"
string(6) "message"
Invalid address: mypassmail variable dumpobject(PHPMailer)#1 (53) {
["Priority"]=>
int(3)
["CharSet"]=>
string(10) "iso-8859-1"
["ContentType"]=>
string(9) "text/html"
["Encoding"]=>
string(4) "8bit"
["ErrorInfo"]=>
string(25) "Invalid address: mypass"
["From"]=>
string(18) "me@gmail.com"
["FromName"]=>
string(18) "me@gmail.com"
["Sender"]=>
string(0) ""
["Subject"]=>
string(2) "ja"
["Body"]=>
string(6) "message"
["AltBody"]=>
string(0) ""
["WordWrap"]=>
int(0)
["Mailer"]=>
string(4) "smtp"
["Sendmail"]=>
string(18) "/usr/sbin/sendmail"
["PluginDir"]=>
string(0) ""
["ConfirmReadingTo"]=>
string(0) ""
["Hostname"]=>
string(0) ""
["MessageID"]=>
string(0) ""
["Host"]=>
string(14) "smtp.gmail.com"
["Port"]=>
int(587)
["Helo"]=>
string(0) ""
["SMTPSecure"]=>
string(3) "ssl"
["SMTPAuth"]=>
bool(true)
["Username"]=>
string(18) "me@gmail.com"
["Password"]=>
string(8) "mypass"
["Timeout"]=>
int(10)
["SMTPDebug"]=>
int(1)
["SMTPKeepAlive"]=>
bool(false)
["SingleTo"]=>
bool(false)
["SingleToArray"]=>
array(0) {
}
["LE"]=>
string(1) "
"
["DKIM_selector"]=>
string(9) "phpmailer"
["DKIM_identity"]=>
string(0) ""
["DKIM_domain"]=>
string(0) ""
["DKIM_private"]=>
string(0) ""
["action_function"]=>
string(0) ""
["Version"]=>
string(3) "5.1"
["smtp:private"]=>
NULL
["to:private"]=>
array(1) {
[0]=>
array(2) {
[0]=>
string(18) "sendTo@yahoo.com"
[1]=>
string(0) ""
}
}
["cc:private"]=>
array(0) {
}
["bcc:private"]=>
array(0) {
}
["ReplyTo:private"]=>
array(0) {
}
["all_recipients:private"]=>
array(1) {
["sendTo@yahoo.com"]=>
bool(true)
}
["attachment:private"]=>
array(0) {
}
["CustomHeader:private"]=>
array(0) {
}
["message_type:private"]=>
string(0) ""
["boundary:private"]=>
array(0) {
}
["language:protected"]=>
array(17) {
["provide_address"]=>
string(54) "You must provide at least one recipient email address."
["mailer_not_supported"]=>
string(25) " mailer is not supported."
["execute"]=>
string(19) "Could not execute: "
["instantiate"]=>
string(36) "Could not instantiate mail function."
["authenticate"]=>
string(35) "SMTP Error: Could not authenticate."
["from_failed"]=>
string(35) "The following From address failed: "
["recipients_failed"]=>
string(45) "SMTP Error: The following recipients failed: "
["data_not_accepted"]=>
string(30) "SMTP Error: Data not accepted."
["connect_host"]=>
string(43) "SMTP Error: Could not connect to SMTP host."
["file_access"]=>
string(23) "Could not access file: "
["file_open"]=>
string(33) "File Error: Could not open file: "
["encoding"]=>
string(18) "Unknown encoding: "
["signing"]=>
string(15) "Signing Error: "
["smtp_error"]=>
string(19) "SMTP server error: "
["empty_message"]=>
string(18) "Message body empty"
["invalid_address"]=>
string(15) "Invalid address"
["variable_set"]=>
string(30) "Cannot set or reset variable: "
}
["error_count:private"]=>
int(1)
["sign_cert_file:private"]=>
string(0) ""
["sign_key_file:private"]=>
string(0) ""
["sign_key_pass:private"]=>
string(0) ""
["exceptions:private"]=>
bool(false)
}
SMTP -> ERROR: Failed to connect to server: Connection timed out (110)
<br />SMTP Error: Could not connect to SMTP host.
SMTP Error: Could not connect to SMTP host.
And the email send fails !
How to check if a input is in binary format(1 and 0)?
How to check if a input is in binary format(1 and 0)?
I have made a program however I wanted to add an exception if the user
inputs is not in a binary format. I have tried many times adding
exceptions but I can't seem to get it to work. The below is the program
code. I would appreciate if someone could help.
import time
error=True
n=0
while n!=1:
while error:
print"***Welcome to the Bin2Dec Converter.***\n"
while error:
try:
bin2dec =raw_input("Please enter a binary number: ")
error=False
except NameError:
print"Enter a Binary number. Please try again.\n"
time.sleep(0.5)
except SyntaxError:
print"Enter a Binary number. Please try again.\n"
time.sleep(0.5)
#converts bin2dec
decnum = 0
for i in bin2dec:
decnum = decnum * 2 + int(i)
time.sleep(0.25)
print decnum, "<<This is your answer.\n" #prints output
I have made a program however I wanted to add an exception if the user
inputs is not in a binary format. I have tried many times adding
exceptions but I can't seem to get it to work. The below is the program
code. I would appreciate if someone could help.
import time
error=True
n=0
while n!=1:
while error:
print"***Welcome to the Bin2Dec Converter.***\n"
while error:
try:
bin2dec =raw_input("Please enter a binary number: ")
error=False
except NameError:
print"Enter a Binary number. Please try again.\n"
time.sleep(0.5)
except SyntaxError:
print"Enter a Binary number. Please try again.\n"
time.sleep(0.5)
#converts bin2dec
decnum = 0
for i in bin2dec:
decnum = decnum * 2 + int(i)
time.sleep(0.25)
print decnum, "<<This is your answer.\n" #prints output
Unable to migrate from Unity 2.0 to Unity 2.1.505.0
Unable to migrate from Unity 2.0 to Unity 2.1.505.0
I have an application written using Unity 2.0 and I am trying to migrate
to version 2.1.505.0. I changed the reference in the project to point to
the DLL corresponding to the newer version. When I build the solution, it
goes through fine. However, when I try to run the application, it gives me
a FileNotfoundException:
Stack Trace:
[FileLoadException: Could not load file or assembly
'Microsoft.Practices.Unity, Version=2.0.414.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located
assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)]
InsightsService.WebApi.WebApiApplication.Application_Start() in
E:\tfs\DisplayApps\Services\InsightsBps\Dev\source\InsightsService.WebApi\Global.asax.cs:30
[HttpException (0x80004005): Could not load file or assembly
'Microsoft.Practices.Unity, Version=2.0.414.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located
assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext
context, HttpApplication app) +12863325
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr
appContext, HttpContext context, MethodInfo[] handlers) +175
System.Web.HttpApplication.InitSpecial(HttpApplicationState state,
MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
appContext, HttpContext context) +404
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
appContext) +475
[HttpException (0x80004005): Could not load file or assembly
'Microsoft.Practices.Unity, Version=2.0.414.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located
assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12880068
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +12721257
I checked web.config and cold not find any overrides. I even cleaned the
solution and rebuilt it, but the problem persists. What could be wrong
here?
I have an application written using Unity 2.0 and I am trying to migrate
to version 2.1.505.0. I changed the reference in the project to point to
the DLL corresponding to the newer version. When I build the solution, it
goes through fine. However, when I try to run the application, it gives me
a FileNotfoundException:
Stack Trace:
[FileLoadException: Could not load file or assembly
'Microsoft.Practices.Unity, Version=2.0.414.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located
assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)]
InsightsService.WebApi.WebApiApplication.Application_Start() in
E:\tfs\DisplayApps\Services\InsightsBps\Dev\source\InsightsService.WebApi\Global.asax.cs:30
[HttpException (0x80004005): Could not load file or assembly
'Microsoft.Practices.Unity, Version=2.0.414.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located
assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext
context, HttpApplication app) +12863325
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr
appContext, HttpContext context, MethodInfo[] handlers) +175
System.Web.HttpApplication.InitSpecial(HttpApplicationState state,
MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
appContext, HttpContext context) +404
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
appContext) +475
[HttpException (0x80004005): Could not load file or assembly
'Microsoft.Practices.Unity, Version=2.0.414.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located
assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12880068
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +12721257
I checked web.config and cold not find any overrides. I even cleaned the
solution and rebuilt it, but the problem persists. What could be wrong
here?
Saturday, 14 September 2013
How to use Messagepack with JSON?
How to use Messagepack with JSON?
I am planning to use Messagepack in our project. Currently, we are using
JSON in our project and we are writing serialize JSON document into
Cassandra. Now we are thinking to use Messagepack which is an efficient
binary serialization format.
And I believe using MessagePack in our project is almost a drop-in
optimization. Below is my code which is serializing the JSON document
using ObjectMapper.
public static void main(String[] args) throws IOException {
final long lmd = System.currentTimeMillis();
Map<String, Object> props = new HashMap<String, Object>();
props.put("site-id", 0);
props.put("price-score", 0.5);
props.put("confidence-score", 0.2);
Map<String, Category> categories = new HashMap<String, Category>();
categories.put("123", new Category("0.4", "0.2"));
categories.put("321", new Category("0.2", "0.5"));
props.put("categories", categories);
AttributeValue av = new AttributeValue(); // using Jackson in this class
av.setProperties(props);
Attribute attr = new Attribute(); // using jackson in this class
attr.instantiateNewListValue();
attr.getListValue().add(av);
attr.setLastModifiedDate(lmd);
System.out.println(attr);
// serialize it
try {
String jsonStr = new ObjectMapper().writeValueAsString(attr);
// write into database
System.out.println(jsonStr);
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Both of my classes, AttributeValue and Attribute are using Jackson
annotations and making a JSON document for me.
Now I am not sure, how to use Messagepack in my above code as I am not
able to find clear documentation on it. Can anyone help me with that?
I am planning to use Messagepack in our project. Currently, we are using
JSON in our project and we are writing serialize JSON document into
Cassandra. Now we are thinking to use Messagepack which is an efficient
binary serialization format.
And I believe using MessagePack in our project is almost a drop-in
optimization. Below is my code which is serializing the JSON document
using ObjectMapper.
public static void main(String[] args) throws IOException {
final long lmd = System.currentTimeMillis();
Map<String, Object> props = new HashMap<String, Object>();
props.put("site-id", 0);
props.put("price-score", 0.5);
props.put("confidence-score", 0.2);
Map<String, Category> categories = new HashMap<String, Category>();
categories.put("123", new Category("0.4", "0.2"));
categories.put("321", new Category("0.2", "0.5"));
props.put("categories", categories);
AttributeValue av = new AttributeValue(); // using Jackson in this class
av.setProperties(props);
Attribute attr = new Attribute(); // using jackson in this class
attr.instantiateNewListValue();
attr.getListValue().add(av);
attr.setLastModifiedDate(lmd);
System.out.println(attr);
// serialize it
try {
String jsonStr = new ObjectMapper().writeValueAsString(attr);
// write into database
System.out.println(jsonStr);
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Both of my classes, AttributeValue and Attribute are using Jackson
annotations and making a JSON document for me.
Now I am not sure, how to use Messagepack in my above code as I am not
able to find clear documentation on it. Can anyone help me with that?
using the simfatic registration form and smtp
using the simfatic registration form and smtp
I added my smtp information into the code but after entering the
registraton information the form just stalls and nothing is sent out.
I am of course willing to pay for help. Thank you Ron
I added my smtp information into the code but after entering the
registraton information the form just stalls and nothing is sent out.
I am of course willing to pay for help. Thank you Ron
POST variable doesn't echo in function
POST variable doesn't echo in function
I am currently learning the most basic PHP ever. I have 5 files.
index.php:
<html>
<head>
<title>Budget Calcule</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h2>Put in your: - </h2>
<form action="functions.php" method="post">
<h3>Income</h3>
<label>Salary: <input name="salary" type="text" /></label><br />
<h3>Outgoings</h3>
<label>Living: <input name="living" type="text" /></label><br />
<label>Insurance: <input name="insurance" type="text" /></label><br />
<label>Communication: <input name="communication" type="text"
/></label><br />
<label>Loan: <input name="loan" type="text" /></label><br />
<label>Food & Drink: <input name="foodAndDrink" type="text" /></label><br />
<label>Entertaintment / Shopping: <input name="entertainmentOrShopping"
type="text" /></label><br />
<label>Transport: <input name="transport" type="text" /></label><br />
<label>Other: <input name="other" type="text" /></label><br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
this is my functions.php:
<?php
include('variables.php');
if(!($_POST['Submit'])){
if(isset($_POST['salary'])){
header('Location: output.php');
return $_POST['lon'];
}else{
echo "All fields are required";
}
}
?>
this is my variables.php:
<?php
$salary= $_POST['salary'];
$living= $_POST['living'];
$insurance= $_POST['insurance'];
$communication = $_POST['communication'];
$loan = $_POST['loan'];
$food = $_POST['food'];
$entertaintmentOrShopping = $_POST['entertaintmentOrShopping'];
$transport = $_POST['transport'];
$other= $_POST['other'];
?>
this is my output.php file:
<?php
include('outputFunction.php');
?>
<html>
<head>
<title>Output.php</title>
</head>
<body>
<?php myText(); ?>
</body>
</html>
and last but not least, this is my outputFunction.php file:
<?php
include('variables.php');
function myText(){
echo "Your salary per month is: " . $_POST['salary'];
}
?>
Now you're thinking "why have he split up his code in different files?"
Well first of all, I split the variables from functions.php because I
wanted outputFunctions.php to get the variables from variables.php so i
could echo my `$_POST['salary']; . The function myText(); outputs the text
just fine, but it doesnt output the $_POST['salary'];.
I do not know why it doesnt work, I just wonder if you could be my extra
eyes and see if I've done some mistake.
PS! Don't down vote my question just because you think it's stupid. I am
having problem with this issue and been working on it for hours without
advancing anywhere.
I am currently learning the most basic PHP ever. I have 5 files.
index.php:
<html>
<head>
<title>Budget Calcule</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h2>Put in your: - </h2>
<form action="functions.php" method="post">
<h3>Income</h3>
<label>Salary: <input name="salary" type="text" /></label><br />
<h3>Outgoings</h3>
<label>Living: <input name="living" type="text" /></label><br />
<label>Insurance: <input name="insurance" type="text" /></label><br />
<label>Communication: <input name="communication" type="text"
/></label><br />
<label>Loan: <input name="loan" type="text" /></label><br />
<label>Food & Drink: <input name="foodAndDrink" type="text" /></label><br />
<label>Entertaintment / Shopping: <input name="entertainmentOrShopping"
type="text" /></label><br />
<label>Transport: <input name="transport" type="text" /></label><br />
<label>Other: <input name="other" type="text" /></label><br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
this is my functions.php:
<?php
include('variables.php');
if(!($_POST['Submit'])){
if(isset($_POST['salary'])){
header('Location: output.php');
return $_POST['lon'];
}else{
echo "All fields are required";
}
}
?>
this is my variables.php:
<?php
$salary= $_POST['salary'];
$living= $_POST['living'];
$insurance= $_POST['insurance'];
$communication = $_POST['communication'];
$loan = $_POST['loan'];
$food = $_POST['food'];
$entertaintmentOrShopping = $_POST['entertaintmentOrShopping'];
$transport = $_POST['transport'];
$other= $_POST['other'];
?>
this is my output.php file:
<?php
include('outputFunction.php');
?>
<html>
<head>
<title>Output.php</title>
</head>
<body>
<?php myText(); ?>
</body>
</html>
and last but not least, this is my outputFunction.php file:
<?php
include('variables.php');
function myText(){
echo "Your salary per month is: " . $_POST['salary'];
}
?>
Now you're thinking "why have he split up his code in different files?"
Well first of all, I split the variables from functions.php because I
wanted outputFunctions.php to get the variables from variables.php so i
could echo my `$_POST['salary']; . The function myText(); outputs the text
just fine, but it doesnt output the $_POST['salary'];.
I do not know why it doesnt work, I just wonder if you could be my extra
eyes and see if I've done some mistake.
PS! Don't down vote my question just because you think it's stupid. I am
having problem with this issue and been working on it for hours without
advancing anywhere.
Redirect to Facebook login URL using PHP SDK in Kohana 3.3
Redirect to Facebook login URL using PHP SDK in Kohana 3.3
I have a controller handling user registration using FB data:
if ($this->isLogged()) {
try {
$apiObject = $this->_fb->api('/me');
} catch (FacebookApiException $e) {
$apiObject = null;
throw $e;
}
} else {
HTTP::redirect($this->getLoginUrl());
}
But redirect is not working it just redirects back to the page at which
was this code triggered.
How can I redirect user to FB in Kohana 3.3 so he can log in?
I have a controller handling user registration using FB data:
if ($this->isLogged()) {
try {
$apiObject = $this->_fb->api('/me');
} catch (FacebookApiException $e) {
$apiObject = null;
throw $e;
}
} else {
HTTP::redirect($this->getLoginUrl());
}
But redirect is not working it just redirects back to the page at which
was this code triggered.
How can I redirect user to FB in Kohana 3.3 so he can log in?
App crashes on iPhone but not simulator or iPad?
App crashes on iPhone but not simulator or iPad?
I have developed an app for the iPhone and everything is going well. Today
i decided to prep it for the upcoming iOS 7 launch, and the app worked as
intended until I tried it on my iPhone 5. Whenever it crashes it throws
some exc_bad_access codes. It doesn't crash in the simulator or on my iPad
which is running iOS 6.1. I hope you guys can help me.
I have developed an app for the iPhone and everything is going well. Today
i decided to prep it for the upcoming iOS 7 launch, and the app worked as
intended until I tried it on my iPhone 5. Whenever it crashes it throws
some exc_bad_access codes. It doesn't crash in the simulator or on my iPad
which is running iOS 6.1. I hope you guys can help me.
Use htaccess to mask few urls
Use htaccess to mask few urls
How can I use htaccess to redirect a few static pages and keep the same url?
Example :
Redirect www.mydomain.com/url-that-remains.php to
www.mydomain.com/page-number-23
How can I use htaccess to redirect a few static pages and keep the same url?
Example :
Redirect www.mydomain.com/url-that-remains.php to
www.mydomain.com/page-number-23
what is the maximum size of a record in a table (MySQL database)? and how can it be increased using phpMyAdmin?
what is the maximum size of a record in a table (MySQL database)? and how
can it be increased using phpMyAdmin?
I am managing a website and i got the following issue:
I cannot insert more than 64 KB of content in a record inside a database
table (MySQL database).
How can i increase the size of that specific record so that it can accept
more content?
Cheers!!
can it be increased using phpMyAdmin?
I am managing a website and i got the following issue:
I cannot insert more than 64 KB of content in a record inside a database
table (MySQL database).
How can i increase the size of that specific record so that it can accept
more content?
Cheers!!
Friday, 13 September 2013
can we implement sorting algorithm or any algorithm in turkik on mturk for my research purpose?
can we implement sorting algorithm or any algorithm in turkik on mturk for
my research purpose?
please tell regarding to this.what are the difficulties to implement these
algorithms.I want to implement algorithm for my research purpose.
my research purpose?
please tell regarding to this.what are the difficulties to implement these
algorithms.I want to implement algorithm for my research purpose.
Age Verification PHP
Age Verification PHP
I'm using a script that works wonderfully to verify age for a website I'm
working on. Currently it's using a dropdown menu to select the Month, Day,
Year. I was hoping it was possible to change the dropdown to have the user
input the Month, Day, Year instead.
Here is the code:
<?php
define('MIN_AGE', 21); // Enter the minimum age that your
website visitors must be to view your content (replace 18 with
your number)
define('COOKIE_DAYS', 30); //Enter the number of days you
would like the cookie to last (replace 30 with your number)
// BE CAREFUL EDITING ANYTHING BELOW THIS LINE //
date_default_timezone_set('America/Los_Angeles');
function get_birth_drops($year = '', $month = '', $day = '')
{
$out = '';
$year = $year ? $year : '';
$month = $month ? $month : '';
$day = $day ? $day : '';
$month_select = '<label>MM: <select name="bmonth"
id="bmonth"><option value=""></option>';
for($i = 1; $i <=12; $i ++)
{
$selected = ($i == $month) ? ' selected':'';
$month_select .= '<option value="' . $i . '"' .
$selected . '>' . $i . '</option>';
}
$month_select .= '</select></label>';
$day_select = ' <label>DD: <select name="bday"
id="bday"><option value=""></option>';
for($i = 1; $i <=31; $i ++)
{
$selected = ($i == $day) ? ' selected':'';
$day_select .= '<option value="' . $i . '"' .
$selected . '>' . $i . '</option>';
}
$day_select .= '</select></label>';
$year_select = ' <label>YYYY: <select name="byear"
id="byear"><option value=""></option>';
for($i = 2010; $i >= 1950; $i --)
{
$selected = ($i == $year) ? ' selected':'';
$year_select .= '<option value="' . $i . '"' .
$selected . '>' . $i . '</option>';
}
$year_select .= '</select></label>';
$out = $month_select . $day_select . $year_select;
return $out;
}
function calculateAge($birthday){
return floor((time() - strtotime($birthday))/31556926);
}
?>
Any thoughts? Thanks a ton!
I'm using a script that works wonderfully to verify age for a website I'm
working on. Currently it's using a dropdown menu to select the Month, Day,
Year. I was hoping it was possible to change the dropdown to have the user
input the Month, Day, Year instead.
Here is the code:
<?php
define('MIN_AGE', 21); // Enter the minimum age that your
website visitors must be to view your content (replace 18 with
your number)
define('COOKIE_DAYS', 30); //Enter the number of days you
would like the cookie to last (replace 30 with your number)
// BE CAREFUL EDITING ANYTHING BELOW THIS LINE //
date_default_timezone_set('America/Los_Angeles');
function get_birth_drops($year = '', $month = '', $day = '')
{
$out = '';
$year = $year ? $year : '';
$month = $month ? $month : '';
$day = $day ? $day : '';
$month_select = '<label>MM: <select name="bmonth"
id="bmonth"><option value=""></option>';
for($i = 1; $i <=12; $i ++)
{
$selected = ($i == $month) ? ' selected':'';
$month_select .= '<option value="' . $i . '"' .
$selected . '>' . $i . '</option>';
}
$month_select .= '</select></label>';
$day_select = ' <label>DD: <select name="bday"
id="bday"><option value=""></option>';
for($i = 1; $i <=31; $i ++)
{
$selected = ($i == $day) ? ' selected':'';
$day_select .= '<option value="' . $i . '"' .
$selected . '>' . $i . '</option>';
}
$day_select .= '</select></label>';
$year_select = ' <label>YYYY: <select name="byear"
id="byear"><option value=""></option>';
for($i = 2010; $i >= 1950; $i --)
{
$selected = ($i == $year) ? ' selected':'';
$year_select .= '<option value="' . $i . '"' .
$selected . '>' . $i . '</option>';
}
$year_select .= '</select></label>';
$out = $month_select . $day_select . $year_select;
return $out;
}
function calculateAge($birthday){
return floor((time() - strtotime($birthday))/31556926);
}
?>
Any thoughts? Thanks a ton!
WinJS Promise progress function does not get executed
WinJS Promise progress function does not get executed
I am trying to create a basic promise with a progress function like:
asyncCall().then(function () {
that.output("complete");
},
null,
function(v) {
that.output(v);
}).done();
function asyncCall() {
return new WinJS.Promise(function (complete, error, progress) {
progress("some progress");
setTimeout(function () {
complete();
}, 1000);
});
}
I would expect this to output 'progress' for 1 second and then display
'complete'; however, 'progress' is never outputted. Debugging the
javascript, the progress function gets called on the promise object
however it gets to this code (line 1447 of base.js) and listeners is
undefined:
function progress(promise, value) {
var listeners = promise._listeners;
if (listeners) {
Any idea what I'm missing to handle the progress event?
I am trying to create a basic promise with a progress function like:
asyncCall().then(function () {
that.output("complete");
},
null,
function(v) {
that.output(v);
}).done();
function asyncCall() {
return new WinJS.Promise(function (complete, error, progress) {
progress("some progress");
setTimeout(function () {
complete();
}, 1000);
});
}
I would expect this to output 'progress' for 1 second and then display
'complete'; however, 'progress' is never outputted. Debugging the
javascript, the progress function gets called on the promise object
however it gets to this code (line 1447 of base.js) and listeners is
undefined:
function progress(promise, value) {
var listeners = promise._listeners;
if (listeners) {
Any idea what I'm missing to handle the progress event?
not able to install python pytesser library in linux enviroment, error No module named pytesser
not able to install python pytesser library in linux enviroment, error No
module named pytesser
Is there any way i can install pytesser in Ubuntu ? the below reference
said it's tested on win xp and some guys had a problem in Linux
http://code.google.com/p/pytesser/wiki/README
can anybody direct me for the steps if that possible ? i extracted the zip
file into usr/lib/python2.6/site-packages but didn't help
Thanks.
module named pytesser
Is there any way i can install pytesser in Ubuntu ? the below reference
said it's tested on win xp and some guys had a problem in Linux
http://code.google.com/p/pytesser/wiki/README
can anybody direct me for the steps if that possible ? i extracted the zip
file into usr/lib/python2.6/site-packages but didn't help
Thanks.
anti-replay attack for secure cookies?
anti-replay attack for secure cookies?
In the system that i'm working on, we are having some session cookies on
the client side that we need to protect against the replay attack ! So I
find the following paper
http://www.cse.msu.edu/~alexliu/publications/Cookie/cookie.pdf from this
forum
http://security.stackexchange.com/questions/7398/secure-session-cookies. I
really like the way that they put things together. There is only one
problem with this and that is the use of SSL session key (this is used for
anti-replay purpose). I have some problems to get this parameter in my
code (we use .Net framework and the server is running on IIS7.0). So I was
wondering whether anyone has implemented this method for his/her system
and whether you have a suggestion on replacing this parameter with another
one.
BTW, I know that server side sessions are more secure than client side
cookies, but my team currently prefers cookies than sessions.
Thanks
In the system that i'm working on, we are having some session cookies on
the client side that we need to protect against the replay attack ! So I
find the following paper
http://www.cse.msu.edu/~alexliu/publications/Cookie/cookie.pdf from this
forum
http://security.stackexchange.com/questions/7398/secure-session-cookies. I
really like the way that they put things together. There is only one
problem with this and that is the use of SSL session key (this is used for
anti-replay purpose). I have some problems to get this parameter in my
code (we use .Net framework and the server is running on IIS7.0). So I was
wondering whether anyone has implemented this method for his/her system
and whether you have a suggestion on replacing this parameter with another
one.
BTW, I know that server side sessions are more secure than client side
cookies, but my team currently prefers cookies than sessions.
Thanks
Thursday, 12 September 2013
Parsing SEC RSS Title field using regex
Parsing SEC RSS Title field using regex
All, I have an RSS feed from the SEC with company title as follows; e.g.,
10-Q - What ever INC (0000123456) (Filer)
so the general structure is:
form_name + whitespace + dash + whitespace + company_name + " (" +
SIC_Number + ") (Filer)"
I need to extract the company_name and SIC_Number. Note the form_name can
have a dash, and the company name will have white spaces. This can be done
(I'm using python) by using the re.split function for the dashes, and
again for the brackets, but it's ugly.
What would the proper RegEx be?
All, I have an RSS feed from the SEC with company title as follows; e.g.,
10-Q - What ever INC (0000123456) (Filer)
so the general structure is:
form_name + whitespace + dash + whitespace + company_name + " (" +
SIC_Number + ") (Filer)"
I need to extract the company_name and SIC_Number. Note the form_name can
have a dash, and the company name will have white spaces. This can be done
(I'm using python) by using the re.split function for the dashes, and
again for the brackets, but it's ugly.
What would the proper RegEx be?
iOS 7 - Status bar overlaps the view
iOS 7 - Status bar overlaps the view
I have a ViewController which is inside a UINavigationcontroller, but the
navigationBar is hidden. When I run the app on iOS 7 the status bar shows
on top of my view. Is there any way to avoid this?
I Don't want to write any OS specific code
I tried setting View controller-based status bar appearance to NO, bit it
did not fix the issue.
I have a ViewController which is inside a UINavigationcontroller, but the
navigationBar is hidden. When I run the app on iOS 7 the status bar shows
on top of my view. Is there any way to avoid this?
I Don't want to write any OS specific code
I tried setting View controller-based status bar appearance to NO, bit it
did not fix the issue.
Git: send commit to another branch so I can merge back, without switching branches
Git: send commit to another branch so I can merge back, without switching
branches
So I have 2 branches, the main one and the one I'm working on a parallel
release.
A --> B --> C (master)
\
-> E --> F (parallel)
The parallel branch will always merge from master. Always. And modify upon
it.
A --> B --> C --> D --> H (master)
\ \ *merge*
-> E --> F --> G --> J (parallel)
This is easy to do if I switch branches. But, if I'm working on parallel,
can I do this without switching branches? The problem with switching is
that it takes a long time to go back and forth (specially with Unity 3D,
because it keeps rebuilding the library)!
So say I'm on F, while master is still on A. Then I wanted to make few
commits on master B and C then merge them into G. How would I do it,
again, without switching branches?
branches
So I have 2 branches, the main one and the one I'm working on a parallel
release.
A --> B --> C (master)
\
-> E --> F (parallel)
The parallel branch will always merge from master. Always. And modify upon
it.
A --> B --> C --> D --> H (master)
\ \ *merge*
-> E --> F --> G --> J (parallel)
This is easy to do if I switch branches. But, if I'm working on parallel,
can I do this without switching branches? The problem with switching is
that it takes a long time to go back and forth (specially with Unity 3D,
because it keeps rebuilding the library)!
So say I'm on F, while master is still on A. Then I wanted to make few
commits on master B and C then merge them into G. How would I do it,
again, without switching branches?
tar utility from busybox 1.18.4 hanging after I have disabled USE_BB_PWD_GRP option
tar utility from busybox 1.18.4 hanging after I have disabled
USE_BB_PWD_GRP option
I have busybox 1.18.4 in that I have disabled USE_BB_PWD_GRP option to
work with /etc/nsswitch.conf but after that tar utility from busybox
starting hanging,so please help me
USE_BB_PWD_GRP option
I have busybox 1.18.4 in that I have disabled USE_BB_PWD_GRP option to
work with /etc/nsswitch.conf but after that tar utility from busybox
starting hanging,so please help me
Wednesday, 11 September 2013
Python's ConfigParser: Cross platform line endings?
Python's ConfigParser: Cross platform line endings?
Does anyone know how Python deals with ConfigParser line endings in the
different OSes? Because it follows the Windows INI format. But what about
Linux?
(As you know, Windows text line endings are typically CRLF, and Unix's are
CR.)
I want users of my app to take their config files (.INI files) easily from
Windows to Linux and I'd like to know if that's going to be problematic.
If it does use different line endings for Unix and Windows, what do you
recommend?
Does anyone know how Python deals with ConfigParser line endings in the
different OSes? Because it follows the Windows INI format. But what about
Linux?
(As you know, Windows text line endings are typically CRLF, and Unix's are
CR.)
I want users of my app to take their config files (.INI files) easily from
Windows to Linux and I'd like to know if that's going to be problematic.
If it does use different line endings for Unix and Windows, what do you
recommend?
Using CSS properties in CSS selectors?
Using CSS properties in CSS selectors?
Context: I have three spans, A B C D (in that order). Based off of what is
put in a form next to these spans, I turn the visibility off or on of
these spans.
There's a line break in A and C that makes the display something like this :
A
B C
D
But if I hide C this ends up being :
A
B D
because the line break is not displayed.
What I'd like to do is add some other element (C') that would display if B
is displayed and C isn't. So that , if C isn't there, I can still get the
line break:
A
B (C')
D
I'm pretty sure this is possible by using a combination of class-based CSS
switching and the :after pseudo-selector, but I'd rather like to avoid
having to go in and modify the Javascript to change from the current
display:show/none mechanisms. So my question ends up being :
Is it possible to 'inspect' currently set styles (such as 'display') in
CSS rules ? I'd like to be able to do something similar to the attribute
mechanism where I can do :
A[display='show']~B[display='none']:after {
content : '\a';
}
But just looking at the selectors I don't see how I could accomplish this
without declaring new classes.
Context: I have three spans, A B C D (in that order). Based off of what is
put in a form next to these spans, I turn the visibility off or on of
these spans.
There's a line break in A and C that makes the display something like this :
A
B C
D
But if I hide C this ends up being :
A
B D
because the line break is not displayed.
What I'd like to do is add some other element (C') that would display if B
is displayed and C isn't. So that , if C isn't there, I can still get the
line break:
A
B (C')
D
I'm pretty sure this is possible by using a combination of class-based CSS
switching and the :after pseudo-selector, but I'd rather like to avoid
having to go in and modify the Javascript to change from the current
display:show/none mechanisms. So my question ends up being :
Is it possible to 'inspect' currently set styles (such as 'display') in
CSS rules ? I'd like to be able to do something similar to the attribute
mechanism where I can do :
A[display='show']~B[display='none']:after {
content : '\a';
}
But just looking at the selectors I don't see how I could accomplish this
without declaring new classes.
Android UI without using classic android UI
Android UI without using classic android UI
I'm starting to learn android development and i learned that to make a GUI
you can use the "android classic UI" (button, textfield...etc).
I was wondering how was the angry birds (or any other "nice looking" UI)
UI was done. I guess they didn't used the "classic android UI"
I just want to know what do they use?
I know a lot of you will get mad at me for asking this kind of question.
Sorry but it's a question that i have in mind for a long time now.
Thank you!
I'm starting to learn android development and i learned that to make a GUI
you can use the "android classic UI" (button, textfield...etc).
I was wondering how was the angry birds (or any other "nice looking" UI)
UI was done. I guess they didn't used the "classic android UI"
I just want to know what do they use?
I know a lot of you will get mad at me for asking this kind of question.
Sorry but it's a question that i have in mind for a long time now.
Thank you!
SELECT Only Records With Duplicate (Column A || Column B) But Different (Column C) Values
SELECT Only Records With Duplicate (Column A || Column B) But Different
(Column C) Values
I apologize for the confusing title, I can't figure out the proper wording
for this question. Instead, I'll just give you the background info and the
goal:
This is in a table where a person may or may not have multiple rows of
data, and those rows may contain the same value for the activity_id, or
may not. Each row has an auto-incremented ID. The people do not have a
unique identifier attached to their names, so we can only use
first_name/last_name to identify a person.
I need to be able to find the people that have multiple rows in this
table, but only the ones who have multiple rows that contain more than one
different activity_id.
Here's a sample of the data we're looking through:
unique_id | first_name | last_name | activity_id
---------------------------------------------------------------
1 | ted | stevens | 544
2 | ted | stevens | 544
3 | ted | stevens | 545
4 | ted | stevens | 546
5 | rachel | jameson | 633
6 | jennifer | tyler | 644
7 | jennifer | tyler | 655
8 | jennifer | tyler | 655
9 | jack | fillion | 544
10 | mallory | taylor | 633
11 | mallory | taylor | 633
From that small sample, here are the records I would want returned:
unique_id | first_name | last_name | activity_id
---------------------------------------------------------------
dontcare | ted | stevens | 544
dontcare | jennifer | tyler | 655
Note that which value of unique_id gets returned is irrelvant, as long as
it's one of the unique_ids belonging to that person, and as long as only
one record is returned for that person.
Can anyone figure out how to write a query like this? I don't care what
version of SQL you use, I can probably translate it into Oracle if it's
somehow different.
(Column C) Values
I apologize for the confusing title, I can't figure out the proper wording
for this question. Instead, I'll just give you the background info and the
goal:
This is in a table where a person may or may not have multiple rows of
data, and those rows may contain the same value for the activity_id, or
may not. Each row has an auto-incremented ID. The people do not have a
unique identifier attached to their names, so we can only use
first_name/last_name to identify a person.
I need to be able to find the people that have multiple rows in this
table, but only the ones who have multiple rows that contain more than one
different activity_id.
Here's a sample of the data we're looking through:
unique_id | first_name | last_name | activity_id
---------------------------------------------------------------
1 | ted | stevens | 544
2 | ted | stevens | 544
3 | ted | stevens | 545
4 | ted | stevens | 546
5 | rachel | jameson | 633
6 | jennifer | tyler | 644
7 | jennifer | tyler | 655
8 | jennifer | tyler | 655
9 | jack | fillion | 544
10 | mallory | taylor | 633
11 | mallory | taylor | 633
From that small sample, here are the records I would want returned:
unique_id | first_name | last_name | activity_id
---------------------------------------------------------------
dontcare | ted | stevens | 544
dontcare | jennifer | tyler | 655
Note that which value of unique_id gets returned is irrelvant, as long as
it's one of the unique_ids belonging to that person, and as long as only
one record is returned for that person.
Can anyone figure out how to write a query like this? I don't care what
version of SQL you use, I can probably translate it into Oracle if it's
somehow different.
Flex-box: Align last row to grid
Flex-box: Align last row to grid
I have a simple flex-box layout with a container like:
.grid {
display: flex;
flex-flow: row wrap;
justify-content: space-between;
}
Now I want the items in the last row to be aligned with the other.
justify-content: space-between; should be used because the width and
height of the grid can be adjusted.
Currently it looks like
Here, I want the item in the bottom right to be in the "middle column".
What is the simplest way to accomplish that? Here is a small jsfiddle that
shows this behaviour.
I have a simple flex-box layout with a container like:
.grid {
display: flex;
flex-flow: row wrap;
justify-content: space-between;
}
Now I want the items in the last row to be aligned with the other.
justify-content: space-between; should be used because the width and
height of the grid can be adjusted.
Currently it looks like
Here, I want the item in the bottom right to be in the "middle column".
What is the simplest way to accomplish that? Here is a small jsfiddle that
shows this behaviour.
Java, Selenium webdriver TestNG "Pls Help Me"
Java, Selenium webdriver TestNG "Pls Help Me"
i have a scenario a single sign on page, before a user can get a full
access to the secure site, they have to request for a one time password
using the request button on the page, the one password is then sent into
their inbox.
First screen user enters username and password and click login then gets
to second screen which they have to request for the one time password
Script will have to sleep and get.url to email, get the password from
email and back to the single sign on page and paste, click on the submit
button and secure page is now displayed.
How do i go about writing this script. i have a pageobject called
LoginPage and Testcase called LoginTest
i have a scenario a single sign on page, before a user can get a full
access to the secure site, they have to request for a one time password
using the request button on the page, the one password is then sent into
their inbox.
First screen user enters username and password and click login then gets
to second screen which they have to request for the one time password
Script will have to sleep and get.url to email, get the password from
email and back to the single sign on page and paste, click on the submit
button and secure page is now displayed.
How do i go about writing this script. i have a pageobject called
LoginPage and Testcase called LoginTest
Convert following class properties into Json format
Convert following class properties into Json format
I need to convert following Employee.cs class in json format,for that i
wrote following code //Employee.cs(In class file)
public class Employee
{
public string Name { get; set; }
public string Job { get; set; }
public string City { get; set; }
}
//In my MyPage.aspx page
Employee oEmployee1 =
new Employee { Name = "Pini", Job = "111", City = "30" };
Employee oEmployee2 =
new Employee { Name = "Yaniv", Job = "Developer", City =
"Hyd" };
Employee oEmployee3 =
new Employee { Name = "Yoni", Job = "Developer", City =
"Bglre" };
List<Employee> oList = new List<Employee>() { oEmployee1,
oEmployee2, oEmployee3 };
System.Web.Script.Serialization.JavaScriptSerializer oSerializer
=new System.Web.Script.Serialization.JavaScriptSerializer();
string sJSON = oSerializer.Serialize(oList);
Response.Write("<pre>"+sJSON+"</pre>");
I got following output:
[{"Name":"Pini","Job":"111","City":"30"},{"Name":"Yaniv","Job":"Developer","City":"Hyd"},{"Name":"Yoni","Job":"Developer","City":"Bglre"}]
Is it any other way to convert to json format more effectively and i want
to beautify json output
Regards Chandu
I need to convert following Employee.cs class in json format,for that i
wrote following code //Employee.cs(In class file)
public class Employee
{
public string Name { get; set; }
public string Job { get; set; }
public string City { get; set; }
}
//In my MyPage.aspx page
Employee oEmployee1 =
new Employee { Name = "Pini", Job = "111", City = "30" };
Employee oEmployee2 =
new Employee { Name = "Yaniv", Job = "Developer", City =
"Hyd" };
Employee oEmployee3 =
new Employee { Name = "Yoni", Job = "Developer", City =
"Bglre" };
List<Employee> oList = new List<Employee>() { oEmployee1,
oEmployee2, oEmployee3 };
System.Web.Script.Serialization.JavaScriptSerializer oSerializer
=new System.Web.Script.Serialization.JavaScriptSerializer();
string sJSON = oSerializer.Serialize(oList);
Response.Write("<pre>"+sJSON+"</pre>");
I got following output:
[{"Name":"Pini","Job":"111","City":"30"},{"Name":"Yaniv","Job":"Developer","City":"Hyd"},{"Name":"Yoni","Job":"Developer","City":"Bglre"}]
Is it any other way to convert to json format more effectively and i want
to beautify json output
Regards Chandu
Tuesday, 10 September 2013
Displaying Message Box using .NET Windows Services In Windows 7
Displaying Message Box using .NET Windows Services In Windows 7
Displaying Message Box using .NET Windows Services In Windows 7
We had a windows service that was used to display a confirmation message
box once a user scanned their access card on windows xp but once we
migrated to windows 7, that pop up functionality no longer works. As
described in this post Displaying Message Box using .NET Windows Services
In Windows 7 , i have followed the instruction and it works when i run the
application as console application but when i install it as a windows
service it does not work. below is my code. Also the result variable is
returning false and the err variable is returning 5.
class Class1
{
public static IntPtr WTS_CURRENT_SERVER_HANDLE = IntPtr.Zero;
public static int WTS_CURRENT_SESSION = -1;
public void test()
{
bool result = false;
string title = "Hello";
int tlen = title.Length;
string msg = "Terminal Service!";
int mlen = msg.Length;
int resp = 0;
result = WTSSendMessage(WTS_CURRENT_SERVER_HANDLE,
WTS_CURRENT_SESSION, title, tlen, msg, mlen, 0, 0, out resp,
true);
int err = Marshal.GetLastWin32Error();
System.Console.WriteLine("result:{0}, errorCode:{1},
response:{2}", result, err, resp);
}
[DllImport("wtsapi32.dll", SetLastError = true)]
static extern bool WTSSendMessage(
IntPtr hServer,
[MarshalAs(UnmanagedType.I4)] int SessionId,
String pTitle,
[MarshalAs(UnmanagedType.U4)] int TitleLength,
String pMessage,
[MarshalAs(UnmanagedType.U4)] int MessageLength,
[MarshalAs(UnmanagedType.U4)] int Style,
[MarshalAs(UnmanagedType.U4)] int Timeout,
[MarshalAs(UnmanagedType.U4)] out int pResponse,
bool bWait);
[DllImport("Kernel32.dll", SetLastError = true)]
static extern int WTSGetActiveConsoleSessionID();
}
Displaying Message Box using .NET Windows Services In Windows 7
We had a windows service that was used to display a confirmation message
box once a user scanned their access card on windows xp but once we
migrated to windows 7, that pop up functionality no longer works. As
described in this post Displaying Message Box using .NET Windows Services
In Windows 7 , i have followed the instruction and it works when i run the
application as console application but when i install it as a windows
service it does not work. below is my code. Also the result variable is
returning false and the err variable is returning 5.
class Class1
{
public static IntPtr WTS_CURRENT_SERVER_HANDLE = IntPtr.Zero;
public static int WTS_CURRENT_SESSION = -1;
public void test()
{
bool result = false;
string title = "Hello";
int tlen = title.Length;
string msg = "Terminal Service!";
int mlen = msg.Length;
int resp = 0;
result = WTSSendMessage(WTS_CURRENT_SERVER_HANDLE,
WTS_CURRENT_SESSION, title, tlen, msg, mlen, 0, 0, out resp,
true);
int err = Marshal.GetLastWin32Error();
System.Console.WriteLine("result:{0}, errorCode:{1},
response:{2}", result, err, resp);
}
[DllImport("wtsapi32.dll", SetLastError = true)]
static extern bool WTSSendMessage(
IntPtr hServer,
[MarshalAs(UnmanagedType.I4)] int SessionId,
String pTitle,
[MarshalAs(UnmanagedType.U4)] int TitleLength,
String pMessage,
[MarshalAs(UnmanagedType.U4)] int MessageLength,
[MarshalAs(UnmanagedType.U4)] int Style,
[MarshalAs(UnmanagedType.U4)] int Timeout,
[MarshalAs(UnmanagedType.U4)] out int pResponse,
bool bWait);
[DllImport("Kernel32.dll", SetLastError = true)]
static extern int WTSGetActiveConsoleSessionID();
}
#EANF#
#EANF#
I'm trying to create an app that will add an additional email account to
the mail app in android. The app is a helpdesk app that makes it easier to
setup IMAP email accounts for technically challenged people. Basically I
want the app to automatically fill in the server, ports, etc where the
user simply puts their username and password and the app will add that
account to the android email account. Is this possible?
I'm trying to create an app that will add an additional email account to
the mail app in android. The app is a helpdesk app that makes it easier to
setup IMAP email accounts for technically challenged people. Basically I
want the app to automatically fill in the server, ports, etc where the
user simply puts their username and password and the app will add that
account to the android email account. Is this possible?
python - How to grep for numbers from log file and do summing
python - How to grep for numbers from log file and do summing
I have a log file with the following strings:
2013-09-10 12:29:06 C9 T3 Update:555 Interfaces: 100 nodes: 0 ports: 0
flows: 106677
2013-09-10 12:30:07 C9 T3 Update:555 Interfaces: 100 nodes: 0 ports: 0
flows: 106281
2013-09-10 12:31:07 C9 T3 Update:555 Interfaces: 100 nodes: 0 ports: 0
flows: 108252
2013-09-10 12:32:06 C9 T3 Update:555 Interfaces: 100 nodes: 0 ports: 0
flows: 106650
2013-09-10 12:33:05 C9 T3 Update:555 Interfaces: 100 nodes: 0 ports: 0
flows: 49734
I would like to write a script to read through the file and grep only for
the # of flows (e.g. 106677) and then do a sum on them. Any ideas on best
approach? I should first try to strip only the # of flows and write to a
file and then do sum?
I have a log file with the following strings:
2013-09-10 12:29:06 C9 T3 Update:555 Interfaces: 100 nodes: 0 ports: 0
flows: 106677
2013-09-10 12:30:07 C9 T3 Update:555 Interfaces: 100 nodes: 0 ports: 0
flows: 106281
2013-09-10 12:31:07 C9 T3 Update:555 Interfaces: 100 nodes: 0 ports: 0
flows: 108252
2013-09-10 12:32:06 C9 T3 Update:555 Interfaces: 100 nodes: 0 ports: 0
flows: 106650
2013-09-10 12:33:05 C9 T3 Update:555 Interfaces: 100 nodes: 0 ports: 0
flows: 49734
I would like to write a script to read through the file and grep only for
the # of flows (e.g. 106677) and then do a sum on them. Any ideas on best
approach? I should first try to strip only the # of flows and write to a
file and then do sum?
C error: lvalue required as unary '&' operand
C error: lvalue required as unary '&' operand
I have a code error but not sure what's wrong with my casting and reference.
BOOL xMBPortSerialPutByte( CHAR ucByte )
{
CDC_Send_DATA(&((unsigned char)ucByte), 1); // code error here
xMBPortEventPost(EV_FRAME_SENT);
return TRUE;
}
The CDC_Send_DATA is defined as the following:
uint32_t CDC_Send_DATA (uint8_t *ptrBuffer, uint8_t Send_length);
Here is the error message:
port/portserial.c:139:19: error: lvalue required as unary '&' operand
Hope someone could help. Thanks!
I have a code error but not sure what's wrong with my casting and reference.
BOOL xMBPortSerialPutByte( CHAR ucByte )
{
CDC_Send_DATA(&((unsigned char)ucByte), 1); // code error here
xMBPortEventPost(EV_FRAME_SENT);
return TRUE;
}
The CDC_Send_DATA is defined as the following:
uint32_t CDC_Send_DATA (uint8_t *ptrBuffer, uint8_t Send_length);
Here is the error message:
port/portserial.c:139:19: error: lvalue required as unary '&' operand
Hope someone could help. Thanks!
Adding multiple columns to MySQL table using PHP loop
Adding multiple columns to MySQL table using PHP loop
My objective
To add a number of columns to a MySQL table. I have two concerns:
1) How to do this
2) Is this a bad idea, and if so why?
My reason for wanting to do this:
I have a form with a systematically named set of fields (e.g. field_1
field_2 etc). I want to post that data to a page and have it store it the
mysql table, and I would like the fields to enter columns of a
corresponding name (i.e. columns are named field_1 field_2 etc)
Rather than manually creating a column for each field name manually, it
seemed obvious to loop the task.
However, research here and here seems tells me this approach illicits
horror from people, and I found no actual solutions.
My attempt:
$mysqli = new mysqli("localhost","user","password","db");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$i = 1;
while ($i <= 14)
{
$column = 'field_'.$i;
$sql= '"ALTER TABLE supply ADD '.$column.' VARCHAR(45)"';
$mysqli->query($sql);
printf("Affected rows (ALTER): %d\n", $mysqli->affected_rows);
$i++;
}
This seems to run without error, however the affected rows message gives
me (per loop, so 14 of these):
Affected rows (ALTER): -1
and the columns are not being added.
Can anyone advise me of my error, or a better way to debug what is going
wrong? Additionally if this is an unwise thing to be doing could could you
explain why and what I should consider doing instead? Thank you.
My objective
To add a number of columns to a MySQL table. I have two concerns:
1) How to do this
2) Is this a bad idea, and if so why?
My reason for wanting to do this:
I have a form with a systematically named set of fields (e.g. field_1
field_2 etc). I want to post that data to a page and have it store it the
mysql table, and I would like the fields to enter columns of a
corresponding name (i.e. columns are named field_1 field_2 etc)
Rather than manually creating a column for each field name manually, it
seemed obvious to loop the task.
However, research here and here seems tells me this approach illicits
horror from people, and I found no actual solutions.
My attempt:
$mysqli = new mysqli("localhost","user","password","db");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$i = 1;
while ($i <= 14)
{
$column = 'field_'.$i;
$sql= '"ALTER TABLE supply ADD '.$column.' VARCHAR(45)"';
$mysqli->query($sql);
printf("Affected rows (ALTER): %d\n", $mysqli->affected_rows);
$i++;
}
This seems to run without error, however the affected rows message gives
me (per loop, so 14 of these):
Affected rows (ALTER): -1
and the columns are not being added.
Can anyone advise me of my error, or a better way to debug what is going
wrong? Additionally if this is an unwise thing to be doing could could you
explain why and what I should consider doing instead? Thank you.
How to change form default button?
How to change form default button?
I have input fields inside the form as follows:
<h:inputText binding="#{MyBean.text1}" />
<h:inputText binding="#{MyBean.text2}" />
<h:inputText binding="#{MyBean.text3}" />
<h:inputText binding="#{MyBean.text4}" />
<h:inputText binding="#{MyBean.text5}" />
<h:inputText binding="#{MyBean.text6}" />
<h:inputText binding="#{MyBean.text7}" />
<h:commandButton value="search1" action="#{MyBean.search1}"
onclick="return validate();"></h:commandButton>
<h:selectOneListbox binding="#{MyBean.cboDepartment}" id="cboDepartment">
<f:selectItems binding="#{MyBean.cboDepartmentSelectItems}"
id="cboDepartmentSelectItems"
value="#{MyBean.cboDepartmentDefaultItems}" />
</h:selectOneListbox>
<h:commandButton value="search2" action="#{MyBean.search2}"
onclick="return validate2();"></h:commandButton>
Now when the user clicks enter in the input text is that the first button
action is fired, and i want to make the second button action fired without
changing the style i tried to handle the keyup event in each input but it
won't work, any ideas how to do that ?
I have input fields inside the form as follows:
<h:inputText binding="#{MyBean.text1}" />
<h:inputText binding="#{MyBean.text2}" />
<h:inputText binding="#{MyBean.text3}" />
<h:inputText binding="#{MyBean.text4}" />
<h:inputText binding="#{MyBean.text5}" />
<h:inputText binding="#{MyBean.text6}" />
<h:inputText binding="#{MyBean.text7}" />
<h:commandButton value="search1" action="#{MyBean.search1}"
onclick="return validate();"></h:commandButton>
<h:selectOneListbox binding="#{MyBean.cboDepartment}" id="cboDepartment">
<f:selectItems binding="#{MyBean.cboDepartmentSelectItems}"
id="cboDepartmentSelectItems"
value="#{MyBean.cboDepartmentDefaultItems}" />
</h:selectOneListbox>
<h:commandButton value="search2" action="#{MyBean.search2}"
onclick="return validate2();"></h:commandButton>
Now when the user clicks enter in the input text is that the first button
action is fired, and i want to make the second button action fired without
changing the style i tried to handle the keyup event in each input but it
won't work, any ideas how to do that ?
Custom segue not working
Custom segue not working
I am trying to use a custom transition. I want a "cover vertical"
transition from View Controller 1 to 2 and then have View Controller 2
(the middle one) slide back down again when moving to View Controller 3.
Storyboard shown below:
http://i.stack.imgur.com/bJYXI.png
Im using the tutorial that is linked to from this post. And have also
replaced the .m code with the code provided in the answer:
Xcode custom segue - Opposite of Cover Vertical (top to bottom) - COMPLETE
NEWBIE
I have created a subclass of UIViewController and named it
FromTopReplaceSegue. My .h and .m code is shown below:
.h
#import <UIKit/UIKit.h>
@interface FromTopReplaceSegue : UIViewController
@property(nonatomic, readonly) id sourceViewController;
@property(nonatomic, readonly) id destinationViewController;
@end
.m
#import "FromTopReplaceSegue.h"
@interface FromTopReplaceSegue ()
@end
@implementation FromTopReplaceSegue
-(void)perform{
UIViewController *sourceViewController = (UIViewController *)
self.sourceViewController;
UIViewController *destinationViewController = (UIViewController *)
self.destinationViewController;
[sourceViewController.view addSubview:destinationViewController.view];
[destinationViewController.view
setFrame:sourceViewController.view.window.frame];
[destinationViewController.view
setTransform:CGAffineTransformMakeTranslation(0,
-sourceViewController.view.frame.size.height)];
[destinationViewController.view setAlpha:1.0];
[UIView animateWithDuration:0.75
delay:0.0
options:UIViewAnimationOptionTransitionFlipFromTop
animations:^{
[destinationViewController.view
setTransform:CGAffineTransformMakeTranslation(0,
0)];
[destinationViewController.view setAlpha:1.0];
}
completion:^(BOOL finished){
[destinationViewController.view
removeFromSuperview];
[sourceViewController
presentViewController:destinationViewController
animated:NO completion:nil];
}];}
@end
When i try to run the simulator i can easily get from Controller View 1 to
2 but it crashes when i try to move from Controller view 2 to 3 using the
custom segue.
Can anyone help.
Thank you so much in advance! Struggling here! :)
I am trying to use a custom transition. I want a "cover vertical"
transition from View Controller 1 to 2 and then have View Controller 2
(the middle one) slide back down again when moving to View Controller 3.
Storyboard shown below:
http://i.stack.imgur.com/bJYXI.png
Im using the tutorial that is linked to from this post. And have also
replaced the .m code with the code provided in the answer:
Xcode custom segue - Opposite of Cover Vertical (top to bottom) - COMPLETE
NEWBIE
I have created a subclass of UIViewController and named it
FromTopReplaceSegue. My .h and .m code is shown below:
.h
#import <UIKit/UIKit.h>
@interface FromTopReplaceSegue : UIViewController
@property(nonatomic, readonly) id sourceViewController;
@property(nonatomic, readonly) id destinationViewController;
@end
.m
#import "FromTopReplaceSegue.h"
@interface FromTopReplaceSegue ()
@end
@implementation FromTopReplaceSegue
-(void)perform{
UIViewController *sourceViewController = (UIViewController *)
self.sourceViewController;
UIViewController *destinationViewController = (UIViewController *)
self.destinationViewController;
[sourceViewController.view addSubview:destinationViewController.view];
[destinationViewController.view
setFrame:sourceViewController.view.window.frame];
[destinationViewController.view
setTransform:CGAffineTransformMakeTranslation(0,
-sourceViewController.view.frame.size.height)];
[destinationViewController.view setAlpha:1.0];
[UIView animateWithDuration:0.75
delay:0.0
options:UIViewAnimationOptionTransitionFlipFromTop
animations:^{
[destinationViewController.view
setTransform:CGAffineTransformMakeTranslation(0,
0)];
[destinationViewController.view setAlpha:1.0];
}
completion:^(BOOL finished){
[destinationViewController.view
removeFromSuperview];
[sourceViewController
presentViewController:destinationViewController
animated:NO completion:nil];
}];}
@end
When i try to run the simulator i can easily get from Controller View 1 to
2 but it crashes when i try to move from Controller view 2 to 3 using the
custom segue.
Can anyone help.
Thank you so much in advance! Struggling here! :)
How to make instant search within wordpress posts?
How to make instant search within wordpress posts?
Today I need to start something special on my website.
I want to create an INSTANT SEARCH which will search within my posts.
A good example is this one: http://stackoverflow.com/users
Another one is: https://sublime.wbond.net/
I don't know from where to start. Any suggestions will be awesome.
PS: I don't need to use any wordpress plugin.
Today I need to start something special on my website.
I want to create an INSTANT SEARCH which will search within my posts.
A good example is this one: http://stackoverflow.com/users
Another one is: https://sublime.wbond.net/
I don't know from where to start. Any suggestions will be awesome.
PS: I don't need to use any wordpress plugin.
Monday, 9 September 2013
Editable text view with spinner android
Editable text view with spinner android
I want to create a control in android where user can input through
keyboard or enter through drop down list(spinner).
Actually the values I hard code in array in spinner is not exhaustive, so
user should have the option to input through virtual keyboard also.
So Either user can enter through keyboard or select from list?
How can i achieve this in android?
I want to create a control in android where user can input through
keyboard or enter through drop down list(spinner).
Actually the values I hard code in array in spinner is not exhaustive, so
user should have the option to input through virtual keyboard also.
So Either user can enter through keyboard or select from list?
How can i achieve this in android?
Let Statement/Random Function in Scheme
Let Statement/Random Function in Scheme
I was wondering if I would be able to use the built in let function from
scheme to define two random variables within the function without their
values changing throughout the code. For example if I wrote:
(let (x (- (* 2 (random)) 1)))
(let (y (- (* 2 (random)) 1)))
Would the value of x be constant until the function exits? I want to
square x and y and take the square root of them, but I need their values
to remain the same.
I was wondering if I would be able to use the built in let function from
scheme to define two random variables within the function without their
values changing throughout the code. For example if I wrote:
(let (x (- (* 2 (random)) 1)))
(let (y (- (* 2 (random)) 1)))
Would the value of x be constant until the function exits? I want to
square x and y and take the square root of them, but I need their values
to remain the same.
Is there any way of getting the parent from the child nsArraycontroller?
Is there any way of getting the parent from the child nsArraycontroller?
using cocoa bindings, i have bound to the following:
ChildArrayController
ContentSet
bindto: ParentArrayController
controllerkey: selection
modelkeypath: children
Is there any way of getting the parent from the child controller?
[childArrayController arrangedObjects] is the children.
[childArrayController selectedObjects] is the selected children.
[childArrayController content] is an array
[childArrayController selection] is a proxy for the selected child.
I want to do something like id parent = [childArrayController xxx];
using cocoa bindings, i have bound to the following:
ChildArrayController
ContentSet
bindto: ParentArrayController
controllerkey: selection
modelkeypath: children
Is there any way of getting the parent from the child controller?
[childArrayController arrangedObjects] is the children.
[childArrayController selectedObjects] is the selected children.
[childArrayController content] is an array
[childArrayController selection] is a proxy for the selected child.
I want to do something like id parent = [childArrayController xxx];
Subscribe to:
Comments (Atom)