freeing the popup twice crashes applcation
In my execute block that gets called with a button click, I create a popup
menu to appear where the button was clicked. It current appears properly,
with a few items with one of them having a couple sub items. When this
that runs once then calls the destructor, it is fine. But if I execute it
twice (show the popup and click an item twice) then destruct, the
application crashes. I think it is because I'm not freeing the popup
correctly (which is declared as a private property).
procedure TPlugIn.Execute(AParameters : WideString);
var
i: Integer;
pnt: TPoint;
begin
GetCursorPos(pnt);
FPopup := TPopupMenu.Create(nil);
FPopup.OwnerDraw:=True;
FPopup.AutoHotkeys := maManual;
//SQL Upgrade
Item := TMenuItem.Create(FPopup);
Item.Caption := 'Database Install/Upgrade';
Item.OnClick := ShowItemCaption;
FPopup.Items.Add(Item);
//Language Folder
Item := TMenuItem.Create(FPopup);
Item.Caption := 'Language Folder';
Item.OnClick := ShowItemCaption;
FPopup.Items.Add(Item);
//Machines
Item := TMenuItem.Create(FPopup);
Item.Caption := 'Machines';
MachineItem := TMenuItem.Create(FPopup);
MachineItem.Caption := 'Sample Machine 1';
MachineItem.OnClick := ShowItemCaption;
Item.Add(MachineItem);
MachineItem := TMenuItem.Create(FPopup);
MachineItem.Caption := 'Sample Machine 2';
MachineItem.OnClick := ShowItemCaption;
Item.Add(MachineItem);
FPopup.Items.Add(Item);
Self.FPopup := FPopup;
FPopup.Popup(pnt.X, pnt.Y);
end;
In the ShowItemCaption procedure I just show the caption of that sender
object. I haven't coded specific events yet. If it free the popup in the
execute procedure, the popup doesn't appear anymore.
destructor TPlugIn.Destroy;
begin
inherited;
FPopup.Free;
//ShowMessage('freed');
end;
Saturday, 31 August 2013
How to echo multiple rows with data based on checkbox input?
How to echo multiple rows with data based on checkbox input?
Got stuck trying to echo out multiple rows with data based on checkbox
input. As of current code it processes data from only one checkbox, no
matter how many checkboxes are ticked. Please help!
while($row = mysql_fetch_assoc($r))
{
$pals .= '<input type="checkbox" name="pal_num[]"
value="'.$row['pal_num'].'">'.$row['pal_num'].'<br>';
}
if($pal == '') {
echo '';
} else {
echo '<form name="get_pal" action="post2.php" method="POST">';
echo $pals;
echo '<input type="submit" name="post" value="Go!">';
echo '</form>';
}
post2.php:
$w = $_POST['pal_num'];
$rrr = mysql_query("SELECT * FROM pl_tab WHERE pal_num".$w[0]);
while($row = mysql_fetch_array($rrr))
{
echo '<tr><td>'.' '.'</td>';
echo '<td rowspan="5">'.$row['descr'].'</td>';
echo '<td><b>'.'Total weight'.'<b></td>';
echo '<td>'.' '.'</td><td>'.' '.'</td></tr>';
echo '<td>'.' '.'</td>';
echo '<td colspan="3">'.' '.'</td>';
//this part should multiple based on how many checkboxes are ticked.
echo '<tr><td>'.$row['l_num'].'</td>';
echo '<td>'.$row['pal_num'].'</td>';
echo '<td>'.$row['weight 1'].'</td><td>'.$row['weight 2'].'</td></tr>';
}
echo "</table>";}
Got stuck trying to echo out multiple rows with data based on checkbox
input. As of current code it processes data from only one checkbox, no
matter how many checkboxes are ticked. Please help!
while($row = mysql_fetch_assoc($r))
{
$pals .= '<input type="checkbox" name="pal_num[]"
value="'.$row['pal_num'].'">'.$row['pal_num'].'<br>';
}
if($pal == '') {
echo '';
} else {
echo '<form name="get_pal" action="post2.php" method="POST">';
echo $pals;
echo '<input type="submit" name="post" value="Go!">';
echo '</form>';
}
post2.php:
$w = $_POST['pal_num'];
$rrr = mysql_query("SELECT * FROM pl_tab WHERE pal_num".$w[0]);
while($row = mysql_fetch_array($rrr))
{
echo '<tr><td>'.' '.'</td>';
echo '<td rowspan="5">'.$row['descr'].'</td>';
echo '<td><b>'.'Total weight'.'<b></td>';
echo '<td>'.' '.'</td><td>'.' '.'</td></tr>';
echo '<td>'.' '.'</td>';
echo '<td colspan="3">'.' '.'</td>';
//this part should multiple based on how many checkboxes are ticked.
echo '<tr><td>'.$row['l_num'].'</td>';
echo '<td>'.$row['pal_num'].'</td>';
echo '<td>'.$row['weight 1'].'</td><td>'.$row['weight 2'].'</td></tr>';
}
echo "</table>";}
Mongo find - replace ObjectId with attribute of object when find
Mongo find - replace ObjectId with attribute of object when find
Let say I obtain a find result as follows:
{ "_id" : ObjectId("5221517ad1b328371c000003"), "user_id" :
ObjectId("5221517ad1b328371c000001"), "item_id" :
ObjectId("5221517ad1b328371c000002"), "preference" : 22 }
The ObjectId is not quite meaningful. Is there a way to replace the
ObjectId with an object's attribute? eg. for user_id -> change to
username?
Let say I obtain a find result as follows:
{ "_id" : ObjectId("5221517ad1b328371c000003"), "user_id" :
ObjectId("5221517ad1b328371c000001"), "item_id" :
ObjectId("5221517ad1b328371c000002"), "preference" : 22 }
The ObjectId is not quite meaningful. Is there a way to replace the
ObjectId with an object's attribute? eg. for user_id -> change to
username?
Jquery pagination - Applying class to items
Jquery pagination - Applying class to items
I am trying to design a pagination system in Jquery. The bit I am stuck on
is when I click on different page number links, I want it to move the
"active" class to the newly clicked page.
In the example page "1" has the active class. When I click "2" I want the
active class to move to "2" and be removed from "1".
http://jsfiddle.net/qKyNL/24/
$('a').click(function(event){
event.preventDefault();
var number = $(this).attr('href');
$.ajax({
url: "/ajax_json_echo/",
type: "GET",
dataType: "json",
timeout: 5000,
beforeSend: function () {
$('#content').fadeTo(500, 0.5);
},
success: function (data, textStatus) {
// TO DO: Load in new content
$('html, body').animate({
scrollTop: '0px'
}, 300);
// TO DO: Change URL
// TO DO: Set number as active class
},
error: function (x, t, m) {
if (t === "timeout") {
alert("Request timeout");
} else {
alert('Request error');
}
},
complete: function () {
$('#content').fadeTo(500, 1);
}
});
});
I'm quite new to Jqeury and could do with some help. Can anyone please
give me some guidance on how to do this?
I am trying to design a pagination system in Jquery. The bit I am stuck on
is when I click on different page number links, I want it to move the
"active" class to the newly clicked page.
In the example page "1" has the active class. When I click "2" I want the
active class to move to "2" and be removed from "1".
http://jsfiddle.net/qKyNL/24/
$('a').click(function(event){
event.preventDefault();
var number = $(this).attr('href');
$.ajax({
url: "/ajax_json_echo/",
type: "GET",
dataType: "json",
timeout: 5000,
beforeSend: function () {
$('#content').fadeTo(500, 0.5);
},
success: function (data, textStatus) {
// TO DO: Load in new content
$('html, body').animate({
scrollTop: '0px'
}, 300);
// TO DO: Change URL
// TO DO: Set number as active class
},
error: function (x, t, m) {
if (t === "timeout") {
alert("Request timeout");
} else {
alert('Request error');
}
},
complete: function () {
$('#content').fadeTo(500, 1);
}
});
});
I'm quite new to Jqeury and could do with some help. Can anyone please
give me some guidance on how to do this?
Using jsoup how to get anchor tags that are within div tags with class that have display none style
Using jsoup how to get anchor tags that are within div tags with class
that have display none style
I have a document from which I am trying to extract the a tags. Some of
them are within tags that have the class attribute and the class has the
display:none property set. I want to eliminate those.
that have display none style
I have a document from which I am trying to extract the a tags. Some of
them are within tags that have the class attribute and the class has the
display:none property set. I want to eliminate those.
Compiler Error while Overloading - Java
Compiler Error while Overloading - Java
class parent
{
public void disp(int i) {System.out.println("int");}
}
class child extends parent
{
private void disp(long l){System.out.println("long");}
}
class impl
{
public static void main(String...args)
{
child c = new child();
c.disp(0l); //Line 1
}
}
Compiler complains as below
inh6.java:27: error: disp(long) has private access in child
c.disp(0l);
The input given is 0L and I am trying to overload the disp() method in
child class.
class parent
{
public void disp(int i) {System.out.println("int");}
}
class child extends parent
{
private void disp(long l){System.out.println("long");}
}
class impl
{
public static void main(String...args)
{
child c = new child();
c.disp(0l); //Line 1
}
}
Compiler complains as below
inh6.java:27: error: disp(long) has private access in child
c.disp(0l);
The input given is 0L and I am trying to overload the disp() method in
child class.
javascript event: get when document is textually fully loaded but scripts haven't ran yet
javascript event: get when document is textually fully loaded but scripts
haven't ran yet
DOMContentLoaded fires after document is loaded and its scripts ran, and
I'd like to run my code before scripts were executed but after
document.body.outerHTML (
document.childNodes[document.childNodes.length-1].outerHTML ) is full
I try this, but looks like it runs many times after is found also so now I
do a timer 200ms job before executing mycode, but i'd like to do it
without timers
var observer = new MutationObserver(function(mutations)
{
if(document.body &&
document.childNodes[document.childNodes.length-1].outerHTML.lastIndexOf("</html>")!=-1)
{
observer.disconnect();
mycode();
}
});
observer.observe(document, {subtree: true, childList: true});
Needs to work in Chrome (so beforescriptexecuted event won't work here)
haven't ran yet
DOMContentLoaded fires after document is loaded and its scripts ran, and
I'd like to run my code before scripts were executed but after
document.body.outerHTML (
document.childNodes[document.childNodes.length-1].outerHTML ) is full
I try this, but looks like it runs many times after is found also so now I
do a timer 200ms job before executing mycode, but i'd like to do it
without timers
var observer = new MutationObserver(function(mutations)
{
if(document.body &&
document.childNodes[document.childNodes.length-1].outerHTML.lastIndexOf("</html>")!=-1)
{
observer.disconnect();
mycode();
}
});
observer.observe(document, {subtree: true, childList: true});
Needs to work in Chrome (so beforescriptexecuted event won't work here)
UItableView get UIScrollView for customization
UItableView get UIScrollView for customization
I have category for UIScrollView for customization
I need get UIScrollView.
I try
UIScrollView *scroll = nil;
for (UIView* subview in self.tableView.subviews) {
NSLog(@"%i", self.tableView.subviews.count);
if ([subview isKindOfClass:[UIScrollView class]]) {
scroll = (UIScrollView *)subview;
//some code
}
}
But it doesn't work. How I can get ScrollView? Thanks
I have category for UIScrollView for customization
I need get UIScrollView.
I try
UIScrollView *scroll = nil;
for (UIView* subview in self.tableView.subviews) {
NSLog(@"%i", self.tableView.subviews.count);
if ([subview isKindOfClass:[UIScrollView class]]) {
scroll = (UIScrollView *)subview;
//some code
}
}
But it doesn't work. How I can get ScrollView? Thanks
Friday, 30 August 2013
How to show entered values in a fixed designed crystal report form
How to show entered values in a fixed designed crystal report form
I am working on a project and i have to implement a dynamic bill. Client
has provided me a bill in excel file. In this bill there are so many
fields like name of party, order number, amount, bill number etc. User
enters these values in textboxes. These values must be shown on the bill.
The bill is as followed -
Name of Party : CST : Date : Bill No : Bill Amount :
When user click on submit button then entered values should be shown on
this bill like this -
Name of Party : ABC CST : 123 Date : 18.08.2013 Bill No : 12345 Bill
Amount : 500
I am working on a project and i have to implement a dynamic bill. Client
has provided me a bill in excel file. In this bill there are so many
fields like name of party, order number, amount, bill number etc. User
enters these values in textboxes. These values must be shown on the bill.
The bill is as followed -
Name of Party : CST : Date : Bill No : Bill Amount :
When user click on submit button then entered values should be shown on
this bill like this -
Name of Party : ABC CST : 123 Date : 18.08.2013 Bill No : 12345 Bill
Amount : 500
Thursday, 29 August 2013
Moving focus from UITextfield after entering 2 characters
Moving focus from UITextfield after entering 2 characters
The next code will work only when the user will enter the third character.
I want the focus to move TextField when the user enters the second
character but still keep the first 2 characters in the first TextField. if
I'll try something likenewString.length < 2 , when entering 2 characters
in a row I'll get the first character in the first UITextField and the
second character in the second UITextField.
- (BOOL)textField:(UITextField *)textField
shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString
*)string
{
NSString *newString = [textField.text
stringByReplacingCharactersInRange:range withString:string];
if (newString.length <= 2 )
{
return YES;
}
else
{
NSInteger nextTag;
nextTag = textField.tag + 1;
UIResponder* nextResponder = [textField.superview
viewWithTag:nextTag];
if(textField.tag == 6)
{
[textField resignFirstResponder];
}
else if (nextResponder) {
[nextResponder becomeFirstResponder];
}
else {
[textField resignFirstResponder];
}
}
}
The next code will work only when the user will enter the third character.
I want the focus to move TextField when the user enters the second
character but still keep the first 2 characters in the first TextField. if
I'll try something likenewString.length < 2 , when entering 2 characters
in a row I'll get the first character in the first UITextField and the
second character in the second UITextField.
- (BOOL)textField:(UITextField *)textField
shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString
*)string
{
NSString *newString = [textField.text
stringByReplacingCharactersInRange:range withString:string];
if (newString.length <= 2 )
{
return YES;
}
else
{
NSInteger nextTag;
nextTag = textField.tag + 1;
UIResponder* nextResponder = [textField.superview
viewWithTag:nextTag];
if(textField.tag == 6)
{
[textField resignFirstResponder];
}
else if (nextResponder) {
[nextResponder becomeFirstResponder];
}
else {
[textField resignFirstResponder];
}
}
}
Ko.bindinghandlers not working in Chrome
Ko.bindinghandlers not working in Chrome
I've created a bindingHandler:
ko.bindingHandlers.highlight = {
update: function (element, valueAccessor) {
$(element).fadeTo("fast", 0.03);
$(element).fadeTo("fast", 1);
$(element).fadeTo("fast", 0.03);
$(element).fadeTo("fast", 1);
$(element).fadeTo("fast", 0.03);
$(element).fadeTo("fast", 1);
$(element).fadeTo("fast", 0.03);
$(element).fadeTo("fast", 1);
}
};
...and bound it to an observableArray:
<div data-bind="foreach: contactsInfrastructure">
<div class="contact" data-bind="highlight: Contact">
<div class="contactAvailability">
<div class="contactAvailabilityColor"
data-bind="css: "availabilityCssClass"></div>
</div>
<div class="contactName" ><span data-bind="text:
name"</span></div>
<!-- <div class="contactNote ellipseText"
data-bind="text: group"></div> -->
</div>
</div>
It works fine in Firefox, but in Chrome this error is returned: Uncaught
ReferenceError:
Unable to parse bindings.
Bindings value: highlight: Contact
Message: Contact is not defined
At first I thought it was caused by the DOM not being ready, but that is
not the case.
I've created a bindingHandler:
ko.bindingHandlers.highlight = {
update: function (element, valueAccessor) {
$(element).fadeTo("fast", 0.03);
$(element).fadeTo("fast", 1);
$(element).fadeTo("fast", 0.03);
$(element).fadeTo("fast", 1);
$(element).fadeTo("fast", 0.03);
$(element).fadeTo("fast", 1);
$(element).fadeTo("fast", 0.03);
$(element).fadeTo("fast", 1);
}
};
...and bound it to an observableArray:
<div data-bind="foreach: contactsInfrastructure">
<div class="contact" data-bind="highlight: Contact">
<div class="contactAvailability">
<div class="contactAvailabilityColor"
data-bind="css: "availabilityCssClass"></div>
</div>
<div class="contactName" ><span data-bind="text:
name"</span></div>
<!-- <div class="contactNote ellipseText"
data-bind="text: group"></div> -->
</div>
</div>
It works fine in Firefox, but in Chrome this error is returned: Uncaught
ReferenceError:
Unable to parse bindings.
Bindings value: highlight: Contact
Message: Contact is not defined
At first I thought it was caused by the DOM not being ready, but that is
not the case.
Wednesday, 28 August 2013
wxpython threading textctrl delay
wxpython threading textctrl delay
I have any issue with wxpython's textctrl and threading. Would appreciate
any help in resolving this issue.
My program processes files, as and when each file is processed it is
listed within the textctrl as being completed. When working with just a
few files the textctrl is responsive and displays itself immediately and
does not disappear. Even if these files are large. Did a test on a 700mb
file and textctrl worked perfectly.
The problem occurs when workin on many files, say 20+ for exmaple. Under
these circumstances the textctrl disappears for 6 or 7 seconds, then
reappears and works as normal.
I have tried normal threading, daemon threading etc.. Also tried using
.join() which made things even worse. I'm wondering if this is just
because my program is very processor intensive, or if I'm just doing
something wrong.
My thread line of code is listed below. So far this is by far the fastest
method, just not good enough for my purposes. Thanks in advance, Clinton.
if __name__ == '__main__':
for _file in self.file2process:
self.filenum += 1
Thread(target=self.Worker, args=(e, _file,)).start()
I have any issue with wxpython's textctrl and threading. Would appreciate
any help in resolving this issue.
My program processes files, as and when each file is processed it is
listed within the textctrl as being completed. When working with just a
few files the textctrl is responsive and displays itself immediately and
does not disappear. Even if these files are large. Did a test on a 700mb
file and textctrl worked perfectly.
The problem occurs when workin on many files, say 20+ for exmaple. Under
these circumstances the textctrl disappears for 6 or 7 seconds, then
reappears and works as normal.
I have tried normal threading, daemon threading etc.. Also tried using
.join() which made things even worse. I'm wondering if this is just
because my program is very processor intensive, or if I'm just doing
something wrong.
My thread line of code is listed below. So far this is by far the fastest
method, just not good enough for my purposes. Thanks in advance, Clinton.
if __name__ == '__main__':
for _file in self.file2process:
self.filenum += 1
Thread(target=self.Worker, args=(e, _file,)).start()
Including Facebook app name in posts to Facebook Page
Including Facebook app name in posts to Facebook Page
I am looking for some way to include something like 'via [app name]' in
posts made by my app to a Facebook Page (not a user's wall).
I know that if I use my app's key/secret as the access key, I can get
posts to a user's wall to indicate the app that made the post. But the
key/secret do not seem to allow me to post to a Facebook Page.
I already have the manage pages permission from the user; I can
successfully post to the Page using a Page-specific access key. I'm
looking for a way to link back to my app in posts to a Page, preferably
without just appending the text 'via [app name]' to the message body.
I am looking for some way to include something like 'via [app name]' in
posts made by my app to a Facebook Page (not a user's wall).
I know that if I use my app's key/secret as the access key, I can get
posts to a user's wall to indicate the app that made the post. But the
key/secret do not seem to allow me to post to a Facebook Page.
I already have the manage pages permission from the user; I can
successfully post to the Page using a Page-specific access key. I'm
looking for a way to link back to my app in posts to a Page, preferably
without just appending the text 'via [app name]' to the message body.
How Does Eclipse know the JRE or JDK locaton?
How Does Eclipse know the JRE or JDK locaton?
According to the Eclipse FAQ. I read that
Eclipse DOES NOT consult the JAVA_HOME environment variable.
My doubt is how does eclipse initializes the Virtual Machine. It does not
know the location of Java. My eclipse.ini file does not have -vm
configuration. Still I am able to run eclipse.
The Source
UPDATE
According to Eclipse Installation Guide. Eclipse does not write entries to
the Windows registry.
According to the Eclipse FAQ. I read that
Eclipse DOES NOT consult the JAVA_HOME environment variable.
My doubt is how does eclipse initializes the Virtual Machine. It does not
know the location of Java. My eclipse.ini file does not have -vm
configuration. Still I am able to run eclipse.
The Source
UPDATE
According to Eclipse Installation Guide. Eclipse does not write entries to
the Windows registry.
Changing to remote branch before pushing local commits
Changing to remote branch before pushing local commits
I have committed some changes in master branch but not yet pushed to remote.
If I now switch to another remote branch (and run a git pull) I will not
have any issue right?
I have committed some changes in master branch but not yet pushed to remote.
If I now switch to another remote branch (and run a git pull) I will not
have any issue right?
Tuesday, 27 August 2013
Building Maven fat jar conditionally
Building Maven fat jar conditionally
I followed the example in Building a fat jar using maven and now I can run
the following to build/test and install my jars.
mvn clean compile install
However, install now takes a lot longer because we are now building a fat
jar. Is it possible to have two versions of install where one just builds
jars without dependencies and the other does that and in addition builds
the fat jar, like:
mvn clean compile install
mvn clean compile install-fatjar
I know install-fatjar is not a valid phase but just want to give an idea
of what I'm trying to accomplish, i.e. a conditional install where the fat
jar is built only when an option is provided.
I followed the example in Building a fat jar using maven and now I can run
the following to build/test and install my jars.
mvn clean compile install
However, install now takes a lot longer because we are now building a fat
jar. Is it possible to have two versions of install where one just builds
jars without dependencies and the other does that and in addition builds
the fat jar, like:
mvn clean compile install
mvn clean compile install-fatjar
I know install-fatjar is not a valid phase but just want to give an idea
of what I'm trying to accomplish, i.e. a conditional install where the fat
jar is built only when an option is provided.
Magento - Hide link in main menu for logged in users
Magento - Hide link in main menu for logged in users
I am trying to modify my main navigation menu.
In the menu for guest I have a link (category) called "Log in". But after
the custommer is logged in I want to change the name from "Log In" to
"Shop".
I searched all over the place. I hope this is posible by modifying my
local.xml file vut any solution would do.
I am trying to modify my main navigation menu.
In the menu for guest I have a link (category) called "Log in". But after
the custommer is logged in I want to change the name from "Log In" to
"Shop".
I searched all over the place. I hope this is posible by modifying my
local.xml file vut any solution would do.
purple screen boot 12.04 (black with recovery mode)
purple screen boot 12.04 (black with recovery mode)
So I have a problem with my asus computer: everything went just fine until
today, my computer shows me the grub menu when I start up like it usually
does. But when I choose a version of linux the only thing I get is a
purple screen or a black one if I use the recovery mode.
I have been using ubuntu 12.04 for about a month and I did not download a
single update the day before it started to act like this. It was also
running perfectly fine on start up until today.
I tried to replace quiet splash with nomodeset but that didn't help,
running an older version of linux didn't help either, as I have the same
problem on every version.
I have an Asus motherboard 8 Gb DDR3 Ram Nvidia GTX 560 graphics card
Intel i7 quad core processor
(Someone posted a similar question here: Ubuntu 12.04.2 LTS boots to
purple screen but nobody answered :/)
Edit Boot repair didn't solve the problem, here is the link it gave me:
http://paste.ubuntu.com/6033493/
Second Edit: ctrl alt delete who worked before the boot repair doesn't
work anymore... :/ (I could use it when I had the purple/black screen)
3th edit: The Grub commandline works, so maybe it's a problem with
graphics? (Even though I didn't change anything when I last used my laptop
on Ubuntu..)
So I have a problem with my asus computer: everything went just fine until
today, my computer shows me the grub menu when I start up like it usually
does. But when I choose a version of linux the only thing I get is a
purple screen or a black one if I use the recovery mode.
I have been using ubuntu 12.04 for about a month and I did not download a
single update the day before it started to act like this. It was also
running perfectly fine on start up until today.
I tried to replace quiet splash with nomodeset but that didn't help,
running an older version of linux didn't help either, as I have the same
problem on every version.
I have an Asus motherboard 8 Gb DDR3 Ram Nvidia GTX 560 graphics card
Intel i7 quad core processor
(Someone posted a similar question here: Ubuntu 12.04.2 LTS boots to
purple screen but nobody answered :/)
Edit Boot repair didn't solve the problem, here is the link it gave me:
http://paste.ubuntu.com/6033493/
Second Edit: ctrl alt delete who worked before the boot repair doesn't
work anymore... :/ (I could use it when I had the purple/black screen)
3th edit: The Grub commandline works, so maybe it's a problem with
graphics? (Even though I didn't change anything when I last used my laptop
on Ubuntu..)
Applet. is not a function
Applet. is not a function
I have the following HTML:
public class HelloApplet extends Applet
{
java.awt.TextField firstName;
public void start()
{
Label d = new Label("Sample java.awt.applet demo");
Label l = new Label("FirstName:");
firstName = new TextField(20);
setFirstName("TestString");
Button btn = new Button("Submit");
add(d);
add(l);
add(firstName);
add(btn);
}
public void setFirstName(String name)
{
System.out.println("SetTheName called");
firstName.setText(name);
}
}
And the following HTML:
.<Html>
<head>
<title>A Sample Applet</title>
<script>
function setName()
{
var obj = document.getElementById("myapplet");
alert("OBJ IS " + obj);
setTimeout(function(){obj.setFirstName("TheFirstName");},1000);
}
</script>
</head>
<body>
<input type="button" value="Enter Name" onClick="set()"/>
<applet code="com.prakash.HelloApplet" id="myapplet" width=500
height=400 MAYSCRIPT></applet>
When I press the html button'Enter Name' ,I get following in the console:
Error: TypeError: obj.setFirstName is not a function
The obj is not null and it is of correct type (checked through alert). I
tried with and w/o the setTimeout but does not help. Am I doing something
wrong? (The page is served through tomcat) -Thanks
I have the following HTML:
public class HelloApplet extends Applet
{
java.awt.TextField firstName;
public void start()
{
Label d = new Label("Sample java.awt.applet demo");
Label l = new Label("FirstName:");
firstName = new TextField(20);
setFirstName("TestString");
Button btn = new Button("Submit");
add(d);
add(l);
add(firstName);
add(btn);
}
public void setFirstName(String name)
{
System.out.println("SetTheName called");
firstName.setText(name);
}
}
And the following HTML:
.<Html>
<head>
<title>A Sample Applet</title>
<script>
function setName()
{
var obj = document.getElementById("myapplet");
alert("OBJ IS " + obj);
setTimeout(function(){obj.setFirstName("TheFirstName");},1000);
}
</script>
</head>
<body>
<input type="button" value="Enter Name" onClick="set()"/>
<applet code="com.prakash.HelloApplet" id="myapplet" width=500
height=400 MAYSCRIPT></applet>
When I press the html button'Enter Name' ,I get following in the console:
Error: TypeError: obj.setFirstName is not a function
The obj is not null and it is of correct type (checked through alert). I
tried with and w/o the setTimeout but does not help. Am I doing something
wrong? (The page is served through tomcat) -Thanks
BlockingQueues and thread access order
BlockingQueues and thread access order
I have a situation where multiple threads will be polling a single
BlockingQueue by calling take(). What I want to know is the following:
If multiple threads are waiting for the queue to receive an item, will
they be given priority for taking items off the queue in the order that
they made their calls to take() or will the order in which the threads
take things off the queue be arbitrary?
Thanks!
Note: I have written my own implementations for this kind of thing in the
past, but I'm wondering if the BlockingQueue implementations in Java would
do this for me.
I have a situation where multiple threads will be polling a single
BlockingQueue by calling take(). What I want to know is the following:
If multiple threads are waiting for the queue to receive an item, will
they be given priority for taking items off the queue in the order that
they made their calls to take() or will the order in which the threads
take things off the queue be arbitrary?
Thanks!
Note: I have written my own implementations for this kind of thing in the
past, but I'm wondering if the BlockingQueue implementations in Java would
do this for me.
Android id returning errors
Android id returning errors
Some insane thing happened to me. I cleaned the project and now I'm
getting a ton of errors int the form of R.something. For some reason
eclipse cannot find my references anymore but they were working fine and I
have run the app a lot of times.
Now I did make some changes: I created separate layout files for some
stuff because the main one was becoming too big to read (and I'm using
include layout) but the errors also appear on items that I have NOT moved
into a different file.
All the errors look like this: R.id.whatever_layout same for layouts and
colors.
Now I'm guessing this is a eclipse bug and I tried restarting it but it
didn't solve the problem.
Can someone tell me how to fix this?
Some insane thing happened to me. I cleaned the project and now I'm
getting a ton of errors int the form of R.something. For some reason
eclipse cannot find my references anymore but they were working fine and I
have run the app a lot of times.
Now I did make some changes: I created separate layout files for some
stuff because the main one was becoming too big to read (and I'm using
include layout) but the errors also appear on items that I have NOT moved
into a different file.
All the errors look like this: R.id.whatever_layout same for layouts and
colors.
Now I'm guessing this is a eclipse bug and I tried restarting it but it
didn't solve the problem.
Can someone tell me how to fix this?
Monday, 26 August 2013
Continue iteration of outer while loop
Continue iteration of outer while loop
I have to read data from two files. For that, I have to iterate these two
files using while. Here is my code...
// Data in File1 are A, B, C, D // Data in File2 are A, B,C
try
{
FileInputStream fOne = openFileInput("File1");
FileInputStream fTwo = openFileInput("File2");
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
Scanner scanFile = new Scanner(new DataInputStream(fOne));
Scanner scanFileT = new Scanner(new DataInputStream(fTwo));
while (scanFile.hasNextLine())
{
if(scanFile.nextLine()!=null)
{
count++;
Toast.makeText(getBaseContext(), "Count : " + count,
500).show();
}
while(scanFileT.hasNextLine())
{
if(scanFileT.nextLine()!=null)
{
countTwo++;
Toast.makeText(getBaseContext(), "CountTwo : " +
countTwo, 500).show();
}
}
}
I am using while loop. What I am getting here, first time count = 1 and
countTwo variable as 1, 2 and 3 and then again count variable as 2, 3, 4
(As data in file1 are 4 and in file2 are 3). Now I have to iterate outer
while loop such as I get count values as count=2 and countTwo= 1, 2, 3.
Again count=3 and countTwo = 1, 2, 3. Again count=4 and countTwo = 1, 2,
3. What needs to be done?
I have to read data from two files. For that, I have to iterate these two
files using while. Here is my code...
// Data in File1 are A, B, C, D // Data in File2 are A, B,C
try
{
FileInputStream fOne = openFileInput("File1");
FileInputStream fTwo = openFileInput("File2");
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
Scanner scanFile = new Scanner(new DataInputStream(fOne));
Scanner scanFileT = new Scanner(new DataInputStream(fTwo));
while (scanFile.hasNextLine())
{
if(scanFile.nextLine()!=null)
{
count++;
Toast.makeText(getBaseContext(), "Count : " + count,
500).show();
}
while(scanFileT.hasNextLine())
{
if(scanFileT.nextLine()!=null)
{
countTwo++;
Toast.makeText(getBaseContext(), "CountTwo : " +
countTwo, 500).show();
}
}
}
I am using while loop. What I am getting here, first time count = 1 and
countTwo variable as 1, 2 and 3 and then again count variable as 2, 3, 4
(As data in file1 are 4 and in file2 are 3). Now I have to iterate outer
while loop such as I get count values as count=2 and countTwo= 1, 2, 3.
Again count=3 and countTwo = 1, 2, 3. Again count=4 and countTwo = 1, 2,
3. What needs to be done?
Discover wireless device from command line
Discover wireless device from command line
Is there a command line option (or C#/Java library/solution) to list
available WiFi devices just like what windows does: (On Windows 7,
"Devices and Printers", then "Add a device" will list available devices
available to be added to this computer"; I want to achieve the same on
Windows XP and Windows 7).
I have found the Bluetooth equivalent Bluetooth command line tools and
32feet.NET
Thanks!
Is there a command line option (or C#/Java library/solution) to list
available WiFi devices just like what windows does: (On Windows 7,
"Devices and Printers", then "Add a device" will list available devices
available to be added to this computer"; I want to achieve the same on
Windows XP and Windows 7).
I have found the Bluetooth equivalent Bluetooth command line tools and
32feet.NET
Thanks!
Failed to load COMPASS resource: the server responded with a status of 404 (Not Found)
Failed to load COMPASS resource: the server responded with a status of 404
(Not Found)
I created a theme on liferay 6.2 using the same css, jsp, js, images of
classic theme (which is located in ROOT\html\themes\classic).
My copied theme works fine and all the standard css works except the
compass and sass doesn't work.
COMPASS Version 0.12.2
SASS Version 3.2.1
My custom.css:
@import "compass";
@import "mixins";
@import url(custom_common.css);
$dockbarGradientEnd: #1273C7;
$dockbarGradientStart: #118ADE;
$dockbarOpenGradientEnd: #0993DD;
$dockbarOpenGradientStart: #0EA6F9;
/* ---------- Base styles ---------- */
.aui {
.separator {
border-color: #BFBFBF transparent #FFF;
border-style: solid;
border-width: 1px 0;
}
#wrapper {
background: none;
margin: 0 auto;
padding: 2em 5em 0;
position: relative;
@include respond-to(phone) {
padding-left: 0.5em;
padding-right: 0.5em;
}
@include respond-to(tablet) {
padding-left: 1em;
padding-right: 1em;
}
}
/* etc....... */
In the Firebug i get this error:
Failed to load resource: the server responded with a status of 404 (Not
Found) http://localhost:8080/test-theme/css/compass
I don't know why the compass and sass works fine in classic theme but
doesn't work in my theme that is identical to the classic theme. Why?!
Any help will be greatly appreciated! Thank you!
(Not Found)
I created a theme on liferay 6.2 using the same css, jsp, js, images of
classic theme (which is located in ROOT\html\themes\classic).
My copied theme works fine and all the standard css works except the
compass and sass doesn't work.
COMPASS Version 0.12.2
SASS Version 3.2.1
My custom.css:
@import "compass";
@import "mixins";
@import url(custom_common.css);
$dockbarGradientEnd: #1273C7;
$dockbarGradientStart: #118ADE;
$dockbarOpenGradientEnd: #0993DD;
$dockbarOpenGradientStart: #0EA6F9;
/* ---------- Base styles ---------- */
.aui {
.separator {
border-color: #BFBFBF transparent #FFF;
border-style: solid;
border-width: 1px 0;
}
#wrapper {
background: none;
margin: 0 auto;
padding: 2em 5em 0;
position: relative;
@include respond-to(phone) {
padding-left: 0.5em;
padding-right: 0.5em;
}
@include respond-to(tablet) {
padding-left: 1em;
padding-right: 1em;
}
}
/* etc....... */
In the Firebug i get this error:
Failed to load resource: the server responded with a status of 404 (Not
Found) http://localhost:8080/test-theme/css/compass
I don't know why the compass and sass works fine in classic theme but
doesn't work in my theme that is identical to the classic theme. Why?!
Any help will be greatly appreciated! Thank you!
background-image no display
background-image no display
I'm currently busy with creating a simple site.
When I tried to create a background-image, it just wouldnt display. I've
used the same mapping for just a normal image, just to check if my mapping
wasn't wrong.
This is my current code:
<body>
<table>
<!-- multiple <trs><tds><divs></divs></tds></trs> -->
</table>
</body>
my css looks like this:
* {
padding:0; margin:0;
}
html, body {
height:100%;
width: 100%;
}
body{
background: transparent url('./img/background.jpg') no-repeat 0 center;
display: inline-block;
}
I'm currently busy with creating a simple site.
When I tried to create a background-image, it just wouldnt display. I've
used the same mapping for just a normal image, just to check if my mapping
wasn't wrong.
This is my current code:
<body>
<table>
<!-- multiple <trs><tds><divs></divs></tds></trs> -->
</table>
</body>
my css looks like this:
* {
padding:0; margin:0;
}
html, body {
height:100%;
width: 100%;
}
body{
background: transparent url('./img/background.jpg') no-repeat 0 center;
display: inline-block;
}
Select count from datatable against dynamic query in c#
Select count from datatable against dynamic query in c#
I have a data set in memory which has two data tables in it.
Cont
Ins
Secondly i have separate data table (in memory) in which i have rows in
following format.
And suppose it has two rows. In actual it may have million of rows
ID Table Name Column Name
Operator value
1 Const ID
= 1
2 Ins app_ID
= 558877
As is: Now i get information from given rows and construct a query and
execute it in database server like:
Select count(*) from Cont.Id= 1 and Ins.app_id = 558877;
On the basis of above query result i have implemented my business logic.
Objective: In order to increase performance i want to execute query in
application server as now i have complete table in memory. how can i do
it.
Note: Tables name may vary according to data.
I have a data set in memory which has two data tables in it.
Cont
Ins
Secondly i have separate data table (in memory) in which i have rows in
following format.
And suppose it has two rows. In actual it may have million of rows
ID Table Name Column Name
Operator value
1 Const ID
= 1
2 Ins app_ID
= 558877
As is: Now i get information from given rows and construct a query and
execute it in database server like:
Select count(*) from Cont.Id= 1 and Ins.app_id = 558877;
On the basis of above query result i have implemented my business logic.
Objective: In order to increase performance i want to execute query in
application server as now i have complete table in memory. how can i do
it.
Note: Tables name may vary according to data.
Sunday, 25 August 2013
Relative & Responsive issues
Relative & Responsive issues
I manage to edit one theme to fit my needs, but now i m facing two
issues.First is that the whole site (when I increased width) is not
centered.Itÿs using position relative and float:left; ..the issue is that
on the left side is bigger gap then on the right side.If i use margin:-10
px; inside #content-outer it looks great but then on the mobile,this -20
do some bad things as the site is aligned -20 to left.
Any idea how to work this out, i am out of ideas, and i m not so good with
the coding. the site is http://neymarjunior-11.com/
Another issue for an example is here http://neymarjunior-11.com/new-stats-12/
where i was working on some match stats, which i need to make responsive
for mobile, but again without any luck.
third issue ,when you open the post,below it, it is shown sidebar which
after 486px width starts to drop outside of site to right
I manage to edit one theme to fit my needs, but now i m facing two
issues.First is that the whole site (when I increased width) is not
centered.Itÿs using position relative and float:left; ..the issue is that
on the left side is bigger gap then on the right side.If i use margin:-10
px; inside #content-outer it looks great but then on the mobile,this -20
do some bad things as the site is aligned -20 to left.
Any idea how to work this out, i am out of ideas, and i m not so good with
the coding. the site is http://neymarjunior-11.com/
Another issue for an example is here http://neymarjunior-11.com/new-stats-12/
where i was working on some match stats, which i need to make responsive
for mobile, but again without any luck.
third issue ,when you open the post,below it, it is shown sidebar which
after 486px width starts to drop outside of site to right
[ Polls & Surveys ] Open Question : What comes to mind when I say.......?
[ Polls & Surveys ] Open Question : What comes to mind when I say.......?
In the criminal justice system, sexually-based offenses are considered
especially heinous. In New York City, the dedicated detectives who
investigate these vicious felonies are members of an elite squad known as
the Special Victims Unit. These are their stories.
In the criminal justice system, sexually-based offenses are considered
especially heinous. In New York City, the dedicated detectives who
investigate these vicious felonies are members of an elite squad known as
the Special Victims Unit. These are their stories.
Saturday, 24 August 2013
Preservative for pickles
Preservative for pickles
What preservative should be used for pickling vegetables like carrot,
couly flower,green chillies which are parboiled and could be used without
refrigeration
What preservative should be used for pickling vegetables like carrot,
couly flower,green chillies which are parboiled and could be used without
refrigeration
Trying to setup subdomain on Apache2 but getting subdomain is unavailable
Trying to setup subdomain on Apache2 but getting subdomain is unavailable
I am trying to setup a subdomain in Apache2, I have two folders in www
folder, ankurkaushal & owncloud. I want to make subdomain for owncloud.
I have a dedicated IP address for my server and I have setup A records on
registrar's end too.
Whenever I try access owncloud.ankurkaushal.me, I get that
owncloud.ankurkaushal.me is unavailable.
Here's my sites-available/default file:
<VirtualHost *:80>
ServerAdmin ankurkaushal@outlook.com
ServerAlias ankurkaushal.me
DocumentRoot /var/www/ankurkaushal/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/ankurkaushal/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
#Owncloud
<VirtualHost *:80>
ServerAdmin ankurkaushal@outlook.com
ServerName owncloud.ankurkaushal.me
ServerAlias owncloud.ankurkaushal.me
DocumentRoot /var/www/owncloud/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/owncloud/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Here is the most recent error.log
[Sun Aug 25 02:25:30 2013] [notice] Apache/2.2.22 (Ubuntu)
PHP/5.3.10-1ubuntu3.7 with Suhosin-Patch configured -- resuming normal
operations
[Sun Aug 25 02:26:57 2013] [error] [client 24.212.255.66] File does not
exist: /var/www/ankurkaushal/owncloud, referer:
http://144.76.93.122/owncloud/
Can someone help me in resolving the issue?
I am trying to setup a subdomain in Apache2, I have two folders in www
folder, ankurkaushal & owncloud. I want to make subdomain for owncloud.
I have a dedicated IP address for my server and I have setup A records on
registrar's end too.
Whenever I try access owncloud.ankurkaushal.me, I get that
owncloud.ankurkaushal.me is unavailable.
Here's my sites-available/default file:
<VirtualHost *:80>
ServerAdmin ankurkaushal@outlook.com
ServerAlias ankurkaushal.me
DocumentRoot /var/www/ankurkaushal/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/ankurkaushal/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
#Owncloud
<VirtualHost *:80>
ServerAdmin ankurkaushal@outlook.com
ServerName owncloud.ankurkaushal.me
ServerAlias owncloud.ankurkaushal.me
DocumentRoot /var/www/owncloud/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/owncloud/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Here is the most recent error.log
[Sun Aug 25 02:25:30 2013] [notice] Apache/2.2.22 (Ubuntu)
PHP/5.3.10-1ubuntu3.7 with Suhosin-Patch configured -- resuming normal
operations
[Sun Aug 25 02:26:57 2013] [error] [client 24.212.255.66] File does not
exist: /var/www/ankurkaushal/owncloud, referer:
http://144.76.93.122/owncloud/
Can someone help me in resolving the issue?
Can I redistribute space between my Linux devices?
Can I redistribute space between my Linux devices?
I don't know too much about Linux. I set up a dual-boot with Windows for
school work, but Ubuntu keeps updating itself and it's eating up all my
space in my root. Every time I install new software, it installs into
root, leaving the rest empty. Is there anything I can do?
I don't know too much about Linux. I set up a dual-boot with Windows for
school work, but Ubuntu keeps updating itself and it's eating up all my
space in my root. Every time I install new software, it installs into
root, leaving the rest empty. Is there anything I can do?
Attempting to add page views using PDO
Attempting to add page views using PDO
I am attempting to update page views ever time a webpage is loaded.
Every time the page loads it runs the following function, but it doesn't
add 1 to the post_views row in the mysql database.
function addPostView($post_id, $dbh){
$stmt = $dbh->prepare('SELECT post_views FROM crm_posts WHERE
post_id=?');
$stmt->bindValue(1, $post_id);
$stmt->execute();
while($views = $stmt->fetch(PDO::FETCH_ASSOC)) {
$addView = $views++;
}
$stmt2 = $dbh->prepare('UPDATE crm_posts SET post_views=? WHERE
post_id=?');
$stmt2->bindValue(1, $addView);
$stmt2->bindValue(2, $post_id);
$stmt2->execute();
}
I am running the function simply as follows:
if(isset($_GET['post_id']) && checkPostID($_GET['post_id'], $dbh)!= 0){
$post_id = $_GET['post_id'];
addPostView($post_id, $dbh);
...
As you can see I am attempting to use two prepared statements in the same
function to a) get the current number of post views and then b) update the
post views by adding one, but it isn't updating at all.
Thanks
I am attempting to update page views ever time a webpage is loaded.
Every time the page loads it runs the following function, but it doesn't
add 1 to the post_views row in the mysql database.
function addPostView($post_id, $dbh){
$stmt = $dbh->prepare('SELECT post_views FROM crm_posts WHERE
post_id=?');
$stmt->bindValue(1, $post_id);
$stmt->execute();
while($views = $stmt->fetch(PDO::FETCH_ASSOC)) {
$addView = $views++;
}
$stmt2 = $dbh->prepare('UPDATE crm_posts SET post_views=? WHERE
post_id=?');
$stmt2->bindValue(1, $addView);
$stmt2->bindValue(2, $post_id);
$stmt2->execute();
}
I am running the function simply as follows:
if(isset($_GET['post_id']) && checkPostID($_GET['post_id'], $dbh)!= 0){
$post_id = $_GET['post_id'];
addPostView($post_id, $dbh);
...
As you can see I am attempting to use two prepared statements in the same
function to a) get the current number of post views and then b) update the
post views by adding one, but it isn't updating at all.
Thanks
Is it possible to freeze Amazon AppStore app on stock unrooted Jelly Bean (4.1+)?
Is it possible to freeze Amazon AppStore app on stock unrooted Jelly Bean
(4.1+)?
Preface: I have had severely negative experiences with Amazon AppStore app
on my previous (2.2) phone. The only saving grace was that the phone was
rooted, so I could use my Titanium Backup to freeze it (my usage pattern
of Amazon-Store apps was to use them very infrequently so this worked).
Now, I upgraded to a 4.1 JellyBean device (HTC Droid DNA if it matters).
Since the device is not rooted - and will stay so for a while, I am
extremely apprehensive about installing Amazon App Store, even though I'd
like to download and play some of the games I already purchased there.
Question:
Is it possible to freeze Amazon AppStore app on stock unrooted Jelly Bean
(4.1+) device (HTC Sense 4)?
As per this Q&A, "Disable" functionality in JB4.1 only works on
pre-installed system apps.
By "Freeze", I specifically mean do something which will make it
impossible for the app itself OR any of its services to start from any and
all of its intents, across reboots, until explicitly "unfrozen".
Freezing does NOT simply mean removing the icon from app drawer, as long
as related services remain running.
Not interested in any methods that involve loading custom loaders/roms/etc...
I am perfectly aware that if I "freeze" Amazon AS, I will not be able to
run any of the apps downloaded from it due to lack of DRM service. I am OK
with that.
I would obviously be happy with a generic "freeze a non-system app" method
not Amazon AS centric as long as it is guaranteed (ideally, proven) to
work on Amazon AS. But I'm also fine with Amazon AS specific method.
(4.1+)?
Preface: I have had severely negative experiences with Amazon AppStore app
on my previous (2.2) phone. The only saving grace was that the phone was
rooted, so I could use my Titanium Backup to freeze it (my usage pattern
of Amazon-Store apps was to use them very infrequently so this worked).
Now, I upgraded to a 4.1 JellyBean device (HTC Droid DNA if it matters).
Since the device is not rooted - and will stay so for a while, I am
extremely apprehensive about installing Amazon App Store, even though I'd
like to download and play some of the games I already purchased there.
Question:
Is it possible to freeze Amazon AppStore app on stock unrooted Jelly Bean
(4.1+) device (HTC Sense 4)?
As per this Q&A, "Disable" functionality in JB4.1 only works on
pre-installed system apps.
By "Freeze", I specifically mean do something which will make it
impossible for the app itself OR any of its services to start from any and
all of its intents, across reboots, until explicitly "unfrozen".
Freezing does NOT simply mean removing the icon from app drawer, as long
as related services remain running.
Not interested in any methods that involve loading custom loaders/roms/etc...
I am perfectly aware that if I "freeze" Amazon AS, I will not be able to
run any of the apps downloaded from it due to lack of DRM service. I am OK
with that.
I would obviously be happy with a generic "freeze a non-system app" method
not Amazon AS centric as long as it is guaranteed (ideally, proven) to
work on Amazon AS. But I'm also fine with Amazon AS specific method.
Friday, 23 August 2013
TERM=(linux|xterm) vi in an xterm or the AAABBBBBBCCDDD-problem
TERM=(linux|xterm) vi in an xterm or the AAABBBBBBCCDDD-problem
Usually when I want to run vim in a desktop konsole session, I make sure
the TERM variable is set to linux as the arrow keys don't work in insert
mode with TERM=xterm. They show capital A..D instead of moving the cursor.
Now I think this is the wrong way of doing thingsas konsole or xterm is
actually of type xterm.
Is there a better way for making arrow keys work under vi / vim?
OS: Kubuntu 13.04 (Clean install)
Usually when I want to run vim in a desktop konsole session, I make sure
the TERM variable is set to linux as the arrow keys don't work in insert
mode with TERM=xterm. They show capital A..D instead of moving the cursor.
Now I think this is the wrong way of doing thingsas konsole or xterm is
actually of type xterm.
Is there a better way for making arrow keys work under vi / vim?
OS: Kubuntu 13.04 (Clean install)
iOS: Error using a file path in fopen
iOS: Error using a file path in fopen
I'm new to objective-c, and I have the following problem in this code:
NSLog(@"Path: %@", _nomFile); //show--> Path:
/Users/heberthdeza/Library/Application Support/iPhone
Simulator/6.1/Applications/75184CE7-6CCD-4E5E-ABD1-E150CB35164E/Documents/discovery/IOS-4F55A50D-A3C7-4090-9969-F186C0501F89-23172117.zvg
FILE *fp;
fp=fopen([_nomFile cStringUsingEncoding:NSASCIIStringEncoding],"rb");
if(fp==NULL)
{
NSLog(@"ERROR");
}
I always fopen returns NULL(show "ERROR"), I'm doing wrong? Thanks in
advance.
I'm new to objective-c, and I have the following problem in this code:
NSLog(@"Path: %@", _nomFile); //show--> Path:
/Users/heberthdeza/Library/Application Support/iPhone
Simulator/6.1/Applications/75184CE7-6CCD-4E5E-ABD1-E150CB35164E/Documents/discovery/IOS-4F55A50D-A3C7-4090-9969-F186C0501F89-23172117.zvg
FILE *fp;
fp=fopen([_nomFile cStringUsingEncoding:NSASCIIStringEncoding],"rb");
if(fp==NULL)
{
NSLog(@"ERROR");
}
I always fopen returns NULL(show "ERROR"), I'm doing wrong? Thanks in
advance.
Angularjs use custom interpolation symbols for scope
Angularjs use custom interpolation symbols for scope
I currently have an underscore.js template that I would also like to use
with angular and still be able to use with underscore. I was wondering if
it's possible to change the interpolation start and end symbols for a
particular scope using a directive, like this:
angular.directive('underscoreTemplate', function ($parse, $compile,
$interpolateProvider, $interpolate) {
return {
restrict: "E",
replace: false,
link: function (scope, element, attrs) {
$interpolateProvider.startSymbol("<%=").endSymbol("%>");
var parsedExp = $interpolate(element.html());
// Then replace element contents with interpolated contents
}
}
})
But this spits out the error
Error: Unknown provider: $interpolateProviderProvider <-
$interpolateProvider <- underscoreTemplateDirective
Is $interpolateProvider only available for module configuration? Would a
better solution be to simply using string replace to change <%= to {{ and
%> to }}?
Also, I noticed that element.html() escapes the < in <%= and > in %>. Is
there a way to prevent this automatic escaping?
I currently have an underscore.js template that I would also like to use
with angular and still be able to use with underscore. I was wondering if
it's possible to change the interpolation start and end symbols for a
particular scope using a directive, like this:
angular.directive('underscoreTemplate', function ($parse, $compile,
$interpolateProvider, $interpolate) {
return {
restrict: "E",
replace: false,
link: function (scope, element, attrs) {
$interpolateProvider.startSymbol("<%=").endSymbol("%>");
var parsedExp = $interpolate(element.html());
// Then replace element contents with interpolated contents
}
}
})
But this spits out the error
Error: Unknown provider: $interpolateProviderProvider <-
$interpolateProvider <- underscoreTemplateDirective
Is $interpolateProvider only available for module configuration? Would a
better solution be to simply using string replace to change <%= to {{ and
%> to }}?
Also, I noticed that element.html() escapes the < in <%= and > in %>. Is
there a way to prevent this automatic escaping?
What can Entity Framework Migrations do that FluentMigrator cannot?
What can Entity Framework Migrations do that FluentMigrator cannot?
I have several databases currently using FluentMigrator and am curious to
know how Entity Framework Migrations compare.
Can EF Migrations seed data in migrations and selectively run migration
scripts based on environments like FluentMigrator can with tags and
profiles?
I am already using EF Database First as the ORM to my application, and I
think I read somewhere that EF Migrations are supported for non-Code First
EF as well now, but my team has been thinking about refactoring to a Code
First approach anyway because of some of the limitations with the Database
First approach. So would EF Migrations just make more sense to use rather
than have another 3rd party migration framework when going with a code
first approach?
I have several databases currently using FluentMigrator and am curious to
know how Entity Framework Migrations compare.
Can EF Migrations seed data in migrations and selectively run migration
scripts based on environments like FluentMigrator can with tags and
profiles?
I am already using EF Database First as the ORM to my application, and I
think I read somewhere that EF Migrations are supported for non-Code First
EF as well now, but my team has been thinking about refactoring to a Code
First approach anyway because of some of the limitations with the Database
First approach. So would EF Migrations just make more sense to use rather
than have another 3rd party migration framework when going with a code
first approach?
Downloading a file (not part of a campaign) with MailChimp
Downloading a file (not part of a campaign) with MailChimp
I've got a simple embedded MailChimp form (email addresss + submit button)
on my site. For now, clicking on submit allows users to subscribe to my
MailChimp list.
But I want that clicking on submit: (1) triggers a free ebook PDF file,
and (2) gets the user subscribed to my MailChimp list, ideally right away
without having to confirm subscription via some confirmation email.
Because the whole thing is a one shot event, there will be no campaign:
it's only about downloading a file once and having people who downloaded
it listed in a MailChimp list. So I have no idea how to achieve this.
I've got a simple embedded MailChimp form (email addresss + submit button)
on my site. For now, clicking on submit allows users to subscribe to my
MailChimp list.
But I want that clicking on submit: (1) triggers a free ebook PDF file,
and (2) gets the user subscribed to my MailChimp list, ideally right away
without having to confirm subscription via some confirmation email.
Because the whole thing is a one shot event, there will be no campaign:
it's only about downloading a file once and having people who downloaded
it listed in a MailChimp list. So I have no idea how to achieve this.
UITableViewCell detailTextLabel area not allowing selection of cell
UITableViewCell detailTextLabel area not allowing selection of cell
Inside a UITableViewCell, the area covered by detailTextLabel doesn't
recognise selection of the cell.
The cell style is UITableViewCellStyleSubtitle
The entire bottom area of the cell is not selectable and users are
sometimes tapping the cell multiple times before tapping high enough on
the cell for it to detect the touch.
I've tried [[myCell detailTextLabel] setUserInteractionEnabled:NO] or
setting background colour to clear which has helped in similar cases, what
else can I do?
I thought about adding a UILabel as a subview of the cell instead of
detailTextLabel which I will try if I can't find the answer here.
EDIT - as requested
Here is the code from cellForRowAtIndexPath
NSString *cellId = @"cell";
locationsCell = [tableView dequeueReusableCellWithIdentifier:cellId];
if(locationsCell == nil) {
locationsCell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:cellId];
}
[[locationsCell textLabel] setFont:[UIFont fontWithName:@"Optima-Bold"
size:18]];
[[locationsCell textLabel] setText:@"Choose your location"];
[[locationsCell detailTextLabel] setFont:[UIFont
fontWithName:@"Optima" size:14]];
[[locationsCell detailTextLabel] setText:@"Tap to select"];
[[locationsCell detailTextLabel] setBackgroundColor:[UIColor
clearColor]];
return locationsCell;
EDIT Sorry I've messed up. I had set a footer view for another table and
it has added a clear footer view that made the cell un-selectable instead
of adding a conditional for the two tables. I removed the footer and it's
working.
Inside a UITableViewCell, the area covered by detailTextLabel doesn't
recognise selection of the cell.
The cell style is UITableViewCellStyleSubtitle
The entire bottom area of the cell is not selectable and users are
sometimes tapping the cell multiple times before tapping high enough on
the cell for it to detect the touch.
I've tried [[myCell detailTextLabel] setUserInteractionEnabled:NO] or
setting background colour to clear which has helped in similar cases, what
else can I do?
I thought about adding a UILabel as a subview of the cell instead of
detailTextLabel which I will try if I can't find the answer here.
EDIT - as requested
Here is the code from cellForRowAtIndexPath
NSString *cellId = @"cell";
locationsCell = [tableView dequeueReusableCellWithIdentifier:cellId];
if(locationsCell == nil) {
locationsCell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:cellId];
}
[[locationsCell textLabel] setFont:[UIFont fontWithName:@"Optima-Bold"
size:18]];
[[locationsCell textLabel] setText:@"Choose your location"];
[[locationsCell detailTextLabel] setFont:[UIFont
fontWithName:@"Optima" size:14]];
[[locationsCell detailTextLabel] setText:@"Tap to select"];
[[locationsCell detailTextLabel] setBackgroundColor:[UIColor
clearColor]];
return locationsCell;
EDIT Sorry I've messed up. I had set a footer view for another table and
it has added a clear footer view that made the cell un-selectable instead
of adding a conditional for the two tables. I removed the footer and it's
working.
Thursday, 22 August 2013
Getting data from other sources, not from Postgres in OpenErp
Getting data from other sources, not from Postgres in OpenErp
I would like to customize OpenERP to get data from other sources rather
than from database (in my case data is retrieved via thrift) and show it
in form. I have tried to customize code but still reach a solution. Is
there any solution and could you give me an advice, please? Many thanks
I would like to customize OpenERP to get data from other sources rather
than from database (in my case data is retrieved via thrift) and show it
in form. I have tried to customize code but still reach a solution. Is
there any solution and could you give me an advice, please? Many thanks
Is it possible to easily make a bar graph using pgfplots with text as x-axis labels?
Is it possible to easily make a bar graph using pgfplots with text as
x-axis labels?
Content wise, I want something like this:
I would like to be able to have text (to be specific, % Copper) as the
x-axis labels. I also want the y-axis to have a scale of 0%-6% with each
1% intervals marked off with horizontal lines as shown.
Graphically, I want something like this:
Which is to say: have the legend on the bottom like so, but only have one
group of bars with one x-axis label. And without any tick marks like shown
in this example nor the red, horizontal line.
I got the pgfplots example from their sourceforge examples page. The
unmodified code to produce that is:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
x tick label style={
/pgf/number format/1000 sep=},
ylabel=Population,
enlargelimits=0.15,
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
ybar,
bar width=7pt,
]
\addplot
coordinates {(1930,50e6) (1940,33e6)
(1950,40e6) (1960,50e6) (1970,70e6)};
\addplot
coordinates {(1930,38e6) (1940,42e6)
(1950,43e6) (1960,45e6) (1970,65e6)};
\addplot
coordinates {(1930,15e6) (1940,12e6)
(1950,13e6) (1960,25e6) (1970,35e6)};
\addplot[red,sharp plot,update limits=false]
coordinates {(1910,4.3e7) (1990,4.3e7)}
node[above] at (axis cs:1950,4.3e7) {Houses};
\legend{Far,Near,Here,Annot}
\end{axis}
\end{tikzpicture}
\end{document}
So far, all I've managed to produce from modifying that example is this:
Using this code:
\begin{tikzpicture}
\begin{axis}[
symbolic x coords={Copper},
ylabel=Mass,
% enlargelimits=0.15,
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
ybar,
bar width=7pt,
width = \textwidth,
height = 0.5\textheight,
grid = major
]
\addplot
coordinates {(Copper,0.02)};
\addplot
coordinates {(Copper,0.05)};
\addplot
coordinates {(Copper,0.04)};
\addplot
coordinates {(Copper,0.03)};
\addplot
coordinates {(Copper,0.05)};
\addplot
coordinates {(Copper,0.038)};
\legend{First1 Last1, First2 Last2, First3 Last3, First4 Last4, First5
Last5, Average}
\end{axis}
\end{tikzpicture}
I have absolutely no idea what to do from here and I would rather not
include a picture in my otherwise completely vector-based PDF file. So,
any ideas?
x-axis labels?
Content wise, I want something like this:
I would like to be able to have text (to be specific, % Copper) as the
x-axis labels. I also want the y-axis to have a scale of 0%-6% with each
1% intervals marked off with horizontal lines as shown.
Graphically, I want something like this:
Which is to say: have the legend on the bottom like so, but only have one
group of bars with one x-axis label. And without any tick marks like shown
in this example nor the red, horizontal line.
I got the pgfplots example from their sourceforge examples page. The
unmodified code to produce that is:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
x tick label style={
/pgf/number format/1000 sep=},
ylabel=Population,
enlargelimits=0.15,
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
ybar,
bar width=7pt,
]
\addplot
coordinates {(1930,50e6) (1940,33e6)
(1950,40e6) (1960,50e6) (1970,70e6)};
\addplot
coordinates {(1930,38e6) (1940,42e6)
(1950,43e6) (1960,45e6) (1970,65e6)};
\addplot
coordinates {(1930,15e6) (1940,12e6)
(1950,13e6) (1960,25e6) (1970,35e6)};
\addplot[red,sharp plot,update limits=false]
coordinates {(1910,4.3e7) (1990,4.3e7)}
node[above] at (axis cs:1950,4.3e7) {Houses};
\legend{Far,Near,Here,Annot}
\end{axis}
\end{tikzpicture}
\end{document}
So far, all I've managed to produce from modifying that example is this:
Using this code:
\begin{tikzpicture}
\begin{axis}[
symbolic x coords={Copper},
ylabel=Mass,
% enlargelimits=0.15,
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
ybar,
bar width=7pt,
width = \textwidth,
height = 0.5\textheight,
grid = major
]
\addplot
coordinates {(Copper,0.02)};
\addplot
coordinates {(Copper,0.05)};
\addplot
coordinates {(Copper,0.04)};
\addplot
coordinates {(Copper,0.03)};
\addplot
coordinates {(Copper,0.05)};
\addplot
coordinates {(Copper,0.038)};
\legend{First1 Last1, First2 Last2, First3 Last3, First4 Last4, First5
Last5, Average}
\end{axis}
\end{tikzpicture}
I have absolutely no idea what to do from here and I would rather not
include a picture in my otherwise completely vector-based PDF file. So,
any ideas?
Android - Keep track of user touching a relativelayout
Android - Keep track of user touching a relativelayout
I am using a relative layout with a background drawable as a custom button
and using the onClick to send notification to a custom method. I am trying
to make sure that I know exactly when the user is touching the relative
view and be updated as soon as the user stops touching the relative view.
I am not sure how to be notified when a user no longer is touching the
relativelayout. Any ideas?
I am using a relative layout with a background drawable as a custom button
and using the onClick to send notification to a custom method. I am trying
to make sure that I know exactly when the user is touching the relative
view and be updated as soon as the user stops touching the relative view.
I am not sure how to be notified when a user no longer is touching the
relativelayout. Any ideas?
How to fix incorrectly alphabetized albums containing numbers
How to fix incorrectly alphabetized albums containing numbers
I have an iPod Classic 160gb 6g. In Cover Flow it appears that some of the
albums containing numbers in the title will end up at the end of the
alphabet. For example, this is the end of the Cover Flow:
Under A Blood Red Sky - U2
Who's Gonna Ride Your Wild Horses - U2
Bringing Down The Horse - The Wallflowers
xx - The xx
Young The Giant - Young The Giant
Eagles Greatest Hits Volume 2 - The Eagles
Erasure: Pop! 20 Hits - Erasure
99.5 The Mountain Homegrown Vol. 6 - Live at The Soiled Dove Underground -
Various Artists
However, there are some albums, such as these, which are alphabetized
correctly:
Greatest Hits, Vol. 1: The Singles - Goo Goo Dolls
The 2nd Law - Muse
TKOL RMX 1234567 [Disc 1] - Radiohead
Why is this happening, and how do I fix it?
I have an iPod Classic 160gb 6g. In Cover Flow it appears that some of the
albums containing numbers in the title will end up at the end of the
alphabet. For example, this is the end of the Cover Flow:
Under A Blood Red Sky - U2
Who's Gonna Ride Your Wild Horses - U2
Bringing Down The Horse - The Wallflowers
xx - The xx
Young The Giant - Young The Giant
Eagles Greatest Hits Volume 2 - The Eagles
Erasure: Pop! 20 Hits - Erasure
99.5 The Mountain Homegrown Vol. 6 - Live at The Soiled Dove Underground -
Various Artists
However, there are some albums, such as these, which are alphabetized
correctly:
Greatest Hits, Vol. 1: The Singles - Goo Goo Dolls
The 2nd Law - Muse
TKOL RMX 1234567 [Disc 1] - Radiohead
Why is this happening, and how do I fix it?
Extract file from my java Project
Extract file from my java Project
I would copy one file stored into my project.
(ProjectName/FileFolder/File.abc)
I would copy and save it into "home/lib/" when i call a function.
How can i do?
I would copy one file stored into my project.
(ProjectName/FileFolder/File.abc)
I would copy and save it into "home/lib/" when i call a function.
How can i do?
printing reciept via android device using bluetooth
printing reciept via android device using bluetooth
I am developing an application for Android phone,now in my application if
i select print option then data should be print in the Bluetooth
printer.to achieve this i have done all things but on printing, printer is
printing blank spaces.
I am developing an application for Android phone,now in my application if
i select print option then data should be print in the Bluetooth
printer.to achieve this i have done all things but on printing, printer is
printing blank spaces.
How to run app in background?
How to run app in background?
I want to write app for instant messaging.
So I want my app to start as soon as possible and run in background. But
it doesn't seem possible. It tells me backgroud permission is deprecated.
But it seems really weird to me. Don't tell me you can't have some instant
messaging app or whatever in Chromebook running in background and just
showing notifications about some events.
I found this ticket, but I don't think it's available right now.
I want to write app for instant messaging.
So I want my app to start as soon as possible and run in background. But
it doesn't seem possible. It tells me backgroud permission is deprecated.
But it seems really weird to me. Don't tell me you can't have some instant
messaging app or whatever in Chromebook running in background and just
showing notifications about some events.
I found this ticket, but I don't think it's available right now.
Wednesday, 21 August 2013
Product Key issue with MS Office 2010 click-to-run
Product Key issue with MS Office 2010 click-to-run
I'm working on a client's PC that has MS Office Home and Student
installed. The unusual thing is that there is no winword.exe or the like
for the applications. The shortcuts point to "C:\Program Files
(x86)\Common Files\microsoft shared\Virtualization Handler\CVH.EXE"
"Microsoft Outlook 2010 xxxxxxxxxxxxxxxx" where xxx is a 16 digit number.
I've learned that this is called a 'click2run' install or something.
Fair enough, but my issue is that I usually use 'Belarc Advisor' or
'Recover My Keys' (if the system won't boot) to to retrieve the product
key in use for Windows and Office. But neither programs find anything for
this computer's office install.
I'm assuming it's a genuine version because it's Home and Student. Who
goes to the trouble of installing a pirated office to only use the base
version...?
How can I find the product key used with this install so I can use it for
an install from the Office 2010 OEM media I have?
I'm working on a client's PC that has MS Office Home and Student
installed. The unusual thing is that there is no winword.exe or the like
for the applications. The shortcuts point to "C:\Program Files
(x86)\Common Files\microsoft shared\Virtualization Handler\CVH.EXE"
"Microsoft Outlook 2010 xxxxxxxxxxxxxxxx" where xxx is a 16 digit number.
I've learned that this is called a 'click2run' install or something.
Fair enough, but my issue is that I usually use 'Belarc Advisor' or
'Recover My Keys' (if the system won't boot) to to retrieve the product
key in use for Windows and Office. But neither programs find anything for
this computer's office install.
I'm assuming it's a genuine version because it's Home and Student. Who
goes to the trouble of installing a pirated office to only use the base
version...?
How can I find the product key used with this install so I can use it for
an install from the Office 2010 OEM media I have?
how want to zoom image dispersed finger on android devices flashcs5.5
how want to zoom image dispersed finger on android devices flashcs5.5
I you make the application of a book on Flash for mobile android by Flash
cs5.5 But I have a big problem for me, I did not find a solution And the
solution be willing, on your hand Problem: I want to zoom in Page
dispersed finger on android devices That turned the pages of a book into a
picture and then to the end Movie clip and Movie clip given the names
elevator, elevator1, elevator 2, elevator3 The findings of the code that
makes me the desired Here is the code:
package {
import flash.display.MovieClip;
import flash.ui.Multitouch;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.display.Sprite;
import flash.events.TransformGestureEvent;
import flash.ui.MultitouchInputMode;
import flash.events.MouseEvent;
public class GestureExample extends MovieClip {
public function GestureExample() {
super();
Multitouch.inputMode = MultitouchInputMode.GESTURE;
stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM, onZoom);
}
protected function onZoom(e:TransformGestureEvent):void
{
elevator.scaleX *= e.scaleX;
elevator.scaleY *= e.scaleY;
}
}
}
The code actually works wonderfully, but with the first page only a name
elevator How do I add the rest of the inquiry names Movie Clips elevator1,
elevator 2, elevator3
Properly within the code I hope to modify Please note that I tried hard
not successful Thank you in advance for your help
I you make the application of a book on Flash for mobile android by Flash
cs5.5 But I have a big problem for me, I did not find a solution And the
solution be willing, on your hand Problem: I want to zoom in Page
dispersed finger on android devices That turned the pages of a book into a
picture and then to the end Movie clip and Movie clip given the names
elevator, elevator1, elevator 2, elevator3 The findings of the code that
makes me the desired Here is the code:
package {
import flash.display.MovieClip;
import flash.ui.Multitouch;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.display.Sprite;
import flash.events.TransformGestureEvent;
import flash.ui.MultitouchInputMode;
import flash.events.MouseEvent;
public class GestureExample extends MovieClip {
public function GestureExample() {
super();
Multitouch.inputMode = MultitouchInputMode.GESTURE;
stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM, onZoom);
}
protected function onZoom(e:TransformGestureEvent):void
{
elevator.scaleX *= e.scaleX;
elevator.scaleY *= e.scaleY;
}
}
}
The code actually works wonderfully, but with the first page only a name
elevator How do I add the rest of the inquiry names Movie Clips elevator1,
elevator 2, elevator3
Properly within the code I hope to modify Please note that I tried hard
not successful Thank you in advance for your help
How does experience work for skills in world of tanks?
How does experience work for skills in world of tanks?
I've got a tank that has just reached 100% crew experience level and, all
excited, I set some skills to advance.
My Commander had a skill "Signal Boosting" and I received 500 experience
points for a match; all my experience is being sent into "accelerate crew
training" and it says that I only need 72 xp to "Upgrade Skill" (estimated
one battle)
But after the 500 xp my skills only went up to 12%, what's happening here?
Even with 500 xp divided amoungst the 4 crew that would seem to be >72 xp
needed!
I've got a tank that has just reached 100% crew experience level and, all
excited, I set some skills to advance.
My Commander had a skill "Signal Boosting" and I received 500 experience
points for a match; all my experience is being sent into "accelerate crew
training" and it says that I only need 72 xp to "Upgrade Skill" (estimated
one battle)
But after the 500 xp my skills only went up to 12%, what's happening here?
Even with 500 xp divided amoungst the 4 crew that would seem to be >72 xp
needed!
How to make a flashing div?
How to make a flashing div?
I need a div to glow from a color to another and vice-versa. This is what
I did using shadow animation jQuery Plugin: jsFiddle and it works well...
but when I refresh the page it doesn't load and I get this error:
Maximum execution time of 30 seconds exceeded
How can I fix it?
I need a div to glow from a color to another and vice-versa. This is what
I did using shadow animation jQuery Plugin: jsFiddle and it works well...
but when I refresh the page it doesn't load and I get this error:
Maximum execution time of 30 seconds exceeded
How can I fix it?
How do I set Mail.app not to send the recipient names as they appear in my address book
How do I set Mail.app not to send the recipient names as they appear in my
address book
When I send mails to addresses from my address book, the recipients in the
address bar are shown like name <nick@domain.tld>. Can I somehow prevent
that name part, so that only the actual mail address is shown and not the
names, as I name them in my personal address book? I kind of feel like
it's not for the public how I name my contacts.
address book
When I send mails to addresses from my address book, the recipients in the
address bar are shown like name <nick@domain.tld>. Can I somehow prevent
that name part, so that only the actual mail address is shown and not the
names, as I name them in my personal address book? I kind of feel like
it's not for the public how I name my contacts.
Tuesday, 20 August 2013
Uploaded File Size Error On IE browser
Uploaded File Size Error On IE browser
How to get uploaded file size using JavaScript or jQuery and using codes
should be applicable whole browsers (IE,chrome, Firefox...etc)
<input id="id_file" type="file" class="attachefile" name="file" >
$("#id_file").live('change', function(){
var size = $(this)[0].files[0].size;
alert(size)
});
This code not working IE browser
How to get uploaded file size using JavaScript or jQuery and using codes
should be applicable whole browsers (IE,chrome, Firefox...etc)
<input id="id_file" type="file" class="attachefile" name="file" >
$("#id_file").live('change', function(){
var size = $(this)[0].files[0].size;
alert(size)
});
This code not working IE browser
Why merge-with is used instead of simple 'merge' in Ring, Clojure?
Why merge-with is used instead of simple 'merge' in Ring, Clojure?
I'm very new to Clojure and learning Clojure by reading good open source
code. So I choose Ring and starting to read the code but got stuck in
assoc-query-params function. (which is located in
ring.middleware/params.clj)
And I could not understand why "merge-with" is used. Can anybody help me
to understand this code snippet?
(defn- assoc-query-params
"Parse and assoc parameters from the query string with the request."
[request encoding]
; I think (merge request (some-form)) is enough
; but the author used merge-with with merge function.
(merge-with merge request
(if-let [query-string (:query-string request)]
(let [params (parse-params query-string encoding)]
{:query-params params, :params params})
{:query-params {}, :params {}})))
I'm very new to Clojure and learning Clojure by reading good open source
code. So I choose Ring and starting to read the code but got stuck in
assoc-query-params function. (which is located in
ring.middleware/params.clj)
And I could not understand why "merge-with" is used. Can anybody help me
to understand this code snippet?
(defn- assoc-query-params
"Parse and assoc parameters from the query string with the request."
[request encoding]
; I think (merge request (some-form)) is enough
; but the author used merge-with with merge function.
(merge-with merge request
(if-let [query-string (:query-string request)]
(let [params (parse-params query-string encoding)]
{:query-params params, :params params})
{:query-params {}, :params {}})))
Best way to store, sort, and compare data values?
Best way to store, sort, and compare data values?
NOTE: The API I'm dealing with is Bukkit's API, which is for creating
plugins for the game Minecraft.
I'm trying to find the easiest/best way to store a set of data values that
I must sort, then compare. Here is what i'm trying to do:
When a player joins, I need the time the player joined and the players
name (like a key and value), then I need a way to compare the values and
check all of the players time and see if the times are too "old". Then,
i'd delete a region through WorldGuard that they own.
For example, if 'Jim' joined at the system time of '10 milliseconds' (I
know it has been more than 10 milliseconds since January 1, 1970), then
his time was recorded. 'Jim' left, and didn't return for a while. In the
config, it says anyone who is gone for longer than '15 milliseconds' is to
have their region deleted. So, after 'Jim' is gone for '15 milliseconds',
the system time is now '25 milliseconds'. So, I have to run a method that
checks 'Jim's' time, and matches the time he joined with his name. Then
get the name, and delete his region.
I've tried HashMaps, but apparently you cannot sort them. I've tried
TreeMaps, but the sorting and comparing seems very complicated, even after
reading about it for a few days. So far, the raw storage has been in a YML
file, but I have also tried SQLite storage, but I'm still not sure on the
easiest/best way.
If you've read this far, thanks, and thanks for helping, AhellHound
NOTE: The API I'm dealing with is Bukkit's API, which is for creating
plugins for the game Minecraft.
I'm trying to find the easiest/best way to store a set of data values that
I must sort, then compare. Here is what i'm trying to do:
When a player joins, I need the time the player joined and the players
name (like a key and value), then I need a way to compare the values and
check all of the players time and see if the times are too "old". Then,
i'd delete a region through WorldGuard that they own.
For example, if 'Jim' joined at the system time of '10 milliseconds' (I
know it has been more than 10 milliseconds since January 1, 1970), then
his time was recorded. 'Jim' left, and didn't return for a while. In the
config, it says anyone who is gone for longer than '15 milliseconds' is to
have their region deleted. So, after 'Jim' is gone for '15 milliseconds',
the system time is now '25 milliseconds'. So, I have to run a method that
checks 'Jim's' time, and matches the time he joined with his name. Then
get the name, and delete his region.
I've tried HashMaps, but apparently you cannot sort them. I've tried
TreeMaps, but the sorting and comparing seems very complicated, even after
reading about it for a few days. So far, the raw storage has been in a YML
file, but I have also tried SQLite storage, but I'm still not sure on the
easiest/best way.
If you've read this far, thanks, and thanks for helping, AhellHound
Ubuntu restarts to install dual with windows 8
Ubuntu restarts to install dual with windows 8
So installed Ubuntu onto an external hard drive and now want to dual boot
it with windows 8. So using the same disc I tried to do so by selecting
the install inside windows 8 option. But all it does is restart my laptop.
Any ideas?
So installed Ubuntu onto an external hard drive and now want to dual boot
it with windows 8. So using the same disc I tried to do so by selecting
the install inside windows 8 option. But all it does is restart my laptop.
Any ideas?
Parcelable android add empty char to the String field value
Parcelable android add empty char to the String field value
I need to implement some mechanism to pass data between Activities. First,
I made my classes Serializable and everything worked fine. Then I had a
task to pass ArrayList of my custom objects. Serializable do not maintain
such feature in android and I decided to implement Parcelable. But when I
create one object of my class, it adds empry char to name field of the
object. Somebody faced with similar?
I need to implement some mechanism to pass data between Activities. First,
I made my classes Serializable and everything worked fine. Then I had a
task to pass ArrayList of my custom objects. Serializable do not maintain
such feature in android and I decided to implement Parcelable. But when I
create one object of my class, it adds empry char to name field of the
object. Somebody faced with similar?
Cocoa Accessibility API: Hide a window
Cocoa Accessibility API: Hide a window
I'm looking to hide a window on OSX (not belonging to my app), but not the
rest of the application. I have tried simply moving the window off the
screen (like I would do in Windows), but the api always positions it at
least 20 pixels away from the edge (#annoying).
Other things I have thought of:
Setting the opacity of the window to zero (can this be done?)
Minimizing the window, but it appears that the window handle becomes null
once the window is minimized, so might be hard to get back
Setting the window level (i.e. desktop) or z order (can this be done?)
Moving the window to a different workspace (can this be done?)
Does anyone know of a way to do this?
I'm looking to hide a window on OSX (not belonging to my app), but not the
rest of the application. I have tried simply moving the window off the
screen (like I would do in Windows), but the api always positions it at
least 20 pixels away from the edge (#annoying).
Other things I have thought of:
Setting the opacity of the window to zero (can this be done?)
Minimizing the window, but it appears that the window handle becomes null
once the window is minimized, so might be hard to get back
Setting the window level (i.e. desktop) or z order (can this be done?)
Moving the window to a different workspace (can this be done?)
Does anyone know of a way to do this?
How to capture click event on Save button of CKEditor
How to capture click event on Save button of CKEditor
i try to capture the the click event occur on save button of CKEditor this
way
var element = CKEDITOR.document.getById('CKEditor1');
element.on('click', function (ev) {
//ev.removeListener();
alert('hello');
return false;
});
but it is not working.when i click on save button of CKEditor then a
postback occur. if possible help me with right code sample to capture
click event occur on Save button of CKEditor. thanks
i try to capture the the click event occur on save button of CKEditor this
way
var element = CKEDITOR.document.getById('CKEditor1');
element.on('click', function (ev) {
//ev.removeListener();
alert('hello');
return false;
});
but it is not working.when i click on save button of CKEditor then a
postback occur. if possible help me with right code sample to capture
click event occur on Save button of CKEditor. thanks
Monday, 19 August 2013
Printing binary representation of a char in C
Printing binary representation of a char in C
I've been searching around for a decent example for a few days now and
seriously cant seem to find anything.
I want a really basic way to print out the binary representation of a
char. I can't seem to find and example code anywhere.
I assumed you could do it in a few lines but everything i find is overly
long and complex using lots of functions I haven't used before. atoi comes
up a lot but it's not standard.
Is there a simple function or simple way of writing a function to take a
char variable and then print out a binary representation?
Eg: char 'x' is the argument taken in by the function and "x is 0111 1000"
is printed out.
It's for a school assignment where I must take user input of a string and
print out the string in binary. I just need to get the basics of
converting a char to binary but i'm struggling at the moment.
Thanks!
I've been searching around for a decent example for a few days now and
seriously cant seem to find anything.
I want a really basic way to print out the binary representation of a
char. I can't seem to find and example code anywhere.
I assumed you could do it in a few lines but everything i find is overly
long and complex using lots of functions I haven't used before. atoi comes
up a lot but it's not standard.
Is there a simple function or simple way of writing a function to take a
char variable and then print out a binary representation?
Eg: char 'x' is the argument taken in by the function and "x is 0111 1000"
is printed out.
It's for a school assignment where I must take user input of a string and
print out the string in binary. I just need to get the basics of
converting a char to binary but i'm struggling at the moment.
Thanks!
List of objects
List of objects
what is the best method to find the parent items of a comma separated string?
e.g.
array(1,2,3),array("test","123, abc"),1,"abc, 123"
to get
array(1,2,3)
array("test","123, abc")
1
"abc, 123"
Is this possible to get with a regular expression, or is there a nifty php
function that will do this?
what is the best method to find the parent items of a comma separated string?
e.g.
array(1,2,3),array("test","123, abc"),1,"abc, 123"
to get
array(1,2,3)
array("test","123, abc")
1
"abc, 123"
Is this possible to get with a regular expression, or is there a nifty php
function that will do this?
Typing into a JTextField enables a button. Is it wrong to use a KeyListener?
Typing into a JTextField enables a button. Is it wrong to use a KeyListener?
I have a button called "save changes" that will save any changes if any
changes are detected in a JTextField component. For now, I assume if the
user types anything, then the content has changed.
I am using a KeyListener, but from this question it sounds like using
anything other than an ActionListener is wrong?
I have a button called "save changes" that will save any changes if any
changes are detected in a JTextField component. For now, I assume if the
user types anything, then the content has changed.
I am using a KeyListener, but from this question it sounds like using
anything other than an ActionListener is wrong?
Visual Studio Express 2012 not building exe in Release folder
Visual Studio Express 2012 not building exe in Release folder
I have compiled a simple 'Hello World' program (of type which are taught
in the first lessons :-) ). The program is successfully compiled without
any errors. The build is also successful. I can see a working executable
in bin folder. But the Release folder of the project is totally empty.
I don't know if there is any settings problem or any problem in building.
Apparently, I don't see any error.
Please note I am completely a beginner and using VS for the first time :-)
I have compiled a simple 'Hello World' program (of type which are taught
in the first lessons :-) ). The program is successfully compiled without
any errors. The build is also successful. I can see a working executable
in bin folder. But the Release folder of the project is totally empty.
I don't know if there is any settings problem or any problem in building.
Apparently, I don't see any error.
Please note I am completely a beginner and using VS for the first time :-)
Create symbolic links in Cygwin
Create symbolic links in Cygwin
I'm trying to create symbolic links in Cygwin, and I get a "Permission
denied" error every time. For example:
BZISAD0@WS006428 ~/Code
$ ln -s Ruby RubyLink
ln: creating symbolic link `RubyLink' to `Ruby': Permission denied
Instead of creating a symlink it creates an empty directory:
BZISAD0@WS006428 ~/Code
$ ls -dhal Ruby*
drwxr-xr-x 8 BZISAD0 Administ 4.0k Jun 17 15:53 Ruby
drwxr-xr-x 2 BZISAD0 Administ 0 Aug 19 10:56 RubyLink
The directory in which I'm trying to create the link is owned by me and
writeable by me. `ln.exe' in /bin is owned by me and executable. I started
up Cygwin as an Administrator. Nothing I've tried makes this work, yet
according to the Cygwin docs it should work, and I'm pretty sure I've done
it in the past.
I'm trying to create symbolic links in Cygwin, and I get a "Permission
denied" error every time. For example:
BZISAD0@WS006428 ~/Code
$ ln -s Ruby RubyLink
ln: creating symbolic link `RubyLink' to `Ruby': Permission denied
Instead of creating a symlink it creates an empty directory:
BZISAD0@WS006428 ~/Code
$ ls -dhal Ruby*
drwxr-xr-x 8 BZISAD0 Administ 4.0k Jun 17 15:53 Ruby
drwxr-xr-x 2 BZISAD0 Administ 0 Aug 19 10:56 RubyLink
The directory in which I'm trying to create the link is owned by me and
writeable by me. `ln.exe' in /bin is owned by me and executable. I started
up Cygwin as an Administrator. Nothing I've tried makes this work, yet
according to the Cygwin docs it should work, and I'm pretty sure I've done
it in the past.
Sunday, 18 August 2013
create an image beside a text with minus margin CSS
create an image beside a text with minus margin CSS
Im newbie in CSS so please bear with me.
Im trying to create this design with CSS :
The image is not simply floating at left of the text. The image is taller
than the text and it has a little minus margin-top.
However, i have 2 problems :
When i tried to use margin-top, the image is moving up, but the moving
part is cropped.
I cant make the text shorter than the image. It always follow the image's
height.
And i need to use % which make things more complicated for me.
I have the code, but its just simply a floating image on the left so i
think i dont need to copy it here.
Any help is appreciated and please ask me if you need something.
Thanks for your help :D
Im newbie in CSS so please bear with me.
Im trying to create this design with CSS :
The image is not simply floating at left of the text. The image is taller
than the text and it has a little minus margin-top.
However, i have 2 problems :
When i tried to use margin-top, the image is moving up, but the moving
part is cropped.
I cant make the text shorter than the image. It always follow the image's
height.
And i need to use % which make things more complicated for me.
I have the code, but its just simply a floating image on the left so i
think i dont need to copy it here.
Any help is appreciated and please ask me if you need something.
Thanks for your help :D
Is it possible to shelve/unshelve with TFS Azure?
Is it possible to shelve/unshelve with TFS Azure?
I'm using TFS to deploy a website to Azure host.
Is it possible to check how my code would look like on the production but
being able to roll-back?
I'm using TFS to deploy a website to Azure host.
Is it possible to check how my code would look like on the production but
being able to roll-back?
jQuery cookie plugin creates same cookie instead of read it
jQuery cookie plugin creates same cookie instead of read it
I've this:
// connect to MemberHub
function connect() {
// get unique id cookie
var uid = $.cookie('UniqueID', { path: '/' });
member.server.connect(uid).done(function (result) {
if (result.msg == 'success') {
// notify user
$('#log').append($('<li>', { html: 'Connected to MemberHUB' }));
}
});
}
Each time I try to read cookie it creates same cookie instead of read it.
Any advice will be helpful.
I've this:
// connect to MemberHub
function connect() {
// get unique id cookie
var uid = $.cookie('UniqueID', { path: '/' });
member.server.connect(uid).done(function (result) {
if (result.msg == 'success') {
// notify user
$('#log').append($('<li>', { html: 'Connected to MemberHUB' }));
}
});
}
Each time I try to read cookie it creates same cookie instead of read it.
Any advice will be helpful.
jQuery.getScript loads javascript file before DOM
jQuery.getScript loads javascript file before DOM
Using ajax to load my content dynamically. I need to load a javascript
file after I click on a button:
<a id="element" href="http://example.com/test">button</a>
But the script below loads the javascript file before the DOM has been
loaded. How can I solve this?
$("#element").click(function () {
jQuery.getScript("example.com/jsfile.js?ver=0.9");
});
Using ajax to load my content dynamically. I need to load a javascript
file after I click on a button:
<a id="element" href="http://example.com/test">button</a>
But the script below loads the javascript file before the DOM has been
loaded. How can I solve this?
$("#element").click(function () {
jQuery.getScript("example.com/jsfile.js?ver=0.9");
});
SimpleDateFormat parsing is not correct
SimpleDateFormat parsing is not correct
I'm using SimpleDateFormat to parse Date String ase bellow:
final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-DD");
System.out.println(formatter.parse(firstDate));
And for String "2011-04-02" i got after parsing "Sun Jan 02 00:00:00 EET
2011" so Month is Jan there but must be Apr.
What i'm doing wrong?
I'm using SimpleDateFormat to parse Date String ase bellow:
final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-DD");
System.out.println(formatter.parse(firstDate));
And for String "2011-04-02" i got after parsing "Sun Jan 02 00:00:00 EET
2011" so Month is Jan there but must be Apr.
What i'm doing wrong?
Which sub-string Javascript method should I use for maximum compatibility?
Which sub-string Javascript method should I use for maximum compatibility?
I thought about using substr() with a negative start number to extract the
last character of a string. But on w3 Schools, it says that it's not
compatible with IE8:
To extract characters from the end of the string, use a negative start
number (This does not work in IE 8 and earlier).
I've also read that there are performance problems.
So I decided to use the method below, which works, but is it best
practice, best for compatibility and good for performance?
q = 'Hello there!'
console.log(q.substring(q.length - 1, q.length));
// logs '!'
I thought about using substr() with a negative start number to extract the
last character of a string. But on w3 Schools, it says that it's not
compatible with IE8:
To extract characters from the end of the string, use a negative start
number (This does not work in IE 8 and earlier).
I've also read that there are performance problems.
So I decided to use the method below, which works, but is it best
practice, best for compatibility and good for performance?
q = 'Hello there!'
console.log(q.substring(q.length - 1, q.length));
// logs '!'
mvc 3 Edit action signature with tabs (multiple id's)
mvc 3 Edit action signature with tabs (multiple id's)
The page consists of several tabs (client tabs made of divs). So, I can
have several edit forms which are the same, and are distinguished by id's.
Each form element (dropdown, textbox) has a differnet Id. I would like to
have the edit form in the same view I have the select form. How should an
edit action signature look like? Should I pass the model as a variable, or
maybe each field individually? Then in the view - should I use TextBoxFor,
DropDownListFor?
The view "ClientDetails" which presents the fields consists of code like
the following:
@Html.TextBoxFor(m => m.ClientName, new { id = "ClientName" +
i.ToString(), @class = "input-large" })
whereas i is an index I pass in the viewbag object and represents the tab
I am working on (the view "ClientDetails" is dedicated for a single tab).
The page consists of several tabs (client tabs made of divs). So, I can
have several edit forms which are the same, and are distinguished by id's.
Each form element (dropdown, textbox) has a differnet Id. I would like to
have the edit form in the same view I have the select form. How should an
edit action signature look like? Should I pass the model as a variable, or
maybe each field individually? Then in the view - should I use TextBoxFor,
DropDownListFor?
The view "ClientDetails" which presents the fields consists of code like
the following:
@Html.TextBoxFor(m => m.ClientName, new { id = "ClientName" +
i.ToString(), @class = "input-large" })
whereas i is an index I pass in the viewbag object and represents the tab
I am working on (the view "ClientDetails" is dedicated for a single tab).
Saturday, 17 August 2013
Rails 4 order by virtual attribute
Rails 4 order by virtual attribute
I have a Product model which has name and description columns in the
database.
I also have a Product.search_results_for(query), where query is a string
like "Green Apple".
I need to return an ActiveRecord::Relation of the results ordered by which
is the best hit. Currently, I'm setting a search_result_value to each
product. search_result_value IS NOT a column in the database, and I don't
want it to be.
So in essence, I have an ActiveRecord::Relation of Products that I need to
order by search_result_value without changing it to an array, which is an
instance variable that isn't stored in the database. How can I do this?
Something like this:
Product.order(:search_result_value)
I have a Product model which has name and description columns in the
database.
I also have a Product.search_results_for(query), where query is a string
like "Green Apple".
I need to return an ActiveRecord::Relation of the results ordered by which
is the best hit. Currently, I'm setting a search_result_value to each
product. search_result_value IS NOT a column in the database, and I don't
want it to be.
So in essence, I have an ActiveRecord::Relation of Products that I need to
order by search_result_value without changing it to an array, which is an
instance variable that isn't stored in the database. How can I do this?
Something like this:
Product.order(:search_result_value)
Clonezilla won't boot up
Clonezilla won't boot up
I'm new to Ubuntu, and trying to make a backup with Clonezilla, but I can
get only to the Clonezilla menu and after that I get blank screen. I tried
different usbs ,but with no result. I also tried different Clonezilla
versions. What can cause that problem?
I'm new to Ubuntu, and trying to make a backup with Clonezilla, but I can
get only to the Clonezilla menu and after that I get blank screen. I tried
different usbs ,but with no result. I also tried different Clonezilla
versions. What can cause that problem?
Nokogiri doc search ignore tag type?
Nokogiri doc search ignore tag type?
Looking at the nokogiri documentation, I see where I can ignore certain
ids and classes with: not(contains(@class, "ignore_class"), but I was
curious if there was a way to do searches that ignore a certain tag type?
Specifically I want to do a document search but not pick up things like
<del> or <strike> nodes.
Looking at the nokogiri documentation, I see where I can ignore certain
ids and classes with: not(contains(@class, "ignore_class"), but I was
curious if there was a way to do searches that ignore a certain tag type?
Specifically I want to do a document search but not pick up things like
<del> or <strike> nodes.
How can I automatically update primary key value in MySQL when an entry is deleted?
How can I automatically update primary key value in MySQL when an entry is
deleted?
I'm using MySQL as database for online examination system. here Question
No. is primary key so, when a question in middle is deleted that number is
wasted,(just like in queue data structure).I want the next question
numbers to be automatically decremented. is it possible by using PHP and
MySQL. If yes, then please write the solution.
deleted?
I'm using MySQL as database for online examination system. here Question
No. is primary key so, when a question in middle is deleted that number is
wasted,(just like in queue data structure).I want the next question
numbers to be automatically decremented. is it possible by using PHP and
MySQL. If yes, then please write the solution.
Program argument (has empty characters) break in pieces in the debugger
Program argument (has empty characters) break in pieces in the debugger
I have a program which needs seven arguments. The problem is that the
fifth argument has empty characters. So I put it in the "" and the program
runs.
The problem:
When I am try to use the debugger inside the eclipse the system put \"
instead of " . The result is the fifth argument is broken and I cannot use
the debugger...
here is what I have in the argument list
168815 blabla/ product_group_and_eshop_global_id blaee/test/test "products
in the211 1SEARCHtitle$$<" filename_mode
/src/cpp/test-pages/FrontLoad.html
And here what the eclipse print in the console
/bin/bash: -c: line 0: syntax error near unexpected token `<'
/bin/bash: -c: line 0: `exec /media/Debug/gcom_au 168815 blabla/
product_group_and_eshop_global_id blaee/test/test \"products in the211
1SEARCHtitle$$<\" filename_mode /src/cpp/test-pages/FrontLoad.html'
I have a program which needs seven arguments. The problem is that the
fifth argument has empty characters. So I put it in the "" and the program
runs.
The problem:
When I am try to use the debugger inside the eclipse the system put \"
instead of " . The result is the fifth argument is broken and I cannot use
the debugger...
here is what I have in the argument list
168815 blabla/ product_group_and_eshop_global_id blaee/test/test "products
in the211 1SEARCHtitle$$<" filename_mode
/src/cpp/test-pages/FrontLoad.html
And here what the eclipse print in the console
/bin/bash: -c: line 0: syntax error near unexpected token `<'
/bin/bash: -c: line 0: `exec /media/Debug/gcom_au 168815 blabla/
product_group_and_eshop_global_id blaee/test/test \"products in the211
1SEARCHtitle$$<\" filename_mode /src/cpp/test-pages/FrontLoad.html'
Break commands into new line in Dos command
Break commands into new line in Dos command
I am trying to copy few commands into dos form notepad file, when i copy
them iwant them to be in new lines for each command
Input: cd.. mkdir 568 cd 568
When i copy this into DOS i want something like
cd..
mkdir 568
cd 568
i tried cd.. ^ mkdir 568 ^ cd 568 using different characters but no luck.
Any will highly appreciated please...
I am trying to copy few commands into dos form notepad file, when i copy
them iwant them to be in new lines for each command
Input: cd.. mkdir 568 cd 568
When i copy this into DOS i want something like
cd..
mkdir 568
cd 568
i tried cd.. ^ mkdir 568 ^ cd 568 using different characters but no luck.
Any will highly appreciated please...
In embedded, is there any difference between a device driver and a library?
In embedded, is there any difference between a device driver and a library?
Assuming a platform with no kernel mode, such as Atmel AVR, is there any
difference between a device driver and a library, given that everything is
user mode anyway?
I ask because I'm thinking about how I want to layer my code. It's like this:
+----------------+
| Business logic |
+----------------+
| CAN library |
+----------------+
| MCP2515 driver |
+----------------+
| SPI driver |
+----------------+
The SPI "driver" has an interrupt handler, and it talks directly to the
microcontroller's SPI peripheral, which sounds like a driver, but other
than that, I don't see how it's any different to, say, the CAN library,
which has high-level functions like "send this message".
Assuming a platform with no kernel mode, such as Atmel AVR, is there any
difference between a device driver and a library, given that everything is
user mode anyway?
I ask because I'm thinking about how I want to layer my code. It's like this:
+----------------+
| Business logic |
+----------------+
| CAN library |
+----------------+
| MCP2515 driver |
+----------------+
| SPI driver |
+----------------+
The SPI "driver" has an interrupt handler, and it talks directly to the
microcontroller's SPI peripheral, which sounds like a driver, but other
than that, I don't see how it's any different to, say, the CAN library,
which has high-level functions like "send this message".
Friday, 16 August 2013
git update remote server after repo rollback
git update remote server after repo rollback
was working on master when should have been on a branch, so I made a
branch & then rolled back to the last good commit with:
git reset --hard <commit_id>
I then pushed master with:
git push origin master -f
This leaves my repo in correct condition - I can see it is all correct on
my gitlab page & when I pull locally it is correctly up-to-date
I have a development server that is currently on branch "master" & I am
now trying to "pull the reset" for lack of the correct expression - set it
back to where my local machine is. However, any fetches or pulls all
result in it telling me that I'm already up-to-date
From dev server git branch -a
* master
remotes/origin/master
What is the correct procedure here?
TIA
was working on master when should have been on a branch, so I made a
branch & then rolled back to the last good commit with:
git reset --hard <commit_id>
I then pushed master with:
git push origin master -f
This leaves my repo in correct condition - I can see it is all correct on
my gitlab page & when I pull locally it is correctly up-to-date
I have a development server that is currently on branch "master" & I am
now trying to "pull the reset" for lack of the correct expression - set it
back to where my local machine is. However, any fetches or pulls all
result in it telling me that I'm already up-to-date
From dev server git branch -a
* master
remotes/origin/master
What is the correct procedure here?
TIA
Saturday, 10 August 2013
How can I stop pages from scrolling with an empty hyperlink jump?
How can I stop pages from scrolling with an empty hyperlink jump?
On Tumblr and a few other websites, when you scroll X amount of pixels
vertically, an arrow appears that takes you to the top, with a hyperlink
jump. (I believe that is the correct term.) They're basically <a> tags
with a href attribute of #.
In my opinion, hyperlink jumps are a lot 'cleaner' looking than your
"javascript:void(0); more code goes here..."
In addition to the hyperlink jump on Tumblr to scroll to the top, there
are many pieces of GUI elements in web pages that use a "blank hashtag
link", but they aren't used for scrolling, but rather, clean, empty
hyperlinks. When THEY are clicked on, they do not scroll the page to the
top, but instead, call a JavaScript function to display an element, do a
task, etc.
As far as I know, these links have no JavaScript events attached to stop
scrolling. (Ex. onclick="window.event.preventDefault()".
Am I missing something?
EDIT:
My personal issue that I'm facing is that I want to have an empty
hyperlink (on my top navigation bar), but I don't want the page to scroll
to the top when it is clicked on (the default action in probably every
browser). How to fix with/without JavaScript?
EDIT:
Possible fix for this issue. Non-JavaScript: Fix an element's position
with the coordinates (0,0), and link the empty links to it. (But it still
wouldn't be empty :()
On Tumblr and a few other websites, when you scroll X amount of pixels
vertically, an arrow appears that takes you to the top, with a hyperlink
jump. (I believe that is the correct term.) They're basically <a> tags
with a href attribute of #.
In my opinion, hyperlink jumps are a lot 'cleaner' looking than your
"javascript:void(0); more code goes here..."
In addition to the hyperlink jump on Tumblr to scroll to the top, there
are many pieces of GUI elements in web pages that use a "blank hashtag
link", but they aren't used for scrolling, but rather, clean, empty
hyperlinks. When THEY are clicked on, they do not scroll the page to the
top, but instead, call a JavaScript function to display an element, do a
task, etc.
As far as I know, these links have no JavaScript events attached to stop
scrolling. (Ex. onclick="window.event.preventDefault()".
Am I missing something?
EDIT:
My personal issue that I'm facing is that I want to have an empty
hyperlink (on my top navigation bar), but I don't want the page to scroll
to the top when it is clicked on (the default action in probably every
browser). How to fix with/without JavaScript?
EDIT:
Possible fix for this issue. Non-JavaScript: Fix an element's position
with the coordinates (0,0), and link the empty links to it. (But it still
wouldn't be empty :()
No Overload for Method. What am i Doing Wrong?
No Overload for Method. What am i Doing Wrong?
No Overload for Method. What am i Doing Wrong? my head alread hurts :)
//this is the first class named Employee
namespace lala
{
public class Employee
{
public static double GrossPay(double WeeklySales) //grosspay
{
return WeeklySales * .07;
}
public static double FedTaxPaid(double GrossPay)
{
return GrossPay * .18;
}
public static double RetirementPaid(double GrossPay)
{
return GrossPay * .1;
}
public static double SocSecPaid(double GrossPay)
{
return GrossPay * .06;
}
public static double TotalDeductions(double SocSecPaid, double
RetirementPaid, double FedTaxPaid)
{
return SocSecPaid + RetirementPaid + FedTaxPaid;
}
public static double TakeHomePay(double GrossPay, double TotalDeductions)
{
return GrossPay - TotalDeductions;
}
}
}
this is the second class named EmployeeApp this is where i dont know why
my program doesnt work
namespace lala
{
public class EmployeeApp
{
public static string name;
public static double WeeklySales;
public static void Main()
{
Employee yuki = new Employee();
GetInfo();
Console.WriteLine();
Console.WriteLine("Name: {0}", name);
Console.WriteLine();
Console.WriteLine("Gross Pay : {0}", yuki.GrossPay());
Console.WriteLine("Federal Tax Paid : {0}", yuki.FedTaxPaid());
Console.WriteLine("Social Security Paid : {0}", yuki.SocSecPaid());
Console.WriteLine("Retirement Paid : {0}",
yuki.RetirementPaid());
Console.WriteLine("Total Deductions : {0}",
yuki.TotalDeductions());
Console.WriteLine();
Console.WriteLine("Take-Home Pay : {0}", yuki.TakeHomePay());
Console.ReadKey();
}
public static string GetInfo()
{
Console.Write("Enter Employee Name : ");
name = Console.ReadLine();
Console.Write("Enter your Weekly Sales : ");
WeeklySales = Convert.ToDouble(Console.ReadLine());
return name;
}
}
}
any help would gladly be appreciated :)
No Overload for Method. What am i Doing Wrong? my head alread hurts :)
//this is the first class named Employee
namespace lala
{
public class Employee
{
public static double GrossPay(double WeeklySales) //grosspay
{
return WeeklySales * .07;
}
public static double FedTaxPaid(double GrossPay)
{
return GrossPay * .18;
}
public static double RetirementPaid(double GrossPay)
{
return GrossPay * .1;
}
public static double SocSecPaid(double GrossPay)
{
return GrossPay * .06;
}
public static double TotalDeductions(double SocSecPaid, double
RetirementPaid, double FedTaxPaid)
{
return SocSecPaid + RetirementPaid + FedTaxPaid;
}
public static double TakeHomePay(double GrossPay, double TotalDeductions)
{
return GrossPay - TotalDeductions;
}
}
}
this is the second class named EmployeeApp this is where i dont know why
my program doesnt work
namespace lala
{
public class EmployeeApp
{
public static string name;
public static double WeeklySales;
public static void Main()
{
Employee yuki = new Employee();
GetInfo();
Console.WriteLine();
Console.WriteLine("Name: {0}", name);
Console.WriteLine();
Console.WriteLine("Gross Pay : {0}", yuki.GrossPay());
Console.WriteLine("Federal Tax Paid : {0}", yuki.FedTaxPaid());
Console.WriteLine("Social Security Paid : {0}", yuki.SocSecPaid());
Console.WriteLine("Retirement Paid : {0}",
yuki.RetirementPaid());
Console.WriteLine("Total Deductions : {0}",
yuki.TotalDeductions());
Console.WriteLine();
Console.WriteLine("Take-Home Pay : {0}", yuki.TakeHomePay());
Console.ReadKey();
}
public static string GetInfo()
{
Console.Write("Enter Employee Name : ");
name = Console.ReadLine();
Console.Write("Enter your Weekly Sales : ");
WeeklySales = Convert.ToDouble(Console.ReadLine());
return name;
}
}
}
any help would gladly be appreciated :)
Friday, 9 August 2013
How do I set up RSpec for Sinatra app: database "funky_learn_test" does not exist
How do I set up RSpec for Sinatra app: database "funky_learn_test" does
not exist
I have a custom Sinatra app here, which I'm using to learn:
https://github.com/vise890/funky_learn
I want to add RSpec tests so that I can learn proper TDD (we already went
through the code without TDD in a huge time constrained blitz and it's
horrible). How can I set up my test environment?
When I run the command 'rspec' from the app root directory I get the
following error for all my tests: PG::Error: FATAL: database
"funky_learn_test" does not exist
not exist
I have a custom Sinatra app here, which I'm using to learn:
https://github.com/vise890/funky_learn
I want to add RSpec tests so that I can learn proper TDD (we already went
through the code without TDD in a huge time constrained blitz and it's
horrible). How can I set up my test environment?
When I run the command 'rspec' from the app root directory I get the
following error for all my tests: PG::Error: FATAL: database
"funky_learn_test" does not exist
navigation list is duplicating
navigation list is duplicating
i was given help previously on how to join multiple tables together to get
this navigation list to work, as you can see i have done this, but now i
am trying to output the navigation in my list, but it is duplicating the
top and bottom categories based on how many products are in those
categories: this is previous link that shows my table setup:
Joining 2 tables with foreign key id
Here is my code trying to echo out the navigation correctly.
try
{
$result = $pdo->query('SELECT product.*, bottom_category.bottom_name,
top_category.top_name
FROM product
INNER JOIN bottom_category ON
bottom_category.id =
product.bottom_category_id
INNER JOIN top_category ON top_category.id =
bottom_category.top_category_id
ORDER BY top_category.id,bottom_category.id');
} // end try
catch (PDOException $e)
{
echo 'There was a error fetching the products.' . $e->getMessage();
exit();
} // end catch
$products = array();
foreach ($result as $row)
{
$products[] = array('top_name' => $row['top_name'],
'bottom_name' => $row['bottom_name']);
}
?>
<div class="sidebar">
<h4 class="sidebar-header">Select Products</h4>
<form class="nav-search-form">
<input type="search" name="search" placeholder="Search products">
</form>
<nav class="sidebar-links">
<ul>
<li><a id="red" href="/semtronics/index.php">New
Products</a></li>
<?php
foreach ($products as $product):
?>
<li><a href="#"><?php echo
htmlspecialchars($product['top_name']);?></a>
<ul>
<li><a href=""><?php echo
htmlspecialchars($product['bottom_name']);?></a></li>
</ul>
</li>
<?php endforeach; ?>
</ul>
</nav>
</div><!-- sidebar -->
Now it all works the only problem is it is duplicating the navigation list
based on how many products are linked to that category.
i was given help previously on how to join multiple tables together to get
this navigation list to work, as you can see i have done this, but now i
am trying to output the navigation in my list, but it is duplicating the
top and bottom categories based on how many products are in those
categories: this is previous link that shows my table setup:
Joining 2 tables with foreign key id
Here is my code trying to echo out the navigation correctly.
try
{
$result = $pdo->query('SELECT product.*, bottom_category.bottom_name,
top_category.top_name
FROM product
INNER JOIN bottom_category ON
bottom_category.id =
product.bottom_category_id
INNER JOIN top_category ON top_category.id =
bottom_category.top_category_id
ORDER BY top_category.id,bottom_category.id');
} // end try
catch (PDOException $e)
{
echo 'There was a error fetching the products.' . $e->getMessage();
exit();
} // end catch
$products = array();
foreach ($result as $row)
{
$products[] = array('top_name' => $row['top_name'],
'bottom_name' => $row['bottom_name']);
}
?>
<div class="sidebar">
<h4 class="sidebar-header">Select Products</h4>
<form class="nav-search-form">
<input type="search" name="search" placeholder="Search products">
</form>
<nav class="sidebar-links">
<ul>
<li><a id="red" href="/semtronics/index.php">New
Products</a></li>
<?php
foreach ($products as $product):
?>
<li><a href="#"><?php echo
htmlspecialchars($product['top_name']);?></a>
<ul>
<li><a href=""><?php echo
htmlspecialchars($product['bottom_name']);?></a></li>
</ul>
</li>
<?php endforeach; ?>
</ul>
</nav>
</div><!-- sidebar -->
Now it all works the only problem is it is duplicating the navigation list
based on how many products are linked to that category.
How to make android native shared library(.so) to be unable to debug by attaching
How to make android native shared library(.so) to be unable to debug by
attaching
I am making the native shared library to be running on android. Before, I
experienced that protecting the shared library from debug(i.e set break
point and trace) by attaching by IDA, at that time, SIGSTOP signal
occurred and process was terminated. So I wanna to make my library such
that. I will be appreciate to tell me how to. Also, if you know another
method to protect the native shared library to be running on android
device from debug, disassemble or reverse-engineering. Thanks in advance.
attaching
I am making the native shared library to be running on android. Before, I
experienced that protecting the shared library from debug(i.e set break
point and trace) by attaching by IDA, at that time, SIGSTOP signal
occurred and process was terminated. So I wanna to make my library such
that. I will be appreciate to tell me how to. Also, if you know another
method to protect the native shared library to be running on android
device from debug, disassemble or reverse-engineering. Thanks in advance.
Best approach? Loop through records, create a temptable, use a view?
Best approach? Loop through records, create a temptable, use a view?
SQL Server newbie question here! I have 3 tables, tbl_Sales,
tbl_SalesItems, tbl_Products. tbl_SalesItems stores the products added to
each sale, and is joined to tbl_Products by product code. Products in
tbl_Products are categorised by a ProductGroup field. Environment-wise,
there are at any time about 200 sales, 4-5 items per sale and 3000
products. Although the record numbers are quite small, the Sales and
SalesItems data is continually changing, the calculation will be done
hundreds of times a day in a live environment, with response time being
critical.
I want to classify each sale based on the numbers of items for that sale
by certain product groups, specifically:
Sale is Type1 if has 1 item of product group 13 and 0 items of product
group 14 and 0 items of product group 16.
Sale is Type2 if has 0 item of product group 13 and 1 items of product
group 14 and 0 items of product group 16.
Else Sale is Type0
If I was using Access/VBA I would create one recordset of 3 records, being
the count of items within that sale for each of the 3 product groups and
then loop through the records to get my values and determine the type.
I'm not sure if this is possible in a sql server function or stored
procedure? At the moment I am running three separate SELECT statements and
then evaluating the results like this:
ALTER FUNCTION [dbo].[fSaleATCType] ( @SaleID int)
RETURNS tinyint
BEGIN
declare @InOutWashCount int
declare @OutWashCount int
declare @ExtraCount int
declare @ATCType tinyint
SET @InOutWashCount =
(
SELECT COUNT(dbo.tbl_SalesItems.SaleItemCode) AS CountItems
FROM dbo.tbl_SalesItems LEFT OUTER JOIN
dbo.tbl_Products ON dbo.tbl_SalesItems.SaleItemCode =
dbo.tbl_Products.ProductCode
WHERE (dbo.tbl_SalesItems.SaleID = @SaleID) AND
(dbo.tbl_Products.ProductGroup = 13)
)
SET @OutWashCount =
(
SELECT COUNT(dbo.tbl_SalesItems.SaleItemCode) AS CountItems
FROM dbo.tbl_SalesItems LEFT OUTER JOIN
dbo.tbl_Products ON dbo.tbl_SalesItems.SaleItemCode =
dbo.tbl_Products.ProductCode
WHERE (dbo.tbl_SalesItems.SaleID = @SaleID) AND
(dbo.tbl_Products.ProductGroup = 14)
)
SET @ExtraCount =
(
SELECT COUNT(dbo.tbl_SalesItems.SaleItemCode) AS CountItems
FROM dbo.tbl_SalesItems LEFT OUTER JOIN
dbo.tbl_Products ON dbo.tbl_SalesItems.SaleItemCode =
dbo.tbl_Products.ProductCode
WHERE (dbo.tbl_SalesItems.SaleID = @SaleID) AND
(dbo.tbl_Products.ProductGroup = 16)
)
SET @ATCType = 0
if @InOutWashCount = 1 and @OutWashCount = 0 and @ExtraCount = 0
SET @ATCType = 1
if @InOutWashCount = 0 and @OutWashCount = 1 and @ExtraCount = 0
SET @ATCType = 2
RETURN @ATCType
END
and doing three SELECT's from that?
Is this the best way of doing it? Would I be better creating a temptable
and then doing three SELECT's from that? Or creating a View like
SELECT dbo.tbl_SalesItems.SaleID,
dbo.tbl_Products.ProductGroup,
COUNT(dbo.tbl_SalesItems.SaleItemCode) AS CountItems
FROM dbo.tbl_SalesItems LEFT OUTER JOIN
dbo.tbl_Products ON dbo.tbl_SalesItems.SaleItemCode =
dbo.tbl_Products.ProductCode
GROUP BY dbo.tbl_Products.ProductGroup,
dbo.tbl_SalesItems.SaleID
and doing three SELECT's from that?
Thanks for reading! I hope this makes sense and any suggestions are
greatly appreciated!
BiigJiim
SQL Server newbie question here! I have 3 tables, tbl_Sales,
tbl_SalesItems, tbl_Products. tbl_SalesItems stores the products added to
each sale, and is joined to tbl_Products by product code. Products in
tbl_Products are categorised by a ProductGroup field. Environment-wise,
there are at any time about 200 sales, 4-5 items per sale and 3000
products. Although the record numbers are quite small, the Sales and
SalesItems data is continually changing, the calculation will be done
hundreds of times a day in a live environment, with response time being
critical.
I want to classify each sale based on the numbers of items for that sale
by certain product groups, specifically:
Sale is Type1 if has 1 item of product group 13 and 0 items of product
group 14 and 0 items of product group 16.
Sale is Type2 if has 0 item of product group 13 and 1 items of product
group 14 and 0 items of product group 16.
Else Sale is Type0
If I was using Access/VBA I would create one recordset of 3 records, being
the count of items within that sale for each of the 3 product groups and
then loop through the records to get my values and determine the type.
I'm not sure if this is possible in a sql server function or stored
procedure? At the moment I am running three separate SELECT statements and
then evaluating the results like this:
ALTER FUNCTION [dbo].[fSaleATCType] ( @SaleID int)
RETURNS tinyint
BEGIN
declare @InOutWashCount int
declare @OutWashCount int
declare @ExtraCount int
declare @ATCType tinyint
SET @InOutWashCount =
(
SELECT COUNT(dbo.tbl_SalesItems.SaleItemCode) AS CountItems
FROM dbo.tbl_SalesItems LEFT OUTER JOIN
dbo.tbl_Products ON dbo.tbl_SalesItems.SaleItemCode =
dbo.tbl_Products.ProductCode
WHERE (dbo.tbl_SalesItems.SaleID = @SaleID) AND
(dbo.tbl_Products.ProductGroup = 13)
)
SET @OutWashCount =
(
SELECT COUNT(dbo.tbl_SalesItems.SaleItemCode) AS CountItems
FROM dbo.tbl_SalesItems LEFT OUTER JOIN
dbo.tbl_Products ON dbo.tbl_SalesItems.SaleItemCode =
dbo.tbl_Products.ProductCode
WHERE (dbo.tbl_SalesItems.SaleID = @SaleID) AND
(dbo.tbl_Products.ProductGroup = 14)
)
SET @ExtraCount =
(
SELECT COUNT(dbo.tbl_SalesItems.SaleItemCode) AS CountItems
FROM dbo.tbl_SalesItems LEFT OUTER JOIN
dbo.tbl_Products ON dbo.tbl_SalesItems.SaleItemCode =
dbo.tbl_Products.ProductCode
WHERE (dbo.tbl_SalesItems.SaleID = @SaleID) AND
(dbo.tbl_Products.ProductGroup = 16)
)
SET @ATCType = 0
if @InOutWashCount = 1 and @OutWashCount = 0 and @ExtraCount = 0
SET @ATCType = 1
if @InOutWashCount = 0 and @OutWashCount = 1 and @ExtraCount = 0
SET @ATCType = 2
RETURN @ATCType
END
and doing three SELECT's from that?
Is this the best way of doing it? Would I be better creating a temptable
and then doing three SELECT's from that? Or creating a View like
SELECT dbo.tbl_SalesItems.SaleID,
dbo.tbl_Products.ProductGroup,
COUNT(dbo.tbl_SalesItems.SaleItemCode) AS CountItems
FROM dbo.tbl_SalesItems LEFT OUTER JOIN
dbo.tbl_Products ON dbo.tbl_SalesItems.SaleItemCode =
dbo.tbl_Products.ProductCode
GROUP BY dbo.tbl_Products.ProductGroup,
dbo.tbl_SalesItems.SaleID
and doing three SELECT's from that?
Thanks for reading! I hope this makes sense and any suggestions are
greatly appreciated!
BiigJiim
C# - Detect Incoming Phone Calls
C# - Detect Incoming Phone Calls
I would like to know how can i listen to my home telephone via my computer
(with C#) and get an alert when someone are calling to my home right now,
and get the phone number to C# I know it's possible because i saw it
before
I have a modem (+ router + switch) that connected to my computer and to my
telephone connection.
I would like to know how can i listen to my home telephone via my computer
(with C#) and get an alert when someone are calling to my home right now,
and get the phone number to C# I know it's possible because i saw it
before
I have a modem (+ router + switch) that connected to my computer and to my
telephone connection.
Thursday, 8 August 2013
PHP: click variable to pop a confirm box
PHP: click variable to pop a confirm box
I have a simple java script which asks for confirmation on clicking $temp.
$temp="V3.2"
echo '<td class="item_unsold"><a href =
"manage-software.php?prod='.$row[0].'"
style="color:red" onclick="return confirm(\'Are you sure you want to Continue
Installation?\')">$temp</a></td>';
Vale of $temp is not getting printed. I am new bie and i dont know how to
do that. echo $temp, print $temp doesn't work and prints "echo
$temp"/"print $temp" and not the value of $temp. how to print value of
variable here?
I have a simple java script which asks for confirmation on clicking $temp.
$temp="V3.2"
echo '<td class="item_unsold"><a href =
"manage-software.php?prod='.$row[0].'"
style="color:red" onclick="return confirm(\'Are you sure you want to Continue
Installation?\')">$temp</a></td>';
Vale of $temp is not getting printed. I am new bie and i dont know how to
do that. echo $temp, print $temp doesn't work and prints "echo
$temp"/"print $temp" and not the value of $temp. how to print value of
variable here?
It takes a long time to show variable fields in openoffice when designing a report
It takes a long time to show variable fields in openoffice when designing
a report
I design reports in openOffice with the plugin -- base_report_designer.
But when i wanna add a field ,It takes a very long time to load the
variable fields. I don't think it is normal, but i don't have a clue where
the problem could be.
plus, I am in windows and the openerp version is 7.
can you help me? Thanks in advance.
a report
I design reports in openOffice with the plugin -- base_report_designer.
But when i wanna add a field ,It takes a very long time to load the
variable fields. I don't think it is normal, but i don't have a clue where
the problem could be.
plus, I am in windows and the openerp version is 7.
can you help me? Thanks in advance.
IPython function call behavior
IPython function call behavior
I have a function in a script problem1.py:
def normal_method(target):
natural_numbers = np.array(np.arange(1,target))
divisible_numbers = np.array([x for x in natural_numbers
if x%3==0 or x%5==0])
sum_value = np.sum(divisible_numbers)
print sum_value
While calling this function in an IPython window using ,
from problem1 import normal_method
%timeit normal_method(100)
It gives me TypeError saying normal_method takes no arguments. But when I
paste the function into IPython and then call it using the same statement
it works. Any ideas why this occurs?
I have a function in a script problem1.py:
def normal_method(target):
natural_numbers = np.array(np.arange(1,target))
divisible_numbers = np.array([x for x in natural_numbers
if x%3==0 or x%5==0])
sum_value = np.sum(divisible_numbers)
print sum_value
While calling this function in an IPython window using ,
from problem1 import normal_method
%timeit normal_method(100)
It gives me TypeError saying normal_method takes no arguments. But when I
paste the function into IPython and then call it using the same statement
it works. Any ideas why this occurs?
JS Click Certain Element By Its ID
JS Click Certain Element By Its ID
I am using a bot making program, and I can't seem to get it to click the
element by the bot making program's methods. I have to option to run
javascript, and I would like to learn how to get the bot to click a
certain HTML element.
I am using a bot making program, and I can't seem to get it to click the
element by the bot making program's methods. I have to option to run
javascript, and I would like to learn how to get the bot to click a
certain HTML element.
Is it possible to create generic functions in C?
Is it possible to create generic functions in C?
I am getting back into using C, but I've been spoiled by generics in other
languages. I have made it to the following piece of code in my
implementation of a resizable array:
typdef struct {
void** array;
int length;
int capacity;
size_t type_size;
} Vector;
void vector_add(Vector* v, void* entry) {
// ... code for adding to the array and resizing
}
int main() {
Vector* vector = vector_create(5, sizeof(int));
vector_add(vector, 4); // This is erroneous...
// ...
}
In my attempt to make this generic, I'm now unable to add an integer to
the vector without storing it in memory somewhere else.
Is there any way to make this work (either as is, or possibly a better
approach to generics)?
I am getting back into using C, but I've been spoiled by generics in other
languages. I have made it to the following piece of code in my
implementation of a resizable array:
typdef struct {
void** array;
int length;
int capacity;
size_t type_size;
} Vector;
void vector_add(Vector* v, void* entry) {
// ... code for adding to the array and resizing
}
int main() {
Vector* vector = vector_create(5, sizeof(int));
vector_add(vector, 4); // This is erroneous...
// ...
}
In my attempt to make this generic, I'm now unable to add an integer to
the vector without storing it in memory somewhere else.
Is there any way to make this work (either as is, or possibly a better
approach to generics)?
Changing read permissions on /private/etc recursively
Changing read permissions on /private/etc recursively
I was trying to make my /private/etc folder and all its contents
world-readable. 'Permission denied' messages from a number of internal
files and folders were a recurrent theme whenever I did a find operation
on that folder. But chmod -R seems to have failed here. Can someone please
explain why I get this error message and what I should do to fix it? I'm
on OS X 10.8.3.
$ sudo chmod -R a+r /private/etc
sudo: /private/etc/sudoers is mode 0444, should be 0440
sudo: no valid sudoers sources found, quitting
I was trying to make my /private/etc folder and all its contents
world-readable. 'Permission denied' messages from a number of internal
files and folders were a recurrent theme whenever I did a find operation
on that folder. But chmod -R seems to have failed here. Can someone please
explain why I get this error message and what I should do to fix it? I'm
on OS X 10.8.3.
$ sudo chmod -R a+r /private/etc
sudo: /private/etc/sudoers is mode 0444, should be 0440
sudo: no valid sudoers sources found, quitting
white-space: nowrap is not working in IE in a horizontally scrolling box
white-space: nowrap is not working in IE in a horizontally scrolling box
I'm using white-space: nowrap combined with inline-block'd elements to
create a horizontally scrolling box. For some reason, in IE, the
white-space: nowrap is being ignored and items are wrapping.
I'm using white-space: nowrap combined with inline-block'd elements to
create a horizontally scrolling box. For some reason, in IE, the
white-space: nowrap is being ignored and items are wrapping.
How to limit length of inner divs inside another div using jquery
How to limit length of inner divs inside another div using jquery
like
<div class="a">
<div class="a1"></div>
<div class="a2"></div>
<div class="a3"></div>
<div class="a4"></div>
<div class="a5"></div>
<div class="a6"></div>
<div class="a7"></div>
<div class="a8"></div>
</div>
i need to limit the length of div 'a' to 4 using jquery. Thanks in advance
like
<div class="a">
<div class="a1"></div>
<div class="a2"></div>
<div class="a3"></div>
<div class="a4"></div>
<div class="a5"></div>
<div class="a6"></div>
<div class="a7"></div>
<div class="a8"></div>
</div>
i need to limit the length of div 'a' to 4 using jquery. Thanks in advance
objC's message passing - compiler won't check whether method is existing?
objC's message passing - compiler won't check whether method is existing?
In Objective-C's Wiki page, there is a section named Messages. It says
when compiling, Objective-C doesn't care whether an object has a given
method, because anyone can send a message to another. This is dynamic
binding.
in C++, obj->method(argument); if no method, wrong. in Objective-C, [obj
method:argument]; if no method, can be fine.
But in my daily coding, with XCode, if compiler cannot find a public
method of an object, it always prompt error even before build. like this,
no visible @interface for 'ClassName' declares the selector 'methodName'
I am a little confused about this 'contradiction'. Please forgive me if
the question is silly. thanks in advance.
In Objective-C's Wiki page, there is a section named Messages. It says
when compiling, Objective-C doesn't care whether an object has a given
method, because anyone can send a message to another. This is dynamic
binding.
in C++, obj->method(argument); if no method, wrong. in Objective-C, [obj
method:argument]; if no method, can be fine.
But in my daily coding, with XCode, if compiler cannot find a public
method of an object, it always prompt error even before build. like this,
no visible @interface for 'ClassName' declares the selector 'methodName'
I am a little confused about this 'contradiction'. Please forgive me if
the question is silly. thanks in advance.
iOS 7 is not rendering Core Text in UITableViewCell
iOS 7 is not rendering Core Text in UITableViewCell
i have a custom table view cell which itself is a subclass of table view
cell.
Cell Hierarchy: UITableViewCell--->SubClassLevel1--->SubClassLevel2
In my view controller i am creating SubClassLevel2 cell and adding to
tableview.
i have core text views in both subclass. But the core text view in
SubClassLevel2 is rendering properly without any issues. But the core text
views in SubClassLevel1 is not rendering.
But i have put breakpoint and checked. I found that drawRect method of CT
Views which is in SubClassLevel1 also getting called. But i am no able to
see the text in screen.
But the same code executes well in iOS 6 and iOS 5. I am facing this issue
only in iOS 7.
Thanks in advance.
i have a custom table view cell which itself is a subclass of table view
cell.
Cell Hierarchy: UITableViewCell--->SubClassLevel1--->SubClassLevel2
In my view controller i am creating SubClassLevel2 cell and adding to
tableview.
i have core text views in both subclass. But the core text view in
SubClassLevel2 is rendering properly without any issues. But the core text
views in SubClassLevel1 is not rendering.
But i have put breakpoint and checked. I found that drawRect method of CT
Views which is in SubClassLevel1 also getting called. But i am no able to
see the text in screen.
But the same code executes well in iOS 6 and iOS 5. I am facing this issue
only in iOS 7.
Thanks in advance.
Wednesday, 7 August 2013
Unable to transfer files from external hard drive
Unable to transfer files from external hard drive
Problem:
I'm trying to transfer about 168 GB of files from an old Windows XP
machine to a newer MacBook Pro running OS X 10.6.8.
I successfully copied the files from the XP machine onto a 2TB Seagate
drive, formatted as NTFS.
I opened the Seagate drive on the Mac and started copying the files.
Though the drive is read-only because it is NTFS, all I need to do is copy
files off of it.
About 15% into the transfer, a message pops up saying "The operation can't
be completed because an unexpected error occurred. (Error -8084)" and the
transfer stops. This has happened multiple times.
What I've tried to fix the problem:
I tried transferring one of the sub-folders of the backup, also resulting
in an error, though this one was different. It was something like: "The
process has been stopped because a file is in use." It then said the name
of the file. I tried this second process twice; each time it gave a
different file name.
In both cases, some of the files transfer properly, but most don't.
I have tried disabling Spotlight for the drive, but that didn't help.
Problem:
I'm trying to transfer about 168 GB of files from an old Windows XP
machine to a newer MacBook Pro running OS X 10.6.8.
I successfully copied the files from the XP machine onto a 2TB Seagate
drive, formatted as NTFS.
I opened the Seagate drive on the Mac and started copying the files.
Though the drive is read-only because it is NTFS, all I need to do is copy
files off of it.
About 15% into the transfer, a message pops up saying "The operation can't
be completed because an unexpected error occurred. (Error -8084)" and the
transfer stops. This has happened multiple times.
What I've tried to fix the problem:
I tried transferring one of the sub-folders of the backup, also resulting
in an error, though this one was different. It was something like: "The
process has been stopped because a file is in use." It then said the name
of the file. I tried this second process twice; each time it gave a
different file name.
In both cases, some of the files transfer properly, but most don't.
I have tried disabling Spotlight for the drive, but that didn't help.
Cannot figure out how to revert back to backed up profile file
Cannot figure out how to revert back to backed up profile file
Basically, I made a backup copy of my /etc/profile (or ~/.profile I can't
remember exactly} file that executes as soon as you login to tty, and then
I changed the one that was there, and now it automatically logs you out as
soon as you login. I just need to view the current file and make a
modification to the script, but I can't figure out a way to get to it.
i've tried a ubuntu live cd but I can't figure out how to get permission
after I mount the drive
I have grub installed but I removed all of the options except the default
from the menu
Basically, I made a backup copy of my /etc/profile (or ~/.profile I can't
remember exactly} file that executes as soon as you login to tty, and then
I changed the one that was there, and now it automatically logs you out as
soon as you login. I just need to view the current file and make a
modification to the script, but I can't figure out a way to get to it.
i've tried a ubuntu live cd but I can't figure out how to get permission
after I mount the drive
I have grub installed but I removed all of the options except the default
from the menu
Detecting each character inputed in field and run conditionals
Detecting each character inputed in field and run conditionals
I am building a Ruby on Rails app. I believe it will be easiest if I try
to explain what I want the user experience to look like before I ask my
question.
I want my user to go on my site and begin to type in a text field. When
each character is inputted, I want to run a conditional statement on that
character to decided if it should be added to the text field. If the
character inputted is not one I want, the character isn't added.
I have validations in my model to do this after the text is submited, but
I want it to be real time. I'm guessing this relates to JavaScript and I
am not comfortable enough in coding it to know what to search
for/research. Can you assist me in where to look (Tutorials, Concepts,
etc)?
Thank you for taking the time to read this.
I am building a Ruby on Rails app. I believe it will be easiest if I try
to explain what I want the user experience to look like before I ask my
question.
I want my user to go on my site and begin to type in a text field. When
each character is inputted, I want to run a conditional statement on that
character to decided if it should be added to the text field. If the
character inputted is not one I want, the character isn't added.
I have validations in my model to do this after the text is submited, but
I want it to be real time. I'm guessing this relates to JavaScript and I
am not comfortable enough in coding it to know what to search
for/research. Can you assist me in where to look (Tutorials, Concepts,
etc)?
Thank you for taking the time to read this.
On suse What is the difference between TIMEZONE and DEFAULT_TIMEZONE in file /etc/sysconfig/clock?
On suse What is the difference between TIMEZONE and DEFAULT_TIMEZONE in
file /etc/sysconfig/clock?
As the title says, i would like to know the difference between TIMEZONE
and DEFAULT_TIMEZONE on suse in the /etc/sysconfig/clock
file /etc/sysconfig/clock?
As the title says, i would like to know the difference between TIMEZONE
and DEFAULT_TIMEZONE on suse in the /etc/sysconfig/clock
RegularExpressionValidator is not working
RegularExpressionValidator is not working
I'm total newbie in using asp.net and I have this regular expression
validator that was working perfectly fine before but after I made a huge
edit to my textboxes its not working anymore.
In before edit, when I try to submit the form, if my textbox is empty or
the value = "" it will show the error message and will NOT redirect to
another page.
In after edit, when I try to submit the form, whether the textbox is empty
or not it will redirect to another page. Not stopping the page from
redirecting or showing the validator
before edit.
<asp:TextBox ID="txttstImmLen" CssClass="forImmLenTb" runat="server"
Width="118" Text="Enter Value Here" OnClick="this.value=''"
onblur="tryPlaceholder(this,'Enter Value Here')" ></asp:TextBox>
<asp:RegularExpressionValidator ID="vldtstImmLen"
ControlToValidate="txttstImmLen" Display="Dynamic" ErrorMessage="Immersion
Length" Text="*" ValidationExpression="(0*[1-9]\d*)" Runat="server"/>
after edit
<asp:TextBox ID="txttstImmLen" CssClass="forImmLenTb" runat="server"
Width="118" onblur="tryPlaceholder(this);"></asp:TextBox>
<asp:RegularExpressionValidator ID="vldtstImmLen"
ControlToValidate="txttstImmLen" Display="Dynamic" ErrorMessage="Immersion
Length" Text="*" ValidationExpression="(0*[1-9]\d*)"
runat="server"/> </td>
Please help!
I'm total newbie in using asp.net and I have this regular expression
validator that was working perfectly fine before but after I made a huge
edit to my textboxes its not working anymore.
In before edit, when I try to submit the form, if my textbox is empty or
the value = "" it will show the error message and will NOT redirect to
another page.
In after edit, when I try to submit the form, whether the textbox is empty
or not it will redirect to another page. Not stopping the page from
redirecting or showing the validator
before edit.
<asp:TextBox ID="txttstImmLen" CssClass="forImmLenTb" runat="server"
Width="118" Text="Enter Value Here" OnClick="this.value=''"
onblur="tryPlaceholder(this,'Enter Value Here')" ></asp:TextBox>
<asp:RegularExpressionValidator ID="vldtstImmLen"
ControlToValidate="txttstImmLen" Display="Dynamic" ErrorMessage="Immersion
Length" Text="*" ValidationExpression="(0*[1-9]\d*)" Runat="server"/>
after edit
<asp:TextBox ID="txttstImmLen" CssClass="forImmLenTb" runat="server"
Width="118" onblur="tryPlaceholder(this);"></asp:TextBox>
<asp:RegularExpressionValidator ID="vldtstImmLen"
ControlToValidate="txttstImmLen" Display="Dynamic" ErrorMessage="Immersion
Length" Text="*" ValidationExpression="(0*[1-9]\d*)"
runat="server"/> </td>
Please help!
Connect local database c#
Connect local database c#
I want to create a empty local database inside my project's folder and
I've error: "An unhandled exception of type
'System.Data.SqlServerCe.SqlCeException' occurred in
System.Data.SqlServerCe.dll" in conn.Open();
I'm lost with what I need to do... I try a lot of possibilities and this
one of them...
SqlCeConnection conn = null;
try
{
conn = new SqlCeConnection("Data Source = bd-avalia.sdf;
Password ='<asdasd>'");
conn.Open();
SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = "create table cliente(id_cliente int
identity not null primary key, nome varchar not null, password
not null int)";
cmd.ExecuteNonQuery();
}
finally
{
conn.Close();
}
I want to create a empty local database inside my project's folder and
I've error: "An unhandled exception of type
'System.Data.SqlServerCe.SqlCeException' occurred in
System.Data.SqlServerCe.dll" in conn.Open();
I'm lost with what I need to do... I try a lot of possibilities and this
one of them...
SqlCeConnection conn = null;
try
{
conn = new SqlCeConnection("Data Source = bd-avalia.sdf;
Password ='<asdasd>'");
conn.Open();
SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = "create table cliente(id_cliente int
identity not null primary key, nome varchar not null, password
not null int)";
cmd.ExecuteNonQuery();
}
finally
{
conn.Close();
}
MCTS 70-515 Expiry Date
MCTS 70-515 Expiry Date
SUB: MCTS 70-515 Expiry Date
Please somebody let me know whether microsoft certification exam code
70-515 is active or expired on july 2013.
Thanks in adv.
SUB: MCTS 70-515 Expiry Date
Please somebody let me know whether microsoft certification exam code
70-515 is active or expired on july 2013.
Thanks in adv.
Unable to read file from server
Unable to read file from server
I want to download file from server. File is created successfully in my
android device but that file is empty file. it is not writing anything in
file.
My filereading code is as follows:
URL url = new URL(urlString);
HttpURLConnection urlConnection = (HttpURLConnection)
url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setDoOutput(true);
//connect
urlConnection.connect();
File SDCardRoot = Environment.getExternalStorageDirectory();
//create a new file, to save the downloaded file
File file = new File(SDCardRoot,pos);
FileOutputStream fileOutput = new FileOutputStream(file);
//Stream used for reading the data from the internet
InputStream inputStream = urlConnection.getInputStream();
//this is the total size of the file which we are downloading
totalSize = urlConnection.getContentLength();
//create a buffer...
byte[] buffer = new byte[1024];
int bufferLength = 0;
while ( (bufferLength = inputStream.read(buffer)) > 0 ) {
fileOutput.write(buffer, 0, bufferLength);
downloadedSize += bufferLength;
}
fileOutput.close();
}
I have debugged the code. There is something wrong in while (
(bufferLength = inputStream.read(buffer)) > 0 ) condition as the compiler
didnt go inside this loop.
I want to download file from server. File is created successfully in my
android device but that file is empty file. it is not writing anything in
file.
My filereading code is as follows:
URL url = new URL(urlString);
HttpURLConnection urlConnection = (HttpURLConnection)
url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setDoOutput(true);
//connect
urlConnection.connect();
File SDCardRoot = Environment.getExternalStorageDirectory();
//create a new file, to save the downloaded file
File file = new File(SDCardRoot,pos);
FileOutputStream fileOutput = new FileOutputStream(file);
//Stream used for reading the data from the internet
InputStream inputStream = urlConnection.getInputStream();
//this is the total size of the file which we are downloading
totalSize = urlConnection.getContentLength();
//create a buffer...
byte[] buffer = new byte[1024];
int bufferLength = 0;
while ( (bufferLength = inputStream.read(buffer)) > 0 ) {
fileOutput.write(buffer, 0, bufferLength);
downloadedSize += bufferLength;
}
fileOutput.close();
}
I have debugged the code. There is something wrong in while (
(bufferLength = inputStream.read(buffer)) > 0 ) condition as the compiler
didnt go inside this loop.
Show language's names in their own native language using JavaScript with the help of UTF-8?
Show language's names in their own native language using JavaScript with
the help of UTF-8?
For example from the server, I am going to get a response as:
{
Language : ["Arabic","Hindi","English"]
}
I have to make tabs like:
[ÇáÚÑÈíÉ][हिंदी][English]
Is this possible?
the help of UTF-8?
For example from the server, I am going to get a response as:
{
Language : ["Arabic","Hindi","English"]
}
I have to make tabs like:
[ÇáÚÑÈíÉ][हिंदी][English]
Is this possible?
Tuesday, 6 August 2013
SSL Error using custom domain with Google App Engine
SSL Error using custom domain with Google App Engine
I followed the steps detailed here to use a custom domain with google app
engine.
I'm the admin of the Google Apps account
I'm the owner of the Google App Engine account
I've added the domain to my Google Apps account through my App Engine account
I see my App Engine app in my Google Apps account
I set the CNAME "test" to point to ghs.googlehosted.com
I added the web address under my Google Apps account and it says "Your
users can access my-app-id at: test.mydomain.com
Now when I go to test.mydomain.com, I get an SSL connection error (Unable
to make a secure connection to the server.)
I called Google Apps customer support because I have a paid business
account, but the customer service guy said that this falls under App
Engine support and he was not trained in this issue.
Help!
I followed the steps detailed here to use a custom domain with google app
engine.
I'm the admin of the Google Apps account
I'm the owner of the Google App Engine account
I've added the domain to my Google Apps account through my App Engine account
I see my App Engine app in my Google Apps account
I set the CNAME "test" to point to ghs.googlehosted.com
I added the web address under my Google Apps account and it says "Your
users can access my-app-id at: test.mydomain.com
Now when I go to test.mydomain.com, I get an SSL connection error (Unable
to make a secure connection to the server.)
I called Google Apps customer support because I have a paid business
account, but the customer service guy said that this falls under App
Engine support and he was not trained in this issue.
Help!
Serving a single HTML page from something like Gist or Pastebin
Serving a single HTML page from something like Gist or Pastebin
Are you aware of any service similar to Gist or Pastebin that just serves
an HTML page at my own subdomain, as fast as your typical CDN, and can
manage <1M requests per day reliably?
....as in nothing else required, just ONE HTML file (which then loads
everything else from S3 or something).
I'm also interested in a service that serves one HTML file + manages an
associated domain/DNS.
Are you aware of any service similar to Gist or Pastebin that just serves
an HTML page at my own subdomain, as fast as your typical CDN, and can
manage <1M requests per day reliably?
....as in nothing else required, just ONE HTML file (which then loads
everything else from S3 or something).
I'm also interested in a service that serves one HTML file + manages an
associated domain/DNS.
How to get WMI object from a WMI object reference?
How to get WMI object from a WMI object reference?
Similar to this question except that no answer was given with regards to
the main question of getting an object from reference.
For example:
PS C:\Users\admin> Get-WmiObject -Namespace $namespace -Class $class
...
IsActive : 1
oA: \\.\ROOT\abc\abc\ABC:abc.xyz="tst2"
oB : \\.\ROOT\abc\abc\ABC:abc.xyz="tst3"
PSComputerName : admin-test2
oA and oB are references and therefore come up as strings in powershell.
Is there a way I can get the object they represent using WMI query in
powershell?
Similar to this question except that no answer was given with regards to
the main question of getting an object from reference.
For example:
PS C:\Users\admin> Get-WmiObject -Namespace $namespace -Class $class
...
IsActive : 1
oA: \\.\ROOT\abc\abc\ABC:abc.xyz="tst2"
oB : \\.\ROOT\abc\abc\ABC:abc.xyz="tst3"
PSComputerName : admin-test2
oA and oB are references and therefore come up as strings in powershell.
Is there a way I can get the object they represent using WMI query in
powershell?
Searching hashtable not working, for loop not executing in c
Searching hashtable not working, for loop not executing in c
I have a hashtable with separetaly linked lists. I Successfully store my
elements in the hashtable but it fails when I try to search for my stored
elements. My function lookup_string is supposed to find the right list in
the hashtable and go through the linked list with the for-loop if more
than one element is stored with the same hash-key.
Inside the lookup_string function I found out that the for-loop never
executes (I used prints to check that) and the function skips that
for-loop and returns NULL directly. This behaviour is really odd and I
don't know why it skips that loop, but this is the reason why I can't find
my elements after I have stored them, atleast what I think.
If someone can shed some light on this problem that would be much
appreciated!
I have functions to delete elements in the hashtable but those are not
necessary to consider, I just uploaded them for understanding purpose. I
choose alternative 1 in the menu to add one element and then alternative 3
in the menu and that is when I can't find my stored element.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct post // structure of node
{
char name[30]; // stored data
int tel; // stored data
struct post *next; // reference to next node
};
typedef struct post Post; // Post = struct post
struct list
{
Post *head;
Post *current;
};
typedef struct list List;
struct hash_table
{
List *table;
int size;
};
typedef struct hash_table Post_table;
Post* CreateList(char tempname[30], int temptel)
{
Post *ptr = (Post*)malloc(sizeof(Post));
strcpy(ptr->name, tempname);
ptr->tel = temptel;
ptr->next = NULL;
printf("\n creating list with headnode as [%s]\n",tempname);
return ptr;
}
Post* AddList(char tempname[30], int temptel, Post *current)
{
if( current == NULL )
{
return (CreateList(tempname, temptel));
}
printf("\n Adding node to end of list with value [%s]\n",tempname);
Post *ptr = (Post*)malloc(sizeof(Post));
strcpy(ptr->name, tempname);
ptr->tel = temptel;
ptr->next = NULL;
current->next = ptr;
return ptr;
}
unsigned int Hash(Post_table *hash_table, char tempname[30])
{
int i, sum, key;
for(i = 0; i < strlen(tempname); i++)
{
sum += (int)tempname[i];
}
key = abs(sum % hash_table->size);
return key;
}
Post_table *create_hash_table(int size)
{
Post_table *new_table;
if (size < 1)
{return NULL;}
// attempt to allocate memory for the table structure
if ((new_table = malloc(sizeof(Post_table))) == NULL)
{return NULL;}
// attempt to allocate memory for the table itself
// calloc() = all head and current are initialized with NULL
if ((new_table->table = calloc(size,sizeof(List *) * size)) == NULL)
{return NULL;}
new_table->size = size;
return new_table;
}
Post *lookup_string(Post_table *hash_table, char tempname[30])
{
Post *list;
unsigned int hashkey = Hash(hash_table, tempname);
printf("testprint-1");
// Go to the correct list based on the hash value and see if str is
// in the list. If it is, return return a pointer to the list element.
// If it isn't, the item isn't in the table, so return NULL.
for(list = hash_table->table[hashkey].head; list != NULL; list =
list->next)
{
printf("testprint-2");
if (strcmp(tempname, list->name) == 0)
{
return list;
}
}
return NULL;
}
int add_string(Post_table *hash_table, char tempname[30], int temptel)
{
Post *current_list;
unsigned int hashkey = Hash(hash_table, tempname);
printf("\nHash-key: %d\n", hashkey);
// if item already exists, don't insert it again
current_list = lookup_string(hash_table, tempname);
if (current_list != NULL)
{
return 2;
}
hash_table->table[hashkey].current = AddList(tempname, temptel,
hash_table->table[hashkey].current);
// if the list has been created just now, then both head and current
must point to the only list element
if( hash_table->table[hashkey].head == NULL )
{
hash_table->table[hashkey].head = hash_table->table[hashkey].current;
}
return 0;
}
void free_entry(Post_table *hash_table, char tempname[30])
{
Post *del_list;
Post *temp;
int ret = 0;
unsigned int hashkey = Hash(hash_table, tempname);
del_list = lookup_string(hash_table, tempname);
ret = Delete(hash_table, tempname, hashkey);
if(ret != 0)
{
printf("\n delete [name = %s] failed, no such element
found\n",tempname);
}
else
{
printf("\n delete [name = %s] passed \n",tempname);
}
}
void skrivMeny(void)
{
printf("\n1: Register name and telephone number\n");
printf("2: Remove name and telephone number\n");
printf("3: Search for name\n");
printf("5: Exit\n");
}
Post* Search(Post_table *hash_table, unsigned int hashkey, char
tempname[30], Post **prev)
{
Post *ptr = hash_table->table[hashkey].head;
Post *tmp = NULL;
int found = 0;
char structname[sizeof(tempname)];
printf("\n Searching the list for value [%s] \n",tempname);
while(ptr != NULL)
{
if (strcmp(ptr->name, tempname) == 0)
{
found = 1;
break;
}
else
{
tmp = ptr;
ptr = ptr->next;
}
}
if(found == 1)
{
if(prev)
{
*prev = tmp;
}
return ptr;
}
else
{
return NULL;
}
}
int Delete(Post_table *hash_table, char tempname[30], unsigned int hashkey)
{
Post *prev = NULL;
Post *del = NULL;
printf("\n Deleting value [%s] from list\n",tempname);
del = Search(hash_table, hashkey, tempname, &prev);
if(del == NULL)
{
return -1;
}
else
{
if(prev != NULL)
{
prev->next = del->next;
}
if(del == hash_table->table[hashkey].current && del !=
hash_table->table[hashkey].head)
{
hash_table->table[hashkey].current = prev;
}
else if(del == hash_table->table[hashkey].head)
{
hash_table->table[hashkey].head = del->next;
}
}
free(del);
del = NULL;
return 0;
}
int main()
{
printf("\nHej och välkommen till hashlistan\n\n");
int menyval = 1;
char tempname[30];
int temptel, key;
Post * ptr;
Post_table *hash_table;
int table_size = 10;
hash_table = create_hash_table(table_size);
while (menyval > 0 && menyval <= 5)
{
skrivMeny();
scanf("%d", &menyval);
if (menyval == 1)
{
printf("[Name] [Number] = ");
scanf("%s %d", &tempname[0], &temptel);
add_string(hash_table, tempname, temptel);
}
if (menyval == 2)
{
printf("[Name] = ");
scanf("%s", &tempname[0]);
free_entry(hash_table, tempname);
}
if (menyval == 3)
{
printf("[Name] = ");
scanf("%s", &tempname[0]);
ptr = lookup_string(hash_table, tempname);
if(ptr == NULL)
{
printf("\n Search [name = %s] failed, no such element
found\n",tempname);
}
else
{
printf("\n Search passed [name = %s tel =
%d]\n",ptr->name, ptr->tel);
}
}
if (menyval == 5)
{
break;
}
}
return 0;
}
I have a hashtable with separetaly linked lists. I Successfully store my
elements in the hashtable but it fails when I try to search for my stored
elements. My function lookup_string is supposed to find the right list in
the hashtable and go through the linked list with the for-loop if more
than one element is stored with the same hash-key.
Inside the lookup_string function I found out that the for-loop never
executes (I used prints to check that) and the function skips that
for-loop and returns NULL directly. This behaviour is really odd and I
don't know why it skips that loop, but this is the reason why I can't find
my elements after I have stored them, atleast what I think.
If someone can shed some light on this problem that would be much
appreciated!
I have functions to delete elements in the hashtable but those are not
necessary to consider, I just uploaded them for understanding purpose. I
choose alternative 1 in the menu to add one element and then alternative 3
in the menu and that is when I can't find my stored element.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct post // structure of node
{
char name[30]; // stored data
int tel; // stored data
struct post *next; // reference to next node
};
typedef struct post Post; // Post = struct post
struct list
{
Post *head;
Post *current;
};
typedef struct list List;
struct hash_table
{
List *table;
int size;
};
typedef struct hash_table Post_table;
Post* CreateList(char tempname[30], int temptel)
{
Post *ptr = (Post*)malloc(sizeof(Post));
strcpy(ptr->name, tempname);
ptr->tel = temptel;
ptr->next = NULL;
printf("\n creating list with headnode as [%s]\n",tempname);
return ptr;
}
Post* AddList(char tempname[30], int temptel, Post *current)
{
if( current == NULL )
{
return (CreateList(tempname, temptel));
}
printf("\n Adding node to end of list with value [%s]\n",tempname);
Post *ptr = (Post*)malloc(sizeof(Post));
strcpy(ptr->name, tempname);
ptr->tel = temptel;
ptr->next = NULL;
current->next = ptr;
return ptr;
}
unsigned int Hash(Post_table *hash_table, char tempname[30])
{
int i, sum, key;
for(i = 0; i < strlen(tempname); i++)
{
sum += (int)tempname[i];
}
key = abs(sum % hash_table->size);
return key;
}
Post_table *create_hash_table(int size)
{
Post_table *new_table;
if (size < 1)
{return NULL;}
// attempt to allocate memory for the table structure
if ((new_table = malloc(sizeof(Post_table))) == NULL)
{return NULL;}
// attempt to allocate memory for the table itself
// calloc() = all head and current are initialized with NULL
if ((new_table->table = calloc(size,sizeof(List *) * size)) == NULL)
{return NULL;}
new_table->size = size;
return new_table;
}
Post *lookup_string(Post_table *hash_table, char tempname[30])
{
Post *list;
unsigned int hashkey = Hash(hash_table, tempname);
printf("testprint-1");
// Go to the correct list based on the hash value and see if str is
// in the list. If it is, return return a pointer to the list element.
// If it isn't, the item isn't in the table, so return NULL.
for(list = hash_table->table[hashkey].head; list != NULL; list =
list->next)
{
printf("testprint-2");
if (strcmp(tempname, list->name) == 0)
{
return list;
}
}
return NULL;
}
int add_string(Post_table *hash_table, char tempname[30], int temptel)
{
Post *current_list;
unsigned int hashkey = Hash(hash_table, tempname);
printf("\nHash-key: %d\n", hashkey);
// if item already exists, don't insert it again
current_list = lookup_string(hash_table, tempname);
if (current_list != NULL)
{
return 2;
}
hash_table->table[hashkey].current = AddList(tempname, temptel,
hash_table->table[hashkey].current);
// if the list has been created just now, then both head and current
must point to the only list element
if( hash_table->table[hashkey].head == NULL )
{
hash_table->table[hashkey].head = hash_table->table[hashkey].current;
}
return 0;
}
void free_entry(Post_table *hash_table, char tempname[30])
{
Post *del_list;
Post *temp;
int ret = 0;
unsigned int hashkey = Hash(hash_table, tempname);
del_list = lookup_string(hash_table, tempname);
ret = Delete(hash_table, tempname, hashkey);
if(ret != 0)
{
printf("\n delete [name = %s] failed, no such element
found\n",tempname);
}
else
{
printf("\n delete [name = %s] passed \n",tempname);
}
}
void skrivMeny(void)
{
printf("\n1: Register name and telephone number\n");
printf("2: Remove name and telephone number\n");
printf("3: Search for name\n");
printf("5: Exit\n");
}
Post* Search(Post_table *hash_table, unsigned int hashkey, char
tempname[30], Post **prev)
{
Post *ptr = hash_table->table[hashkey].head;
Post *tmp = NULL;
int found = 0;
char structname[sizeof(tempname)];
printf("\n Searching the list for value [%s] \n",tempname);
while(ptr != NULL)
{
if (strcmp(ptr->name, tempname) == 0)
{
found = 1;
break;
}
else
{
tmp = ptr;
ptr = ptr->next;
}
}
if(found == 1)
{
if(prev)
{
*prev = tmp;
}
return ptr;
}
else
{
return NULL;
}
}
int Delete(Post_table *hash_table, char tempname[30], unsigned int hashkey)
{
Post *prev = NULL;
Post *del = NULL;
printf("\n Deleting value [%s] from list\n",tempname);
del = Search(hash_table, hashkey, tempname, &prev);
if(del == NULL)
{
return -1;
}
else
{
if(prev != NULL)
{
prev->next = del->next;
}
if(del == hash_table->table[hashkey].current && del !=
hash_table->table[hashkey].head)
{
hash_table->table[hashkey].current = prev;
}
else if(del == hash_table->table[hashkey].head)
{
hash_table->table[hashkey].head = del->next;
}
}
free(del);
del = NULL;
return 0;
}
int main()
{
printf("\nHej och välkommen till hashlistan\n\n");
int menyval = 1;
char tempname[30];
int temptel, key;
Post * ptr;
Post_table *hash_table;
int table_size = 10;
hash_table = create_hash_table(table_size);
while (menyval > 0 && menyval <= 5)
{
skrivMeny();
scanf("%d", &menyval);
if (menyval == 1)
{
printf("[Name] [Number] = ");
scanf("%s %d", &tempname[0], &temptel);
add_string(hash_table, tempname, temptel);
}
if (menyval == 2)
{
printf("[Name] = ");
scanf("%s", &tempname[0]);
free_entry(hash_table, tempname);
}
if (menyval == 3)
{
printf("[Name] = ");
scanf("%s", &tempname[0]);
ptr = lookup_string(hash_table, tempname);
if(ptr == NULL)
{
printf("\n Search [name = %s] failed, no such element
found\n",tempname);
}
else
{
printf("\n Search passed [name = %s tel =
%d]\n",ptr->name, ptr->tel);
}
}
if (menyval == 5)
{
break;
}
}
return 0;
}
Subscribe to:
Posts (Atom)