Click on NSBezierPath
I'm drawing a NSBezierPath line on my NSImageView. I'm creating
NSBezierPath object, setting moveToPoint, setting lineToPoint, setting
setLineWidth: and after that in drawRect of my NSImageView subclass I'm
calling [myNSBezierPath stroke]. It all works just like I want, but I
can't seem to use containsPoint: method... I tried implementing
if([myNSBezierPath containsPoint:[theEvent locationInWindow]]{
//do something
}
in -(void)mouseUp:(NSEvent*)theEvent of my NSImageView subclass but it's
never reacting and I'm sure I'm hitting that line... Am I doing something
wrong? I just need to detect if NSBezierPath is being clicked.
Cheers.
Saturday, 31 August 2013
How to free Watch Henderson vs Pettis live streaming UFC?
How to free Watch Henderson vs Pettis live streaming UFC?
Watch UFC live Fighting Click Here To: Watch Henderson vs Pettis
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
Henderson vs Pettis Live Fight DETAILS Date : Saturday, August 31, 2013
Competition: UFC MMA Major Events live Live / Repeat:Live 10:00pm ET
Watch UFC live Fighting Click Here To: Watch Henderson vs Pettis
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
Henderson vs Pettis Live Fight DETAILS Date : Saturday, August 31, 2013
Competition: UFC MMA Major Events live Live / Repeat:Live 10:00pm ET
I can't get the html form to run a php script
I can't get the html form to run a php script
I'm just trying to get this simple php file to work:
<html>
<head>
<title>Aarons Editor</title>
</head>
<body>
<form action="index.php" method="get">
<select name="page">
<option value="default"> </option>
<option value="file">File</option>
</select>
<input type="submit">
</form>
<?php
if (page == $_GET['file']){
echo "<h1>File</h1>";
}
else {
echo "<h1>not file</h1>";
}
}
?>
</body>
</html>
Also, I can't figure out how to call a specific function in a form.
I'm just trying to get this simple php file to work:
<html>
<head>
<title>Aarons Editor</title>
</head>
<body>
<form action="index.php" method="get">
<select name="page">
<option value="default"> </option>
<option value="file">File</option>
</select>
<input type="submit">
</form>
<?php
if (page == $_GET['file']){
echo "<h1>File</h1>";
}
else {
echo "<h1>not file</h1>";
}
}
?>
</body>
</html>
Also, I can't figure out how to call a specific function in a form.
Mouseout not working on Android webpage
Mouseout not working on Android webpage
I am trying to rewrite my webpages to display properly on a smartphone. In
my testing I cannot get a dropdown menu to disappear when the mouse moves
out of the div of the dropdown menu. Below is my code:
<script type="text/javascript">
function expandMenu() {
document.getElementById("moreMenu").style.display = "block";
}
function hideMenu() {
document.getElementById("moreMenu").style.display = "none";
}
</script>
.......
<div class="medianfont"><a href="news/pastnews.aspx">News -
</a><a href="email.aspx"> Email - </a><a
href="pastedit.aspx">Editorials - </a>
<span style="cursor:pointer; color:blue" onclick="expandMenu()">
More</span><br />
<div id="moreMenu" style="display:none; margin-left:14em;"
onmouseout="hideMenu()" onclick="hideMenu()">
<a href="histart.htm">History </a><br />
<a href="calendar.aspx">Events </a><br />
</div>
</div>
It works ok when testing on my desktop but in testing on my Android phone,
the dropdown menu will appear but no amount of clicking will make it go
away even though the links do work. So is there a way to get a dropdown
menu to disappear on a smartphone similar to a desktop? I am not coding in
Android, I am merely displaying the webpage on a smartphone.
I am trying to rewrite my webpages to display properly on a smartphone. In
my testing I cannot get a dropdown menu to disappear when the mouse moves
out of the div of the dropdown menu. Below is my code:
<script type="text/javascript">
function expandMenu() {
document.getElementById("moreMenu").style.display = "block";
}
function hideMenu() {
document.getElementById("moreMenu").style.display = "none";
}
</script>
.......
<div class="medianfont"><a href="news/pastnews.aspx">News -
</a><a href="email.aspx"> Email - </a><a
href="pastedit.aspx">Editorials - </a>
<span style="cursor:pointer; color:blue" onclick="expandMenu()">
More</span><br />
<div id="moreMenu" style="display:none; margin-left:14em;"
onmouseout="hideMenu()" onclick="hideMenu()">
<a href="histart.htm">History </a><br />
<a href="calendar.aspx">Events </a><br />
</div>
</div>
It works ok when testing on my desktop but in testing on my Android phone,
the dropdown menu will appear but no amount of clicking will make it go
away even though the links do work. So is there a way to get a dropdown
menu to disappear on a smartphone similar to a desktop? I am not coding in
Android, I am merely displaying the webpage on a smartphone.
Retrieve element from array in Coldfusion
Retrieve element from array in Coldfusion
I get the following struct return from disqus.com API and I just don't
know how to retrieve only the following value in red using Coldfusion.
This is the full array returned.
{
"cursor":{
"prev":null,
"hasNext":false,
"next":"1213061503000000:1:0",
"hasPrev":false,
"total":null,
"id":"1213061503000000:1:0",
"more":false
},
"code":0,
"response":[
{
"category":"1",
"reactions":0,
"identifiers":[],
"forum":"bobross",
"title":"Donkeys live a long time",
"dislikes":0,
"isDeleted":false,
"author":"1",
"userScore":0,
"id":"2",
"isClosed":false,
"posts":0,
"link":null,
"likes":0,
"message":"\"Donkeys live a long time. None of you have ever seen a
dead donkey.\"",
"ipAddress":"127.0.0.1",
"slug":"donkeys_live_a_long_time",
"createdAt":"2008-06-10T02:31:43"
},
{
"category":"1",
"reactions":0,
"identifiers":[
"my-identifier"
],
"forum":"bobross",
"title":"Happy Accidents",
"dislikes":0,
"isDeleted":false,
"author":"1",
"userScore":0,
"id":"1",
"isClosed":false,
"posts":76,
"link":null,
"likes":0,
"message":"\"If you've painted before you know that we don't make
mistakes -- we have happy accidents.\"",
"ipAddress":"127.0.0.1",
"slug":"happy_accidents",
"createdAt":"2008-06-10T01:31:43"
}
]
}
I get the following struct return from disqus.com API and I just don't
know how to retrieve only the following value in red using Coldfusion.
This is the full array returned.
{
"cursor":{
"prev":null,
"hasNext":false,
"next":"1213061503000000:1:0",
"hasPrev":false,
"total":null,
"id":"1213061503000000:1:0",
"more":false
},
"code":0,
"response":[
{
"category":"1",
"reactions":0,
"identifiers":[],
"forum":"bobross",
"title":"Donkeys live a long time",
"dislikes":0,
"isDeleted":false,
"author":"1",
"userScore":0,
"id":"2",
"isClosed":false,
"posts":0,
"link":null,
"likes":0,
"message":"\"Donkeys live a long time. None of you have ever seen a
dead donkey.\"",
"ipAddress":"127.0.0.1",
"slug":"donkeys_live_a_long_time",
"createdAt":"2008-06-10T02:31:43"
},
{
"category":"1",
"reactions":0,
"identifiers":[
"my-identifier"
],
"forum":"bobross",
"title":"Happy Accidents",
"dislikes":0,
"isDeleted":false,
"author":"1",
"userScore":0,
"id":"1",
"isClosed":false,
"posts":76,
"link":null,
"likes":0,
"message":"\"If you've painted before you know that we don't make
mistakes -- we have happy accidents.\"",
"ipAddress":"127.0.0.1",
"slug":"happy_accidents",
"createdAt":"2008-06-10T01:31:43"
}
]
}
How to capture size of an API response in Rails?
How to capture size of an API response in Rails?
I want to capture the size of responses being made by the API of my Rails
3 app.
The idea is that if a client application requests a resource, the full
size of the JSON response (in KB/MB, after RABL renders it) can be
captured and stored, so that I can see how much data the client
application is using later. Because they are exceptionally large, some of
these API JSON responses are cached (locally for now, on Redis in the near
future), so the solution needs to be able to capture the size of cached
responses, not just rendered ones.
What is the best method and place for accomplishing this in Rails? On the
Rack level? In the controller (the controllers use
ActionController::Metal)? Obviously, the less overhead this puts on
response times, the better.
I want to capture the size of responses being made by the API of my Rails
3 app.
The idea is that if a client application requests a resource, the full
size of the JSON response (in KB/MB, after RABL renders it) can be
captured and stored, so that I can see how much data the client
application is using later. Because they are exceptionally large, some of
these API JSON responses are cached (locally for now, on Redis in the near
future), so the solution needs to be able to capture the size of cached
responses, not just rendered ones.
What is the best method and place for accomplishing this in Rails? On the
Rack level? In the controller (the controllers use
ActionController::Metal)? Obviously, the less overhead this puts on
response times, the better.
Load images in jar file
Load images in jar file
I'm trying to load an image from an executable JAR file.
I've followed the information from here, then the information from here.
This is the function to retrieve the images:
public static ImageIcon loadImage(String fileName, Object o) {
BufferedImage buff = null;
try {
buff = ImageIO.read(o.getClass().getResource(fileName));
// Also tried getResourceAsStream
} catch (IOException e) {
e.printStackTrace();
return null;
}
if (buff == null) {
System.out.println("Image Null");
return null;
}
return new ImageIcon(buff);
}
And this is how it's being called:
logo = FileConverter.loadImage("/pictures/Logo1.png", this);
JFrame.setIconImage(logo.getImage());
With this being a simple Object. I'm also not getting a
NullPointerException unless it is being masked by the UI.
I checked the JAR file and the image is at:
/pictures/Logo1.png
This current code works both in eclipse and when it's been exported to a
JAR and run in a terminal, but doesn't work when the JAR is double
clicked, in which case the icon is the default JFrame icon.
Thanks for you're help. It's probably only me missing something obvious.
I'm trying to load an image from an executable JAR file.
I've followed the information from here, then the information from here.
This is the function to retrieve the images:
public static ImageIcon loadImage(String fileName, Object o) {
BufferedImage buff = null;
try {
buff = ImageIO.read(o.getClass().getResource(fileName));
// Also tried getResourceAsStream
} catch (IOException e) {
e.printStackTrace();
return null;
}
if (buff == null) {
System.out.println("Image Null");
return null;
}
return new ImageIcon(buff);
}
And this is how it's being called:
logo = FileConverter.loadImage("/pictures/Logo1.png", this);
JFrame.setIconImage(logo.getImage());
With this being a simple Object. I'm also not getting a
NullPointerException unless it is being masked by the UI.
I checked the JAR file and the image is at:
/pictures/Logo1.png
This current code works both in eclipse and when it's been exported to a
JAR and run in a terminal, but doesn't work when the JAR is double
clicked, in which case the icon is the default JFrame icon.
Thanks for you're help. It's probably only me missing something obvious.
deleting sms from inbox
deleting sms from inbox
Hi I am developing an android SMS app where I am deleting messages based
on _id using below code :
getContentResolver().delete(Uri.parse("content://sms/" + id),"address=?
and date=?",null);
This is working fine on some phones. But on Samsung phones the oldest
message is getting deleted. And I don't want that to happen. I want to
delete particular Sms on touch. How can I do it. Please Help.Thanks!
Hi I am developing an android SMS app where I am deleting messages based
on _id using below code :
getContentResolver().delete(Uri.parse("content://sms/" + id),"address=?
and date=?",null);
This is working fine on some phones. But on Samsung phones the oldest
message is getting deleted. And I don't want that to happen. I want to
delete particular Sms on touch. How can I do it. Please Help.Thanks!
Friday, 30 August 2013
converting StringBuilder variable to html in textview
converting StringBuilder variable to html in textview
i'm reading the textfile(html tag file) in android and i trying to convert
it into html. i'm getting error when i setText in textView(output).. The
method setText(String, TextView.BufferType) is undefined for the type
StringBuffer how to change StringBuilder to String to get ouput...
String s = "";
StringBuilder str=null;
while ((s = buffer.readLine()) != null){
str.append(s+"/n");}
String a=str.toString().trim();
Spanned marked_up = Html.fromHtml(a);
output.setText((marked_up).toString(),BufferType.SPANNABLE);
plz help ...
i'm reading the textfile(html tag file) in android and i trying to convert
it into html. i'm getting error when i setText in textView(output).. The
method setText(String, TextView.BufferType) is undefined for the type
StringBuffer how to change StringBuilder to String to get ouput...
String s = "";
StringBuilder str=null;
while ((s = buffer.readLine()) != null){
str.append(s+"/n");}
String a=str.toString().trim();
Spanned marked_up = Html.fromHtml(a);
output.setText((marked_up).toString(),BufferType.SPANNABLE);
plz help ...
How can I make Xcode complete correct types?
How can I make Xcode complete correct types?
I do
UIImageView *bg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0,
250, 250)];
bg.image = [UIImageView]
the UIImageView is autocompleted.
This is one of many examples. How can I customize autocomplete to be more
intelligent?
I do
UIImageView *bg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0,
250, 250)];
bg.image = [UIImageView]
the UIImageView is autocompleted.
This is one of many examples. How can I customize autocomplete to be more
intelligent?
Thursday, 29 August 2013
SQL Select - Some Rows Won't Display
SQL Select - Some Rows Won't Display
I have two tables. One of them named files and there is al list of all
files. the second table called payments, and there is in there a list of
payments for some files.
Payments:
id | fileid | {...}
1 2
2 3
3 2
Files:
id | {...}
1
2
3
I want to select all files, and join the table payments to order by count
of this table.
In this case, the first row will be file #2, because it repeats the most
in the payments table.
I tried to do it, but when I do it - not all of the rows are shown!
I think it happens because not all of the files are in the payments table.
So in this case, I think that it won't display the first row.
Thanks, and sorry for my English
P.S: I use mysql engine
** UPDATE ** My Code:
SELECT
`id`,`name`,`size`,`downloads`,`upload_date`,`server_ip`,COUNT(`uploadid`)
AS numProfits
FROM `uploads`
JOIN `profits`
ON `uploads`.`id` = `profits`.`uploadid`
WHERE `uploads`.`userid` = 1
AND `removed` = 0
ORDER BY numProfits
I have two tables. One of them named files and there is al list of all
files. the second table called payments, and there is in there a list of
payments for some files.
Payments:
id | fileid | {...}
1 2
2 3
3 2
Files:
id | {...}
1
2
3
I want to select all files, and join the table payments to order by count
of this table.
In this case, the first row will be file #2, because it repeats the most
in the payments table.
I tried to do it, but when I do it - not all of the rows are shown!
I think it happens because not all of the files are in the payments table.
So in this case, I think that it won't display the first row.
Thanks, and sorry for my English
P.S: I use mysql engine
** UPDATE ** My Code:
SELECT
`id`,`name`,`size`,`downloads`,`upload_date`,`server_ip`,COUNT(`uploadid`)
AS numProfits
FROM `uploads`
JOIN `profits`
ON `uploads`.`id` = `profits`.`uploadid`
WHERE `uploads`.`userid` = 1
AND `removed` = 0
ORDER BY numProfits
Get index of empty space returns wrong value
Get index of empty space returns wrong value
In JS I have a text line and I want to get the index of the first
occurrence of an empty space.
For example, this is my line:
gram somethin b
And this is my code:
index = line.indexOf(" ");
if (index == -1)
index = line.indexOf("\u00a0");
The problem here is that the result of the code is 13, but it should be 4.
Why doesnt it recognize the empty space after 'gram' as empty space? How
can I check?
In JS I have a text line and I want to get the index of the first
occurrence of an empty space.
For example, this is my line:
gram somethin b
And this is my code:
index = line.indexOf(" ");
if (index == -1)
index = line.indexOf("\u00a0");
The problem here is that the result of the code is 13, but it should be 4.
Why doesnt it recognize the empty space after 'gram' as empty space? How
can I check?
Wednesday, 28 August 2013
Can't get AppWidget Size... Can I get a child view's size?
Can't get AppWidget Size... Can I get a child view's size?
Doing some research it seems there is no way to get the size of a widget
(I have no idea why that is!!!). So I had an idea, is it possible to get
the size of one of its children views by using RemoteViews? The child (an
ImageView) is set to fill_parent for it's layout_width and layout_height
properties. So theoretically that would be the size of the widget, but
more importantly the size I actually need. I looked through RemoteView's
methods and didn't see anything particularly useful, did I miss something?
Am I at least on the right track?
The reason I need to know the size is because I'm using a custom font, so
I need to draw to a bitmap and place that in an ImageView. I need to know
the size so I can draw the text correctly.
Doing some research it seems there is no way to get the size of a widget
(I have no idea why that is!!!). So I had an idea, is it possible to get
the size of one of its children views by using RemoteViews? The child (an
ImageView) is set to fill_parent for it's layout_width and layout_height
properties. So theoretically that would be the size of the widget, but
more importantly the size I actually need. I looked through RemoteView's
methods and didn't see anything particularly useful, did I miss something?
Am I at least on the right track?
The reason I need to know the size is because I'm using a custom font, so
I need to draw to a bitmap and place that in an ImageView. I need to know
the size so I can draw the text correctly.
Efficient way of reading part of a file into an std::vector?
Efficient way of reading part of a file into an std::vector?
Refering to this question: Efficient way of reading a file into an
std::vector<char>? I need a function that does the followig thing:
void readFromFile( std::vector< unsigned char >& buffer,
string filename,
size_t offset, size_t count );
so the function read from the file from offset to offset + count into vector;
void readFromFile( std::vector< unsigned char >& buffer,
string filename,
size_t offset, size_t count )
{
// get file size and reallocate the buffer
size_t fsize = filesize( filename );
buffer.reserve( buffer.size() + size );
// open the file
ifstream file( filename );
// first way
file.seekg( offset );
file.read( ???? )
// second way
istreambuf_iterator< unsigned char > from( file );
istreambuf_iterator< unsigned char > eof;
advance( from, offset );
copy( from, eof, back_inserter( buffer );
}
In the first way I don't know how to read the file at once. In the second
way the read operation is quite slow because I read byte per byte.
Are better alternatives?
Refering to this question: Efficient way of reading a file into an
std::vector<char>? I need a function that does the followig thing:
void readFromFile( std::vector< unsigned char >& buffer,
string filename,
size_t offset, size_t count );
so the function read from the file from offset to offset + count into vector;
void readFromFile( std::vector< unsigned char >& buffer,
string filename,
size_t offset, size_t count )
{
// get file size and reallocate the buffer
size_t fsize = filesize( filename );
buffer.reserve( buffer.size() + size );
// open the file
ifstream file( filename );
// first way
file.seekg( offset );
file.read( ???? )
// second way
istreambuf_iterator< unsigned char > from( file );
istreambuf_iterator< unsigned char > eof;
advance( from, offset );
copy( from, eof, back_inserter( buffer );
}
In the first way I don't know how to read the file at once. In the second
way the read operation is quite slow because I read byte per byte.
Are better alternatives?
Difference between "as $key => $value" and "as $value" in PHP foreach
Difference between "as $key => $value" and "as $value" in PHP foreach
I have a database call and I'm trying to figure out what the $key =>
$value does in a foreach loop.
The reason I ask is because both these codes output the same thing, so I'm
trying to understand why it's written this way. Here's the code:
foreach($featured as $key => $value){
echo $value['name'];
}
this outputs the same as:
foreach($featured as $value) {
echo $value['name']
}
So my question is, what is the difference between $key => $value or just
$value in the foreach loop. The array is multidimensional if that makes a
difference, I just want to know why to pass $key to $value in the foreach
loop.
I have a database call and I'm trying to figure out what the $key =>
$value does in a foreach loop.
The reason I ask is because both these codes output the same thing, so I'm
trying to understand why it's written this way. Here's the code:
foreach($featured as $key => $value){
echo $value['name'];
}
this outputs the same as:
foreach($featured as $value) {
echo $value['name']
}
So my question is, what is the difference between $key => $value or just
$value in the foreach loop. The array is multidimensional if that makes a
difference, I just want to know why to pass $key to $value in the foreach
loop.
Making a sequential list of files
Making a sequential list of files
I have been stuck on a problem for a while now and can't seem to find an
answer. I'm trying to create multiple files with the same name but a
different number at the end each time, I have attempted this at first just
by using
int seq_number = 1;
while (seq_number < 10)
{
ofstream fsave;
fsave.open("filename" + seq_number + ".txt");
fsave << "blablabla";
fsave.close();
seq_number = seq_number + 1;
}
But that gives me a very strange result where the letters get jumbled up,
I'm not sure how that works but I know it doesn't.
I've looked online and found stringstream or sstream, and tried with that,
but it keeps giving me errors too,
string filename;
filename = "character";
ostringstream s;
s << filename << seq_number;
filename(s.str());
fsave.open(filename + ".txt");
fsave << "blabla"
fsave.close(;)
but i keep getting an error:
no match for call to `(std::string) (std::basic_string, std::allocator >)'
I'm not sure how string stream works exactly so im working off of
instinct, but i would appreciate any way this is possible, and honestly I
think I would prefer doing it without sstream, but i need a way to get an
int and str together and save a filename that is a string. unless you know
a better way ;) thanks guys
I have been stuck on a problem for a while now and can't seem to find an
answer. I'm trying to create multiple files with the same name but a
different number at the end each time, I have attempted this at first just
by using
int seq_number = 1;
while (seq_number < 10)
{
ofstream fsave;
fsave.open("filename" + seq_number + ".txt");
fsave << "blablabla";
fsave.close();
seq_number = seq_number + 1;
}
But that gives me a very strange result where the letters get jumbled up,
I'm not sure how that works but I know it doesn't.
I've looked online and found stringstream or sstream, and tried with that,
but it keeps giving me errors too,
string filename;
filename = "character";
ostringstream s;
s << filename << seq_number;
filename(s.str());
fsave.open(filename + ".txt");
fsave << "blabla"
fsave.close(;)
but i keep getting an error:
no match for call to `(std::string) (std::basic_string, std::allocator >)'
I'm not sure how string stream works exactly so im working off of
instinct, but i would appreciate any way this is possible, and honestly I
think I would prefer doing it without sstream, but i need a way to get an
int and str together and save a filename that is a string. unless you know
a better way ;) thanks guys
Isis 3 using MRO CTX Imagery (Mars)
Isis 3 using MRO CTX Imagery (Mars)
I have downloaded a selection of MRO Context Camera images from the NASA
PDS website (in .img format), but when trying to convert them to ISIS
files with the mroctx2isis command, I get this error:
I/O ERROR Unable to open
[/home/psxjs6/Software/Isis3/isis/../data/mro/translations/mroctxInstrument.trn]
When I check in the Isis3 directory for the 'mroctxIntrument.trn' file, it
is not there, any suggestions?
James
I have downloaded a selection of MRO Context Camera images from the NASA
PDS website (in .img format), but when trying to convert them to ISIS
files with the mroctx2isis command, I get this error:
I/O ERROR Unable to open
[/home/psxjs6/Software/Isis3/isis/../data/mro/translations/mroctxInstrument.trn]
When I check in the Isis3 directory for the 'mroctxIntrument.trn' file, it
is not there, any suggestions?
James
Is Encrpyting Home Sufficient=?iso-8859-1?Q?=3F_=96_security.stackexchange.com?=
Is Encrpyting Home Sufficient? – security.stackexchange.com
I currently have a fully encrypted Windows System, and I'm looking at
switching to Ubuntu. Is encrypting my home directory (with ecryptfs)
sufficient? On windows this would be problematic due to ...
I currently have a fully encrypted Windows System, and I'm looking at
switching to Ubuntu. Is encrypting my home directory (with ecryptfs)
sufficient? On windows this would be problematic due to ...
Tuesday, 27 August 2013
Add button in MvcContrib Grid column
Add button in MvcContrib Grid column
I am new to mvc.I am using MvcContrib Html.Grid in my MVC 2 project.I have
an existing Html.Grid where I have to added a new column with a button in
it. I have managed to add a Link,but struggling to add a Button. The code
for adding the link is:
<%: Html.Grid(Model.Results)
.RowAttributes(row => new Hash(@class => row.Item.CadPriority1
? "redgrid" : row.IsAlternate ? "alternategrid" : "grid"))
.Columns(column =>
{
column.For(c =>
c.Status == "Complete" ?
Html.ActionLink("Generate Report",
"GenerateCaseSheetReport", "CareRecord", new { id =
c.CaseNumber }, new { target = "_blank" })
: Html.Label("Generate Report")
)
.Named("Generate Report")
.Encode(false);
column.For(c => c.CrewId);
})
.Sort(Model.SortOptions)%>
I have to use a button instead of Html.ActionLink and enable/disable it
based on the value of "status". Please help.
I am new to mvc.I am using MvcContrib Html.Grid in my MVC 2 project.I have
an existing Html.Grid where I have to added a new column with a button in
it. I have managed to add a Link,but struggling to add a Button. The code
for adding the link is:
<%: Html.Grid(Model.Results)
.RowAttributes(row => new Hash(@class => row.Item.CadPriority1
? "redgrid" : row.IsAlternate ? "alternategrid" : "grid"))
.Columns(column =>
{
column.For(c =>
c.Status == "Complete" ?
Html.ActionLink("Generate Report",
"GenerateCaseSheetReport", "CareRecord", new { id =
c.CaseNumber }, new { target = "_blank" })
: Html.Label("Generate Report")
)
.Named("Generate Report")
.Encode(false);
column.For(c => c.CrewId);
})
.Sort(Model.SortOptions)%>
I have to use a button instead of Html.ActionLink and enable/disable it
based on the value of "status". Please help.
Socket.IO.js is unavailable
Socket.IO.js is unavailable
I have a nodejs server, and socket.io.js is unreachable sometimes. Can you
help me? It's usually good, but sometimes it's unreachable.
I have a nodejs server, and socket.io.js is unreachable sometimes. Can you
help me? It's usually good, but sometimes it's unreachable.
Could not parse knowledge - JBPM
Could not parse knowledge - JBPM
This is my code, I am trying to create an application which compares the
loan amount and prints whether its a low amount, high amount or medium
amount:
public static void main(String[] args) {
System.out.println("application starting.....");
KnowledgeBuilder kBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kBuilder.add(ResourceFactory.newClassPathResource("bpmn/sampleProcess.bpmn"),ResourceType.BPMN2
);
System.out.println("KnowledgeBuilder is :::::: "+kBuilder);
KieBase kBase = kBuilder.newKnowledgeBase();
System.out.println("KieBase is ::::::: "+kBase);
KieSession kSession = kBase.newKieSession();
System.out.println("KSession is :::::::: "+kSession);
// PROCESS PARAMETERS
Map<String,Object> params = new HashMap<>();
//Creating a Person who applies to loan.
Person p = new Person();
p.setName("Ayushya K Devmurari");
p.setUniqueId("A007");
p.setIncome(new BigDecimal(5_00_000.00));
p.setIncome(new BigDecimal(2_40_000.00));
// setting parameter in Map
params.put("Applicant1", p);
//Starting the process.
kSession.startProcess("com.discusit.loanapplication", params);
System.out.println("application now closing.....");
kSession.dispose();
}
And its showing following error:
Exception in thread "main" java.lang.IllegalArgumentException: Could not
parse knowledge.
at
org.drools.compiler.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:79)
at com.discusit.loanapplication.main.MainClass.main(MainClass.java:26)
I am new to Jbpm. And successfully created two more jbpm hello world.
This is my bpmn file:
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="Definition"
targetNamespace="http://www.jboss.org/drools"
typeLanguage="http://www.java.com/javaTypes"
expressionLanguage="http://www.mvel.org/2.0"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL
BPMN20.xsd"
xmlns:g="http://www.jboss.org/drools/flow/gpd"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
xmlns:tns="http://www.jboss.org/drools">
<process processType="Private" isExecutable="true"
id="com.discusit.loanapplication" name="Sample Process"
tns:packageName="defaultPackage" >
<!-- nodes -->
<startEvent id="_1" isInterrupting="true"/>
<exclusiveGateway id="_3" name="Gateway" gatewayDirection="Diverging" />
<scriptTask id="_4" name="Low Amount" >
<script>System.out.println("Amount is Low :::::::");
</script>
</scriptTask>
<scriptTask id="_5" name="Medium Amount" >
<script>System.out.println("Amount is medium :::::");
</script>
</scriptTask>
<scriptTask id="_6" name="High Amount" >
<script>System.out.println("Amount is HIGH :::::::::");</script>
</scriptTask>
<!-- connections -->
<sequenceFlow id="_1-_3" sourceRef="_1" targetRef="_3" />
<sequenceFlow id="_3-_4" sourceRef="_3" targetRef="_4" name="low
Amount" tns:priority="1" >
<conditionExpression xsi:type="tFormalExpression"
language="http://www.jboss.org/drools/rule" >return
loanAmount<50000;</conditionExpression>
</sequenceFlow>
<sequenceFlow id="_3-_5" sourceRef="_3" targetRef="_5" name="medium
amount" tns:priority="1" >
<conditionExpression xsi:type="tFormalExpression"
language="http://www.jboss.org/drools/rule" >return (loanAmount
>=50000 && loanAmount < 100000);
</conditionExpression>
</sequenceFlow>
<sequenceFlow id="_3-_6" sourceRef="_3" targetRef="_6" name="high
amount" tns:priority="1" >
<conditionExpression xsi:type="tFormalExpression"
language="http://www.jboss.org/drools/rule" >return loanAmount
>=100000;</conditionExpression>
</sequenceFlow>
</process>
<bpmndi:BPMNDiagram>
<bpmndi:BPMNPlane bpmnElement="com.discusit.loanapplication" >
<bpmndi:BPMNShape bpmnElement="_1" >
<dc:Bounds x="261" y="15" width="48" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" >
<dc:Bounds x="260" y="225" width="48" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_4" >
<dc:Bounds x="-11" y="405" width="132" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_5" >
<dc:Bounds x="215" y="406" width="142" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_6" >
<dc:Bounds x="512" y="407" width="132" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_1-_3" >
<di:waypoint x="285" y="39" />
<di:waypoint x="284" y="249" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_3-_4" >
<di:waypoint x="284" y="249" />
<di:waypoint x="55" y="429" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_3-_5" >
<di:waypoint x="284" y="249" />
<di:waypoint x="286" y="430" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_3-_6" >
<di:waypoint x="284" y="249" />
<di:waypoint x="578" y="431" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
Any help would be appreciated.
This is my code, I am trying to create an application which compares the
loan amount and prints whether its a low amount, high amount or medium
amount:
public static void main(String[] args) {
System.out.println("application starting.....");
KnowledgeBuilder kBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kBuilder.add(ResourceFactory.newClassPathResource("bpmn/sampleProcess.bpmn"),ResourceType.BPMN2
);
System.out.println("KnowledgeBuilder is :::::: "+kBuilder);
KieBase kBase = kBuilder.newKnowledgeBase();
System.out.println("KieBase is ::::::: "+kBase);
KieSession kSession = kBase.newKieSession();
System.out.println("KSession is :::::::: "+kSession);
// PROCESS PARAMETERS
Map<String,Object> params = new HashMap<>();
//Creating a Person who applies to loan.
Person p = new Person();
p.setName("Ayushya K Devmurari");
p.setUniqueId("A007");
p.setIncome(new BigDecimal(5_00_000.00));
p.setIncome(new BigDecimal(2_40_000.00));
// setting parameter in Map
params.put("Applicant1", p);
//Starting the process.
kSession.startProcess("com.discusit.loanapplication", params);
System.out.println("application now closing.....");
kSession.dispose();
}
And its showing following error:
Exception in thread "main" java.lang.IllegalArgumentException: Could not
parse knowledge.
at
org.drools.compiler.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:79)
at com.discusit.loanapplication.main.MainClass.main(MainClass.java:26)
I am new to Jbpm. And successfully created two more jbpm hello world.
This is my bpmn file:
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="Definition"
targetNamespace="http://www.jboss.org/drools"
typeLanguage="http://www.java.com/javaTypes"
expressionLanguage="http://www.mvel.org/2.0"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL
BPMN20.xsd"
xmlns:g="http://www.jboss.org/drools/flow/gpd"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
xmlns:tns="http://www.jboss.org/drools">
<process processType="Private" isExecutable="true"
id="com.discusit.loanapplication" name="Sample Process"
tns:packageName="defaultPackage" >
<!-- nodes -->
<startEvent id="_1" isInterrupting="true"/>
<exclusiveGateway id="_3" name="Gateway" gatewayDirection="Diverging" />
<scriptTask id="_4" name="Low Amount" >
<script>System.out.println("Amount is Low :::::::");
</script>
</scriptTask>
<scriptTask id="_5" name="Medium Amount" >
<script>System.out.println("Amount is medium :::::");
</script>
</scriptTask>
<scriptTask id="_6" name="High Amount" >
<script>System.out.println("Amount is HIGH :::::::::");</script>
</scriptTask>
<!-- connections -->
<sequenceFlow id="_1-_3" sourceRef="_1" targetRef="_3" />
<sequenceFlow id="_3-_4" sourceRef="_3" targetRef="_4" name="low
Amount" tns:priority="1" >
<conditionExpression xsi:type="tFormalExpression"
language="http://www.jboss.org/drools/rule" >return
loanAmount<50000;</conditionExpression>
</sequenceFlow>
<sequenceFlow id="_3-_5" sourceRef="_3" targetRef="_5" name="medium
amount" tns:priority="1" >
<conditionExpression xsi:type="tFormalExpression"
language="http://www.jboss.org/drools/rule" >return (loanAmount
>=50000 && loanAmount < 100000);
</conditionExpression>
</sequenceFlow>
<sequenceFlow id="_3-_6" sourceRef="_3" targetRef="_6" name="high
amount" tns:priority="1" >
<conditionExpression xsi:type="tFormalExpression"
language="http://www.jboss.org/drools/rule" >return loanAmount
>=100000;</conditionExpression>
</sequenceFlow>
</process>
<bpmndi:BPMNDiagram>
<bpmndi:BPMNPlane bpmnElement="com.discusit.loanapplication" >
<bpmndi:BPMNShape bpmnElement="_1" >
<dc:Bounds x="261" y="15" width="48" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" >
<dc:Bounds x="260" y="225" width="48" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_4" >
<dc:Bounds x="-11" y="405" width="132" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_5" >
<dc:Bounds x="215" y="406" width="142" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_6" >
<dc:Bounds x="512" y="407" width="132" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_1-_3" >
<di:waypoint x="285" y="39" />
<di:waypoint x="284" y="249" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_3-_4" >
<di:waypoint x="284" y="249" />
<di:waypoint x="55" y="429" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_3-_5" >
<di:waypoint x="284" y="249" />
<di:waypoint x="286" y="430" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_3-_6" >
<di:waypoint x="284" y="249" />
<di:waypoint x="578" y="431" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
Any help would be appreciated.
Monday, 26 August 2013
How do i check database table through datatable and extract information of another column of database table?
How do i check database table through datatable and extract information of
another column of database table?
I was trying to check whether there is any rows having username and friend
username in database table. If any then I have to take the friendship
status in a string and will return that string.
Here is the code:
string query = "Select * from tblfriend where username = '" + username +
"'and friend = '" + friendname + "'";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataReader reader = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(reader);
rows = dt.Rows.Count;
if (rows > 0)
{
friendship = reader["friendshipstatus"].ToString();
}
But it gives a error message:
Invalid Call to call MetData when reader is closed.
Can you guys please give a hint?
another column of database table?
I was trying to check whether there is any rows having username and friend
username in database table. If any then I have to take the friendship
status in a string and will return that string.
Here is the code:
string query = "Select * from tblfriend where username = '" + username +
"'and friend = '" + friendname + "'";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataReader reader = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(reader);
rows = dt.Rows.Count;
if (rows > 0)
{
friendship = reader["friendshipstatus"].ToString();
}
But it gives a error message:
Invalid Call to call MetData when reader is closed.
Can you guys please give a hint?
May vs Might in Sentence
May vs Might in Sentence
On an average Sunday, you might find yourself
In the sentence above, the possibility of the person reading finding
themselves doing what it says is pretty high. It's almost certain. Should
I use may instead? Might still sounds better when the sentence is read.
I often find sentences where may might be more appropriate but might
sounds better. Even in this previous sentence I used might even though
what I'm describing is much more likely than not.
On an average Sunday, you might find yourself
In the sentence above, the possibility of the person reading finding
themselves doing what it says is pretty high. It's almost certain. Should
I use may instead? Might still sounds better when the sentence is read.
I often find sentences where may might be more appropriate but might
sounds better. Even in this previous sentence I used might even though
what I'm describing is much more likely than not.
Mongodb Aggregate: Nested totals
Mongodb Aggregate: Nested totals
I am trying to generate a report from our mongo db that tallies up the
unique visits by country code per referral site. I'd like to use
aggregation as I've heard it is quite fast and performance here is an
issue.
We have an account db that has a cc and last referral site associated with
each account.
{
account:"user123",
CountryCode:"CA",
ReferalSite:"Google",
lastLogin:"someisodate"
}
Conceptually, I can write the javascript in a few minutes.
For each unique vistor in accounts db;
visits[vistor.country_code][vistor.refferal_site]+= 1;
Is this query possible with a db.accounts.aggregate()? Or is a map/reduce
the better way to go about this.
Thanks in advance,
I am trying to generate a report from our mongo db that tallies up the
unique visits by country code per referral site. I'd like to use
aggregation as I've heard it is quite fast and performance here is an
issue.
We have an account db that has a cc and last referral site associated with
each account.
{
account:"user123",
CountryCode:"CA",
ReferalSite:"Google",
lastLogin:"someisodate"
}
Conceptually, I can write the javascript in a few minutes.
For each unique vistor in accounts db;
visits[vistor.country_code][vistor.refferal_site]+= 1;
Is this query possible with a db.accounts.aggregate()? Or is a map/reduce
the better way to go about this.
Thanks in advance,
Why is "subpar" not "superpar"?
Why is "subpar" not "superpar"?
My understanding is that the "par" portion of "subpar" comes from the
sport of golf, as in the phrase "par for the course". However if this is
the case, then the construction of the word doesn't seem to make sense. In
golf, the farther below (i.e., sub) the par you are, the better you've
done and the better your score is. Likewise, the farther above you are,
the worse you've done.
Is there a legitimate etymological reason for this word's construction in
relation to its meaning?
Note that I saw this question, but it's completely different and unrelated.
My understanding is that the "par" portion of "subpar" comes from the
sport of golf, as in the phrase "par for the course". However if this is
the case, then the construction of the word doesn't seem to make sense. In
golf, the farther below (i.e., sub) the par you are, the better you've
done and the better your score is. Likewise, the farther above you are,
the worse you've done.
Is there a legitimate etymological reason for this word's construction in
relation to its meaning?
Note that I saw this question, but it's completely different and unrelated.
PHP resize and crop centered-top image
PHP resize and crop centered-top image
I'm trying to resize (keeping the aspect ratio) and crop the excess of
image (outside the thumbnail limits), but doing that while crop x = center
and y = top.
I'm missing something here, but my final image fits inside the thumbnail
area, and not fill it and crop the excess. Hope someone can help me on
this.
This is my code, so far:
$image_width = 725;
$image_height = 409;
$width = 140;
$height = 160;
$thumbnail = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($thumbnail, 255, 255, 255);
imagefill($thumbnail, 0, 0, $white);
$width_ratio = $image_width/$width;
$height_ratio = $image_height/$height;
if ($width_ratio>$height_ratio) {
$dest_width=$width;
$dest_height=$image_height/$width_ratio;
}
else{
$dest_width=$image_width/$height_ratio;
$dest_height=$height;
}
$int_width = ($width - $dest_width)/2;
$int_height = ($height - $dest_height)/2;
imagecopyresampled($thumbnail, $original_image, $int_width, $int_height,
0, 0, $dest_width, $dest_height, $image_width, $image_height);
Thanks!
I'm trying to resize (keeping the aspect ratio) and crop the excess of
image (outside the thumbnail limits), but doing that while crop x = center
and y = top.
I'm missing something here, but my final image fits inside the thumbnail
area, and not fill it and crop the excess. Hope someone can help me on
this.
This is my code, so far:
$image_width = 725;
$image_height = 409;
$width = 140;
$height = 160;
$thumbnail = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($thumbnail, 255, 255, 255);
imagefill($thumbnail, 0, 0, $white);
$width_ratio = $image_width/$width;
$height_ratio = $image_height/$height;
if ($width_ratio>$height_ratio) {
$dest_width=$width;
$dest_height=$image_height/$width_ratio;
}
else{
$dest_width=$image_width/$height_ratio;
$dest_height=$height;
}
$int_width = ($width - $dest_width)/2;
$int_height = ($height - $dest_height)/2;
imagecopyresampled($thumbnail, $original_image, $int_width, $int_height,
0, 0, $dest_width, $dest_height, $image_width, $image_height);
Thanks!
#if debug --> #if myOwnConfig?
#if debug --> #if myOwnConfig?
is there a way in c# to use a custom Configuration like "#if DEBUG"
I need a "#if OFFLINE" as my Build-Config's name is "Offline" (only for
further debug-purposes too)...
Thanks!
is there a way in c# to use a custom Configuration like "#if DEBUG"
I need a "#if OFFLINE" as my Build-Config's name is "Offline" (only for
further debug-purposes too)...
Thanks!
I have following piece of code to stop media player
I have following piece of code to stop media player
While pressing start button it starts playing the mp3 file, but it doesn't
stop while pressing Stop button, I have been through few examples but
couldn't find the exact solution
public Button play;
public Button stop;
MediaPlayer mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
play = (Button)findViewById(R.id.played);
stop = (Button)findViewById(R.id.stopped);
play.setOnClickListener(this);
stop.setOnClickListener(this);
}
public void onClick(View v) {
mp = MediaPlayer.create(this,R.raw.you);
if(v==play && !mp.isPlaying())
{
mp.start();
}
else if (v==stop) //this part of code executes but doesnot stop the
player
{
mp.stop();
mp.release();
}
}
While pressing start button it starts playing the mp3 file, but it doesn't
stop while pressing Stop button, I have been through few examples but
couldn't find the exact solution
public Button play;
public Button stop;
MediaPlayer mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
play = (Button)findViewById(R.id.played);
stop = (Button)findViewById(R.id.stopped);
play.setOnClickListener(this);
stop.setOnClickListener(this);
}
public void onClick(View v) {
mp = MediaPlayer.create(this,R.raw.you);
if(v==play && !mp.isPlaying())
{
mp.start();
}
else if (v==stop) //this part of code executes but doesnot stop the
player
{
mp.stop();
mp.release();
}
}
Sunday, 25 August 2013
Checkboxes instead of drop down list in PHP, MySQL
Checkboxes instead of drop down list in PHP, MySQL
I have this working code below, but i'd like to change it from drop down
list to checkboxes, so multiple options can be selected and passed for
further action instead of just one that the drop down list allows. I'm
fairy new to PHP and have done tons of searching on this without any
success. Any help is much appreciated.
$l = $_POST['LT'];
$pals = '';
$r = mysql_query("SELECT DISTINCT pal_num FROM pl_tab WHERE
lt_num='$l'");
while($row = mysql_fetch_assoc($r))
{
$pals .= '<option>'.$row['pal_num'].'</option>';
}
if($pal == '')
echo '';
else
echo '<form name="get_pal" action="post.php" method="POST">';
echo '<select name="pal_numb"><option>Select
Pal</option>'.$pals.'</select>';
echo '<input type="submit" name="post" value="Go!">';
echo '</form>';
I have this working code below, but i'd like to change it from drop down
list to checkboxes, so multiple options can be selected and passed for
further action instead of just one that the drop down list allows. I'm
fairy new to PHP and have done tons of searching on this without any
success. Any help is much appreciated.
$l = $_POST['LT'];
$pals = '';
$r = mysql_query("SELECT DISTINCT pal_num FROM pl_tab WHERE
lt_num='$l'");
while($row = mysql_fetch_assoc($r))
{
$pals .= '<option>'.$row['pal_num'].'</option>';
}
if($pal == '')
echo '';
else
echo '<form name="get_pal" action="post.php" method="POST">';
echo '<select name="pal_numb"><option>Select
Pal</option>'.$pals.'</select>';
echo '<input type="submit" name="post" value="Go!">';
echo '</form>';
Edit files with SharePoint 2010 Client Object Model
Edit files with SharePoint 2010 Client Object Model
I'm new to SharePoint and using SharePoint Foundation server 2010 to save
files using client object model. The application will list the files in
the server using MVC4 UI. To retreive the files and folders I use
SharePoint 2010 client object model. I want to implement the Edit feature
for the word and excel documents which is already available when we access
SharePoint site directly through IE. Simply I just want to open the file
and save changes to the server when we save it or close the program. Is it
possible to do using client object model. I can open the file but not save
the changes to the server. I google it to find a solution but yet not
succeeded. If anybody knows how to do it please answer. Thanks in advance.
I just want to implement the following feature in my mvc4 application
using client object model.
http://social.msdn.microsoft.com/Forums/getfile/323127
I'm new to SharePoint and using SharePoint Foundation server 2010 to save
files using client object model. The application will list the files in
the server using MVC4 UI. To retreive the files and folders I use
SharePoint 2010 client object model. I want to implement the Edit feature
for the word and excel documents which is already available when we access
SharePoint site directly through IE. Simply I just want to open the file
and save changes to the server when we save it or close the program. Is it
possible to do using client object model. I can open the file but not save
the changes to the server. I google it to find a solution but yet not
succeeded. If anybody knows how to do it please answer. Thanks in advance.
I just want to implement the following feature in my mvc4 application
using client object model.
http://social.msdn.microsoft.com/Forums/getfile/323127
Make operation with aggregate function result
Make operation with aggregate function result
I confess that I do not get along very well with the Deferred object. I'm
making a query to the database on several "Stores" and as a result I want
to do a series of operations. This troubles me because the results are
returned asynchronously and I have no way to perform the corresponding
operation on the "store" you should. In short, the problem is that this
piece of code always executes the same function on the same "Store"
for (var i = 0; i < schema['stores'].length; i++) {
storeName = schema['stores'][i].name;
var objeto = db.executeSql('SELECT MAX(date_upd) FROM ' + '"' +
storeName + '"').done(
function(result, a){
//saveDataSynce(db, storeName, result);
console.log(result);
}
);
}
I confess that I do not get along very well with the Deferred object. I'm
making a query to the database on several "Stores" and as a result I want
to do a series of operations. This troubles me because the results are
returned asynchronously and I have no way to perform the corresponding
operation on the "store" you should. In short, the problem is that this
piece of code always executes the same function on the same "Store"
for (var i = 0; i < schema['stores'].length; i++) {
storeName = schema['stores'][i].name;
var objeto = db.executeSql('SELECT MAX(date_upd) FROM ' + '"' +
storeName + '"').done(
function(result, a){
//saveDataSynce(db, storeName, result);
console.log(result);
}
);
}
[ Women's Health ] Open Question : Pregnancy? period help? really worried!?
[ Women's Health ] Open Question : Pregnancy? period help? really worried!?
So im about to start my senior year in a week and my life is just getting
extremely hectic, i might be getting a job and im turning 18 next month
and a lot is going on right now and is going to happen this year. Im
honestly excited about it but i cant seem to relax. My boyfriend and i had
unprotected on the last day of my period in the end of july. I took the
plan b pill. My last normal period started on july 24th. But ten days
later i bleed again for three days, could that have been my period? Now my
periods late and im really worried and i dont know what to do. Please help
me. Its my fault cause we kept on having unprotected sex anyways. He didnt
ejaculate inside of me the other times. I really need to go on
birthcontrol but first i need to know if im pregnant or not or if im just
being paraniod. Is.the plan b just screwing up everything??
So im about to start my senior year in a week and my life is just getting
extremely hectic, i might be getting a job and im turning 18 next month
and a lot is going on right now and is going to happen this year. Im
honestly excited about it but i cant seem to relax. My boyfriend and i had
unprotected on the last day of my period in the end of july. I took the
plan b pill. My last normal period started on july 24th. But ten days
later i bleed again for three days, could that have been my period? Now my
periods late and im really worried and i dont know what to do. Please help
me. Its my fault cause we kept on having unprotected sex anyways. He didnt
ejaculate inside of me the other times. I really need to go on
birthcontrol but first i need to know if im pregnant or not or if im just
being paraniod. Is.the plan b just screwing up everything??
Saturday, 24 August 2013
How to remove Section, SubSection titles?
How to remove Section, SubSection titles?
How do I remove a section/subsection title, but keep the
section/subsection name in the headings and in the table of contents?
For example, I type in my document somewhere,
\section{My Section}
and I get
"(section number) MY SECTION" in the headings,
"(section number) My Section.........(page number)" in the table of contents,
"(section number) My Section" before the first paragraph.
How do I prevent the third item from occurring?
I have been searching for hours and it seems that this should have a
simple one line solution, but I haven't found it. I have thought about
using
\addcontentsline{toc}{subsection}{My Section}
but then I lose "(section number) MY SECTION" in the headings and I lose
the (section number) in the table of contents. So an equivalent set of
question,
How do I add numbered sections to the toc and to the headings?
How do I remove a section/subsection title, but keep the
section/subsection name in the headings and in the table of contents?
For example, I type in my document somewhere,
\section{My Section}
and I get
"(section number) MY SECTION" in the headings,
"(section number) My Section.........(page number)" in the table of contents,
"(section number) My Section" before the first paragraph.
How do I prevent the third item from occurring?
I have been searching for hours and it seems that this should have a
simple one line solution, but I haven't found it. I have thought about
using
\addcontentsline{toc}{subsection}{My Section}
but then I lose "(section number) MY SECTION" in the headings and I lose
the (section number) in the table of contents. So an equivalent set of
question,
How do I add numbered sections to the toc and to the headings?
Watch@@ San Diego Chargers vs Arizona Cardinals Live Streaming NFL Game Preseason Week 3 Saturday August 24, TV Pc
Watch@@ San Diego Chargers vs Arizona Cardinals Live Streaming NFL Game
Preseason Week 3 Saturday August 24, TV Pc
Hi Guys Today Live: Copy paste link==http://is.gd/VaRut4 You can easily
watch NFL Match San Diego Chargers vs Arizona Cardinals Live Stream Online
Game Free Preseason Week 3 Game 2013 National Football League ( NFL )
Pre-Season Live Streaming. San Diego Chargers vs Arizona Cardinals Live
match Don't miss your exciting game in National Football League, Preseason
Week 3 San Diego Chargers vs Arizona Cardinals Live Stream. Watch San
Diego Chargers vs Arizona Cardinals Live stream 'National Football League'
(NFL) College Football online 2013 "Season/Pre-Season" live streaming in
HD quality on PC, Laptop and MAC. San Diego Chargers vs Arizona Cardinals
Live Streaming
Copy paste link==http://is.gd/VaRut4 Watch San Diego Chargers vs Arizona
Cardinals Live stream online Free NFL Game Today.Don't miss San Diego
Chargers vs Arizona Cardinals live The great match. NFL–Sports live San
Diego Chargers vs Arizona Cardinals now on Sky Sports 4,bet air tv,CBS,HD4
,Fox Network.This Match live.Both team are ready to face each other.So
this match will be very enjoyable Watch Live FOX,CBS,NBC,ESPN TV Get the
best online sports coverage on the net directly on your PC. MATCH DETAILS
Competition: NFL Sports Date: Saturday August 24,2013 Time: 10:00 pm Live
/ Repeat:Live WATCH ONLINE LINK ON YOUR PC Don't worry,it is too easy to
watch.just try it. you all about US Football entertainment like
NFL,CFL,NCAA, AFL ect by which All you can watch each and every games live
streaming online. You love watching live National Football League games?
Are you finding it difficult to get to a TV or come up with the costly
payments for cable TV? Or are you working abroad and don't have access to
all the best NFL games that you want to see?If you answered yes to any of
these questions then you have come to the perfect place.stream direct-tv
pc.com .US NFL Sports.com is your home for all the live NFL football
action that you want and crave.
Preseason Week 3 Saturday August 24, TV Pc
Hi Guys Today Live: Copy paste link==http://is.gd/VaRut4 You can easily
watch NFL Match San Diego Chargers vs Arizona Cardinals Live Stream Online
Game Free Preseason Week 3 Game 2013 National Football League ( NFL )
Pre-Season Live Streaming. San Diego Chargers vs Arizona Cardinals Live
match Don't miss your exciting game in National Football League, Preseason
Week 3 San Diego Chargers vs Arizona Cardinals Live Stream. Watch San
Diego Chargers vs Arizona Cardinals Live stream 'National Football League'
(NFL) College Football online 2013 "Season/Pre-Season" live streaming in
HD quality on PC, Laptop and MAC. San Diego Chargers vs Arizona Cardinals
Live Streaming
Copy paste link==http://is.gd/VaRut4 Watch San Diego Chargers vs Arizona
Cardinals Live stream online Free NFL Game Today.Don't miss San Diego
Chargers vs Arizona Cardinals live The great match. NFL–Sports live San
Diego Chargers vs Arizona Cardinals now on Sky Sports 4,bet air tv,CBS,HD4
,Fox Network.This Match live.Both team are ready to face each other.So
this match will be very enjoyable Watch Live FOX,CBS,NBC,ESPN TV Get the
best online sports coverage on the net directly on your PC. MATCH DETAILS
Competition: NFL Sports Date: Saturday August 24,2013 Time: 10:00 pm Live
/ Repeat:Live WATCH ONLINE LINK ON YOUR PC Don't worry,it is too easy to
watch.just try it. you all about US Football entertainment like
NFL,CFL,NCAA, AFL ect by which All you can watch each and every games live
streaming online. You love watching live National Football League games?
Are you finding it difficult to get to a TV or come up with the costly
payments for cable TV? Or are you working abroad and don't have access to
all the best NFL games that you want to see?If you answered yes to any of
these questions then you have come to the perfect place.stream direct-tv
pc.com .US NFL Sports.com is your home for all the live NFL football
action that you want and crave.
Multiple discrete keyboard inputs on one machine
Multiple discrete keyboard inputs on one machine
Background:
I am running a large event in October and plan to monitor who attends and
where people are in the building for safety using a system that reads
mifare cards that everyone in my organsiation has. To do this I have found
a cheap mifare reader that reads a particular sector of the card and
returns the data as hex which I can convert to a string then send to a
server for processing and recording. So far, so good. However, close to
20,000 people attend this event and that means a lot of scanning and so a
lot of mifare readers, all of which need to be connected to a computer to
read the data and send it on. Ideally, I'd like to connect about 3 or four
readers to a machine, and have about three or four of these, one on each
entrances/exit at the event.
What I need help doing:
My card readers act as generic keyboards on Windows and Android (and I
assume Linux, but I'm about to check this), the computer in essence just
acts as though it has multiple keyboards, all of which can enter data
simultaneously, but only to one program (i.e., there's ever one caret on
the screen). This could cause a problem if two cards are scanned at the
same time and the keystrokes from each card get "intermingled" and so
cause processing problems.
What I'd like to do is set up one linux box to have multiple carets, so
that I could have say four command lines all going at the same time taking
data from one card reader each.
For example: if John and Saira scanned in at the same time, at the moment
the resulting input could be:
j s o a h i n r a
Whereas I'd like it to be:
CLI 1:
john
CLI2:
saira
etc. etc. for CLI3, CLI4
I know this must be possible, I'd looked at potentially settign up a
multi-seat linux distribution, but I feel that would be using a
sledgehammer to solve the problem, and creates a new problem since it
introduces the need for monitors, mice, etc.
Ideally I'd like this whole system to be as streamlined as possible,
either running off a laptop or just a linux box that I can plug in, boot
up and let run automatically (with no need for monitors, mice or other
clunky bits and pieces!).
Does anyone have any experience on this or advice they can offer? Any help
would be much appreciated!
Thanks,
Dom
Background:
I am running a large event in October and plan to monitor who attends and
where people are in the building for safety using a system that reads
mifare cards that everyone in my organsiation has. To do this I have found
a cheap mifare reader that reads a particular sector of the card and
returns the data as hex which I can convert to a string then send to a
server for processing and recording. So far, so good. However, close to
20,000 people attend this event and that means a lot of scanning and so a
lot of mifare readers, all of which need to be connected to a computer to
read the data and send it on. Ideally, I'd like to connect about 3 or four
readers to a machine, and have about three or four of these, one on each
entrances/exit at the event.
What I need help doing:
My card readers act as generic keyboards on Windows and Android (and I
assume Linux, but I'm about to check this), the computer in essence just
acts as though it has multiple keyboards, all of which can enter data
simultaneously, but only to one program (i.e., there's ever one caret on
the screen). This could cause a problem if two cards are scanned at the
same time and the keystrokes from each card get "intermingled" and so
cause processing problems.
What I'd like to do is set up one linux box to have multiple carets, so
that I could have say four command lines all going at the same time taking
data from one card reader each.
For example: if John and Saira scanned in at the same time, at the moment
the resulting input could be:
j s o a h i n r a
Whereas I'd like it to be:
CLI 1:
john
CLI2:
saira
etc. etc. for CLI3, CLI4
I know this must be possible, I'd looked at potentially settign up a
multi-seat linux distribution, but I feel that would be using a
sledgehammer to solve the problem, and creates a new problem since it
introduces the need for monitors, mice, etc.
Ideally I'd like this whole system to be as streamlined as possible,
either running off a laptop or just a linux box that I can plug in, boot
up and let run automatically (with no need for monitors, mice or other
clunky bits and pieces!).
Does anyone have any experience on this or advice they can offer? Any help
would be much appreciated!
Thanks,
Dom
Problems with sound in Linux Mint 15 on video
Problems with sound in Linux Mint 15 on video
Problem:
I think you'll enjoy this fun problem. I set-up a dev/media server. Steps
to reproduce:
Start up any video file (with Banshee or VLC or xfce player - doesn't
matter) -- all is well. Sound plays properly.
Pause the file. Unpause. Sound stops and there is no way of bringind it back.
That's problem nr 1. Now after playing this file, try to start up another
video file:
Play another file in Banshee/Integrated/XBMC. There is no sound.
Play another file in VLC, you'll get get a ~0.2s looping white noise
instead of the sound. Also, when changing the VLC volume by mouse or
keyboard (in steps), it will temporarily change the volume (for like 1s)
and the revert back to 87%. When changind the volume by the VLC slider,
the volume stays at that level.
And the most interesting thing: If I play another audio application
(tested only with a browser playing Grooveshark) before opening the second
file, the sound will be proper (with the aforementioned pause caveat).
This has no effect on the pause bug (i.e. pausing the video, then playing
other audio with the browser and unpausing does not fix the sound).
Config:
Mainboard: FM2-A75IA
CPU: A10 5800K (with Radeon HD 7660D)
OS: Linux Mint 15 with Xfce or straight up XBMC 13
Latest ATI catalyst drivers - stable (13.4)
Display: A 42 inch Panasosic plasma connected via HDMI
Problem:
I think you'll enjoy this fun problem. I set-up a dev/media server. Steps
to reproduce:
Start up any video file (with Banshee or VLC or xfce player - doesn't
matter) -- all is well. Sound plays properly.
Pause the file. Unpause. Sound stops and there is no way of bringind it back.
That's problem nr 1. Now after playing this file, try to start up another
video file:
Play another file in Banshee/Integrated/XBMC. There is no sound.
Play another file in VLC, you'll get get a ~0.2s looping white noise
instead of the sound. Also, when changing the VLC volume by mouse or
keyboard (in steps), it will temporarily change the volume (for like 1s)
and the revert back to 87%. When changind the volume by the VLC slider,
the volume stays at that level.
And the most interesting thing: If I play another audio application
(tested only with a browser playing Grooveshark) before opening the second
file, the sound will be proper (with the aforementioned pause caveat).
This has no effect on the pause bug (i.e. pausing the video, then playing
other audio with the browser and unpausing does not fix the sound).
Config:
Mainboard: FM2-A75IA
CPU: A10 5800K (with Radeon HD 7660D)
OS: Linux Mint 15 with Xfce or straight up XBMC 13
Latest ATI catalyst drivers - stable (13.4)
Display: A 42 inch Panasosic plasma connected via HDMI
Is there a mash of meeting management and sru cards tool?
Is there a mash of meeting management and sru cards tool?
What I mix of Facebook group with its ability to very easily schedule
meetings in a from of events and functionality of trello with its cards
system overseeing those events.
It would be nice if those two would be integrated. For example this card
was added after or during #6 meeting at Johns' bar. And the last thing
some notifications before the meeting or for the card changes.
Is there a thing like that maybe some Facebook app for groups?
What I mix of Facebook group with its ability to very easily schedule
meetings in a from of events and functionality of trello with its cards
system overseeing those events.
It would be nice if those two would be integrated. For example this card
was added after or during #6 meeting at Johns' bar. And the last thing
some notifications before the meeting or for the card changes.
Is there a thing like that maybe some Facebook app for groups?
Friday, 23 August 2013
How to hide multiple Show/Hide DIV's when another DIV is clicked
How to hide multiple Show/Hide DIV's when another DIV is clicked
How do I hide all buttons in the second and third row if a different
button is clicked in the first row and if a another button is clicked in
the second row it will hide the buttons for that column and show buttons
for the column that is clicked? I'm trying to achieve a form similar to
http://gazelle.com/ for my website but it's getting a bit difficult for
me.
Example: If I click, "iPhone" -- buttons iphone 5, iphone 4s, iphone 4,
and iphone 3gs show, then click, "iphone 5" -- buttons at&t, sprint,
verizon, unlocked, and other show under the first row, then I change my
mind and decide to click "tablet" in the first, the buttons for "tablet"
show up but the buttons from iphone 5 go back to hiding but the buttons
for "tablet" show up.
<!DOCTYPE html>
<html>
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function showHide(obj) {
var div = document.getElementById(obj);
if (div.style.display == 'none') {
div.style.display = '';
}
else {
div.style.display = 'none';
}
}
</script>
</head>
<body>
<table>
<td>
<a href="#" onclick="showHide('hidden_div'); return
false;"><button>iPhone</button></a>
<a href="#" onclick="showHide('q2'); return false;"><button>iPod</button></a>
<a href="#" onclick="showHide('q3'); return
false;"><button>Tablet</button></a>
</td>
</table>
<div id="hidden_div" style="display: none;">
<button onclick="showHide('q4'); return false;">iPhone 5</button>
<button>iPhone 4S</button>
<button>iPhone 4</button>
<button>iPhone 3GS</button>
</div>
<div id="q2" style="display: none;">
<button>iPod Touch</button>
<button>iPod Nano</button>
<button>Classic iPod</button>
</div>
<div id="q3" style="display: none;">
<button>iPad</button>
<button>Windows</button>
<button>Nook</button>
</div>
<div id="q4" style="display: none;">
<button onclick="showHide('q'); return false;">AT&T</button>
<button>Sprint</button>
<button>Verizon</button>
<button>Unlocked</button>
<button>Other</button>
</div>
</body>
</html>
http://jsfiddle.net/EbbCc/
How do I hide all buttons in the second and third row if a different
button is clicked in the first row and if a another button is clicked in
the second row it will hide the buttons for that column and show buttons
for the column that is clicked? I'm trying to achieve a form similar to
http://gazelle.com/ for my website but it's getting a bit difficult for
me.
Example: If I click, "iPhone" -- buttons iphone 5, iphone 4s, iphone 4,
and iphone 3gs show, then click, "iphone 5" -- buttons at&t, sprint,
verizon, unlocked, and other show under the first row, then I change my
mind and decide to click "tablet" in the first, the buttons for "tablet"
show up but the buttons from iphone 5 go back to hiding but the buttons
for "tablet" show up.
<!DOCTYPE html>
<html>
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function showHide(obj) {
var div = document.getElementById(obj);
if (div.style.display == 'none') {
div.style.display = '';
}
else {
div.style.display = 'none';
}
}
</script>
</head>
<body>
<table>
<td>
<a href="#" onclick="showHide('hidden_div'); return
false;"><button>iPhone</button></a>
<a href="#" onclick="showHide('q2'); return false;"><button>iPod</button></a>
<a href="#" onclick="showHide('q3'); return
false;"><button>Tablet</button></a>
</td>
</table>
<div id="hidden_div" style="display: none;">
<button onclick="showHide('q4'); return false;">iPhone 5</button>
<button>iPhone 4S</button>
<button>iPhone 4</button>
<button>iPhone 3GS</button>
</div>
<div id="q2" style="display: none;">
<button>iPod Touch</button>
<button>iPod Nano</button>
<button>Classic iPod</button>
</div>
<div id="q3" style="display: none;">
<button>iPad</button>
<button>Windows</button>
<button>Nook</button>
</div>
<div id="q4" style="display: none;">
<button onclick="showHide('q'); return false;">AT&T</button>
<button>Sprint</button>
<button>Verizon</button>
<button>Unlocked</button>
<button>Other</button>
</div>
</body>
</html>
http://jsfiddle.net/EbbCc/
Strategy for normalising and interpreting location data
Strategy for normalising and interpreting location data
I'm a bit stuck with a problem involving the normalisation of location
input data from the user (which comes from a third party).
Aim
To logically breakdown and interpret the user location input field and
understand if it is listing single or multiple locations, from one or more
countries.
The Problem
The type of data that I am receiving from the user input is messy and has
no logical structure or consistency as show below. Daily geocodes are
limited from google, so I have to use them sparingly. I want to
efficiently process the location input from the user and send the correct
geocoding query to google to get the right result.
Data Sources
Data is irrational and irregular and could be supplied in some of the
following formats:
London, UK Alternative format
England, London Reversed order
London Generic location
London Sheffield, Newcastle Three separate locations in the
same country without consistent commas
London, Sales, Sales Assistant Non location content inserted
London [NOT SPECIFIED] Other non location content
inserted with non alphabet chars not separate with commas
London, Washington, Brazil, England Mix of unrelated locations,
including cities and countries
Washington, London, Kent Mix of places within a single country
Proposed Solution
Step 1: Breakdown data
Put each separated word in an array
Step 2: Sanitize data
Strip out invalid chars, commas, additional spaces etc
Strip out any words against a stoplist.txt (like job, sales, in, at, etc)
Step 3: Deterimine if valid location
See if each individual array item has been geocoded before, if not,
geocode and store
Log any words which have been geocoded with no result – add these into the
stoplist file to avoid pointless geocodes
Step 4: Interlink values
Compare if a places coordinate value falls within the range of another
array item. If it does, we know they are parents and we treat them as a
single item
London + England -> London coordinates falls within the co-ordinate range
of England so we know it is a single location, not two separate ones.
Issues
Issue 1: Kent, London, Sussex Technically, there is a Kent in the USA, and
it is the first one that comes up when you type it into google maps.
However since all the results are in England it is extremely unlikely that
the result we want is the USA one
Issue 2: England, Washington, New York There is a Washington in England,
but this doesnt seem likely to be the one in England
Question
Is my proposed solution of breaking the words down into separate entities
and relinking them the most logical solution? Any help or advice would be
much appreciated, I know it's not any easy problem.
I'm a bit stuck with a problem involving the normalisation of location
input data from the user (which comes from a third party).
Aim
To logically breakdown and interpret the user location input field and
understand if it is listing single or multiple locations, from one or more
countries.
The Problem
The type of data that I am receiving from the user input is messy and has
no logical structure or consistency as show below. Daily geocodes are
limited from google, so I have to use them sparingly. I want to
efficiently process the location input from the user and send the correct
geocoding query to google to get the right result.
Data Sources
Data is irrational and irregular and could be supplied in some of the
following formats:
London, UK Alternative format
England, London Reversed order
London Generic location
London Sheffield, Newcastle Three separate locations in the
same country without consistent commas
London, Sales, Sales Assistant Non location content inserted
London [NOT SPECIFIED] Other non location content
inserted with non alphabet chars not separate with commas
London, Washington, Brazil, England Mix of unrelated locations,
including cities and countries
Washington, London, Kent Mix of places within a single country
Proposed Solution
Step 1: Breakdown data
Put each separated word in an array
Step 2: Sanitize data
Strip out invalid chars, commas, additional spaces etc
Strip out any words against a stoplist.txt (like job, sales, in, at, etc)
Step 3: Deterimine if valid location
See if each individual array item has been geocoded before, if not,
geocode and store
Log any words which have been geocoded with no result – add these into the
stoplist file to avoid pointless geocodes
Step 4: Interlink values
Compare if a places coordinate value falls within the range of another
array item. If it does, we know they are parents and we treat them as a
single item
London + England -> London coordinates falls within the co-ordinate range
of England so we know it is a single location, not two separate ones.
Issues
Issue 1: Kent, London, Sussex Technically, there is a Kent in the USA, and
it is the first one that comes up when you type it into google maps.
However since all the results are in England it is extremely unlikely that
the result we want is the USA one
Issue 2: England, Washington, New York There is a Washington in England,
but this doesnt seem likely to be the one in England
Question
Is my proposed solution of breaking the words down into separate entities
and relinking them the most logical solution? Any help or advice would be
much appreciated, I know it's not any easy problem.
How to write from array to outputfile?
How to write from array to outputfile?
I have a vector vec (256, 0) that I use to record type of characters and
their frequency from the input file. So given 3 A's my vec[65] will hold
value of 3. I am trying to write to output file the count non-empty chars
in total followed by their ascii character and the frequency of
occurrence.
int count = 0;
for (int i = 0; i < 256; i++)
if (vec[i] != 0) // if not 0 count it
count++;
// print the count as the first char in output file
outfile << count;
for (int i = 0; i < 256; i++)
if (vec[i] != 0)
outfile << (char) i << vec[i];
Given input "a bb c" what I want is:
4a1b2c1
But what I get is:
5
1 2a1b2c1
What can I do to fix this?
I have a vector vec (256, 0) that I use to record type of characters and
their frequency from the input file. So given 3 A's my vec[65] will hold
value of 3. I am trying to write to output file the count non-empty chars
in total followed by their ascii character and the frequency of
occurrence.
int count = 0;
for (int i = 0; i < 256; i++)
if (vec[i] != 0) // if not 0 count it
count++;
// print the count as the first char in output file
outfile << count;
for (int i = 0; i < 256; i++)
if (vec[i] != 0)
outfile << (char) i << vec[i];
Given input "a bb c" what I want is:
4a1b2c1
But what I get is:
5
1 2a1b2c1
What can I do to fix this?
PHP Function that Counts String Length and Charges Price Based on # of Characters
PHP Function that Counts String Length and Charges Price Based on # of
Characters
I've got an OpenCart VQMod that currently counts string length and charges
by character. This is close, but I need it to charge with the following
rules:
30-45 characters: $8.50
46+ characters: $12.00
Can anyone help me modify the following PHP?
<file name="admin/controller/catalog/option.php">
<operation>
<search position="after"><![CDATA[
public function index() {
]]></search>
<add><![CDATA[
//Q: Option Price By Character
$query = $this->db->query("DESC `".DB_PREFIX."option`
price_per_char");
if (!$query->num_rows) {
$this->db->query("ALTER TABLE `" . DB_PREFIX . "option` ADD
`price_per_char` DECIMAL(15,4)");
}
]]></add>
</operation>
<operation>
<search position="before"><![CDATA[
if (isset($this->request->post['sort_order'])) {
]]></search>
<add><![CDATA[
//Q: Option Price By Character
if (isset($this->request->post['price_per_char'])) {
$this->data['price_per_char'] =
$this->request->post['price_per_char'];
} elseif (!empty($option_info)) {
$this->data['price_per_char'] = $option_info['price_per_char'];
} else {
$this->data['price_per_char'] = '';
}
]]></add>
</operation>
</file>
<file name="admin/view/template/catalog/option_form.tpl">
<operation>
<search position="before" index="1"><![CDATA[
</table>
]]></search>
<add><![CDATA[
<tr>
<td>Price Per Char:<br/><span class="help">For 'Text' and
'Textarea' types only</span></td>
<td><input type="text" name="price_per_char" value="<?php echo
(isset($price_per_char)) ? $price_per_char : '' ?>" size="3"
/></td>
</tr>
]]></add>
</operation>
</file>
<file name="admin/model/catalog/option.php">
<operation><!-- matches twice -->
<search position="replace"><![CDATA[
sort_order = '" . (int)$data['sort_order'] . "'
]]></search>
<add><![CDATA[
sort_order = '" . (int)$data['sort_order'] . "', price_per_char =
'" . (float)$data['price_per_char'] . "'
]]></add>
</operation>
</file>
<file name="catalog/model/catalog/product.php">
<operation>
<search position="after" index="2"><![CDATA[
$product_option_data[] = array(
]]></search>
<add><![CDATA[
'price_per_char' => $product_option['price_per_char'],
]]></add>
</operation>
</file>
<file name="catalog/controller/product/product.php">
<operation>
<search position="after" index="2"><![CDATA[
$this->data['options'][] = array(
]]></search>
<add><![CDATA[
'price_per_char' => $option['price_per_char'],
]]></add>
</operation>
</file>
<file name="catalog/view/theme/*/template/product/product.tpl">
<operation>
<search position="replace"><![CDATA[
<input type="text" name="option[<?php echo
$option['product_option_id']; ?>]" value="<?php echo
$option['option_value']; ?>" />
]]></search>
<add><![CDATA[
<input type="text" name="option[<?php echo
$option['product_option_id']; ?>]" value="<?php echo
$option['option_value']; ?>" price_per_char="<?php echo
$option['price_per_char']; ?>" onkeyup="$('.pbctotal<?php echo
$option['product_option_id']; ?>').remove(); var pbcval =
(this.value.length * <?php echo
$this->currency->format($option['price_per_char'], false, false,
false); ?>); if (pbcval > 0) { $(this).after(' <span
class=\'pbctotal<?php echo $option['product_option_id'];
?>\'>+'+parseFloat(pbcval).toFixed(2)+'</span>'); }" />
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[
<textarea name="option[<?php echo $option['product_option_id'];
?>]" cols="40" rows="5"><?php echo $option['option_value'];
?></textarea>
]]></search>
<add><![CDATA[
<textarea name="option[<?php echo $option['product_option_id'];
?>]" cols="40" rows="5" price_per_char="<?php echo
$option['price_per_char']; ?>" onkeyup="$('.pbctotal<?php echo
$option['product_option_id']; ?>').remove(); var pbcval =
(this.value.length * <?php echo
$this->currency->format($option['price_per_char'], false, false,
false); ?>); if (pbcval > 0) { $(this).after(' <span
class=\'pbctotal<?php echo $option['product_option_id'];
?>\'>+'+parseFloat(pbcval).toFixed(2)+'</span>'); }"><?php echo
$option['option_value']; ?></textarea>
]]></add>
</operation>
</file>
<file name="system/library/cart.php">
<operation>
<search position="after"><![CDATA[
$option_query =
]]></search>
<add><![CDATA[
//Q: Option Price By Character
$option_query = $this->db->query("SELECT * FROM " .
DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX .
"option` o ON (po.option_id = o.option_id) LEFT JOIN " .
DB_PREFIX . "option_description od ON (o.option_id =
od.option_id) WHERE po.product_option_id = '" .
(int)$product_option_id . "' AND po.product_id = '" .
(int)$product_id . "' AND od.language_id = '" .
(int)$this->config->get('config_language_id') . "'");
]]></add>
</operation>
<operation>
<search position="after"><![CDATA[
$option_query->row['type'] == 'text' || $option_query->row['type']
== 'textarea'
]]></search>
<add><![CDATA[
//Q: Option Price By Character
$optprice = '';
$optprefix = '';
if ($option_query->row['type'] == 'text' ||
$option_query->row['type'] == 'textarea') {
if (strlen($option_value)) {
$optprice = (strlen($option_value) *
$option_query->row['price_per_char']);
$optprefix = '+';
$option_price += $optprice;
}
}
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[
'price' => '',
]]></search>
<add trim="true"><![CDATA[
'price' => $optprice,
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[
'price_prefix' => '',
]]></search>
<add trim="true"><![CDATA[
'price_prefix' => $optprefix,
]]></add>
</operation>
</file>
Characters
I've got an OpenCart VQMod that currently counts string length and charges
by character. This is close, but I need it to charge with the following
rules:
30-45 characters: $8.50
46+ characters: $12.00
Can anyone help me modify the following PHP?
<file name="admin/controller/catalog/option.php">
<operation>
<search position="after"><![CDATA[
public function index() {
]]></search>
<add><![CDATA[
//Q: Option Price By Character
$query = $this->db->query("DESC `".DB_PREFIX."option`
price_per_char");
if (!$query->num_rows) {
$this->db->query("ALTER TABLE `" . DB_PREFIX . "option` ADD
`price_per_char` DECIMAL(15,4)");
}
]]></add>
</operation>
<operation>
<search position="before"><![CDATA[
if (isset($this->request->post['sort_order'])) {
]]></search>
<add><![CDATA[
//Q: Option Price By Character
if (isset($this->request->post['price_per_char'])) {
$this->data['price_per_char'] =
$this->request->post['price_per_char'];
} elseif (!empty($option_info)) {
$this->data['price_per_char'] = $option_info['price_per_char'];
} else {
$this->data['price_per_char'] = '';
}
]]></add>
</operation>
</file>
<file name="admin/view/template/catalog/option_form.tpl">
<operation>
<search position="before" index="1"><![CDATA[
</table>
]]></search>
<add><![CDATA[
<tr>
<td>Price Per Char:<br/><span class="help">For 'Text' and
'Textarea' types only</span></td>
<td><input type="text" name="price_per_char" value="<?php echo
(isset($price_per_char)) ? $price_per_char : '' ?>" size="3"
/></td>
</tr>
]]></add>
</operation>
</file>
<file name="admin/model/catalog/option.php">
<operation><!-- matches twice -->
<search position="replace"><![CDATA[
sort_order = '" . (int)$data['sort_order'] . "'
]]></search>
<add><![CDATA[
sort_order = '" . (int)$data['sort_order'] . "', price_per_char =
'" . (float)$data['price_per_char'] . "'
]]></add>
</operation>
</file>
<file name="catalog/model/catalog/product.php">
<operation>
<search position="after" index="2"><![CDATA[
$product_option_data[] = array(
]]></search>
<add><![CDATA[
'price_per_char' => $product_option['price_per_char'],
]]></add>
</operation>
</file>
<file name="catalog/controller/product/product.php">
<operation>
<search position="after" index="2"><![CDATA[
$this->data['options'][] = array(
]]></search>
<add><![CDATA[
'price_per_char' => $option['price_per_char'],
]]></add>
</operation>
</file>
<file name="catalog/view/theme/*/template/product/product.tpl">
<operation>
<search position="replace"><![CDATA[
<input type="text" name="option[<?php echo
$option['product_option_id']; ?>]" value="<?php echo
$option['option_value']; ?>" />
]]></search>
<add><![CDATA[
<input type="text" name="option[<?php echo
$option['product_option_id']; ?>]" value="<?php echo
$option['option_value']; ?>" price_per_char="<?php echo
$option['price_per_char']; ?>" onkeyup="$('.pbctotal<?php echo
$option['product_option_id']; ?>').remove(); var pbcval =
(this.value.length * <?php echo
$this->currency->format($option['price_per_char'], false, false,
false); ?>); if (pbcval > 0) { $(this).after(' <span
class=\'pbctotal<?php echo $option['product_option_id'];
?>\'>+'+parseFloat(pbcval).toFixed(2)+'</span>'); }" />
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[
<textarea name="option[<?php echo $option['product_option_id'];
?>]" cols="40" rows="5"><?php echo $option['option_value'];
?></textarea>
]]></search>
<add><![CDATA[
<textarea name="option[<?php echo $option['product_option_id'];
?>]" cols="40" rows="5" price_per_char="<?php echo
$option['price_per_char']; ?>" onkeyup="$('.pbctotal<?php echo
$option['product_option_id']; ?>').remove(); var pbcval =
(this.value.length * <?php echo
$this->currency->format($option['price_per_char'], false, false,
false); ?>); if (pbcval > 0) { $(this).after(' <span
class=\'pbctotal<?php echo $option['product_option_id'];
?>\'>+'+parseFloat(pbcval).toFixed(2)+'</span>'); }"><?php echo
$option['option_value']; ?></textarea>
]]></add>
</operation>
</file>
<file name="system/library/cart.php">
<operation>
<search position="after"><![CDATA[
$option_query =
]]></search>
<add><![CDATA[
//Q: Option Price By Character
$option_query = $this->db->query("SELECT * FROM " .
DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX .
"option` o ON (po.option_id = o.option_id) LEFT JOIN " .
DB_PREFIX . "option_description od ON (o.option_id =
od.option_id) WHERE po.product_option_id = '" .
(int)$product_option_id . "' AND po.product_id = '" .
(int)$product_id . "' AND od.language_id = '" .
(int)$this->config->get('config_language_id') . "'");
]]></add>
</operation>
<operation>
<search position="after"><![CDATA[
$option_query->row['type'] == 'text' || $option_query->row['type']
== 'textarea'
]]></search>
<add><![CDATA[
//Q: Option Price By Character
$optprice = '';
$optprefix = '';
if ($option_query->row['type'] == 'text' ||
$option_query->row['type'] == 'textarea') {
if (strlen($option_value)) {
$optprice = (strlen($option_value) *
$option_query->row['price_per_char']);
$optprefix = '+';
$option_price += $optprice;
}
}
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[
'price' => '',
]]></search>
<add trim="true"><![CDATA[
'price' => $optprice,
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[
'price_prefix' => '',
]]></search>
<add trim="true"><![CDATA[
'price_prefix' => $optprefix,
]]></add>
</operation>
</file>
Symfony2 : Recursive Validation
Symfony2 : Recursive Validation
I've got an entity with some validators (not a form).
So I use $validator->validate($entity), but it doesn't validate my
sub-ojects (the entity class has some others entity classes with some
validators).
Is there an "automatic" way to do this, or I have to do
$errorList->addAll($validator->validate($entity)); for each of them ?
I've got an entity with some validators (not a form).
So I use $validator->validate($entity), but it doesn't validate my
sub-ojects (the entity class has some others entity classes with some
validators).
Is there an "automatic" way to do this, or I have to do
$errorList->addAll($validator->validate($entity)); for each of them ?
jquery : how to apply same changes inside mulitple container with same class name
jquery : how to apply same changes inside mulitple container with same
class name
i am trying to move a .details outside of .buttons
<div class="product-actions">product 1
<div class="buttons buttons_3 group">buttons
<a class="details" title="Détails" rel="nofollow" >link</a>
</div>
</div>
<div class="product-actions">product 2
<div class="buttons buttons_3 group">buttons
<a class="details" title="Détails" rel="nofollow" >link</a>
</div>
</div>
this do the trick
if ($('.product-actions').length )
{
$('.product-actions').prepend("<div id='new_details_location'></div>");
$(".details").prependTo("#new_details_location");
$('.buttons_3').attr('class','buttons buttons_2 group');
}
the problem is there is more than one product and all a.details get moved
to the first product div instead of being prepend at the beginning of each
div .product-actions:
http://jsfiddle.net/upKhq/2/ any idea?
class name
i am trying to move a .details outside of .buttons
<div class="product-actions">product 1
<div class="buttons buttons_3 group">buttons
<a class="details" title="Détails" rel="nofollow" >link</a>
</div>
</div>
<div class="product-actions">product 2
<div class="buttons buttons_3 group">buttons
<a class="details" title="Détails" rel="nofollow" >link</a>
</div>
</div>
this do the trick
if ($('.product-actions').length )
{
$('.product-actions').prepend("<div id='new_details_location'></div>");
$(".details").prependTo("#new_details_location");
$('.buttons_3').attr('class','buttons buttons_2 group');
}
the problem is there is more than one product and all a.details get moved
to the first product div instead of being prepend at the beginning of each
div .product-actions:
http://jsfiddle.net/upKhq/2/ any idea?
Thursday, 22 August 2013
Windows 7 shows 1280x 1024 resolution but refuses to accept and display
Windows 7 shows 1280x 1024 resolution but refuses to accept and display
My Monitor is HPvs17x which has 1280x 1024 resolution resolution. But I am
unable to set in windows 7 inspite of the fact that this resoultion is
displayed in its setting box.
My Monitor is HPvs17x which has 1280x 1024 resolution resolution. But I am
unable to set in windows 7 inspite of the fact that this resoultion is
displayed in its setting box.
How to post a picture in my phone with Feed Dialog
How to post a picture in my phone with Feed Dialog
When you post picture with feed dialog you put the url at the picture
value https://developers.facebook.com/docs/concepts/feed/ like here
But how can you post a picture that is in your phone?
Do I have to upload the picture to my album first??
If I have to, how can I upload the picture to my album in facebook?
When you post picture with feed dialog you put the url at the picture
value https://developers.facebook.com/docs/concepts/feed/ like here
But how can you post a picture that is in your phone?
Do I have to upload the picture to my album first??
If I have to, how can I upload the picture to my album in facebook?
Hive with space delimited values
Hive with space delimited values
I'm new to hive and I want to use it on data that is space delimited. Is
there a pre-existing way to do it so that it groups together things that
are in quotes ("")?
I'm new to hive and I want to use it on data that is space delimited. Is
there a pre-existing way to do it so that it groups together things that
are in quotes ("")?
.Net ASMX client called remote service twice for every request
.Net ASMX client called remote service twice for every request
I have a web service hosted on remote AIX server, the service has HTTPS
access and with basic authentication turned on.
I used ASMX Web References to generate the proxy classes from my .Net 4.0
project. So I have following codes to call to the web service
var service = new ServiceProxy();
service.Credentials = new NetworkCredential("service-uid", "service-pwd");
var response = service.add(request);
That is very simple code. Now I ran Fiddler to inspect the traffic between
my local Windows machine and remote Unix server, but I noticed following 4
lines from Fiddler:
200, HTTP, Tunnel To, unix-server-host
401, HTTPS, unix-server-host, /srvcs/method
200, HTTP, Tunnel To, unix-server-host
200, HTTPS, unix-server-host, /srvcs/method
I also opened my log file on AIX server, and confirmed 2 requests coming
in within very close time
source IP - unauthenticated 22/Aug/2013:14:05:51 -0500 "POST /srvcs/method
HTTP/1.0" 401 1244
source IP - service-uid 22/Aug/2013:14:05:52 -0500 "POST /srvcs/method
HTTP/1.0" 200 3473
Anybody understands why .Net client will generate first call without
passing credential at all?
I have a web service hosted on remote AIX server, the service has HTTPS
access and with basic authentication turned on.
I used ASMX Web References to generate the proxy classes from my .Net 4.0
project. So I have following codes to call to the web service
var service = new ServiceProxy();
service.Credentials = new NetworkCredential("service-uid", "service-pwd");
var response = service.add(request);
That is very simple code. Now I ran Fiddler to inspect the traffic between
my local Windows machine and remote Unix server, but I noticed following 4
lines from Fiddler:
200, HTTP, Tunnel To, unix-server-host
401, HTTPS, unix-server-host, /srvcs/method
200, HTTP, Tunnel To, unix-server-host
200, HTTPS, unix-server-host, /srvcs/method
I also opened my log file on AIX server, and confirmed 2 requests coming
in within very close time
source IP - unauthenticated 22/Aug/2013:14:05:51 -0500 "POST /srvcs/method
HTTP/1.0" 401 1244
source IP - service-uid 22/Aug/2013:14:05:52 -0500 "POST /srvcs/method
HTTP/1.0" 200 3473
Anybody understands why .Net client will generate first call without
passing credential at all?
How to integrate tesserect in my Qt Project
How to integrate tesserect in my Qt Project
can someone give a small tutorial on using tesserect libraries in Qt. I am
using Qt5 with Qt Creator using msvc2010 (VS2010) compiler.
can someone give a small tutorial on using tesserect libraries in Qt. I am
using Qt5 with Qt Creator using msvc2010 (VS2010) compiler.
Combine 3 arrays with column format(PHP)
Combine 3 arrays with column format(PHP)
I have 3 arrays like this format
$array1 = array(a,b,c,d);
$array2 = array(e,f,g,h);
$array3 = array(i,j,k,l);
I need to merge this 3 arrays with column format
My expected result
array(a,e,i,b,f,j,c,g,k,d,h,l);
How can i do this. I am already do array merge. But its merge row format.
but i need column format.
Please Advise
I have 3 arrays like this format
$array1 = array(a,b,c,d);
$array2 = array(e,f,g,h);
$array3 = array(i,j,k,l);
I need to merge this 3 arrays with column format
My expected result
array(a,e,i,b,f,j,c,g,k,d,h,l);
How can i do this. I am already do array merge. But its merge row format.
but i need column format.
Please Advise
Android: how to store (add and delete) files to an application
Android: how to store (add and delete) files to an application
Thank you for your time and consideration.
I am facing the following situation and I need some advice on how to proceed.
I am building an application that needs to store files (pdf, word,...)
that are downloaded form the internet or come as attachments in emails,
etc.
The application needs to have the ability to add and delete the files.
Please I need some suggestion hon how to proceed to implement such a
functionality.
Please if there is some open source project that I could re-use for the
purpose that would be very helpful as well.
Thank you very much!!!
LISA
Thank you for your time and consideration.
I am facing the following situation and I need some advice on how to proceed.
I am building an application that needs to store files (pdf, word,...)
that are downloaded form the internet or come as attachments in emails,
etc.
The application needs to have the ability to add and delete the files.
Please I need some suggestion hon how to proceed to implement such a
functionality.
Please if there is some open source project that I could re-use for the
purpose that would be very helpful as well.
Thank you very much!!!
LISA
Wednesday, 21 August 2013
absolute positioning with percentages 50%
absolute positioning with percentages 50%
I found an anwswer from this: Absolute positioning with percentages giving
unexpected results
but the answer is not quite right shows on my screen
Here is jsFiddle from that answer.
#container {
border: 1px solid red;
height: 100px;
width: 100px;
overflow: hidden;
position: relative;
}
#item {
border: 1px dashed purple;
position: absolute;
left: 50%;
}
I am having this issue, 50% is not half of the parent's width, if someone
could help?
I found an anwswer from this: Absolute positioning with percentages giving
unexpected results
but the answer is not quite right shows on my screen
Here is jsFiddle from that answer.
#container {
border: 1px solid red;
height: 100px;
width: 100px;
overflow: hidden;
position: relative;
}
#item {
border: 1px dashed purple;
position: absolute;
left: 50%;
}
I am having this issue, 50% is not half of the parent's width, if someone
could help?
select all inputs except hidden (but with one exception)
select all inputs except hidden (but with one exception)
Lets say I have a set of inputs on a form:
<form id="myform">
<input type="checkbox" id="goat_1">
<input type="checkbox" id="goat_2">
<input type="text" id="pig_3">
<input type="hidden" id="cow_1">
<input type="hidden" id="chick_3">
<input type="hidden" id="duck_5">
</form>
I want to select all inputs, except type="hidden", but with one exception
I DO want any hidden input with an id beginning with "duck". I need this
all in one array so I can iterate through it.
So the first two parts are easy:
$("#myform").find(":input").not("[type=hidden]").each(
function () { alert("do stuff"); })
But what about the exception?
I am looking for the cleanest way to do this (prefer one line/statement).
Lets say I have a set of inputs on a form:
<form id="myform">
<input type="checkbox" id="goat_1">
<input type="checkbox" id="goat_2">
<input type="text" id="pig_3">
<input type="hidden" id="cow_1">
<input type="hidden" id="chick_3">
<input type="hidden" id="duck_5">
</form>
I want to select all inputs, except type="hidden", but with one exception
I DO want any hidden input with an id beginning with "duck". I need this
all in one array so I can iterate through it.
So the first two parts are easy:
$("#myform").find(":input").not("[type=hidden]").each(
function () { alert("do stuff"); })
But what about the exception?
I am looking for the cleanest way to do this (prefer one line/statement).
PowerShell do until or while exiting script
PowerShell do until or while exiting script
My script is exiting after the when the while loop is done. I have also
tried do until, but that exits as well. If I am going about this wrong let
me know.
#ADD VMWARE PSSNAPIN
Add-PSSnapin -Name "VMware.VimAutomation.Core"
#FORCE TO LOAD VMWARE POWERSHELL PLUGIN
[Reflection.Assembly]::LoadWithPartialName("vmware.vim")
$server_name = "VCENTER"
$vm_name = "VM_STAGING13"
$vc = Connect-VIServer -Server $server_name
$vm = Get-VM -Name $vm_name
#If the VM is not powered off then shut it down.
if ($vm.PowerState -notmatch "PoweredOff")
{
Shutdown-VMGuest -VM $vm.Name -Confirm:$false
}
#Sleep and check the power state of the VM.
do {
Start-Sleep -s 1
$vmpower = Get-VM -Name $vm_name | select PowerState
Write-Host "Sleeping 1 second...$vmpower"
}
while ($vmpower -notmatch "PoweredOff")
#If the VM indicates that it is off then update resources.
if ($vm.PowerState -match "PoweredOff")
{
Write-Host "Setting VM resources"
Set-VM -VM $vm.Name -MemoryMB "256" -NumCpu "1" -Confirm:$FALSE
Write-Host "Starting VM"
Start-VM -VM $vm.Name -Confirm:$FALSE
}
My script is exiting after the when the while loop is done. I have also
tried do until, but that exits as well. If I am going about this wrong let
me know.
#ADD VMWARE PSSNAPIN
Add-PSSnapin -Name "VMware.VimAutomation.Core"
#FORCE TO LOAD VMWARE POWERSHELL PLUGIN
[Reflection.Assembly]::LoadWithPartialName("vmware.vim")
$server_name = "VCENTER"
$vm_name = "VM_STAGING13"
$vc = Connect-VIServer -Server $server_name
$vm = Get-VM -Name $vm_name
#If the VM is not powered off then shut it down.
if ($vm.PowerState -notmatch "PoweredOff")
{
Shutdown-VMGuest -VM $vm.Name -Confirm:$false
}
#Sleep and check the power state of the VM.
do {
Start-Sleep -s 1
$vmpower = Get-VM -Name $vm_name | select PowerState
Write-Host "Sleeping 1 second...$vmpower"
}
while ($vmpower -notmatch "PoweredOff")
#If the VM indicates that it is off then update resources.
if ($vm.PowerState -match "PoweredOff")
{
Write-Host "Setting VM resources"
Set-VM -VM $vm.Name -MemoryMB "256" -NumCpu "1" -Confirm:$FALSE
Write-Host "Starting VM"
Start-VM -VM $vm.Name -Confirm:$FALSE
}
Least square solutions when Ax=b has no solution
Least square solutions when Ax=b has no solution
I have this linear alegbra question that I don't know how to start. The
question:
A = \begin{matrix}1 & -2 \\3 & 1 \\2 & 3 \\\end{matrix}
b= \begin{matrix} 0 \\ 1 \\ 0 \\ \end{matrix}
r = \begin{matrix} x \\ y \\ \end{matrix}
The matrix equation of Ar-b has no solution because it is inconsistent. If
we define the square error to be $\Delta^2 = \delta^T\delta$, we can still
solve the least square sense.
Explain why $\Delta^2$ is a function of x and y and that $\Delta^2 $ is
minimised by the solution of $$A^TAR = A^Tb$$
Need some guidance in solving this two parts.
I have this linear alegbra question that I don't know how to start. The
question:
A = \begin{matrix}1 & -2 \\3 & 1 \\2 & 3 \\\end{matrix}
b= \begin{matrix} 0 \\ 1 \\ 0 \\ \end{matrix}
r = \begin{matrix} x \\ y \\ \end{matrix}
The matrix equation of Ar-b has no solution because it is inconsistent. If
we define the square error to be $\Delta^2 = \delta^T\delta$, we can still
solve the least square sense.
Explain why $\Delta^2$ is a function of x and y and that $\Delta^2 $ is
minimised by the solution of $$A^TAR = A^Tb$$
Need some guidance in solving this two parts.
capture Alt D when application isnt in focus
capture Alt D when application isnt in focus
I have a c# winforms app that can be active or minimized. I want to be
able to capture and override any existing shortcut so that NO matter what
my app will respond to "Alt+D".
If the app has focus I can do this with
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Alt | Keys.D))
{
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
But when the app doesnt have focus it doesnt execute, e.g. if I am inside
firefox my Ctrl D keystroke sequence doesnt get activated
How can I get this to work?
Ideally I want to be able to highlight with the mouse / select some text
in ANY app and press Alt D and then send this text to my app.
I have a c# winforms app that can be active or minimized. I want to be
able to capture and override any existing shortcut so that NO matter what
my app will respond to "Alt+D".
If the app has focus I can do this with
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Alt | Keys.D))
{
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
But when the app doesnt have focus it doesnt execute, e.g. if I am inside
firefox my Ctrl D keystroke sequence doesnt get activated
How can I get this to work?
Ideally I want to be able to highlight with the mouse / select some text
in ANY app and press Alt D and then send this text to my app.
Get custom options in product page like a lable when the option is One?
Get custom options in product page like a lable when the option is One?
I've got this problem that I can't solve. Partly because I can't explain
it with the right terms. I'm new to this so sorry for this clumsy
question.
Below you can see an overview of my goal.
Here i am creating a product manually for that i gave a custom option
(Color = Red) And its a Dropdown type But here i am feeling when i have
only one value in dropdown it should display like a label.
for this i tried to modify the file select.phtml But no use
i need to do this
& I am using Magento CE1.7.0.2
Any Ideas ?
I've got this problem that I can't solve. Partly because I can't explain
it with the right terms. I'm new to this so sorry for this clumsy
question.
Below you can see an overview of my goal.
Here i am creating a product manually for that i gave a custom option
(Color = Red) And its a Dropdown type But here i am feeling when i have
only one value in dropdown it should display like a label.
for this i tried to modify the file select.phtml But no use
i need to do this
& I am using Magento CE1.7.0.2
Any Ideas ?
advantages and disadvantages of Editor Template in MVC3
advantages and disadvantages of Editor Template in MVC3
I searched a lot on it but didn't got any answer for my query. I wanted to
know Advantages and Disadvantages of using Editor Template in MVC3 Razor.
For eg. - By using editor template we do not have to loop down the things.
Are there more advantages and disadvantages for it?
I searched a lot on it but didn't got any answer for my query. I wanted to
know Advantages and Disadvantages of using Editor Template in MVC3 Razor.
For eg. - By using editor template we do not have to loop down the things.
Are there more advantages and disadvantages for it?
Tuesday, 20 August 2013
How `erl -make` does its work?
How `erl -make` does its work?
I found files won't be compiled in following situation with erl -make.
Compile file a.erl
Copy an old version of a.erl from other directory
Compile file a.erl
a.erl not compiled
Then I tested it on OS X, a.erl was compiled successfully.
In above two situations, the only difference is that the 'last modified
time' in OS X was changed when I copy the file with cp command, while not
changed in Windows without command.
I found files won't be compiled in following situation with erl -make.
Compile file a.erl
Copy an old version of a.erl from other directory
Compile file a.erl
a.erl not compiled
Then I tested it on OS X, a.erl was compiled successfully.
In above two situations, the only difference is that the 'last modified
time' in OS X was changed when I copy the file with cp command, while not
changed in Windows without command.
Smoothing in Mixture of Bernoullis for high-dimensional vectors
Smoothing in Mixture of Bernoullis for high-dimensional vectors
I've implemented mixture of Bernoullis in python, for a data set of
416-dimensional multivariate random variable. As expected, when
calculating the probability of such an R.V., I run into numerical
underflow problems about 300 dimensions into the calculation.
I have implemented smoothing in two places. The first uses a sum of
logprobs instead of a product over small probability values. This seems to
work, until I am caught taking the log of 0 if any Bernoulli mean = 1 or
0. So I smooth that also. If the mean = 1, I set it equal to .99, and if
0, I set it equal to .01. Ultimately, the combination of these two
smoothing techniques leads to problems after a few iterations of EM.
Initially, the cluster assignments adequately explain the data (they come
from two different sources and two separate clusters are apparent when the
data are visualized). After this though, the cluster proportions shift
dramatically, and one cluster assignment completely dominates the other
after only a few more iterations. Any idea why this is happening? I have
provided a code snippet below containing both of the smoothing techniques,
in case the problem exists there.
Also, here is a sample output. (Crude as yet, I know.)
Evaluating initial log-likelihood.
log likelihood: -288528.389451
Iteration #: 1 old mixing_proportions: [0.1, 0.1] new mixing_proportions:
[0.46218130113590206, 0.5378186988640978] Iteration #: 2 old
mixing_proportions: [0.46218130113590206, 0.5378186988640978] new
mixing_proportions: [0.5602861839787503, 0.43971381602124976] Iteration #:
3 old mixing_proportions: [0.5602861839787503, 0.43971381602124976] new
mixing_proportions: [0.4137759544813409, 0.5862240455186591] Iteration #:
4 old mixing_proportions: [0.4137759544813409, 0.5862240455186591]
new mixing_proportions: [0.6131604985789163, 0.38683950142108375]
Iteration #: 5 old mixing_proportions: [0.6131604985789163,
0.38683950142108375] new mixing_proportions: [0.3537971913067085,
0.6462028086932916] Iteration #: 6 old mixing_proportions:
[0.3537971913067085, 0.6462028086932916] new mixing_proportions:
[0.6972187269487877, 0.3027812730512123] Iteration #: 7 old
mixing_proportions: [0.6972187269487877, 0.3027812730512123] new
mixing_proportions: [0.23220293867520006, 0.7677970613247999] Iteration #:
8 old mixing_proportions: [0.23220293867520006, 0.7677970613247999] new
mixing_proportions: [0.8774645158252881, 0.12253548417471194] Iteration #:
9 old mixing_proportions: [0.8774645158252881, 0.12253548417471194] new
mixing_proportions: [0.0013733019674422116, 0.9986266980325578] Iteration
#: 10 old mixing_proportions: [0.0013733019674422116, 0.9986266980325578]
new mixing_proportions: [1.0, 1.863681856053267e-20]
Any advice would be tremendously appreciated. I'm really in a jam!
for i in range(0, 20):
print "Iteration #: " + str(i + 1)
# E - STEP
# re-calculate gammas
for n in range(0, N):
k_numerators = []
for k in range(0, K):
log_prob_xn = 0.0 # for calculating the logprobs
#calculate the inner summation of the logprobs (over the vector
dimensions) Bishop pg 446
for d in range(0, D):
if MUs[k][d] == 1.0:
smoothed_mu = .99
log_prob_xn = log_prob_xn + ((babies[n][d] *
math.log(smoothed_mu)) + ((1 - babies[n][d]) * math.log(1 -
smoothed_mu)))
elif MUs[k][d] == 0.0:
smoothed_mu = .01
log_prob_xn = log_prob_xn + ((babies[n][d] *
math.log(smoothed_mu)) + ((1 - babies[n][d]) * math.log(1 -
smoothed_mu)))
else:
log_prob_xn = log_prob_xn + ((babies[n][d] *
math.log(MUs[k][d])) + ((1 - babies[n][d]) * math.log(1 -
MUs[k][d])))
numerator = math.log(mixing_proportions[k]) * log_prob_xn
k_numerators.append(numerator)
#now we need to get m - the max of the numerators, so that we can
estimate our gammas with stable numbers
max_numerator = k_numerators[0]
for k in range(1, K):
if k_numerators[k] > max_numerator:
max_numerator = k_numerators[k]
denominator = 0.0
#now, this is more complicated: we want to approximate the denominator
ignoring very small numbers right now we're trying for -100 as our
threshold
for k in range(0, K):
if ((k_numerators[k] - max_numerator) >= -100):
denominator = denominator + math.exp(k_numerators[k] - max_numerator)
for k in range(0, K):
if ((k_numerators[k] - max_numerator) < -100):
gamma[n][k] = 0
else:
gamma[n][k] = (math.exp(k_numerators[k] - max_numerator) /
denominator)
I've implemented mixture of Bernoullis in python, for a data set of
416-dimensional multivariate random variable. As expected, when
calculating the probability of such an R.V., I run into numerical
underflow problems about 300 dimensions into the calculation.
I have implemented smoothing in two places. The first uses a sum of
logprobs instead of a product over small probability values. This seems to
work, until I am caught taking the log of 0 if any Bernoulli mean = 1 or
0. So I smooth that also. If the mean = 1, I set it equal to .99, and if
0, I set it equal to .01. Ultimately, the combination of these two
smoothing techniques leads to problems after a few iterations of EM.
Initially, the cluster assignments adequately explain the data (they come
from two different sources and two separate clusters are apparent when the
data are visualized). After this though, the cluster proportions shift
dramatically, and one cluster assignment completely dominates the other
after only a few more iterations. Any idea why this is happening? I have
provided a code snippet below containing both of the smoothing techniques,
in case the problem exists there.
Also, here is a sample output. (Crude as yet, I know.)
Evaluating initial log-likelihood.
log likelihood: -288528.389451
Iteration #: 1 old mixing_proportions: [0.1, 0.1] new mixing_proportions:
[0.46218130113590206, 0.5378186988640978] Iteration #: 2 old
mixing_proportions: [0.46218130113590206, 0.5378186988640978] new
mixing_proportions: [0.5602861839787503, 0.43971381602124976] Iteration #:
3 old mixing_proportions: [0.5602861839787503, 0.43971381602124976] new
mixing_proportions: [0.4137759544813409, 0.5862240455186591] Iteration #:
4 old mixing_proportions: [0.4137759544813409, 0.5862240455186591]
new mixing_proportions: [0.6131604985789163, 0.38683950142108375]
Iteration #: 5 old mixing_proportions: [0.6131604985789163,
0.38683950142108375] new mixing_proportions: [0.3537971913067085,
0.6462028086932916] Iteration #: 6 old mixing_proportions:
[0.3537971913067085, 0.6462028086932916] new mixing_proportions:
[0.6972187269487877, 0.3027812730512123] Iteration #: 7 old
mixing_proportions: [0.6972187269487877, 0.3027812730512123] new
mixing_proportions: [0.23220293867520006, 0.7677970613247999] Iteration #:
8 old mixing_proportions: [0.23220293867520006, 0.7677970613247999] new
mixing_proportions: [0.8774645158252881, 0.12253548417471194] Iteration #:
9 old mixing_proportions: [0.8774645158252881, 0.12253548417471194] new
mixing_proportions: [0.0013733019674422116, 0.9986266980325578] Iteration
#: 10 old mixing_proportions: [0.0013733019674422116, 0.9986266980325578]
new mixing_proportions: [1.0, 1.863681856053267e-20]
Any advice would be tremendously appreciated. I'm really in a jam!
for i in range(0, 20):
print "Iteration #: " + str(i + 1)
# E - STEP
# re-calculate gammas
for n in range(0, N):
k_numerators = []
for k in range(0, K):
log_prob_xn = 0.0 # for calculating the logprobs
#calculate the inner summation of the logprobs (over the vector
dimensions) Bishop pg 446
for d in range(0, D):
if MUs[k][d] == 1.0:
smoothed_mu = .99
log_prob_xn = log_prob_xn + ((babies[n][d] *
math.log(smoothed_mu)) + ((1 - babies[n][d]) * math.log(1 -
smoothed_mu)))
elif MUs[k][d] == 0.0:
smoothed_mu = .01
log_prob_xn = log_prob_xn + ((babies[n][d] *
math.log(smoothed_mu)) + ((1 - babies[n][d]) * math.log(1 -
smoothed_mu)))
else:
log_prob_xn = log_prob_xn + ((babies[n][d] *
math.log(MUs[k][d])) + ((1 - babies[n][d]) * math.log(1 -
MUs[k][d])))
numerator = math.log(mixing_proportions[k]) * log_prob_xn
k_numerators.append(numerator)
#now we need to get m - the max of the numerators, so that we can
estimate our gammas with stable numbers
max_numerator = k_numerators[0]
for k in range(1, K):
if k_numerators[k] > max_numerator:
max_numerator = k_numerators[k]
denominator = 0.0
#now, this is more complicated: we want to approximate the denominator
ignoring very small numbers right now we're trying for -100 as our
threshold
for k in range(0, K):
if ((k_numerators[k] - max_numerator) >= -100):
denominator = denominator + math.exp(k_numerators[k] - max_numerator)
for k in range(0, K):
if ((k_numerators[k] - max_numerator) < -100):
gamma[n][k] = 0
else:
gamma[n][k] = (math.exp(k_numerators[k] - max_numerator) /
denominator)
How to align two divs side by side using the float, clear, and overflow elements with a fixed position div/
How to align two divs side by side using the float, clear, and overflow
elements with a fixed position div/
So I've been trying to align two divs side by side without overlapping. I
have one div which will be fixed as a sidebar and the right div as the
content. Hopefully, someone can help me.
HTML:
<div id="wrapper">
<div id="leftcolumn">
</div>
<div id="rightcolumn">
</div>
</div>
CSS:
body {
background-color: #444;
margin-top: 0;
margin-bottom: 0;
}
#wrapper {
width: 1005px;
margin: 0 auto;
padding: 0;
overflow: auto;
}
#leftcolumn {
width: 750px;
background-color: #111;
padding: 0;
margin: 0;
display: block;
float: left;
border: 1px solid white;
position: fixed;
}
#rightcolumn {
width: 250px;
background-color: #777;
display: block;
float: left;
border: 1px solid white;
}
elements with a fixed position div/
So I've been trying to align two divs side by side without overlapping. I
have one div which will be fixed as a sidebar and the right div as the
content. Hopefully, someone can help me.
HTML:
<div id="wrapper">
<div id="leftcolumn">
</div>
<div id="rightcolumn">
</div>
</div>
CSS:
body {
background-color: #444;
margin-top: 0;
margin-bottom: 0;
}
#wrapper {
width: 1005px;
margin: 0 auto;
padding: 0;
overflow: auto;
}
#leftcolumn {
width: 750px;
background-color: #111;
padding: 0;
margin: 0;
display: block;
float: left;
border: 1px solid white;
position: fixed;
}
#rightcolumn {
width: 250px;
background-color: #777;
display: block;
float: left;
border: 1px solid white;
}
Splitting circular nodes in tikz
Splitting circular nodes in tikz
I'm trying to reproduce the attached figure using the tikz package, but am
having a hard time splitting the node with the {X,x} in it. Any
suggestions?
Here's what I've come up with so far, but it's not good enough. The {X,x}
node needs to be rotated and split, exactly as in the figure (colors not
important):
\begin{tikzpicture}
\node [circle split,
draw,
line width = .05cm,
minimum width=1cm,
append after command={%
let \p1=($(\tikzlastnode.east)-(\tikzlastnode.west)$) in
node[draw,
shape=semicircle,
rotate=180,
anchor=south,
double,
minimum width=\x1] at (\tikzlastnode.center) {}}]
{$X$
\nodepart{lower}
$x$
};
\node [ellipse,draw,line width=.05cm] at (3.75,0) {$Y(x)$};
\node [circle,draw,line width=.05cm] at (1.5,3) {$L$};
\node [circle,draw,line width=.05cm] at (4,4.5) {$H$};
\draw[->, line width=.125cm] (1.1,0) -- (2.5,0);
\draw[->, line width=.125cm] (0.9,3) to [out=180,in=90] (-.5,1);
\draw[->, line width=.125cm] (1.8,2.6) -- (3,.75);
\draw[->, line width=.125cm] (3.45,4.2) -- (2.1,3.25);
\draw[->, line width=.125cm] (4,3.9) -- (4,.85);
%\draw[help lines] (0,0) grid (8,6) ;
\end{tikzpicture}
I'm trying to reproduce the attached figure using the tikz package, but am
having a hard time splitting the node with the {X,x} in it. Any
suggestions?
Here's what I've come up with so far, but it's not good enough. The {X,x}
node needs to be rotated and split, exactly as in the figure (colors not
important):
\begin{tikzpicture}
\node [circle split,
draw,
line width = .05cm,
minimum width=1cm,
append after command={%
let \p1=($(\tikzlastnode.east)-(\tikzlastnode.west)$) in
node[draw,
shape=semicircle,
rotate=180,
anchor=south,
double,
minimum width=\x1] at (\tikzlastnode.center) {}}]
{$X$
\nodepart{lower}
$x$
};
\node [ellipse,draw,line width=.05cm] at (3.75,0) {$Y(x)$};
\node [circle,draw,line width=.05cm] at (1.5,3) {$L$};
\node [circle,draw,line width=.05cm] at (4,4.5) {$H$};
\draw[->, line width=.125cm] (1.1,0) -- (2.5,0);
\draw[->, line width=.125cm] (0.9,3) to [out=180,in=90] (-.5,1);
\draw[->, line width=.125cm] (1.8,2.6) -- (3,.75);
\draw[->, line width=.125cm] (3.45,4.2) -- (2.1,3.25);
\draw[->, line width=.125cm] (4,3.9) -- (4,.85);
%\draw[help lines] (0,0) grid (8,6) ;
\end{tikzpicture}
Resize the text font in UILabel
Resize the text font in UILabel
I want to change the font of text to fit it in UILabel acoording to the
length of text. Any help will be appreciated.
I want to change the font of text to fit it in UILabel acoording to the
length of text. Any help will be appreciated.
My server has falled down
My server has falled down
My server has falled down since I have tried to install apc. I just have
installed php-pear and apache2-prefork-mem. Now my server does not respond
and don't know why.
[Tue Aug 20 11:07:01.123491 2013] [core:notice] [pid 16080] AH00094:
Command line: '/usr/sbin/apache2'
[Tue Aug 20 11:14:33.510798 2013] [mpm_prefork:notice] [pid 16080]
AH00169: caught SIGTERM, shutting down
[Tue Aug 20 11:14:34.698790 2013] [mpm_prefork:notice] [pid 17880]
AH00163: Apache/2.4.6 (Ubuntu) PHP/5.5.1-2+debphp.org~precise+2 configured
-- resuming normal operations
[Tue Aug 20 11:14:34.698977 2013] [core:notice] [pid 17880] AH00094:
Command line: '/usr/sbin/apache2'
Any idea of how to solve it? I've tried to remove them but nothing changes
My server has falled down since I have tried to install apc. I just have
installed php-pear and apache2-prefork-mem. Now my server does not respond
and don't know why.
[Tue Aug 20 11:07:01.123491 2013] [core:notice] [pid 16080] AH00094:
Command line: '/usr/sbin/apache2'
[Tue Aug 20 11:14:33.510798 2013] [mpm_prefork:notice] [pid 16080]
AH00169: caught SIGTERM, shutting down
[Tue Aug 20 11:14:34.698790 2013] [mpm_prefork:notice] [pid 17880]
AH00163: Apache/2.4.6 (Ubuntu) PHP/5.5.1-2+debphp.org~precise+2 configured
-- resuming normal operations
[Tue Aug 20 11:14:34.698977 2013] [core:notice] [pid 17880] AH00094:
Command line: '/usr/sbin/apache2'
Any idea of how to solve it? I've tried to remove them but nothing changes
Using ? operator: "only assignment, call, increment..."
Using ? operator: "only assignment, call, increment..."
I have action dictionary defined as:
var actions = new Dictionary<string, Action<string, string>>();
I put there actions like:
actions.Add("default", (value, key) => result.Compare(value,
properties[key], Comparers.SomeComparer, key));
...
I'm using this code to run it:
if (actions.ContainsKey(pair.Key))
{
actions[pair.Key](pair.Value, pair.Key);
}
else
{
actions[""](pair.Value, pair.Key);
}
It works just fine, but I wanted to use '?' notation to make it shorter:
actions.ContainsKey(pair.Key) ? actions[pair.Key](pair.Value, pair.Key) :
actions[""](pair.Value, pair.Key);
This code shows me error:
Error 1 Only assignment, call, increment, decrement, and new object
expressions can be used as a statement
actions[pair.Key](pair.Value, pair.Key) isn't it a call? Am I missing
something? Is it possible to use '?' notation with action dictionaries? I
was trying to find something about that but it's hard to find anything
about '?' operator and this error because '?' is ignored by google.
I have action dictionary defined as:
var actions = new Dictionary<string, Action<string, string>>();
I put there actions like:
actions.Add("default", (value, key) => result.Compare(value,
properties[key], Comparers.SomeComparer, key));
...
I'm using this code to run it:
if (actions.ContainsKey(pair.Key))
{
actions[pair.Key](pair.Value, pair.Key);
}
else
{
actions[""](pair.Value, pair.Key);
}
It works just fine, but I wanted to use '?' notation to make it shorter:
actions.ContainsKey(pair.Key) ? actions[pair.Key](pair.Value, pair.Key) :
actions[""](pair.Value, pair.Key);
This code shows me error:
Error 1 Only assignment, call, increment, decrement, and new object
expressions can be used as a statement
actions[pair.Key](pair.Value, pair.Key) isn't it a call? Am I missing
something? Is it possible to use '?' notation with action dictionaries? I
was trying to find something about that but it's hard to find anything
about '?' operator and this error because '?' is ignored by google.
Monday, 19 August 2013
CSV Search AutoIT
CSV Search AutoIT
I have a csv file that contains 4 columns, I want to search column 2 and
change the corresponding data in column 4 using AutoIT
col 1 col 2 col 3 col 4 1 502 shop 25.00 2 106 house 50.00 3 307 boat 15.00
I have a csv file that contains 4 columns, I want to search column 2 and
change the corresponding data in column 4 using AutoIT
col 1 col 2 col 3 col 4 1 502 shop 25.00 2 106 house 50.00 3 307 boat 15.00
Media Queries or a Mobile SIte
Media Queries or a Mobile SIte
Lets take agrilife.co.nz for example
If you were in my shoes what would you do to make sure the site is
functioning 100% across the world of devices and responsive design?
At this stage I am not sure what road to take and was just wanting another
people point of view.
It seems ok on my iPhone but could do with the container being set at 320px;
I have taken this site over so I did not do it from the start.
Lets take agrilife.co.nz for example
If you were in my shoes what would you do to make sure the site is
functioning 100% across the world of devices and responsive design?
At this stage I am not sure what road to take and was just wanting another
people point of view.
It seems ok on my iPhone but could do with the container being set at 320px;
I have taken this site over so I did not do it from the start.
Cost of Hosting a java website on Amazon EC2 [on hold]
Cost of Hosting a java website on Amazon EC2 [on hold]
I want to use amazon ec2 as web hosting for my java website. I want to
know what will be the approximated cost of using it? Tell me in details
for monthly basis. And if you could give any tutorial links for this then
it would be really helpful. If you know any better hosting for java
website then do let me know.
I want to use amazon ec2 as web hosting for my java website. I want to
know what will be the approximated cost of using it? Tell me in details
for monthly basis. And if you could give any tutorial links for this then
it would be really helpful. If you know any better hosting for java
website then do let me know.
How can i use camera on kivy?
How can i use camera on kivy?
I want to write a little application that opens the camera of my mobile
device. Does anyone have a little script for it all my trys still failed.
I want to write a little application that opens the camera of my mobile
device. Does anyone have a little script for it all my trys still failed.
Sunday, 18 August 2013
C++, best way to change a string at a particular index
C++, best way to change a string at a particular index
I want to change a C++ string at a particular index like this:
string s = "abc";
s[1] = 'a';
Is the following code valid? Is this an acceptable way to do this?
I didn't find any reference which says it is valid:
http://www.cplusplus.com/reference/string/string/
Which says that through "overloaded [] operator in string" we can perform
the write operation.
I want to change a C++ string at a particular index like this:
string s = "abc";
s[1] = 'a';
Is the following code valid? Is this an acceptable way to do this?
I didn't find any reference which says it is valid:
http://www.cplusplus.com/reference/string/string/
Which says that through "overloaded [] operator in string" we can perform
the write operation.
run python function on a website
run python function on a website
So I have written a module that parses text; certain keywords have
different abilities and create different things.
I am setting up a website, and all I want to do is, on a button click,
have some text from a div be put into my Python function and then replaced
with the output of that function
I have never used Python for web stuff before, and Django seems like
overkill here as all I need to do is run one function and everything else
is pure HTML, CSS and JS
so is there an easy way to do this?
So I have written a module that parses text; certain keywords have
different abilities and create different things.
I am setting up a website, and all I want to do is, on a button click,
have some text from a div be put into my Python function and then replaced
with the output of that function
I have never used Python for web stuff before, and Django seems like
overkill here as all I need to do is run one function and everything else
is pure HTML, CSS and JS
so is there an easy way to do this?
which cms to opt for college information website
which cms to opt for college information website
i want to create a information website for college students that contain
information for classes and upcoming events to be held in the college.
Then which content management system should i opt to make my site more
responsive and adaptable.
i want to create a information website for college students that contain
information for classes and upcoming events to be held in the college.
Then which content management system should i opt to make my site more
responsive and adaptable.
Using spring DI for providing mock data
Using spring DI for providing mock data
Im new to spring, In my program Im using JSF+ spring integration and for
the UI testing I need to make mock datas(by not using database).I am going
to use spring's Dependency injection for this. This is my data,
Vehicle ID --- veh101, veh102,veh103
Vehicle Type --- car, bus, bike
Vehicle color --- Red, blue, white
veh101, car, red are description of a single object. I have created a bean
class 'VehicleBean' with properties - vehicleId,vechicleType and
vechicleColor
in the xml, I have given,
<bean id="VehicleBean" class="com.Vechicle.components.VechicleBean"
scope="request">
<property name="vehicleId" value="veh101" />
<property name="vechicleType" value="car" />
<property name="vechicleColor" value="Red" />
</bean>
These values are to be accessed in the UI by #{value} so how do I
refer/create objects for the rest of it,veh102 and veh 103?
Thanks in advance
Im new to spring, In my program Im using JSF+ spring integration and for
the UI testing I need to make mock datas(by not using database).I am going
to use spring's Dependency injection for this. This is my data,
Vehicle ID --- veh101, veh102,veh103
Vehicle Type --- car, bus, bike
Vehicle color --- Red, blue, white
veh101, car, red are description of a single object. I have created a bean
class 'VehicleBean' with properties - vehicleId,vechicleType and
vechicleColor
in the xml, I have given,
<bean id="VehicleBean" class="com.Vechicle.components.VechicleBean"
scope="request">
<property name="vehicleId" value="veh101" />
<property name="vechicleType" value="car" />
<property name="vechicleColor" value="Red" />
</bean>
These values are to be accessed in the UI by #{value} so how do I
refer/create objects for the rest of it,veh102 and veh 103?
Thanks in advance
Facebook comment box plugin clipped
Facebook comment box plugin clipped
I'm trying to integrate the Facebook comment box plugin into a HTML
website. I'm using the example code generated at
https://developers.facebook.com/docs/reference/plugins/comments/
For some reason, my comments box is clipped and does not resize vertically
- see image http://i.stack.imgur.com/yaSAg.png
My example website code:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>FB Comments Test</title>
</head>
<body>
<!-- LOAD THE FB JavaScript SDK -->
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src =
"http://connect.facebook.net/en_US/all.js#xfbml=1&appId=158996047491784";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<!-- DISPLAY THE COMMENTS -->
<div class="fb-comments" data-href="http://example.com"
data-width="470"></div><br/>
</body>
</html>
Thanks for help! Lukas
I'm trying to integrate the Facebook comment box plugin into a HTML
website. I'm using the example code generated at
https://developers.facebook.com/docs/reference/plugins/comments/
For some reason, my comments box is clipped and does not resize vertically
- see image http://i.stack.imgur.com/yaSAg.png
My example website code:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>FB Comments Test</title>
</head>
<body>
<!-- LOAD THE FB JavaScript SDK -->
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src =
"http://connect.facebook.net/en_US/all.js#xfbml=1&appId=158996047491784";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<!-- DISPLAY THE COMMENTS -->
<div class="fb-comments" data-href="http://example.com"
data-width="470"></div><br/>
</body>
</html>
Thanks for help! Lukas
Apache configuration - rewrite rule for all virtual hosts
Apache configuration - rewrite rule for all virtual hosts
I have the following configuration with 2 virtual hosts on my Apache:
www.domain.com and res.domain.com. The first one is open the second is
limited to registred users.
<VirtualHost *:80>
ServerName www.domain.com
DocumentRoot /website/www
<Directory "/website/www">
Options FollowSymLinks
AllowOverride All
RewriteEngine On
RewriteCond %{REQUEST_URI} !api/dispatch\.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^api/.*$ api/dispatch.php [L,QSA]
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName res.domain.com
DocumentRoot /website/res
<Directory "/website/res">
Options FollowSymLinks
AllowOverride All
AuthType Basic
AuthUserFile /website/res/users.sec
<Limit GET POST>
Require valid-user
</Limit>
</Directory>
</VirtualHost>
I would like to serve all the calls http://res.domain.com/api/* exactly as
if they were http://www.domain.com/api/*. No authentication and same
behavior...
Important: I don't want my users see a redirect...
I need help because I tried so many things but no success.
I have the following configuration with 2 virtual hosts on my Apache:
www.domain.com and res.domain.com. The first one is open the second is
limited to registred users.
<VirtualHost *:80>
ServerName www.domain.com
DocumentRoot /website/www
<Directory "/website/www">
Options FollowSymLinks
AllowOverride All
RewriteEngine On
RewriteCond %{REQUEST_URI} !api/dispatch\.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^api/.*$ api/dispatch.php [L,QSA]
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName res.domain.com
DocumentRoot /website/res
<Directory "/website/res">
Options FollowSymLinks
AllowOverride All
AuthType Basic
AuthUserFile /website/res/users.sec
<Limit GET POST>
Require valid-user
</Limit>
</Directory>
</VirtualHost>
I would like to serve all the calls http://res.domain.com/api/* exactly as
if they were http://www.domain.com/api/*. No authentication and same
behavior...
Important: I don't want my users see a redirect...
I need help because I tried so many things but no success.
Saturday, 17 August 2013
Sum of m+n terms if sum of m and n terms are given
Sum of m+n terms if sum of m and n terms are given
The sum of $m$ terms of an arithmetic series is $n$, and that of $n$ terms
is $m$. Then how do we calculate the sum of $m+n$ terms?
We know this:
The sum of $p$ terms of an arithmetic series is $\frac{p}{2(2a+(p-1)d)}$
where $a$ is the first term and $d$ is the difference between each term.
We can express what $m$ and $n$ equal to by putting $p$ equal to $n$ and
$m$ respectively.
Then to get $m+n$, we simply add the new ways of expressing $m$ and $n$.
Now to get the sum, we take $p=m+n$, but that yields an expression that is
way too big to handle, and since this is a textbook problem, I am assuming
the answer is short and succint.
Also, can you guys actually show me the example of a series where sum of
$m$ terms is $n$ and vice versa?
The sum of $m$ terms of an arithmetic series is $n$, and that of $n$ terms
is $m$. Then how do we calculate the sum of $m+n$ terms?
We know this:
The sum of $p$ terms of an arithmetic series is $\frac{p}{2(2a+(p-1)d)}$
where $a$ is the first term and $d$ is the difference between each term.
We can express what $m$ and $n$ equal to by putting $p$ equal to $n$ and
$m$ respectively.
Then to get $m+n$, we simply add the new ways of expressing $m$ and $n$.
Now to get the sum, we take $p=m+n$, but that yields an expression that is
way too big to handle, and since this is a textbook problem, I am assuming
the answer is short and succint.
Also, can you guys actually show me the example of a series where sum of
$m$ terms is $n$ and vice versa?
Undefined Symbols for custom C++ classes in Xcode 4.6.3. Works in Xcode 4.5.2
Undefined Symbols for custom C++ classes in Xcode 4.6.3. Works in Xcode 4.5.2
I have an iOS app that works fine in Xcode 4.5.2 but in Xcode 4.6.3 i get
undefined symbols for my custom c++ classes.
SomeClass.hpp
class SomeClass{
public:
SomeClass();
void doStuff();
}
SomeClass.cpp
#include "SomeClass.hpp"
SomeClass::SomeClass(){
// ra ra ra
}
SomeClass::doStuff() {
// ra ra ra
}
CallingClass.mm
#include "SomeClass.hpp"
@implementation CallingClass
-(void) execute{
SomeClass someObject;
someObject.doStuff();
}
@end
Error
Undefined Symbols for arm7:
SomeClass::SomeClass() referenced from:
-[CallingClass execute:] in CallingClass.o
The .hpp files are set to C++ Headers, the .cpp files are set to C++
Source, and the .mm files are set to Objective-C++ Source. libc++.dylib is
included in the project for a library that i'm using.
Any guidance would be highly appreciated.
Cheers
I have an iOS app that works fine in Xcode 4.5.2 but in Xcode 4.6.3 i get
undefined symbols for my custom c++ classes.
SomeClass.hpp
class SomeClass{
public:
SomeClass();
void doStuff();
}
SomeClass.cpp
#include "SomeClass.hpp"
SomeClass::SomeClass(){
// ra ra ra
}
SomeClass::doStuff() {
// ra ra ra
}
CallingClass.mm
#include "SomeClass.hpp"
@implementation CallingClass
-(void) execute{
SomeClass someObject;
someObject.doStuff();
}
@end
Error
Undefined Symbols for arm7:
SomeClass::SomeClass() referenced from:
-[CallingClass execute:] in CallingClass.o
The .hpp files are set to C++ Headers, the .cpp files are set to C++
Source, and the .mm files are set to Objective-C++ Source. libc++.dylib is
included in the project for a library that i'm using.
Any guidance would be highly appreciated.
Cheers
Acronyms with Full stops python
Acronyms with Full stops python
I have code which reads a text file and outputs the amount of TLA's in the
text as a percentage out of how many lines contain text.
import re
total_lines = 0
matched_lines = 0
for line in open("sentences.txt"):
total_lines += 1
matched_lines += bool(re.search(r"\b[A-Z]{3}\b", line))
matched_lines += bool(re.search(r"\b[A-Z]\\.[A-Z]\\.[A-Z]\b", line)) #
DOES NOT WORK
print('{}% of sentences contain a TLA'.format(round(float(matched_lines) /
total_lines * 100, 1)))
What i'm trying to do is count TLA's with full stops between them. So like
now it counts WWW but i want it to count W.W.W as well.
I have code which reads a text file and outputs the amount of TLA's in the
text as a percentage out of how many lines contain text.
import re
total_lines = 0
matched_lines = 0
for line in open("sentences.txt"):
total_lines += 1
matched_lines += bool(re.search(r"\b[A-Z]{3}\b", line))
matched_lines += bool(re.search(r"\b[A-Z]\\.[A-Z]\\.[A-Z]\b", line)) #
DOES NOT WORK
print('{}% of sentences contain a TLA'.format(round(float(matched_lines) /
total_lines * 100, 1)))
What i'm trying to do is count TLA's with full stops between them. So like
now it counts WWW but i want it to count W.W.W as well.
Trouble with button on iphone?
Trouble with button on iphone?
I have this code in my body,
<button onclick="change();" id="button2">Click!</button>
And this in my css
#button2
{
width: 200px;
height: 200px;
}
The button appears 200x200 on my computer but appears wrong on my iphone.
Why is this? I have used this code before with no problem
I have this code in my body,
<button onclick="change();" id="button2">Click!</button>
And this in my css
#button2
{
width: 200px;
height: 200px;
}
The button appears 200x200 on my computer but appears wrong on my iphone.
Why is this? I have used this code before with no problem
I cant get the result with g_hash_table_look_up
I cant get the result with g_hash_table_look_up
//here is my code,i want to use string for key ,and find my value,my value
mustbe a pointer. Thanks for help!
#include <stdio.h>
#include <glib.h>
int main()
{
GHashTable *hash_list; ///denfine my hashtable
char str1[32];
sprintf(str1, "key");
char str2[32];
sprintf(str2, "key");
hash_list = g_hash_table_new(g_str_hash, g_direct_equal); ///create my
hashtable
g_hash_table_insert(tcp_stream_list, str1, "ssssssssssssssss");
///insert my key and value
char *c = (char*) g_hash_table_lookup(tcp_stream_list, (str2)); ///find
my key
if (c)
{
printf("%s\n", c); ///print the string
}
return 0;
}
//here is my code,i want to use string for key ,and find my value,my value
mustbe a pointer. Thanks for help!
#include <stdio.h>
#include <glib.h>
int main()
{
GHashTable *hash_list; ///denfine my hashtable
char str1[32];
sprintf(str1, "key");
char str2[32];
sprintf(str2, "key");
hash_list = g_hash_table_new(g_str_hash, g_direct_equal); ///create my
hashtable
g_hash_table_insert(tcp_stream_list, str1, "ssssssssssssssss");
///insert my key and value
char *c = (char*) g_hash_table_lookup(tcp_stream_list, (str2)); ///find
my key
if (c)
{
printf("%s\n", c); ///print the string
}
return 0;
}
wpf TreeView Expand all children by using ViewModel
wpf TreeView Expand all children by using ViewModel
I see there are some questions related expanding all children using
ViewModel-s I've tried to follow some of them to solve my problem, but
without results.
The problem is when I'm setting IsExpanded(in viewmodel) to true, the only
top parent is being expanded, I've added TreeViewItem.Expand event handler
to my TreeView and set a breakpoint in the handler.
I'm waiting to be paused on breakpoint in the TreeViewItem.Expand event
handler, but it is happening only once: after top parent IsExpanded
changing.
What is wrong, what I missed?
I see there are some questions related expanding all children using
ViewModel-s I've tried to follow some of them to solve my problem, but
without results.
The problem is when I'm setting IsExpanded(in viewmodel) to true, the only
top parent is being expanded, I've added TreeViewItem.Expand event handler
to my TreeView and set a breakpoint in the handler.
I'm waiting to be paused on breakpoint in the TreeViewItem.Expand event
handler, but it is happening only once: after top parent IsExpanded
changing.
What is wrong, what I missed?
Turn On GPS using NDK
Turn On GPS using NDK
I have read a lot of posts about managing GPS in android using code. All
of them saying that it is not possible. But they are all using android SDK
to talk about the topic. Since it is not possible with SDK, can it be done
using NDK?
I am asking this question, even after reading all those, because the
android settings application can enable/disable it, which means it is not
impossible.
In my app, it needs to turn GPS for a while and turn it off (for power
reduction) and send the GPS data to a server.
Ultimately android is Linux based. So there must a way to turn it on/off
using the Linux commands/APIs right? (or using the NDK) can anyone share
the ideas about that?
If it is not at all possible (last option), is there any alternate way to
get location information using any other functionalists.
I have read a lot of posts about managing GPS in android using code. All
of them saying that it is not possible. But they are all using android SDK
to talk about the topic. Since it is not possible with SDK, can it be done
using NDK?
I am asking this question, even after reading all those, because the
android settings application can enable/disable it, which means it is not
impossible.
In my app, it needs to turn GPS for a while and turn it off (for power
reduction) and send the GPS data to a server.
Ultimately android is Linux based. So there must a way to turn it on/off
using the Linux commands/APIs right? (or using the NDK) can anyone share
the ideas about that?
If it is not at all possible (last option), is there any alternate way to
get location information using any other functionalists.
Friday, 16 August 2013
Multiple files/Folder scan using virustotal?
Multiple files/Folder scan using virustotal?
I want a quicker way to scan many files using virustotal. It's quite tired
to upload one by one file using the website.
Is there a way to do it via batch scanning?
I want a quicker way to scan many files using virustotal. It's quite tired
to upload one by one file using the website.
Is there a way to do it via batch scanning?
Saturday, 10 August 2013
php form: take user back to previous page from register form
php form: take user back to previous page from register form
Tried various solution from stack overflow and internet but none seems to
be working. My php registration page is a modal window form. what I am
looking for is to take the user back to the page from where he redirected
to login form.
Register link:
<a data-toggle="modal" href="#myModal" class="btn btn-primary
btn-lg">SIGN UP</a>
Register processing:
<?php
ob_start();
session_start();
require_once("config.php");
require_once("all_functions.php");
$cust_email = stripslashes($_POST['cust_email']);
$cust_password = stripslashes($_POST['cust_password']););
$res = mysql_query("SELECT * FROM register WHERE cust_email =
'$cust_email'");
if (mysql_num_rows($res)>0)
{
echo 'That email is already registered';
exit;
}
mysql_query("INSERT INTO register (`cust_email`, `cust_password`)
VALUES
('$cust_email', '$cust_password')");
$_SESSION['valid_user'] = $cust_email;
header("Location: http://tre.com/");
exit;
?>
function to check user is logged in or not
<?php
function check_valid_user()
// see if somebody is logged in and notify them if not
{
global $_SESSION;
if (isset($_SESSION['valid_user']))
{
return $_SESSION['valid_user'];
}
else
{
return false;
}
}
?>
Tried various solution from stack overflow and internet but none seems to
be working. My php registration page is a modal window form. what I am
looking for is to take the user back to the page from where he redirected
to login form.
Register link:
<a data-toggle="modal" href="#myModal" class="btn btn-primary
btn-lg">SIGN UP</a>
Register processing:
<?php
ob_start();
session_start();
require_once("config.php");
require_once("all_functions.php");
$cust_email = stripslashes($_POST['cust_email']);
$cust_password = stripslashes($_POST['cust_password']););
$res = mysql_query("SELECT * FROM register WHERE cust_email =
'$cust_email'");
if (mysql_num_rows($res)>0)
{
echo 'That email is already registered';
exit;
}
mysql_query("INSERT INTO register (`cust_email`, `cust_password`)
VALUES
('$cust_email', '$cust_password')");
$_SESSION['valid_user'] = $cust_email;
header("Location: http://tre.com/");
exit;
?>
function to check user is logged in or not
<?php
function check_valid_user()
// see if somebody is logged in and notify them if not
{
global $_SESSION;
if (isset($_SESSION['valid_user']))
{
return $_SESSION['valid_user'];
}
else
{
return false;
}
}
?>
#EANF#
#EANF#
I often receive emails containing extremely long (>= 300 characters) URLs
that I'd like to click on. This does not work properly because emacs flows
the text onto multiple lines on the terminal and appends a "\" character
at the end of each of these virtual lines to indicate continuation. The
normal mouse-select and ctrl-left-click method doesn't work properly
because the "\" characters are included and invalidate the URL.
I use emacs in -nw (terminal) mode.
Is there a way to change my OS's (Linux Mint 15) or emacs' behavior so
that the entire URL is selected instead of just the first virtual line?
The workaround I've been using is to mouse-select the entire URL,
including the "\" characters, copy, paste into the browser, then delete
the "\" characters by hand.
The other thing I do, if the URL is less than about 250 characters is
stretch the terminal window wide enough to contain the entire URL on a
single line.
I often receive emails containing extremely long (>= 300 characters) URLs
that I'd like to click on. This does not work properly because emacs flows
the text onto multiple lines on the terminal and appends a "\" character
at the end of each of these virtual lines to indicate continuation. The
normal mouse-select and ctrl-left-click method doesn't work properly
because the "\" characters are included and invalidate the URL.
I use emacs in -nw (terminal) mode.
Is there a way to change my OS's (Linux Mint 15) or emacs' behavior so
that the entire URL is selected instead of just the first virtual line?
The workaround I've been using is to mouse-select the entire URL,
including the "\" characters, copy, paste into the browser, then delete
the "\" characters by hand.
The other thing I do, if the URL is less than about 250 characters is
stretch the terminal window wide enough to contain the entire URL on a
single line.
Validating Sender Addresses in Appengine
Validating Sender Addresses in Appengine
My app needs to send emails from several addresses: noreply@, accounts@
and support@, for instance. Now I'm setting up country-specific domains.
To send emails from Appengine, the sender address has to be a registered
admin. To become an admin, you need to have a Google Apps account. But it
appears you can't use aliases ("nicknames") - when you click the invite
link, you have to log in, which you can't do as an alias. I think this
also means I can't set up the country-specific domains as alias domains in
Google Apps.
I'm not a cheapskate, but paying $50 per account (three accounts times
five domains - $2,250) per year purely to validate the sender addresses is
a bit rich. Am I missing something blindingly obvious?
My app needs to send emails from several addresses: noreply@, accounts@
and support@, for instance. Now I'm setting up country-specific domains.
To send emails from Appengine, the sender address has to be a registered
admin. To become an admin, you need to have a Google Apps account. But it
appears you can't use aliases ("nicknames") - when you click the invite
link, you have to log in, which you can't do as an alias. I think this
also means I can't set up the country-specific domains as alias domains in
Google Apps.
I'm not a cheapskate, but paying $50 per account (three accounts times
five domains - $2,250) per year purely to validate the sender addresses is
a bit rich. Am I missing something blindingly obvious?
Friday, 9 August 2013
ValueError: zero length field name in format
ValueError: zero length field name in format
I am trying to convert date to a nice format using below code and
runninginto following error..can anyone provide inputs on how to overcome
here?
from datetime import datetime
d = datetime.fromtimestamp(1372058963)
print d
create_date = datetime.strptime(str(d), '%Y-%m-%d %H:%M:%S')
print create_date
gerrit_created_date =
"{}/{}/{}".format(create_date.month,create_date.day,create_date.year)
print gerrit_created_date
Error:-
File "test.py", line 7, in <module>
gerrit_created_date =
"{}/{}/{}".format(create_date.month,create_date.day,create_date.year)
ValueError: zero length field name in format
I am trying to convert date to a nice format using below code and
runninginto following error..can anyone provide inputs on how to overcome
here?
from datetime import datetime
d = datetime.fromtimestamp(1372058963)
print d
create_date = datetime.strptime(str(d), '%Y-%m-%d %H:%M:%S')
print create_date
gerrit_created_date =
"{}/{}/{}".format(create_date.month,create_date.day,create_date.year)
print gerrit_created_date
Error:-
File "test.py", line 7, in <module>
gerrit_created_date =
"{}/{}/{}".format(create_date.month,create_date.day,create_date.year)
ValueError: zero length field name in format