how to remove keyboard when user click any where in window?
can you please tell me how to hide the keyboard in IOS when user click
anywhere in window.I used blur() on button click it work but when i used
in view it not work..:(
I check if user click any where other than textfield it hide the keyboard
my my logic fail..:(
Here is my code..
//FirstView Component Constructor
function FirstView() {
//create object instance, a parasitic subclass of Observable
var self = Ti.UI.createView({
layout:"vertical"
});
var self1 = Ti.UI.createView({
layout:"horizontal",
top:20,
height:Ti.UI.SIZE
});
var self2 = Ti.UI.createView({
layout:"horizontal",
top:10,
height:Ti.UI.SIZE
});
//label using localization-ready strings from <app
dir>/i18n/en/strings.xml
var nameLabel=Ti.UI.createLabel({
text:"Name",
left:15,
width:100,
height:35
});
var nameTextField=Ti.UI.createTextField({
height:35,
width:140,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});
self1.add(nameLabel);
self1.add(nameTextField);
self.add(self1);
var passwordLabel=Ti.UI.createLabel({
text:"Password",
left:15,
width:100,
height:35
});
var passwordTextField=Ti.UI.createTextField({
height:35,
width:140,
passwordMask:true,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});
var loginButton =Ti.UI.createButton({
title:"LOGIN",
top: 120,
width:200,
height:40
});
loginButton.addEventListener('click',function(e){
passwordTextField.blur();
nameTextField.blur();
});
self2.add(passwordLabel);
self2.add(passwordTextField);//
self.backgroundImage="http://bluebackground.com/__oneclick_uploads/2008/04/blue_background_03.jpg";
self.add(self2);
self.add(loginButton);
self.addEventListener('click',function(e){
if(e.source != [Ti.UI.TextField]){
alert("window click");
passwordTextField.blur();
nameTextField.blur();
}
});
return self;
}
module.exports = FirstView;
Saturday, 31 August 2013
Sql server prefix difference between custom and "dbo"
Sql server prefix difference between custom and "dbo"
I've a shared web hosting and Sql Server with it.
When I create a View or Stored Procedure via Sql Server Management Studio
it appends as prefix my username instead of dbo.
Suppose my username is UserJustWork which I use while connecting to remote
sql server.
SPs and Views are being named as:
UserJustWork.Users_Get -- SP
UserJustWork.ActiveUsers -- View
According to hundreds of people (e.g. SQLMenace's answer) using prefix
makes sql faster on finding object.
Sure, it is shared sql server (that means there are so many people using it).
What I wonder is that does it make better performance using UserJustWork
than dbo?
I've a shared web hosting and Sql Server with it.
When I create a View or Stored Procedure via Sql Server Management Studio
it appends as prefix my username instead of dbo.
Suppose my username is UserJustWork which I use while connecting to remote
sql server.
SPs and Views are being named as:
UserJustWork.Users_Get -- SP
UserJustWork.ActiveUsers -- View
According to hundreds of people (e.g. SQLMenace's answer) using prefix
makes sql faster on finding object.
Sure, it is shared sql server (that means there are so many people using it).
What I wonder is that does it make better performance using UserJustWork
than dbo?
Application Exception in tapestry subforms - Parameter is bound to null
Application Exception in tapestry subforms - Parameter is bound to null
I want to create a subform with tapestry5:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
<t:TextField t:id="name" />
</html>
and use it like this:
<form t:type="form" t:id="testForm">
<t:testComponent name="name" />
<input type="submit"/>
</form>
TestComponent.java:
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
public class TestComponent {
@Parameter(required = true, allowNull = false)
@Property
private String name;
}
so that i can use the value of 'name' like:
@Property
private String name;
void onSuccessFromTestForm() {
System.out.println(name);
}
But all i get is an application exception:
Render queue error in BeginRender[Index:testcomponent.name]: Failure
reading parameter 'value' of component Index:testcomponent.name: Parameter
'name' of component Index:testcomponent is bound to null. This parameter
is not allowed to be null.
Whats the problem?
I want to create a subform with tapestry5:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
<t:TextField t:id="name" />
</html>
and use it like this:
<form t:type="form" t:id="testForm">
<t:testComponent name="name" />
<input type="submit"/>
</form>
TestComponent.java:
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
public class TestComponent {
@Parameter(required = true, allowNull = false)
@Property
private String name;
}
so that i can use the value of 'name' like:
@Property
private String name;
void onSuccessFromTestForm() {
System.out.println(name);
}
But all i get is an application exception:
Render queue error in BeginRender[Index:testcomponent.name]: Failure
reading parameter 'value' of component Index:testcomponent.name: Parameter
'name' of component Index:testcomponent is bound to null. This parameter
is not allowed to be null.
Whats the problem?
CKEditor 4 and nonstandard HTML element
CKEditor 4 and nonstandard HTML element
Here is a nonstandard HTML element that I defined (AngularJS makes this
easy):
<exercise id="Sample Exercise" language="Scala" lectureId="5437"> This is
the text of the lecture </exercise>
If I use this element in an HTML document, each time I switch from
CKEditor's rendered mode to source mode a new empty paragraph is added
between each of the block elements in the document:
<p> </p>
The 2nd time I switch, I get two insertions:
<p> </p>
<p> </p>
The 3rd time I switch, I get three insertions between each block-level
element, etc:
<p> </p>
<p> </p>
<p> </p>
Can anyone suggest a workaround?
Here is a nonstandard HTML element that I defined (AngularJS makes this
easy):
<exercise id="Sample Exercise" language="Scala" lectureId="5437"> This is
the text of the lecture </exercise>
If I use this element in an HTML document, each time I switch from
CKEditor's rendered mode to source mode a new empty paragraph is added
between each of the block elements in the document:
<p> </p>
The 2nd time I switch, I get two insertions:
<p> </p>
<p> </p>
The 3rd time I switch, I get three insertions between each block-level
element, etc:
<p> </p>
<p> </p>
<p> </p>
Can anyone suggest a workaround?
Hibernate Inheritance SingleTable Subclass Joins
Hibernate Inheritance SingleTable Subclass Joins
Ive been working with Hibernate since a couple of weeks. Well its a very
helpful tool but i cannot resolve following task:
Table:
Create Table `Product`
(
`product_id` INT(10) PRIMARY KEY,
`package_id` INT(10) NULL,
`product_type` VARCHAR(50) NOT NULL,
`title` VARCHAR(255) NOT NULL,
`desc` VARCHAR(255) NULL,
`price` REAL(10) NOT NULL,
...
);
in Java i have 3 Classes
@Entity
@Table(name = "Product")
@DiscriminatorColumn(name = "product_type")
public abstract class Product {
...
}
there are two types of instances, where an "Item" could but may not always
deserve to a "Bundle". "Bundles" have at least one "Item"
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue(value = "Item")
public class Item extends Product {
Bundle bundle;
....
@ManyToOne (fetch=FetchType.LAZY, targetEntity=Bundle.class)
@JoinColumn (name="album_id")
public Bundle getBundle() {...}
public void setBundle(Bundle bundle) {...}
....
}
and:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue(value = "Bundle")
public class Bundle extends Product {
Set<Item> items;
....
@OneToMany (mappedBy="album", targetEntity=MusicSong.class)
@OrderBy ("track")
public Set<Item> getItems() {...}
public void setItems(Set<Item> items) {...}
....
}
At Runtime its not possible to call any data, error: Expected type:
org.blah.Bundle, actual value: org.blah.Item
does anyone have an idea or hint. isearching google up&down but i cannot
find this specific issue.
Ive been working with Hibernate since a couple of weeks. Well its a very
helpful tool but i cannot resolve following task:
Table:
Create Table `Product`
(
`product_id` INT(10) PRIMARY KEY,
`package_id` INT(10) NULL,
`product_type` VARCHAR(50) NOT NULL,
`title` VARCHAR(255) NOT NULL,
`desc` VARCHAR(255) NULL,
`price` REAL(10) NOT NULL,
...
);
in Java i have 3 Classes
@Entity
@Table(name = "Product")
@DiscriminatorColumn(name = "product_type")
public abstract class Product {
...
}
there are two types of instances, where an "Item" could but may not always
deserve to a "Bundle". "Bundles" have at least one "Item"
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue(value = "Item")
public class Item extends Product {
Bundle bundle;
....
@ManyToOne (fetch=FetchType.LAZY, targetEntity=Bundle.class)
@JoinColumn (name="album_id")
public Bundle getBundle() {...}
public void setBundle(Bundle bundle) {...}
....
}
and:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue(value = "Bundle")
public class Bundle extends Product {
Set<Item> items;
....
@OneToMany (mappedBy="album", targetEntity=MusicSong.class)
@OrderBy ("track")
public Set<Item> getItems() {...}
public void setItems(Set<Item> items) {...}
....
}
At Runtime its not possible to call any data, error: Expected type:
org.blah.Bundle, actual value: org.blah.Item
does anyone have an idea or hint. isearching google up&down but i cannot
find this specific issue.
How could this happen? about hibernate and spring and SessionFactory
How could this happen? about hibernate and spring and SessionFactory
I have a bean in spring's config, which is
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
and in my MVC controller, I use:
@autowired
SessionFactory sf;
and spring can inject hibernate's SessionFactory (not just the
bean:LocalSessionFactoryBean)
how could this happen, SessionFactory is just a property of
LocalSessionFactoryBean.
I have a bean in spring's config, which is
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
and in my MVC controller, I use:
@autowired
SessionFactory sf;
and spring can inject hibernate's SessionFactory (not just the
bean:LocalSessionFactoryBean)
how could this happen, SessionFactory is just a property of
LocalSessionFactoryBean.
How to run a secondary query within a primary query inside a for each loop
How to run a secondary query within a primary query inside a for each loop
How can I modify my code to allow me to run a second query in the for each
loop?
For now I have commented out the second query, as Im sure I need to make
some changes prior to removing the slashes.
<?php
$mysqli = new mysqli('LOGIN DETAILS HERE');
if ($mysqli->connect_error) {
die('Connect Error: ' . $mysqli->connect_error);
}
$query = "SELECT * FROM toptips WHERE userid = 2";
$result = $mysqli->query($query);
while($row = $result->fetch_array())
{ $rows[] = $row; }
foreach($rows as $row) {
$id = $row['id'];
echo $row['time'] . " " . $row['course'] . " - " . $row['horse'] . " "
. $row['description'] ."<br/>";
// second query here
// $query2 = "SELECT likes FROM Likes_table WHERE id = $id";
// $result = $mysqli->query($query2);
// while($row = $result->fetch_assoc()){
// echo $row['likes'] . '<br />';
// }
}
?>
How can I modify my code to allow me to run a second query in the for each
loop?
For now I have commented out the second query, as Im sure I need to make
some changes prior to removing the slashes.
<?php
$mysqli = new mysqli('LOGIN DETAILS HERE');
if ($mysqli->connect_error) {
die('Connect Error: ' . $mysqli->connect_error);
}
$query = "SELECT * FROM toptips WHERE userid = 2";
$result = $mysqli->query($query);
while($row = $result->fetch_array())
{ $rows[] = $row; }
foreach($rows as $row) {
$id = $row['id'];
echo $row['time'] . " " . $row['course'] . " - " . $row['horse'] . " "
. $row['description'] ."<br/>";
// second query here
// $query2 = "SELECT likes FROM Likes_table WHERE id = $id";
// $result = $mysqli->query($query2);
// while($row = $result->fetch_assoc()){
// echo $row['likes'] . '<br />';
// }
}
?>
Friday, 30 August 2013
Python HTTP Exception Handling
Python HTTP Exception Handling
I'm running a program that downloads files from a web sit. I've introduced
one exception handling urllib.error.HTTPError, but now I'm getting from
time to time additional errors that I'm not sure how to capture:
http.client.IncompleteRead. Do I just add the following to the code at the
bottom?
except http.client.IncompleteRead:
How many exceptions do I have to add to make sure the program doesn't
stop? And do I have to add them all in the same Except statement or in
several Except statements.
try:
# Open a file object for the webpage
f = urllib.request.urlopen(imageURL)
# Open the local file where you will store the image
imageF = open('{0}{1}{2}{3}'.format(dirImages, imageName, imageNumber,
extension), 'wb')
# Write the image to the local file
imageF.write(f.read())
# Clean up
imageF.close()
f.close()
except urllib.error.HTTPError: # The 'except' block executes if an
HTTPError is thrown by the try block, then the program continues as usual.
print ("Image fetch failed.")
I'm running a program that downloads files from a web sit. I've introduced
one exception handling urllib.error.HTTPError, but now I'm getting from
time to time additional errors that I'm not sure how to capture:
http.client.IncompleteRead. Do I just add the following to the code at the
bottom?
except http.client.IncompleteRead:
How many exceptions do I have to add to make sure the program doesn't
stop? And do I have to add them all in the same Except statement or in
several Except statements.
try:
# Open a file object for the webpage
f = urllib.request.urlopen(imageURL)
# Open the local file where you will store the image
imageF = open('{0}{1}{2}{3}'.format(dirImages, imageName, imageNumber,
extension), 'wb')
# Write the image to the local file
imageF.write(f.read())
# Clean up
imageF.close()
f.close()
except urllib.error.HTTPError: # The 'except' block executes if an
HTTPError is thrown by the try block, then the program continues as usual.
print ("Image fetch failed.")
Thursday, 29 August 2013
OpenLayers map turns grey in Google Chrome
OpenLayers map turns grey in Google Chrome
I have an OpenLayers map that renders several layers where each layer
contains a number of feature vectors. There is a base layer that loads an
image.
This seems to work fine in every browser except Chrome. Whenever I load
the map in chrome the entire page turns grey, even the areas not covered
by the map - see attached screenshot. When I remove all the vectors it
works fine again.
I have the markers set up to not load until they are visible using
openLayers.Strategy.BBOX and the protocol attribute.
I am guessing this is a memory issue with Chrome but does anyone know how
to resolve this? I will post some of my code if required but hopefully
someone will have had the same issue before.
Thanks!
I have an OpenLayers map that renders several layers where each layer
contains a number of feature vectors. There is a base layer that loads an
image.
This seems to work fine in every browser except Chrome. Whenever I load
the map in chrome the entire page turns grey, even the areas not covered
by the map - see attached screenshot. When I remove all the vectors it
works fine again.
I have the markers set up to not load until they are visible using
openLayers.Strategy.BBOX and the protocol attribute.
I am guessing this is a memory issue with Chrome but does anyone know how
to resolve this? I will post some of my code if required but hopefully
someone will have had the same issue before.
Thanks!
Wednesday, 28 August 2013
Get map center in maps version 2 of google maps
Get map center in maps version 2 of google maps
I am upgrading my google maps version from 1 to version 2, but I have a
problem as i used to use the getMapCenter() but i am not able to use it in
v2
Any help is appreciated. Thanks in advance.
I am upgrading my google maps version from 1 to version 2, but I have a
problem as i used to use the getMapCenter() but i am not able to use it in
v2
Any help is appreciated. Thanks in advance.
Google fonts not working on any browsers or tablets
Google fonts not working on any browsers or tablets
I am having a serious issue with Google fonts. They were working fine till
last week and since then they have stopped working on all the browsers and
tablets. If I manually install fonts on my PC then only they show up but
not very accurately.
Header code of API:
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,300'
rel='stylesheet' type='text/css'>
http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700'
rel='stylesheet' type='text/css'>
CSS: body { font-family: 'Open Sans', Arial, sans-serif; font-size: 16px;
color: #4c4c4c; background: url('images/textures/header_bg1.png')
no-repeat center top, url(images/textures/11.png) 0px 0px; }
h1, h2, h3, h4, h5, h6 { font-family: 'Open Sans', Arial, sans-serif;
padding-bottom: 6px; color: #474747; line-height: 1em; font-weight: 300; }
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { color: #2b2b2b; }
h1 { font-size: 41px; font-weight: 300; color: #5a5a5a; margin-top: 25px;
margin-bottom:5px;}
h2 { font-size: 30px; font-weight: 300; margin-top: 25px;
margin-bottom:5px;}
h3 { font-size: 23px; font-weight: 300; margin-top: 25px;
margin-bottom:5px;}
h4 { font-size: 18px; font-weight: lighter; margin-top: 25px;
margin-bottom:5px;}
h5 { font-size: 16px; font-weight: lighter; margin-top: 25px;
margin-bottom:5px;}
h6 { font-size: 14px; font-weight: lighter; margin-top: 25px;
margin-bottom:5px;}
p { font-family: 'Open Sans', Arial, sans-serif; font-size: 12px; color:
#4c4c4c; text-align: justify; margin-top: 10px; margin-bottom: 10px;
line-height: 25px;}
Any help on this issue be highly appreciated and Thanks in advanced :)
-P
I am having a serious issue with Google fonts. They were working fine till
last week and since then they have stopped working on all the browsers and
tablets. If I manually install fonts on my PC then only they show up but
not very accurately.
Header code of API:
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,300'
rel='stylesheet' type='text/css'>
http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700'
rel='stylesheet' type='text/css'>
CSS: body { font-family: 'Open Sans', Arial, sans-serif; font-size: 16px;
color: #4c4c4c; background: url('images/textures/header_bg1.png')
no-repeat center top, url(images/textures/11.png) 0px 0px; }
h1, h2, h3, h4, h5, h6 { font-family: 'Open Sans', Arial, sans-serif;
padding-bottom: 6px; color: #474747; line-height: 1em; font-weight: 300; }
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { color: #2b2b2b; }
h1 { font-size: 41px; font-weight: 300; color: #5a5a5a; margin-top: 25px;
margin-bottom:5px;}
h2 { font-size: 30px; font-weight: 300; margin-top: 25px;
margin-bottom:5px;}
h3 { font-size: 23px; font-weight: 300; margin-top: 25px;
margin-bottom:5px;}
h4 { font-size: 18px; font-weight: lighter; margin-top: 25px;
margin-bottom:5px;}
h5 { font-size: 16px; font-weight: lighter; margin-top: 25px;
margin-bottom:5px;}
h6 { font-size: 14px; font-weight: lighter; margin-top: 25px;
margin-bottom:5px;}
p { font-family: 'Open Sans', Arial, sans-serif; font-size: 12px; color:
#4c4c4c; text-align: justify; margin-top: 10px; margin-bottom: 10px;
line-height: 25px;}
Any help on this issue be highly appreciated and Thanks in advanced :)
-P
How to display the text message in text view of directions from source map point to destination map point in mkmapview in ios
How to display the text message in text view of directions from source map
point to destination map point in mkmapview in ios
I am new to Mapview application, can any one help to display the the text
message in textview of directions from Source to destionation (For eg.
1.Turn west onto Juniper street 2. Head west on Juniper Street for 5 feet
3. Head East onto Broadway for 10ft)
Thanks in advance..!!
point to destination map point in mkmapview in ios
I am new to Mapview application, can any one help to display the the text
message in textview of directions from Source to destionation (For eg.
1.Turn west onto Juniper street 2. Head west on Juniper Street for 5 feet
3. Head East onto Broadway for 10ft)
Thanks in advance..!!
Tuesday, 27 August 2013
how to use javascript for string words comparision
how to use javascript for string words comparision
I am using two text areas. Project is about online typing test. I used two
text area. First textarea contains the matter to be typed in second
textarea. For calculating the the net typing speed I need a javascript
diff algorithm. This algo fits my all requirements..which uses this
javascript file for differencing of two strings. This is a demo which uses
the same javascript file...You should have look of this demo. But I how
can I know count correct words typed? Trouble is that the javascript file
provided is not using any comments nor gives any documentation.
I am using two text areas. Project is about online typing test. I used two
text area. First textarea contains the matter to be typed in second
textarea. For calculating the the net typing speed I need a javascript
diff algorithm. This algo fits my all requirements..which uses this
javascript file for differencing of two strings. This is a demo which uses
the same javascript file...You should have look of this demo. But I how
can I know count correct words typed? Trouble is that the javascript file
provided is not using any comments nor gives any documentation.
Button width issue
Button width issue
I just did an UL list with 4 LI elements and I did this in CSS:
ul li {
width:200px;/*problem*/
display:inline;
color:white;
background-color:red;
border-radius:5px;
font-family:verdana;
font-size:2em;
box-shadow:0 7px 0 #600;
padding:5px 20px;
margin:15px;
}
The problem is that the width property has no influency in the width of
the li element, and if I want to do it larger I have to add padding to the
right and left but that is not good because there are different lenghts in
each box since some have more letters than others.
Why is that happening?
Thanks,
I just did an UL list with 4 LI elements and I did this in CSS:
ul li {
width:200px;/*problem*/
display:inline;
color:white;
background-color:red;
border-radius:5px;
font-family:verdana;
font-size:2em;
box-shadow:0 7px 0 #600;
padding:5px 20px;
margin:15px;
}
The problem is that the width property has no influency in the width of
the li element, and if I want to do it larger I have to add padding to the
right and left but that is not good because there are different lenghts in
each box since some have more letters than others.
Why is that happening?
Thanks,
Do diff between pairs of a file a list
Do diff between pairs of a file a list
I have a directory on my Linux system whose contents are file names in
pairs as follows:
File1a
File1b
File2a
File2b
File3a
File3b
I want to do a diff between the contents of File1a and File1b and store
the results in a separate file. Similarly do this over other pairs
iterating through the entire list. Can this be achieved with a shell
script ?
I have a directory on my Linux system whose contents are file names in
pairs as follows:
File1a
File1b
File2a
File2b
File3a
File3b
I want to do a diff between the contents of File1a and File1b and store
the results in a separate file. Similarly do this over other pairs
iterating through the entire list. Can this be achieved with a shell
script ?
In App store My new version of the app is not uploaded downloading only previous version
In App store My new version of the app is not uploaded downloading only
previous version
On 25th August 2013 my app changed to Ready for sale status.When i
download my app in store its still downloading my previous version not the
updated version.I waited for more than 24 hours.Please help me out.Thank
You
previous version
On 25th August 2013 my app changed to Ready for sale status.When i
download my app in store its still downloading my previous version not the
updated version.I waited for more than 24 hours.Please help me out.Thank
You
NSOperation KVO isFinished
NSOperation KVO isFinished
Im trying to subclass a NSOperation, and read some sample from, they say:
when the task finished, using KVO of NSOperation, to finish the operation,
code here:
[self willChangeValueForKey:@"isFinished"];
[self willChangeValueForKey:@"isExecuting"]
finished = YES;
executing = NO;
[self didChangeValueForKey:@"isFinished"];
[self didChangeValueForKey:@"isExecuting"];
then isFinished get called
- (BOOL) isFinished{
return(finished);
}
anyone could explain this to me? why isFinished gets called, will the
isFinished finish the operation? as I understanded, do KVO manually need
[self didChangeValueForKey:@"isExecuting"]; and I didnt see code like
addobserver: and observeValueForKeyPath:
I write
-(void)call
{
[self willChangeValueForKey:@"isVip"];
[self didChangeValueForKey:@"isVip"];
}
-(void)isVip
{
NSLog(@"Im vip");
}
isVip is not called when do [self call];
Im trying to subclass a NSOperation, and read some sample from, they say:
when the task finished, using KVO of NSOperation, to finish the operation,
code here:
[self willChangeValueForKey:@"isFinished"];
[self willChangeValueForKey:@"isExecuting"]
finished = YES;
executing = NO;
[self didChangeValueForKey:@"isFinished"];
[self didChangeValueForKey:@"isExecuting"];
then isFinished get called
- (BOOL) isFinished{
return(finished);
}
anyone could explain this to me? why isFinished gets called, will the
isFinished finish the operation? as I understanded, do KVO manually need
[self didChangeValueForKey:@"isExecuting"]; and I didnt see code like
addobserver: and observeValueForKeyPath:
I write
-(void)call
{
[self willChangeValueForKey:@"isVip"];
[self didChangeValueForKey:@"isVip"];
}
-(void)isVip
{
NSLog(@"Im vip");
}
isVip is not called when do [self call];
Monday, 26 August 2013
Jquery mobile input issue in android
Jquery mobile input issue in android
I am facing a weird issue while using jquery mobile in a phonegap
application. I have attached the fiddle the issue is happening only in
android not in desktop.
I have two input fields where in the first field I have an onfocus event
and onblur event to change the input field's type to number and text and
viceversa.
The second field contains a inputfield which has an onfocus event.
The issue now is when i type some value on the first field and click the
second field and type a number the number gets keep on repeating. Example
: if i type 1 then it continuously comes as 111111111111111
Any idea why this is happening?
Issue Fiddle
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Employee Details</title>
<!-- LIBRARIES -->
<script language="javascript" type="text/javascript"
src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script
src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"
type="text/javascript"
charset="utf-8"></script>
<!-- STYLESHEETS -->
<link rel="stylesheet"
href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css"
type="text/css" media="screen" title="no title" charset="utf-8" />
<script type="text/javascript">
function setText(obj){
$("#" + id).val("");
var id = obj.id;
$("#" + id).attr("type","text");
if(obj.value && obj.value.replace(/ /g,'') != 'Z'){
$("#" + id).val(obj.value +" Z");
}
}
</script>
</head>
<body >
<div data-role="page">
<div data-role="header" data-theme="a" data-position="fixed">
<a data-rel="back" class="hdrBtns" id="infoBtn">Back</a>
<h1>Employee Details</h1>
</div>
<div data-role="content" id="mainContent">
<div style="background-color: blue;">
<p class="contenthdrlbl"
style="background-color: blue; color: white;
text-align: left; line-height: 2.5; font-weight:
200;">Input
values for Employee</p>
</div>
<div style="height: 30px; background-color: white;" class="last">
<div class="ui-block-a"
style="background-color: #EBF4F8; line-height: 1.9;
text-align: center; width: 40%">
<span>Employee Id</span>
<p id="currency" style="display:inline !important;"></p>
</div>
<div class="ui-block-b ">
<input type="text" id="empid"
class="inputElement" placeholder="MANDATORY"
onfocus="this.value='';this.type='tel';"
onblur="setText(this);"></input>
</div>
</div>
<div style="height: 30px; background-color: white;" class="last">
<p class="ui-block-a"
style="background-color: #EBF4F8; line-height: 1.9;
text-align: center; width: 40%">Salary
</p>
<div class="ui-block-b ">
<input type="text" id="salary"
class="inputElement" placeholder="MANDATORY"
onfocus="this.value='';this.type='number';"
></input>
</div>
</div>
</div>
</div>
<!-- JQuery Mobile Page End Tag-->
</body>
</html>
I am facing a weird issue while using jquery mobile in a phonegap
application. I have attached the fiddle the issue is happening only in
android not in desktop.
I have two input fields where in the first field I have an onfocus event
and onblur event to change the input field's type to number and text and
viceversa.
The second field contains a inputfield which has an onfocus event.
The issue now is when i type some value on the first field and click the
second field and type a number the number gets keep on repeating. Example
: if i type 1 then it continuously comes as 111111111111111
Any idea why this is happening?
Issue Fiddle
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Employee Details</title>
<!-- LIBRARIES -->
<script language="javascript" type="text/javascript"
src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script
src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"
type="text/javascript"
charset="utf-8"></script>
<!-- STYLESHEETS -->
<link rel="stylesheet"
href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css"
type="text/css" media="screen" title="no title" charset="utf-8" />
<script type="text/javascript">
function setText(obj){
$("#" + id).val("");
var id = obj.id;
$("#" + id).attr("type","text");
if(obj.value && obj.value.replace(/ /g,'') != 'Z'){
$("#" + id).val(obj.value +" Z");
}
}
</script>
</head>
<body >
<div data-role="page">
<div data-role="header" data-theme="a" data-position="fixed">
<a data-rel="back" class="hdrBtns" id="infoBtn">Back</a>
<h1>Employee Details</h1>
</div>
<div data-role="content" id="mainContent">
<div style="background-color: blue;">
<p class="contenthdrlbl"
style="background-color: blue; color: white;
text-align: left; line-height: 2.5; font-weight:
200;">Input
values for Employee</p>
</div>
<div style="height: 30px; background-color: white;" class="last">
<div class="ui-block-a"
style="background-color: #EBF4F8; line-height: 1.9;
text-align: center; width: 40%">
<span>Employee Id</span>
<p id="currency" style="display:inline !important;"></p>
</div>
<div class="ui-block-b ">
<input type="text" id="empid"
class="inputElement" placeholder="MANDATORY"
onfocus="this.value='';this.type='tel';"
onblur="setText(this);"></input>
</div>
</div>
<div style="height: 30px; background-color: white;" class="last">
<p class="ui-block-a"
style="background-color: #EBF4F8; line-height: 1.9;
text-align: center; width: 40%">Salary
</p>
<div class="ui-block-b ">
<input type="text" id="salary"
class="inputElement" placeholder="MANDATORY"
onfocus="this.value='';this.type='number';"
></input>
</div>
</div>
</div>
</div>
<!-- JQuery Mobile Page End Tag-->
</body>
</html>
BÝR DEÐÝL , IKI DEÐIL, MODERATOR, SEN BU AÞKI BANA ZEHÝR
BÝR DEÐÝL , IKI DEÐIL, MODERATOR, SEN BU AÞKI BANA ZEHÝR
You are about to be provided with information to
start your own Google.
Some people posted comments and said this can not
be done because google has 1 million servers and we do not.
The truth is, google has those many servers for trolling
purposes (e.g. google +, google finance, youtube the bandwidth consuming
no-profit making web site, etc ).
all for trolling purposes.
if you wanted to start your own search engine...
you need to know few things.
1: you need to know how beautiful mysql is.
2: you need to not listen to people that tell you to use a framework
with python, and simply use mod-wsgi.
3: you need to cache popular searches when your search engine is running.
4: you need to connect numbers to words. maybe even something like..
numbers to numbers to words.
in other words let's say in the past 24 hours people searched for
some phrases over and over again.. you cache those and assign numbers
to them, this way you are matching numbers with numbers in mysql.
not words with words.
in other words let's say google uses 1/2 their servers for trolling
and 1/2 for search engine.
we need technology and ideas so that you can run a search engine
on 1 or 2 dedicated servers that cost no more than $100/month each.
once you make money, you can begin buying more and more servers.
after you make lots of money.. you probably gonna turn into a troll
too like google inc.
because god is brutal.
god is void-state
it keeps singing you songs when you are sleeping and says
"nothing matters, there is simply no meaning"
but of course to start this search engine, you need a jump start.
if you notice google constantly links to other web sites with a
trackable way when people click on search results.
this means google knows which web sites are becoming popular
are popular, etc. they can see what is rising before it rises.
it's like being able to see the future.
the computer tells them " you better get in touch with this guy
before he becomes rich and becomes un-stopable "
sometimes they send cops onto people. etc.
AMAZON INC however..
will provide you with the top 1 million web sites in the world.
updated daily in a csv file.
downloadable at alexa.com
simply click on 'top sites' and then you will see the downloadable
file on the right side.
everyday they update it. and it is being given away for free.
google would never do this.
amazon does this.
this list you can use to ensure you show the top sites first in your
search engine .
this makes your search engine look 'credible'
in other words as you start making money, you first display things
in a "Generic" way but at the same time not in a "questionable" way
by displaying them based on "rank"
of course amazon only gives you URLS of the web sites.
you need to grab the title and etc from the web sites.
the truth is, to get started you do not need everything from web sites.
a title and some tags is all you need.
simple.
basic.
functional
will get peoples attention.
i always ask questions on SO but most questions get deleted. here's
something that did not get deleted..
How do I ensure that re.findall() stops at the right place?
use python, skrew php, php is no good.
do not use python frameworks, it's all lies and b.s. use mod-wsgi
use memcache to cache the templates and thus no need for a template engine.
always look at russian dedicated servers, and so on.
do not put your trust in america.
it has all turned into a mafia.
google can file a report, fbi can send cops onto you, and next thing you know
they frame you as a criminal, thug, mentally ill, bipolar, peadophile, and
so on.
all you can do is bleed to death behind bars.
do not give into the lies of AMERICA.
find russian dedicated servers.
i tried signing up with pw-service.com but i couldn't do it due to
restrictions with their russian payment systems and so on..
again, amazon's web site alexa.com provides you with downloadable
top 1 mil web sites in the form of a csv file.
use it.
again, do not give into python programmers suggesting frameworks for python.
it's all b.s. use mod_wsgi with memcache.
again, american corporations can ruin you with lies and all you can do is
bleed to death behind bars
again, a basic search engine needs : url, title, tags, and popular searches
can be "cached" and words can be connected to "numbers" within the mysql.
mysql has capabilities to cache things as well.
cache once, cache twice, and you will not need 1 million servers in order
to troll.
if you need some xdotool commands to deal with people calling you a troll
here it is;
xdotool key ctrl+c
a=`xclip -o`
b=`echo "$a" | sed -e 's/^ *//g' -e 's/ *$//g'`
xdotool key Tab Tab Tab Return
xdotool type '@'
xdotool type "$b"
xdotool type --clearmodifiers ', there can not be such thing as a `troll`
unless compared to a stationary point, if you are complaining, you are not
stationary. which means you are the one that is trolling.'
xdotool key Tab Return
create an application launcher on your gnome-panel, and then select the
username in the comments section that called you a 'troll' and click the
shortcut on the gnome-panel.
it will copy the selected username to the clipboard and then hit TAB TAB
TAB RETURN
which opens the comment typing box. and then it will type @ + username +
comma, and then the rest. ..........................................
............ .............. ........... . . . .. . . . . . . .. . . . . .
. . . . . . . .
You are about to be provided with information to
start your own Google.
Some people posted comments and said this can not
be done because google has 1 million servers and we do not.
The truth is, google has those many servers for trolling
purposes (e.g. google +, google finance, youtube the bandwidth consuming
no-profit making web site, etc ).
all for trolling purposes.
if you wanted to start your own search engine...
you need to know few things.
1: you need to know how beautiful mysql is.
2: you need to not listen to people that tell you to use a framework
with python, and simply use mod-wsgi.
3: you need to cache popular searches when your search engine is running.
4: you need to connect numbers to words. maybe even something like..
numbers to numbers to words.
in other words let's say in the past 24 hours people searched for
some phrases over and over again.. you cache those and assign numbers
to them, this way you are matching numbers with numbers in mysql.
not words with words.
in other words let's say google uses 1/2 their servers for trolling
and 1/2 for search engine.
we need technology and ideas so that you can run a search engine
on 1 or 2 dedicated servers that cost no more than $100/month each.
once you make money, you can begin buying more and more servers.
after you make lots of money.. you probably gonna turn into a troll
too like google inc.
because god is brutal.
god is void-state
it keeps singing you songs when you are sleeping and says
"nothing matters, there is simply no meaning"
but of course to start this search engine, you need a jump start.
if you notice google constantly links to other web sites with a
trackable way when people click on search results.
this means google knows which web sites are becoming popular
are popular, etc. they can see what is rising before it rises.
it's like being able to see the future.
the computer tells them " you better get in touch with this guy
before he becomes rich and becomes un-stopable "
sometimes they send cops onto people. etc.
AMAZON INC however..
will provide you with the top 1 million web sites in the world.
updated daily in a csv file.
downloadable at alexa.com
simply click on 'top sites' and then you will see the downloadable
file on the right side.
everyday they update it. and it is being given away for free.
google would never do this.
amazon does this.
this list you can use to ensure you show the top sites first in your
search engine .
this makes your search engine look 'credible'
in other words as you start making money, you first display things
in a "Generic" way but at the same time not in a "questionable" way
by displaying them based on "rank"
of course amazon only gives you URLS of the web sites.
you need to grab the title and etc from the web sites.
the truth is, to get started you do not need everything from web sites.
a title and some tags is all you need.
simple.
basic.
functional
will get peoples attention.
i always ask questions on SO but most questions get deleted. here's
something that did not get deleted..
How do I ensure that re.findall() stops at the right place?
use python, skrew php, php is no good.
do not use python frameworks, it's all lies and b.s. use mod-wsgi
use memcache to cache the templates and thus no need for a template engine.
always look at russian dedicated servers, and so on.
do not put your trust in america.
it has all turned into a mafia.
google can file a report, fbi can send cops onto you, and next thing you know
they frame you as a criminal, thug, mentally ill, bipolar, peadophile, and
so on.
all you can do is bleed to death behind bars.
do not give into the lies of AMERICA.
find russian dedicated servers.
i tried signing up with pw-service.com but i couldn't do it due to
restrictions with their russian payment systems and so on..
again, amazon's web site alexa.com provides you with downloadable
top 1 mil web sites in the form of a csv file.
use it.
again, do not give into python programmers suggesting frameworks for python.
it's all b.s. use mod_wsgi with memcache.
again, american corporations can ruin you with lies and all you can do is
bleed to death behind bars
again, a basic search engine needs : url, title, tags, and popular searches
can be "cached" and words can be connected to "numbers" within the mysql.
mysql has capabilities to cache things as well.
cache once, cache twice, and you will not need 1 million servers in order
to troll.
if you need some xdotool commands to deal with people calling you a troll
here it is;
xdotool key ctrl+c
a=`xclip -o`
b=`echo "$a" | sed -e 's/^ *//g' -e 's/ *$//g'`
xdotool key Tab Tab Tab Return
xdotool type '@'
xdotool type "$b"
xdotool type --clearmodifiers ', there can not be such thing as a `troll`
unless compared to a stationary point, if you are complaining, you are not
stationary. which means you are the one that is trolling.'
xdotool key Tab Return
create an application launcher on your gnome-panel, and then select the
username in the comments section that called you a 'troll' and click the
shortcut on the gnome-panel.
it will copy the selected username to the clipboard and then hit TAB TAB
TAB RETURN
which opens the comment typing box. and then it will type @ + username +
comma, and then the rest. ..........................................
............ .............. ........... . . . .. . . . . . . .. . . . . .
. . . . . . . .
Opposite of client?
Opposite of client?
Is there an antonym of "client"?
The ??? performs services for his clients
Usually one would just say the profession or job title:
The contractor does home improvement for his clients
But is there a term that is as generic as "client"? I thought of
"professional", but that obviously implies they are practicing a
profession, which they might not be.
Is there an antonym of "client"?
The ??? performs services for his clients
Usually one would just say the profession or job title:
The contractor does home improvement for his clients
But is there a term that is as generic as "client"? I thought of
"professional", but that obviously implies they are practicing a
profession, which they might not be.
Modify Macro to put vlookup results in empty column for next month
Modify Macro to put vlookup results in empty column for next month
I am trying to automate a monthly report that I run. Each month, I run a
query (embedded into a separate tab) and then use vlookup to move the
values into the column for the current month.
I want to create a macro to move the values for the current month, but
what I need to figure out, is how to modify the macro to check if a column
for a month has been filled out, and if it is, then to put the monthly
numbers in the column to the right (next month). I have been researching
this for a while, but I have very little VBA experience and get stuck when
I run into errors. I know I can use the "IsEmpty" function, but I'm not
sure of the best way to use it.
Here is a copy of the Macro:
Range("N6").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-10],'ENT - Query
Totals'!C2:C4,3,FALSE)"
Range("N6").Select
ActiveWindow.SmallScroll Down:=-9
Range("N6").Select
Selection.AutoFill Destination:=Range("N6:N82"), Type:=xlFillDefault
Range("N6:N82").Select
ActiveWindow.SmallScroll Down:=-60
Range("N6:N82").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("O64").Select
Cells.Replace What:="#N/A", Replacement:="0", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
So basically, I want to check if "N6" is empty. If it is, the macro would
use vlookup to move the data from the query tab into the column "N". If it
is not empty, I want it to copy the data from the query tab into column
"O", etc.
Any help or guidance will be greatly appreciated while I continue to learn
VBA
I am trying to automate a monthly report that I run. Each month, I run a
query (embedded into a separate tab) and then use vlookup to move the
values into the column for the current month.
I want to create a macro to move the values for the current month, but
what I need to figure out, is how to modify the macro to check if a column
for a month has been filled out, and if it is, then to put the monthly
numbers in the column to the right (next month). I have been researching
this for a while, but I have very little VBA experience and get stuck when
I run into errors. I know I can use the "IsEmpty" function, but I'm not
sure of the best way to use it.
Here is a copy of the Macro:
Range("N6").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-10],'ENT - Query
Totals'!C2:C4,3,FALSE)"
Range("N6").Select
ActiveWindow.SmallScroll Down:=-9
Range("N6").Select
Selection.AutoFill Destination:=Range("N6:N82"), Type:=xlFillDefault
Range("N6:N82").Select
ActiveWindow.SmallScroll Down:=-60
Range("N6:N82").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("O64").Select
Cells.Replace What:="#N/A", Replacement:="0", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
So basically, I want to check if "N6" is empty. If it is, the macro would
use vlookup to move the data from the query tab into the column "N". If it
is not empty, I want it to copy the data from the query tab into column
"O", etc.
Any help or guidance will be greatly appreciated while I continue to learn
VBA
Issue while printing selected range of papers using UIPrintInteractionController
Issue while printing selected range of papers using
UIPrintInteractionController
I need to print documents using UIPrintInteractionController below is code
i have been using
UIPrintInteractionController *printController =
[UIPrintInteractionController sharedPrintController];
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = [filePath lastPathComponent];
printInfo.duplex = UIPrintInfoDuplexLongEdge;
printController.printInfo = printInfo;
printController.showsPageRange = YES;
printController.delegate = self;
NSData *fileData =[NSData dataWithContentsOfURL:localFileURL];
printController.printingItem = fileData;
Printing works fine for PDF file & other documents type but even when i
select page range say Page 1-2 for documents of say 5 pages , it prints
all the 5 pages Printing selected range of pages works fine when i either
set printFormatter & printPageRenderer instead of printingItem
UIPrintPageRenderer *myRenderer = [[UIPrintPageRenderer alloc] init];
// To draw the content of each page, a UIViewPrintFormatter is used.
UIViewPrintFormatter *viewFormatter = [self.documentWebview
viewPrintFormatter];
[myRenderer addPrintFormatter:viewFormatter startingAtPageAtIndex:0];
printController.printPageRenderer = myRenderer;
Here documentWebview is UIWebview where i am loading my local copy of
documents in application document directory But this inserts extra space
for header & footer on each page and causes each page to extend across a
second page of paper Is there any why by which i can remove this headers &
footer space
UIPrintInteractionController
I need to print documents using UIPrintInteractionController below is code
i have been using
UIPrintInteractionController *printController =
[UIPrintInteractionController sharedPrintController];
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = [filePath lastPathComponent];
printInfo.duplex = UIPrintInfoDuplexLongEdge;
printController.printInfo = printInfo;
printController.showsPageRange = YES;
printController.delegate = self;
NSData *fileData =[NSData dataWithContentsOfURL:localFileURL];
printController.printingItem = fileData;
Printing works fine for PDF file & other documents type but even when i
select page range say Page 1-2 for documents of say 5 pages , it prints
all the 5 pages Printing selected range of pages works fine when i either
set printFormatter & printPageRenderer instead of printingItem
UIPrintPageRenderer *myRenderer = [[UIPrintPageRenderer alloc] init];
// To draw the content of each page, a UIViewPrintFormatter is used.
UIViewPrintFormatter *viewFormatter = [self.documentWebview
viewPrintFormatter];
[myRenderer addPrintFormatter:viewFormatter startingAtPageAtIndex:0];
printController.printPageRenderer = myRenderer;
Here documentWebview is UIWebview where i am loading my local copy of
documents in application document directory But this inserts extra space
for header & footer on each page and causes each page to extend across a
second page of paper Is there any why by which i can remove this headers &
footer space
angular spring macro
angular spring macro
Does anyone have a macro for an "angular spring" ? I'm looking for
something similar to that in pst-coil (PS-Tricks package) but the geometry
of the "spring" is not straight but an arch (with eventually, variable
opening).
Does anyone have a macro for an "angular spring" ? I'm looking for
something similar to that in pst-coil (PS-Tricks package) but the geometry
of the "spring" is not straight but an arch (with eventually, variable
opening).
fullcalendar eventsources no longer display events?
fullcalendar eventsources no longer display events?
Just updated my fullcalendar to 1.6.3 and jquery to 1.10.2 Suddenly my
calendar no longer shows events from "eventSources". I cant find anything
in the documentation that states that something has changed. To isolate
the problem I have created a very small test example so that I'm sure that
no 3rd party plugin og CSS or anything is responsible.
<html>
<head>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/fullcalendar.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/fullcalendar.css" />
<script type="text/javascript">
$(document).ready(function()
{
$('#kalender').fullCalendar(
{
eventSources: ['testfeed.php']
//testfeed.php returns exactly: [{title: 'test1', start:
'2013-08-15'},{title: 'test2', start: '2013-08-16'}]
// events: [{title: 'test1', start: '2013-08-15'},{title:
'test2', start: '2013-08-16'}]
});
});
</script>
</head>
<body>
<div id="kalender"></div>
</body>
</html>
This example doesn't work even though my "testfeed.php" returns exactly
the same json code as if I put it directly into the "events" property. If
i comment out the "eventSources" line and uncomment the "events" line,
then everything is fine. But I need to use the eventsources as I did
before the update. What am I missing? This is driving med insane :)
Thanks in advance for all your input!
Kind regards
Just updated my fullcalendar to 1.6.3 and jquery to 1.10.2 Suddenly my
calendar no longer shows events from "eventSources". I cant find anything
in the documentation that states that something has changed. To isolate
the problem I have created a very small test example so that I'm sure that
no 3rd party plugin og CSS or anything is responsible.
<html>
<head>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/fullcalendar.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/fullcalendar.css" />
<script type="text/javascript">
$(document).ready(function()
{
$('#kalender').fullCalendar(
{
eventSources: ['testfeed.php']
//testfeed.php returns exactly: [{title: 'test1', start:
'2013-08-15'},{title: 'test2', start: '2013-08-16'}]
// events: [{title: 'test1', start: '2013-08-15'},{title:
'test2', start: '2013-08-16'}]
});
});
</script>
</head>
<body>
<div id="kalender"></div>
</body>
</html>
This example doesn't work even though my "testfeed.php" returns exactly
the same json code as if I put it directly into the "events" property. If
i comment out the "eventSources" line and uncomment the "events" line,
then everything is fine. But I need to use the eventsources as I did
before the update. What am I missing? This is driving med insane :)
Thanks in advance for all your input!
Kind regards
at com.app.pixitch.Albums$PrevAlb$1.onClick(Albums.java:124)
at com.app.pixitch.Albums$PrevAlb$1.onClick(Albums.java:124)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.albums);
session = new SessionManager(getApplicationContext());
session.checkLogin();
HashMap<String, String> user = session.getUserDetails();
email = user.get(SessionManager.KEY_EMAIL);
name = user.get(SessionManager.KEY_NAME);
memid = user.get(SessionManager.KEY_UID);
new PrevAlb().execute();
lnrLayout = (LinearLayout) findViewById(R.id.albLyt);
// alnrLayot = (LinearLayout) findViewById(R.id.albLyt2);
btnupdate = (Button) findViewById(R.id.ACrAlbum);
btnupdate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
crtAlbums();
}
private void crtAlbums() {
// TODO Auto-generated method stub
}
});
// ares = null;
// adob = null;
}
private class PrevAlb extends AsyncTask<Object, Object, Object> {
String gen = "";
String[] ares;
String[] adob;
ArrayList<String> imgArrayList = new ArrayList<String>();
public ProgressDialog RegDialog = new ProgressDialog(Albums.this);
@Override
protected void onPreExecute() {
RegDialog.setMessage("Please Wait Loading your Albums...");
RegDialog.show();
}
@Override
protected Object doInBackground(Object... arg0) {
String res = methods.GetAlls("memberId", memid, "1",
"tbl_pixitchname", "pixitchname,pixitchtype,Id");
tres = res.trim();
return null;
}
@Override
protected void onPostExecute(Object unused) {
RegDialog.dismiss();
ares = tres.split("-");
if (!ares[0].toString().equals("0")) {
for (int i = 0; i <= ares.length - 1; i++) {
adob = ares[i].toString().split(",");
// txtv = new TextView(Albums.this);
valueTV = new TextView(Albums.this);
valueTV.setText(adob[0].toString() + "["
+ adob[1].toString() + "]");
// valueTV.setId(i);
valueTV.setGravity(Gravity.CENTER);
valueTV.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
valueTV.setTextSize(20);
valueTV.setTextColor(Color.BLUE);
valueTV.setClickable(true);
valueTV.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// imgArrayList = null;
valpixid = adob[2].toString().trim();
new GetAlb().execute();
if (!strimgurls[0].toString().equals("0")) {
for (int j = 0; j <= strimgurls.length - 1;
j++) {
String[] tmpimgurls = strimgurls[j]
.toString().split("_");
String extn = strimgurls[j]
.toString()
.trim()
.substring(
strimgurls[j].toString()
.trim()
.lastIndexOf("."));
String fname = strimgurls[j].toString()
.trim().replace(extn, "_b" + extn);
String temp = methods.albimg.trim()
+ tmpimgurls[1].toString() + "/"
+ tmpimgurls[2].toString() + "/"
+ tmpimgurls[3].toString() + "/"
+ fname.trim();
imgArrayList.add(temp.trim());
}
String[] imgulls = imgArrayList
.toArray(new
String[imgArrayList.size()]);
Intent i = new Intent(Albums.this,
ImageGridActivity.class);
i.putExtra("imgurls", imgulls);
startActivity(i);
}
}
});
lnrLayout.addView(valueTV);
}
}
}
}
public void crtAlbums() {
final EditText edtn = new EditText(Albums.this);
edtn.setText("Enter Album Name", TextView.BufferType.EDITABLE);
final ArrayAdapter<String> adp = new ArrayAdapter<String>(Albums.this,
android.R.layout.simple_spinner_item, s);
final Spinner sp = new Spinner(Albums.this);
sp.setLayoutParams(new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
sp.setAdapter(adp);
final LinearLayout alnrlyt = new LinearLayout(Albums.this);
alnrlyt.setOrientation(1);
alnrlyt.addView(edtn);
alnrlyt.addView(sp);
AlertDialog.Builder builder = new AlertDialog.Builder(Albums.this);
builder.setTitle("Enter Album Name Choose AlbumType ");
builder.setView(alnrlyt);
builder.setPositiveButton("Create", new OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
arg0.dismiss();
pixtype = sp.getSelectedItem().toString();
pixname = edtn.getText().toString();
new CrtAlb().execute();
Intent nextActivity = new Intent(Albums.this, Albums.class);
Albums.this.finish();
startActivity(nextActivity);
}
});
builder.setNegativeButton("Cancel", new OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
}
});
builder.create().show();
}
private class CrtAlb extends AsyncTask<Object, Object, Object> {
public ProgressDialog CrtDialog = new ProgressDialog(Albums.this);
String tres = "";
@Override
protected void onPreExecute() {
CrtDialog.setMessage("Please Wait Creating your Albums...");
CrtDialog.show();
}
@Override
protected Object doInBackground(Object... arg0) {
// goforIt();
pixname = pixname.replace(" ", "");
String als = memid + "," + pixname.trim() + "," + pixtype.trim();
String vals = als + "," + dtDiff;
// pixitchname=pixitchname.
String res = methods.InsAlls(
"memberid,pixitchname,pixitchtype,createdon", vals, "0",
"tbl_pixitchname", "memberid,pixitchname,pixitchtype", als);
tres = res.trim();
return null;
}
@Override
protected void onPostExecute(Object unused) {
CrtDialog.dismiss();
if (tres.toString().charAt(0) != '0') {
Toast.makeText(Albums.this, "Done Album Created...",
Toast.LENGTH_LONG).show();
} else if (tres.toString().charAt(0) == '0') {
Toast.makeText(Albums.this, "Album Already Exist.",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(Albums.this,
"Got Some Error While Creating, Check Network.",
Toast.LENGTH_LONG).show();
}
}
}
private class GetAlb extends AsyncTask<Object, Object, Object> {
// public ProgressDialog CrtDialog = new ProgressDialog(Albums.this);
String tres = "";
String pnameid = valpixid;
@Override
protected void onPreExecute() {
// CrtDialog.setMessage("Please Wait Creating your Albums...");
// CrtDialog.show();
}
@Override
protected Object doInBackground(Object... arg0) {
// goforIt();
strimgurls = methods.GetAlls("pixitchnameid", pnameid.trim(), "0",
"uploadphotos", "photo_b").split("-");
return null;
}
@Override
protected void onPostExecute(Object unused) {
// CrtDialog.dismiss();
}
}
}
and Error Logcat is
08-26 15:39:48.672: W/dalvikvm(23423): threadid=1: thread exiting with
uncaught exception (group=0x409e61f8) 08-26 15:39:48.672:
E/AndroidRuntime(23423): FATAL EXCEPTION: main 08-26 15:39:48.672:
E/AndroidRuntime(23423): java.lang.NullPointerException 08-26
15:39:48.672: E/AndroidRuntime(23423): at
com.app.pixitch.Albums$PrevAlb$1.onClick(Albums.java:124) 08-26
15:39:48.672: E/AndroidRuntime(23423): at
android.view.View.performClick(View.java:3511) 08-26 15:39:48.672:
E/AndroidRuntime(23423): at
android.view.View$PerformClick.run(View.java:14109) 08-26 15:39:48.672:
E/AndroidRuntime(23423): at
android.os.Handler.handleCallback(Handler.java:605) 08-26 15:39:48.672:
E/AndroidRuntime(23423): at
android.os.Handler.dispatchMessage(Handler.java:92) 08-26 15:39:48.672:
E/AndroidRuntime(23423): at android.os.Looper.loop(Looper.java:137) 08-26
15:39:48.672: E/AndroidRuntime(23423): at
android.app.ActivityThread.main(ActivityThread.java:4424) 08-26
15:39:48.672: E/AndroidRuntime(23423): at
java.lang.reflect.Method.invokeNative(Native Method) 08-26 15:39:48.672:
E/AndroidRuntime(23423): at
java.lang.reflect.Method.invoke(Method.java:511) 08-26 15:39:48.672:
E/AndroidRuntime(23423): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-26 15:39:48.672: E/AndroidRuntime(23423): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 08-26
15:39:48.672: E/AndroidRuntime(23423): at
dalvik.system.NativeStart.main(Native Method)
and line 124 in albums.java is : if (!strimgurls[0].toString().equals("0"))
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.albums);
session = new SessionManager(getApplicationContext());
session.checkLogin();
HashMap<String, String> user = session.getUserDetails();
email = user.get(SessionManager.KEY_EMAIL);
name = user.get(SessionManager.KEY_NAME);
memid = user.get(SessionManager.KEY_UID);
new PrevAlb().execute();
lnrLayout = (LinearLayout) findViewById(R.id.albLyt);
// alnrLayot = (LinearLayout) findViewById(R.id.albLyt2);
btnupdate = (Button) findViewById(R.id.ACrAlbum);
btnupdate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
crtAlbums();
}
private void crtAlbums() {
// TODO Auto-generated method stub
}
});
// ares = null;
// adob = null;
}
private class PrevAlb extends AsyncTask<Object, Object, Object> {
String gen = "";
String[] ares;
String[] adob;
ArrayList<String> imgArrayList = new ArrayList<String>();
public ProgressDialog RegDialog = new ProgressDialog(Albums.this);
@Override
protected void onPreExecute() {
RegDialog.setMessage("Please Wait Loading your Albums...");
RegDialog.show();
}
@Override
protected Object doInBackground(Object... arg0) {
String res = methods.GetAlls("memberId", memid, "1",
"tbl_pixitchname", "pixitchname,pixitchtype,Id");
tres = res.trim();
return null;
}
@Override
protected void onPostExecute(Object unused) {
RegDialog.dismiss();
ares = tres.split("-");
if (!ares[0].toString().equals("0")) {
for (int i = 0; i <= ares.length - 1; i++) {
adob = ares[i].toString().split(",");
// txtv = new TextView(Albums.this);
valueTV = new TextView(Albums.this);
valueTV.setText(adob[0].toString() + "["
+ adob[1].toString() + "]");
// valueTV.setId(i);
valueTV.setGravity(Gravity.CENTER);
valueTV.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
valueTV.setTextSize(20);
valueTV.setTextColor(Color.BLUE);
valueTV.setClickable(true);
valueTV.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// imgArrayList = null;
valpixid = adob[2].toString().trim();
new GetAlb().execute();
if (!strimgurls[0].toString().equals("0")) {
for (int j = 0; j <= strimgurls.length - 1;
j++) {
String[] tmpimgurls = strimgurls[j]
.toString().split("_");
String extn = strimgurls[j]
.toString()
.trim()
.substring(
strimgurls[j].toString()
.trim()
.lastIndexOf("."));
String fname = strimgurls[j].toString()
.trim().replace(extn, "_b" + extn);
String temp = methods.albimg.trim()
+ tmpimgurls[1].toString() + "/"
+ tmpimgurls[2].toString() + "/"
+ tmpimgurls[3].toString() + "/"
+ fname.trim();
imgArrayList.add(temp.trim());
}
String[] imgulls = imgArrayList
.toArray(new
String[imgArrayList.size()]);
Intent i = new Intent(Albums.this,
ImageGridActivity.class);
i.putExtra("imgurls", imgulls);
startActivity(i);
}
}
});
lnrLayout.addView(valueTV);
}
}
}
}
public void crtAlbums() {
final EditText edtn = new EditText(Albums.this);
edtn.setText("Enter Album Name", TextView.BufferType.EDITABLE);
final ArrayAdapter<String> adp = new ArrayAdapter<String>(Albums.this,
android.R.layout.simple_spinner_item, s);
final Spinner sp = new Spinner(Albums.this);
sp.setLayoutParams(new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
sp.setAdapter(adp);
final LinearLayout alnrlyt = new LinearLayout(Albums.this);
alnrlyt.setOrientation(1);
alnrlyt.addView(edtn);
alnrlyt.addView(sp);
AlertDialog.Builder builder = new AlertDialog.Builder(Albums.this);
builder.setTitle("Enter Album Name Choose AlbumType ");
builder.setView(alnrlyt);
builder.setPositiveButton("Create", new OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
arg0.dismiss();
pixtype = sp.getSelectedItem().toString();
pixname = edtn.getText().toString();
new CrtAlb().execute();
Intent nextActivity = new Intent(Albums.this, Albums.class);
Albums.this.finish();
startActivity(nextActivity);
}
});
builder.setNegativeButton("Cancel", new OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
}
});
builder.create().show();
}
private class CrtAlb extends AsyncTask<Object, Object, Object> {
public ProgressDialog CrtDialog = new ProgressDialog(Albums.this);
String tres = "";
@Override
protected void onPreExecute() {
CrtDialog.setMessage("Please Wait Creating your Albums...");
CrtDialog.show();
}
@Override
protected Object doInBackground(Object... arg0) {
// goforIt();
pixname = pixname.replace(" ", "");
String als = memid + "," + pixname.trim() + "," + pixtype.trim();
String vals = als + "," + dtDiff;
// pixitchname=pixitchname.
String res = methods.InsAlls(
"memberid,pixitchname,pixitchtype,createdon", vals, "0",
"tbl_pixitchname", "memberid,pixitchname,pixitchtype", als);
tres = res.trim();
return null;
}
@Override
protected void onPostExecute(Object unused) {
CrtDialog.dismiss();
if (tres.toString().charAt(0) != '0') {
Toast.makeText(Albums.this, "Done Album Created...",
Toast.LENGTH_LONG).show();
} else if (tres.toString().charAt(0) == '0') {
Toast.makeText(Albums.this, "Album Already Exist.",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(Albums.this,
"Got Some Error While Creating, Check Network.",
Toast.LENGTH_LONG).show();
}
}
}
private class GetAlb extends AsyncTask<Object, Object, Object> {
// public ProgressDialog CrtDialog = new ProgressDialog(Albums.this);
String tres = "";
String pnameid = valpixid;
@Override
protected void onPreExecute() {
// CrtDialog.setMessage("Please Wait Creating your Albums...");
// CrtDialog.show();
}
@Override
protected Object doInBackground(Object... arg0) {
// goforIt();
strimgurls = methods.GetAlls("pixitchnameid", pnameid.trim(), "0",
"uploadphotos", "photo_b").split("-");
return null;
}
@Override
protected void onPostExecute(Object unused) {
// CrtDialog.dismiss();
}
}
}
and Error Logcat is
08-26 15:39:48.672: W/dalvikvm(23423): threadid=1: thread exiting with
uncaught exception (group=0x409e61f8) 08-26 15:39:48.672:
E/AndroidRuntime(23423): FATAL EXCEPTION: main 08-26 15:39:48.672:
E/AndroidRuntime(23423): java.lang.NullPointerException 08-26
15:39:48.672: E/AndroidRuntime(23423): at
com.app.pixitch.Albums$PrevAlb$1.onClick(Albums.java:124) 08-26
15:39:48.672: E/AndroidRuntime(23423): at
android.view.View.performClick(View.java:3511) 08-26 15:39:48.672:
E/AndroidRuntime(23423): at
android.view.View$PerformClick.run(View.java:14109) 08-26 15:39:48.672:
E/AndroidRuntime(23423): at
android.os.Handler.handleCallback(Handler.java:605) 08-26 15:39:48.672:
E/AndroidRuntime(23423): at
android.os.Handler.dispatchMessage(Handler.java:92) 08-26 15:39:48.672:
E/AndroidRuntime(23423): at android.os.Looper.loop(Looper.java:137) 08-26
15:39:48.672: E/AndroidRuntime(23423): at
android.app.ActivityThread.main(ActivityThread.java:4424) 08-26
15:39:48.672: E/AndroidRuntime(23423): at
java.lang.reflect.Method.invokeNative(Native Method) 08-26 15:39:48.672:
E/AndroidRuntime(23423): at
java.lang.reflect.Method.invoke(Method.java:511) 08-26 15:39:48.672:
E/AndroidRuntime(23423): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-26 15:39:48.672: E/AndroidRuntime(23423): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 08-26
15:39:48.672: E/AndroidRuntime(23423): at
dalvik.system.NativeStart.main(Native Method)
and line 124 in albums.java is : if (!strimgurls[0].toString().equals("0"))
Canon LBP 2900 printer for Ubuntu 13.04?
Canon LBP 2900 printer for Ubuntu 13.04?
I had to recreate my computer and have installed Ubuntu 13.04 as my main
OS. As a printer I would like to install a Canon iSensys LBP 2900 printer.
The printer-setup recognizes the device, but it won'T allow me to install
the proper driver for this device - simply because there seems to be none
available. Is that true?
I checked the various similar topics about this issue, but they are either
outdated and the data-packages (drivers) are not available anymore or
about older/ earlier Ubuntu versions.
Thank you for any advice or help or support.
Best wishes! Liam
I had to recreate my computer and have installed Ubuntu 13.04 as my main
OS. As a printer I would like to install a Canon iSensys LBP 2900 printer.
The printer-setup recognizes the device, but it won'T allow me to install
the proper driver for this device - simply because there seems to be none
available. Is that true?
I checked the various similar topics about this issue, but they are either
outdated and the data-packages (drivers) are not available anymore or
about older/ earlier Ubuntu versions.
Thank you for any advice or help or support.
Best wishes! Liam
Sunday, 25 August 2013
Conversion failed when converting date and/or time from character string SQL Server
Conversion failed when converting date and/or time from character string
SQL Server
I am Surprised, While i copy and paste 'Mon, 26 Aug 2013 5:32:44 GMT' in
database table field of type DateTime in Editable mode it update that cell
but while i am Executing query Like
declare @Manoj date
Set @Manoj = 'Mon, 26 Aug 2013 5:32:44 GMT'
update NK_News set PubDate =@Manoj where ID= 70
here PubDate is DateTime field
It generate error as Conversion failed when converting date and/or time
from character string
Is there any way to find what exactly Query run at Editable Mode in SQL
Server Management Studio.
SQL Server
I am Surprised, While i copy and paste 'Mon, 26 Aug 2013 5:32:44 GMT' in
database table field of type DateTime in Editable mode it update that cell
but while i am Executing query Like
declare @Manoj date
Set @Manoj = 'Mon, 26 Aug 2013 5:32:44 GMT'
update NK_News set PubDate =@Manoj where ID= 70
here PubDate is DateTime field
It generate error as Conversion failed when converting date and/or time
from character string
Is there any way to find what exactly Query run at Editable Mode in SQL
Server Management Studio.
ARP WORKS ONLY IN ONE WAY
ARP WORKS ONLY IN ONE WAY
everyone. I have encountered a problem and I am looking for your help.
I have been trying to run a Red Hat 6.3 in qemu and make its network work.
This time I want to use the VT-d mechanism.
I have two NIC in my computer, eth2 and eth3. I build the virtual function
from the physical function and give the vf to qemu. The specific info is
as follows:
The pf:
8: eth3: mtu 1500 qdisc noop state DOWN qlen 1000 link/ether
00:90:fa:10:35:0e brd ff:ff:ff:ff:ff:ff vf 0 MAC 00:90:fa:29:4c:13, tx
rate 90 (Mbps)
9: eth2: mtu 1500 qdisc mq state UP qlen 1000 link/ether 00:90:fa:10:35:10
brd ff:ff:ff:ff:ff:ff vf 0 MAC 00:90:fa:ae:82:04, tx rate 90 (Mbps)
The vf:
3: eth4: mtu 1500 qdisc noop state DOWN qlen 1000 link/ether
00:90:fa:29:4c:13 brd ff:ff:ff:ff:ff:ff
4: eth3: mtu 1500 qdisc mq state UP qlen 1000 link/ether 00:90:fa:ae:82:04
brd ff:ff:ff:ff:ff:ff
As you can see, vf eth3 in qemu corresponds to pf eth2 in my computer, and
vf eth4 in qemu corresponds to pf eth3 in my computer.
I have tried to plug in and plug out the network cable to test whether the
vf will detect the change. The thing is, the vf works well. Every time I
plug out the network cable, ethtool eth3/4(3 or 4 depends on which cable I
plug out) tells me that "Link detected: no". And every time I plug the
cable back, and rerun ethtool, I get "Link detected: yes".
Then I began to configure the network. I choose the pf eth2 and its
corresponding vf eth3. I use "ifconfig eht2 192.168.1.1/24 up" to config
pf and "ifconfig eth3 192.168.1.3/24 up" to config the vf. Then I ping and
find that it does not work!
I have checked that the iptables have not banned my network.
Here is something I find that may be the root cause. After I ping from vf
to pf, I check the arp tables and find this:
arp tables in virtual machine:
? (192.168.1.1) at on eth3
arp tables in my computer:
? (192.168.1.3) at 00:90:fa:ae:82:04 [ether] on eth2
According to my opinion, arp works in this way: it first send a broadcast
to ask what is the corresponding MAC address of the IP address. The node
that has the specific IP address will send a package back. Thus they both
know each other's MAC address. From the arp tables above, it seems that
the broadcast works well thus the arp table in my computer find the MAC of
the vf. However, the "sending a package back" thing does not work. Thus
the arp table in virtual machine does not know the MAC of the pf.
Do anybody know the reason?
Orz.
everyone. I have encountered a problem and I am looking for your help.
I have been trying to run a Red Hat 6.3 in qemu and make its network work.
This time I want to use the VT-d mechanism.
I have two NIC in my computer, eth2 and eth3. I build the virtual function
from the physical function and give the vf to qemu. The specific info is
as follows:
The pf:
8: eth3: mtu 1500 qdisc noop state DOWN qlen 1000 link/ether
00:90:fa:10:35:0e brd ff:ff:ff:ff:ff:ff vf 0 MAC 00:90:fa:29:4c:13, tx
rate 90 (Mbps)
9: eth2: mtu 1500 qdisc mq state UP qlen 1000 link/ether 00:90:fa:10:35:10
brd ff:ff:ff:ff:ff:ff vf 0 MAC 00:90:fa:ae:82:04, tx rate 90 (Mbps)
The vf:
3: eth4: mtu 1500 qdisc noop state DOWN qlen 1000 link/ether
00:90:fa:29:4c:13 brd ff:ff:ff:ff:ff:ff
4: eth3: mtu 1500 qdisc mq state UP qlen 1000 link/ether 00:90:fa:ae:82:04
brd ff:ff:ff:ff:ff:ff
As you can see, vf eth3 in qemu corresponds to pf eth2 in my computer, and
vf eth4 in qemu corresponds to pf eth3 in my computer.
I have tried to plug in and plug out the network cable to test whether the
vf will detect the change. The thing is, the vf works well. Every time I
plug out the network cable, ethtool eth3/4(3 or 4 depends on which cable I
plug out) tells me that "Link detected: no". And every time I plug the
cable back, and rerun ethtool, I get "Link detected: yes".
Then I began to configure the network. I choose the pf eth2 and its
corresponding vf eth3. I use "ifconfig eht2 192.168.1.1/24 up" to config
pf and "ifconfig eth3 192.168.1.3/24 up" to config the vf. Then I ping and
find that it does not work!
I have checked that the iptables have not banned my network.
Here is something I find that may be the root cause. After I ping from vf
to pf, I check the arp tables and find this:
arp tables in virtual machine:
? (192.168.1.1) at on eth3
arp tables in my computer:
? (192.168.1.3) at 00:90:fa:ae:82:04 [ether] on eth2
According to my opinion, arp works in this way: it first send a broadcast
to ask what is the corresponding MAC address of the IP address. The node
that has the specific IP address will send a package back. Thus they both
know each other's MAC address. From the arp tables above, it seems that
the broadcast works well thus the arp table in my computer find the MAC of
the vf. However, the "sending a package back" thing does not work. Thus
the arp table in virtual machine does not know the MAC of the pf.
Do anybody know the reason?
Orz.
On load page CSS image transform scale smoothly
On load page CSS image transform scale smoothly
this is my link http://hashtaginc.us/Projects/Relax/index_plus.html when i
click on and icon it get bigger then other for promting on which page
you're. I need it to transform scale smoothly (icon become bigger
smoothly)
this is my link http://hashtaginc.us/Projects/Relax/index_plus.html when i
click on and icon it get bigger then other for promting on which page
you're. I need it to transform scale smoothly (icon become bigger
smoothly)
Cannot run remote ssh command
Cannot run remote ssh command
Consider the following command:
ssh -o UserKnownHostsFile=Files/known_hosts -i Files/id_rsa 172.16.0.2 foo
This works perfectly on my development box; it does exactly what I want.
However, on the production server where this actually needs to run, it
fails miserably. SSH insists that the host key cannot be verified with
this error message:
Host key verification failed
I spent literally 3 hours straight trying to force this error message to
go away so I can get on with my job; I am now extremely frustrated, to say
the least.
Two machines, same command, same files, same permissions and owner,
different outcomes. What is causing this?
Consider the following command:
ssh -o UserKnownHostsFile=Files/known_hosts -i Files/id_rsa 172.16.0.2 foo
This works perfectly on my development box; it does exactly what I want.
However, on the production server where this actually needs to run, it
fails miserably. SSH insists that the host key cannot be verified with
this error message:
Host key verification failed
I spent literally 3 hours straight trying to force this error message to
go away so I can get on with my job; I am now extremely frustrated, to say
the least.
Two machines, same command, same files, same permissions and owner,
different outcomes. What is causing this?
Get a variable from an abstract class
Get a variable from an abstract class
Basicly i want to get the name of the map that is played from the
"World.class", in a string on my main mod class...
public abstract class World implements IBlockAccess{
protected WorldInfo worldInfo;
//=====OtherStuff=====
public World(ISaveHandler par1ISaveHandler, String par2Str,
WorldSettings par3WorldSettings, WorldProvider par4WorldProvider,
Profiler par5Profiler, ILogAgent par6ILogAgent)
{
this.worldInfo.setWorldName(par2Str);
}
//=====OtherStuff=====
}
i created a class in the same package with this one
public class World_Spy extends World{
public World_Spy(ISaveHandler par1iSaveHandler, String par2Str,
WorldProvider par3WorldProvider, WorldSettings par4WorldSettings,
Profiler par5Profiler, ILogAgent par6iLogAgent) {
super(par1iSaveHandler, par2Str, par3WorldProvider,
par4WorldSettings,
par5Profiler, par6iLogAgent);
}
@Override
protected IChunkProvider createChunkProvider() {
return null;
}
@Override
public Entity getEntityByID(int i) {
return null;
}
String TheName = "";
public void gotIt(){
TheName = this.worldInfo.getWorldName();
System.out.println(TheName);
}
}
and i call it from my main class with:
World_Spy WName = new World_Spy(null, null, null, null, null, null);
but it chrashes on startup... any ideas?
Basicly i want to get the name of the map that is played from the
"World.class", in a string on my main mod class...
public abstract class World implements IBlockAccess{
protected WorldInfo worldInfo;
//=====OtherStuff=====
public World(ISaveHandler par1ISaveHandler, String par2Str,
WorldSettings par3WorldSettings, WorldProvider par4WorldProvider,
Profiler par5Profiler, ILogAgent par6ILogAgent)
{
this.worldInfo.setWorldName(par2Str);
}
//=====OtherStuff=====
}
i created a class in the same package with this one
public class World_Spy extends World{
public World_Spy(ISaveHandler par1iSaveHandler, String par2Str,
WorldProvider par3WorldProvider, WorldSettings par4WorldSettings,
Profiler par5Profiler, ILogAgent par6iLogAgent) {
super(par1iSaveHandler, par2Str, par3WorldProvider,
par4WorldSettings,
par5Profiler, par6iLogAgent);
}
@Override
protected IChunkProvider createChunkProvider() {
return null;
}
@Override
public Entity getEntityByID(int i) {
return null;
}
String TheName = "";
public void gotIt(){
TheName = this.worldInfo.getWorldName();
System.out.println(TheName);
}
}
and i call it from my main class with:
World_Spy WName = new World_Spy(null, null, null, null, null, null);
but it chrashes on startup... any ideas?
Saturday, 24 August 2013
Parse any currency to decimal
Parse any currency to decimal
I'm trying to parse any currency like Dollar, Euro and Yen to double for
instance, and the US dollar is being parsed correctly, but the Yen and
Euro are not being parsed using this code.
double _amount;
bool _isParsed= double.TryParse("(¥123,45)", NumberStyles.Any, null, out
_amount);
The US Dollar works and is parsed into -12345.0:
double _amount;
bool _isParsed= double.TryParse("($123,45)", NumberStyles.Any, null, out
_amount);
I'm trying not to set the specific culture, because I will be parsing many
different currencies into a decimal.
I'm trying to find whether a string is actually a number (including
dollars, yens, euros, etc.)
How do I write a code that can parse any numbers including currencies in
yen, euro and what have you into a decimal?
I'm trying to parse any currency like Dollar, Euro and Yen to double for
instance, and the US dollar is being parsed correctly, but the Yen and
Euro are not being parsed using this code.
double _amount;
bool _isParsed= double.TryParse("(¥123,45)", NumberStyles.Any, null, out
_amount);
The US Dollar works and is parsed into -12345.0:
double _amount;
bool _isParsed= double.TryParse("($123,45)", NumberStyles.Any, null, out
_amount);
I'm trying not to set the specific culture, because I will be parsing many
different currencies into a decimal.
I'm trying to find whether a string is actually a number (including
dollars, yens, euros, etc.)
How do I write a code that can parse any numbers including currencies in
yen, euro and what have you into a decimal?
Submit method not recognizing AddWithValue
Submit method not recognizing AddWithValue
I'm trying to get my submit button to insert data entered into a couple
text boxes and a hidden field. Right now, it gives me an error saying that
the name "txtComments", "txtName", and "datePosted" do not exist in the
current context. I'm relatively certain that I have to create the
variable, but how would I make sure they are equal to what's in the
respective ASP controls? Here's my code:
protected void submitButton_Click(object sender, EventArgs e)
{
string constr = @"Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=~\App_Data\TravelJoansDB.accdb";
string cmdstr = "INSERT INTO Comments VALUES (@txtComments,
@datePosted, @personName)";
OleDbConnection con = new OleDbConnection(constr);
OleDbCommand com = new OleDbCommand(cmdstr, con);
con.Open();
com.Parameters.AddWithValue("@txtComments", txtComments.TextBox);
com.Parameters.AddWithValue("@datePosted", datePosted.DateTime);
com.Parameters.AddWithValue("@personName", txtName.TextBox);
com.ExecuteNonQuery();
con.Close();
}
So how do I make sure the variables are set to the asp controls? Which are
here:
<InsertItemTemplate>
Name: <asp:TextBox ID="txtName" runat="server" Text='<%#
Bind("personName") %>'></asp:TextBox><br />
Comments:<br />
<asp:TextBox ID="txtComments" runat="server" Text='<%#
Bind("commentText") %>'
TextMode="MultiLine" Rows="4"
Columns="50"></asp:TextBox><br />
<asp:HiddenField ID="hidTimeDate" runat="server" Value='<%#
Bind("datePosted") %>' />
<asp:Button ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Submit"
OnClick="submitButton_Click" />
</InsertItemTemplate>
I'm trying to get my submit button to insert data entered into a couple
text boxes and a hidden field. Right now, it gives me an error saying that
the name "txtComments", "txtName", and "datePosted" do not exist in the
current context. I'm relatively certain that I have to create the
variable, but how would I make sure they are equal to what's in the
respective ASP controls? Here's my code:
protected void submitButton_Click(object sender, EventArgs e)
{
string constr = @"Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=~\App_Data\TravelJoansDB.accdb";
string cmdstr = "INSERT INTO Comments VALUES (@txtComments,
@datePosted, @personName)";
OleDbConnection con = new OleDbConnection(constr);
OleDbCommand com = new OleDbCommand(cmdstr, con);
con.Open();
com.Parameters.AddWithValue("@txtComments", txtComments.TextBox);
com.Parameters.AddWithValue("@datePosted", datePosted.DateTime);
com.Parameters.AddWithValue("@personName", txtName.TextBox);
com.ExecuteNonQuery();
con.Close();
}
So how do I make sure the variables are set to the asp controls? Which are
here:
<InsertItemTemplate>
Name: <asp:TextBox ID="txtName" runat="server" Text='<%#
Bind("personName") %>'></asp:TextBox><br />
Comments:<br />
<asp:TextBox ID="txtComments" runat="server" Text='<%#
Bind("commentText") %>'
TextMode="MultiLine" Rows="4"
Columns="50"></asp:TextBox><br />
<asp:HiddenField ID="hidTimeDate" runat="server" Value='<%#
Bind("datePosted") %>' />
<asp:Button ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Submit"
OnClick="submitButton_Click" />
</InsertItemTemplate>
Is there a way to see what tables and/or rows were affected in an UPDATE in MS SQL Server 2005?
Is there a way to see what tables and/or rows were affected in an UPDATE
in MS SQL Server 2005?
I have a sample UPDATE that should only be updating one row on one table:
update o
set o.actStatus = 'completed',
o.completed = 1,
o.completedDate = dbo.datetongdate(getdate()),
o.completedTime = ltrim(right(CONVERT(varchar, getdate(), 100),7))
from order_ o
where o.encounterID = '20724584-8C98-4599-B742-5EACC48792E7'
and o.actCode = (select top 1 test_code_id from lab_order_tests where
order_num = '160C14E2-D0DB-4275-A6D1-B0C2E726C85A')
But when I execute it in SQL Server Management Studio the message box
indicates that many rows have been affected:
(1 row(s) affected)
(15 row(s) affected)
(0 row(s) affected)
(0 row(s) affected)
(23 row(s) affected)
(21 row(s) affected)
(96 row(s) affected)
(5 row(s) affected)
(1 row(s) affected)
(15 row(s) affected)
(0 row(s) affected)
(0 row(s) affected)
(1 row(s) affected)
(14 row(s) affected)
(0 row(s) affected)
(0 row(s) affected)
(0 row(s) affected)
(0 row(s) affected)
(0 row(s) affected)
(1 row(s) affected)
(0 row(s) affected)
(0 row(s) affected)
(0 row(s) affected)
(15 row(s) affected)
(1 row(s) affected)
(15 row(s) affected)
(0 row(s) affected)
(15 row(s) affected)
(0 row(s) affected)
(5 row(s) affected)
(15 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
There are multiple triggers on that table, one of which I've built, but
four I didn't - and they would take a while to analyze. So is there are
way I can execute the statement and have it return what tables (maybe even
rows) were affected?
EDIT: I should add that I ruled out profiler because our DB server sees a
lot of traffic. It could still be an option, but I think it would be
difficult to identify what SQL originated from this update.
in MS SQL Server 2005?
I have a sample UPDATE that should only be updating one row on one table:
update o
set o.actStatus = 'completed',
o.completed = 1,
o.completedDate = dbo.datetongdate(getdate()),
o.completedTime = ltrim(right(CONVERT(varchar, getdate(), 100),7))
from order_ o
where o.encounterID = '20724584-8C98-4599-B742-5EACC48792E7'
and o.actCode = (select top 1 test_code_id from lab_order_tests where
order_num = '160C14E2-D0DB-4275-A6D1-B0C2E726C85A')
But when I execute it in SQL Server Management Studio the message box
indicates that many rows have been affected:
(1 row(s) affected)
(15 row(s) affected)
(0 row(s) affected)
(0 row(s) affected)
(23 row(s) affected)
(21 row(s) affected)
(96 row(s) affected)
(5 row(s) affected)
(1 row(s) affected)
(15 row(s) affected)
(0 row(s) affected)
(0 row(s) affected)
(1 row(s) affected)
(14 row(s) affected)
(0 row(s) affected)
(0 row(s) affected)
(0 row(s) affected)
(0 row(s) affected)
(0 row(s) affected)
(1 row(s) affected)
(0 row(s) affected)
(0 row(s) affected)
(0 row(s) affected)
(15 row(s) affected)
(1 row(s) affected)
(15 row(s) affected)
(0 row(s) affected)
(15 row(s) affected)
(0 row(s) affected)
(5 row(s) affected)
(15 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
There are multiple triggers on that table, one of which I've built, but
four I didn't - and they would take a while to analyze. So is there are
way I can execute the statement and have it return what tables (maybe even
rows) were affected?
EDIT: I should add that I ruled out profiler because our DB server sees a
lot of traffic. It could still be an option, but I think it would be
difficult to identify what SQL originated from this update.
VIsual C++ LoadLibrary Error 1114
VIsual C++ LoadLibrary Error 1114
I'm trying to load a DLL compiled in Visual Studio 2005 C + + with \ clr
in Visual Studio 2003 C + + with LoadLibrary and gives me the error 1114,
what I understand is blocking when trying to load the DLL.
Note: the same compiled DLL in Visual Stuio the 2010 C + + and Visual
Studio 2003 by C + + and it works perfect.
I'm trying to load a DLL compiled in Visual Studio 2005 C + + with \ clr
in Visual Studio 2003 C + + with LoadLibrary and gives me the error 1114,
what I understand is blocking when trying to load the DLL.
Note: the same compiled DLL in Visual Stuio the 2010 C + + and Visual
Studio 2003 by C + + and it works perfect.
MYSQL Query - grabbing all the records that meet the criteria 3 or more times
MYSQL Query - grabbing all the records that meet the criteria 3 or more times
Not sure how to do this but I am trying to grab all the parcels from a
MYSQL DB that have had multiple years of delinquencies. Right now I can
count how many delinquencies I have for the years given using the
following query:
SELECT parcel, COUNT(), due FROM deliquent_property WHERE year IN ('2013',
'2012', '2011', '2010', '2009') AND
CAST(replace(replace(ifnull(due,0),',',''),'$','') AS decimal(10,2)) > 0
GROUP BY parcel HAVING COUNT() > 2;
So I get something like this
'XXX-XXX-XXX1' '3' '167.00'
'XXX-XXX-XXX2' '4' '190'
Where the amount is the last record for that parcel in the DB. The problem
is what I really want is a list of parcels with each years overdue amount
shown, something like this (skipping those that do not have a least 3
delinquencies):
'XXX-XXX-XXX1' '2013' '1267.78'
'XXX-XXX-XXX1' '2012' '1000.38'
'XXX-XXX-XXX1' '2011' '167.00'
'XXX-XXX-XXX2' '2013' '1000.00'
'XXX-XXX-XXX2' '2012' '500.00'
'XXX-XXX-XXX2' '2011' '100.00'
'XXX-XXX-XXX2' '2010' '190.00'
I am half way there but I am lost on getting this last part.
Thanks
Not sure how to do this but I am trying to grab all the parcels from a
MYSQL DB that have had multiple years of delinquencies. Right now I can
count how many delinquencies I have for the years given using the
following query:
SELECT parcel, COUNT(), due FROM deliquent_property WHERE year IN ('2013',
'2012', '2011', '2010', '2009') AND
CAST(replace(replace(ifnull(due,0),',',''),'$','') AS decimal(10,2)) > 0
GROUP BY parcel HAVING COUNT() > 2;
So I get something like this
'XXX-XXX-XXX1' '3' '167.00'
'XXX-XXX-XXX2' '4' '190'
Where the amount is the last record for that parcel in the DB. The problem
is what I really want is a list of parcels with each years overdue amount
shown, something like this (skipping those that do not have a least 3
delinquencies):
'XXX-XXX-XXX1' '2013' '1267.78'
'XXX-XXX-XXX1' '2012' '1000.38'
'XXX-XXX-XXX1' '2011' '167.00'
'XXX-XXX-XXX2' '2013' '1000.00'
'XXX-XXX-XXX2' '2012' '500.00'
'XXX-XXX-XXX2' '2011' '100.00'
'XXX-XXX-XXX2' '2010' '190.00'
I am half way there but I am lost on getting this last part.
Thanks
Is there a vay to make this code faster? Drawing a point on chart is slow
Is there a vay to make this code faster? Drawing a point on chart is slow
is there any way to make this work faster?
Here is my sample code in vb.net. This adds a point on a chart at mouse
position but it is quite slow.
Private Sub Chart2_MouseMove(sender As Object, e As MouseEventArgs)
Handles Chart2.MouseMove
Dim coord() As Double = GetAxisValuesFromMouse(e.X, e.Y)
Dim test As Series
Try
Chart2.Series.RemoveAt(1)
Catch ex As Exception
End Try
Dim pt As New DataPoint
pt.XValue = coord(0)
pt.YValues(0) = coord(1)
test = New Series
Chart2.Series.Add(test)
Chart2.Series(test.Name).ChartType = SeriesChartType.Point
Chart2.Series(test.Name).Points.Add(pt)
End Sub
Function returns the coordinates of x and y axis at mouse position.
Private Function GetAxisValuesFromMouse(x As Integer, y As Integer) As
Double()
Dim coord(1) As Double
Dim chartArea = Chart2.ChartAreas(0)
coord(0) = chartArea.AxisX.PixelPositionToValue(x)
coord(1) = chartArea.AxisY.PixelPositionToValue(y)
Return coord
End Function
Result:
is there any way to make this work faster?
Here is my sample code in vb.net. This adds a point on a chart at mouse
position but it is quite slow.
Private Sub Chart2_MouseMove(sender As Object, e As MouseEventArgs)
Handles Chart2.MouseMove
Dim coord() As Double = GetAxisValuesFromMouse(e.X, e.Y)
Dim test As Series
Try
Chart2.Series.RemoveAt(1)
Catch ex As Exception
End Try
Dim pt As New DataPoint
pt.XValue = coord(0)
pt.YValues(0) = coord(1)
test = New Series
Chart2.Series.Add(test)
Chart2.Series(test.Name).ChartType = SeriesChartType.Point
Chart2.Series(test.Name).Points.Add(pt)
End Sub
Function returns the coordinates of x and y axis at mouse position.
Private Function GetAxisValuesFromMouse(x As Integer, y As Integer) As
Double()
Dim coord(1) As Double
Dim chartArea = Chart2.ChartAreas(0)
coord(0) = chartArea.AxisX.PixelPositionToValue(x)
coord(1) = chartArea.AxisY.PixelPositionToValue(y)
Return coord
End Function
Result:
Hp scanner application fails to save a file in Hebrew format
Hp scanner application fails to save a file in Hebrew format
I have an HP laserjet M1522NF and i am using the scanner software that
comes with the drivers.
what is happening is when i scan a document and try to save the document
in Hebrew i get a message:
"Cannot save the file /???.tif" save as with other file formats though i
don't think that the file format has anything to do with it.
further more, if i save the file name in English, there is no problem
renaming it to Hebrew from the file explorer.
Anyone has any idea what can cause this behavior.
Thanks
I have an HP laserjet M1522NF and i am using the scanner software that
comes with the drivers.
what is happening is when i scan a document and try to save the document
in Hebrew i get a message:
"Cannot save the file /???.tif" save as with other file formats though i
don't think that the file format has anything to do with it.
further more, if i save the file name in English, there is no problem
renaming it to Hebrew from the file explorer.
Anyone has any idea what can cause this behavior.
Thanks
Change individual button state
Change individual button state
I have the following which uses clicks and jquery fade to display a div
when a button is clicked and then change the state of the button....
http://jsfiddle.net/ttj9J/5/
HTML
<a class="link" href="#" data-rel="content1"><img
src="http://i.imgur.com/vi1KLp9.png"></a>
<a class="link" href="#" data-rel="content2"><img
src="http://i.imgur.com/u1SbuRE.png"></a>
<a class="link" href="#" data-rel="content3"><img
src="http://i.imgur.com/u1SbuRE.png"></a>
<a class="link" href="#" data-rel="content4"><img
src="http://i.imgur.com/u1SbuRE.png"></a>
<a class="link" href="#" data-rel="content5"><img
src="http://i.imgur.com/u1SbuRE.png"></a>
<div class="content-container">
<div id="content1">This is the test content for part 1</div>
<div id="content2">This is the test content for part 2</div>
<div id="content3">This is the test content for part 3</div>
<div id="content4">This is the test content for part 4</div>
<div id="content5">This is the test content for part 5</div>
</div>
CSS
.content-container {
position: relative;
width: 400px;
height: 400px;
}
.content-container div {
display: none;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
JQUERY
$(".link").click(function(e) {
e.preventDefault();
$('.content-container div').fadeOut('slow');
$('#' + $(this).data('rel')).fadeIn('slow');
$(".link img").attr("src", "http://i.imgur.com/u1SbuRE.png");
$(this).find("img").attr("src", "http://i.imgur.com/vi1KLp9.png");
});
$( document ).ready(function() {
$(".link")[0].click();
});
This all works great but what I am trying to do is have a different button
/ pressed button image for each of the five buttons. Can anyone help?
I have the following which uses clicks and jquery fade to display a div
when a button is clicked and then change the state of the button....
http://jsfiddle.net/ttj9J/5/
HTML
<a class="link" href="#" data-rel="content1"><img
src="http://i.imgur.com/vi1KLp9.png"></a>
<a class="link" href="#" data-rel="content2"><img
src="http://i.imgur.com/u1SbuRE.png"></a>
<a class="link" href="#" data-rel="content3"><img
src="http://i.imgur.com/u1SbuRE.png"></a>
<a class="link" href="#" data-rel="content4"><img
src="http://i.imgur.com/u1SbuRE.png"></a>
<a class="link" href="#" data-rel="content5"><img
src="http://i.imgur.com/u1SbuRE.png"></a>
<div class="content-container">
<div id="content1">This is the test content for part 1</div>
<div id="content2">This is the test content for part 2</div>
<div id="content3">This is the test content for part 3</div>
<div id="content4">This is the test content for part 4</div>
<div id="content5">This is the test content for part 5</div>
</div>
CSS
.content-container {
position: relative;
width: 400px;
height: 400px;
}
.content-container div {
display: none;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
JQUERY
$(".link").click(function(e) {
e.preventDefault();
$('.content-container div').fadeOut('slow');
$('#' + $(this).data('rel')).fadeIn('slow');
$(".link img").attr("src", "http://i.imgur.com/u1SbuRE.png");
$(this).find("img").attr("src", "http://i.imgur.com/vi1KLp9.png");
});
$( document ).ready(function() {
$(".link")[0].click();
});
This all works great but what I am trying to do is have a different button
/ pressed button image for each of the five buttons. Can anyone help?
to XML using XStream
to XML using XStream
I wanted to serialize and deserialize an instance of ObservableList.
The plan was the following:
ObservableList<Expense> data; //Contains Objects of the type Expense...
....
XStream xmlStream = new XStream(new DomDriver());
xmlStream.toXML(data);
This doesn't work, what didn't really confuse me. I ended doing something
like this:
DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(new
FileOutputStream(serializedFile)));
for (int i=0; i<data.size(); ++i) {
serialize = xmlStream.toXML(data.get(i));
dos.writeUTF(serialize);
}
dos.flush();
dos.close();
This worked well, but I have no idea, how I could deserialize this,
because I don't know, what the size of data will be. I heard of Iterators
and stuff, but how should I use one of them with this 3rd party library?
Do you have an answer or maybe a better idea? I would really appreciate
it. :)
I wanted to serialize and deserialize an instance of ObservableList.
The plan was the following:
ObservableList<Expense> data; //Contains Objects of the type Expense...
....
XStream xmlStream = new XStream(new DomDriver());
xmlStream.toXML(data);
This doesn't work, what didn't really confuse me. I ended doing something
like this:
DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(new
FileOutputStream(serializedFile)));
for (int i=0; i<data.size(); ++i) {
serialize = xmlStream.toXML(data.get(i));
dos.writeUTF(serialize);
}
dos.flush();
dos.close();
This worked well, but I have no idea, how I could deserialize this,
because I don't know, what the size of data will be. I heard of Iterators
and stuff, but how should I use one of them with this 3rd party library?
Do you have an answer or maybe a better idea? I would really appreciate
it. :)
Friday, 23 August 2013
Google Adsense code not showing up in Html
Google Adsense code not showing up in Html
Please pardon me for this Novice question, in Trying to manage a website
by myself, without programming knowledge.
I have a html page for my home page, where I want to insert the Adsense code.
I inserted in within the <body>,inside <div id = "container"> , by
specifying a <h2>.
With in the the <h2>, I copied the following script
<script type="text/javascript"><!--
google_ad_client = "xxxxxxxx";
/* Plusfirst */
google_ad_slot = "xxxxxxx";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
BUT the page does not display google ads.
Something has gone wrong there , but not sure. I hope to get some advice.
Please pardon me for this Novice question, in Trying to manage a website
by myself, without programming knowledge.
I have a html page for my home page, where I want to insert the Adsense code.
I inserted in within the <body>,inside <div id = "container"> , by
specifying a <h2>.
With in the the <h2>, I copied the following script
<script type="text/javascript"><!--
google_ad_client = "xxxxxxxx";
/* Plusfirst */
google_ad_slot = "xxxxxxx";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
BUT the page does not display google ads.
Something has gone wrong there , but not sure. I hope to get some advice.
Adding TextMesh by script Unity C#
Adding TextMesh by script Unity C#
My code is: GameObject textwin = new GameObject("win");
textwin.AddComponent().text = "YOU WIN!";
textwin.GetComponent().font(Arial);
It errors out on the third line because it is not the correct syntax, help
I'm a noobie in Unity3D this is my first game in it. And no I don't want
to use GuiText.
My code is: GameObject textwin = new GameObject("win");
textwin.AddComponent().text = "YOU WIN!";
textwin.GetComponent().font(Arial);
It errors out on the third line because it is not the correct syntax, help
I'm a noobie in Unity3D this is my first game in it. And no I don't want
to use GuiText.
What the best way to capture the payload within an 802.15.4 frame for processing on a PC?
What the best way to capture the payload within an 802.15.4 frame for
processing on a PC?
I am receiving IEEE 802.15.4 frames from an embedded device and I can see
them with my packet sniffer.
I am trying to feed this stream of frames into a LabView program but I'm
not sure what the best way to do this would be.
How can I get a labview program to continuously read the live stream of
802.15.4 frames and parse out the payload?
Can I use the packet sniffer itself?
processing on a PC?
I am receiving IEEE 802.15.4 frames from an embedded device and I can see
them with my packet sniffer.
I am trying to feed this stream of frames into a LabView program but I'm
not sure what the best way to do this would be.
How can I get a labview program to continuously read the live stream of
802.15.4 frames and parse out the payload?
Can I use the packet sniffer itself?
Setting ConnectionTimeout when using EntityFramework
Setting ConnectionTimeout when using EntityFramework
I would like to set the ConnectionTimeout to something other than the
default, which is 15 seconds. I have inherited some code that uses
EntityFramework and the app.config looks like this:
<configuration>
<configSections>
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,
EntityFramework, Version=5.0.0.0, Culture=neutral,
PublicKeyToken=xxxxxxxxxxxxxxxx" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;
Integrated Security=True; ConnectionTimeout=30;
MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory
type="System.Data.Entity.Infrastructure.SqlConnectionFactory,
EntityFramework">
<parameters>
<parameter value="Data Source=.\SQLEXPRESS; Integrated Security=True;
ConnectionTimeout=30; MultipleActiveResultSets=True" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
I'm the one who added the sectino in an attempt to get things working. I
can tell it's not working be setting a breakpoint at:
var adapter = (IObjectContextAdapter) this;
var objectContext = adapter.ObjectContext;
objectContext.CommandTimeout = CommandTimeoutSeconds;
int test = objectContext.Connection.ConnectionTimeout;
test is always 15. What is going on? Can someone tell me how to set
ConnectionTimeout? I have tried both "ConnectionTimeout" and "Connection
Timeout" I.e. no space vs. space.
Can someone help me? I'm pulling my hair out. I'm sure it's a simple fix!
Dave
I would like to set the ConnectionTimeout to something other than the
default, which is 15 seconds. I have inherited some code that uses
EntityFramework and the app.config looks like this:
<configuration>
<configSections>
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,
EntityFramework, Version=5.0.0.0, Culture=neutral,
PublicKeyToken=xxxxxxxxxxxxxxxx" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;
Integrated Security=True; ConnectionTimeout=30;
MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory
type="System.Data.Entity.Infrastructure.SqlConnectionFactory,
EntityFramework">
<parameters>
<parameter value="Data Source=.\SQLEXPRESS; Integrated Security=True;
ConnectionTimeout=30; MultipleActiveResultSets=True" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
I'm the one who added the sectino in an attempt to get things working. I
can tell it's not working be setting a breakpoint at:
var adapter = (IObjectContextAdapter) this;
var objectContext = adapter.ObjectContext;
objectContext.CommandTimeout = CommandTimeoutSeconds;
int test = objectContext.Connection.ConnectionTimeout;
test is always 15. What is going on? Can someone tell me how to set
ConnectionTimeout? I have tried both "ConnectionTimeout" and "Connection
Timeout" I.e. no space vs. space.
Can someone help me? I'm pulling my hair out. I'm sure it's a simple fix!
Dave
Can start sentence with "Allowing to"
Can start sentence with "Allowing to"
Can I start a sentence as follows? "Allowing to detect only circular shape
objects, objects, classified mistakenly as trees, can be avoided from the
modelling process."
or may be can we write it as: Objects, classified mistakenly as trees, can
be avoided from the modelling process allowing to detect only circular
shape objects.
Please correct me in this.
Can I start a sentence as follows? "Allowing to detect only circular shape
objects, objects, classified mistakenly as trees, can be avoided from the
modelling process."
or may be can we write it as: Objects, classified mistakenly as trees, can
be avoided from the modelling process allowing to detect only circular
shape objects.
Please correct me in this.
How to store name of file in folder to array in c ++ ?
How to store name of file in folder to array in c ++ ?
I am new in c++ . And i want to write a function which takes names from
folder.
for example i have a folder which name is C:\TEST and in this folder i
have lots of text.txt files i want to store all .txt files name in a
string array.
Anybody could help me about this issue.
i tried something like this but i failed
const int arr_size = 10;
some_type src[arr_size];
// ...
some_type dest[arr_size];
std::copy(std::begin(src), std::end(src), std::begin(dest));
I am new in c++ . And i want to write a function which takes names from
folder.
for example i have a folder which name is C:\TEST and in this folder i
have lots of text.txt files i want to store all .txt files name in a
string array.
Anybody could help me about this issue.
i tried something like this but i failed
const int arr_size = 10;
some_type src[arr_size];
// ...
some_type dest[arr_size];
std::copy(std::begin(src), std::end(src), std::begin(dest));
Thursday, 22 August 2013
How i can set Error on a Listview
How i can set Error on a Listview
I have studied this about ListView :
ListView component did not render element on position that is hidden ib
scroll. It is a lazy component that renders only what is on screen.
So how could i put error on the items of the ListView .If i am using
setError it is working fine for the items that are visible on screen so
could set error on that part that is not visible.
I am trying to set error like this
View myView = listView.getChildAt(position);
TextView textView=(TextView)myView.findViewById(android.R.id.text1);
textView.setError(error);
Exception is
08-23 11:20:47.385: E/AndroidRuntime(2931): FATAL EXCEPTION: main
08-23 11:20:47.385: E/AndroidRuntime(2931): java.lang.NullPointerException
08-23 11:20:47.385: E/AndroidRuntime(2931): at
com.example.iweenflightbookingpage.MainActivity$1.onClick(MainActivity.java:118)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
android.view.View.performClick(View.java:4091)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
android.view.View$PerformClick.run(View.java:17072)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
android.os.Handler.handleCallback(Handler.java:615)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
android.os.Handler.dispatchMessage(Handler.java:92)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
android.os.Looper.loop(Looper.java:153)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
android.app.ActivityThread.main(ActivityThread.java:4987)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
java.lang.reflect.Method.invokeNative(Native Method)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
java.lang.reflect.Method.invoke(Method.java:511)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
dalvik.system.NativeStart.main(Native Method)
I have studied this about ListView :
ListView component did not render element on position that is hidden ib
scroll. It is a lazy component that renders only what is on screen.
So how could i put error on the items of the ListView .If i am using
setError it is working fine for the items that are visible on screen so
could set error on that part that is not visible.
I am trying to set error like this
View myView = listView.getChildAt(position);
TextView textView=(TextView)myView.findViewById(android.R.id.text1);
textView.setError(error);
Exception is
08-23 11:20:47.385: E/AndroidRuntime(2931): FATAL EXCEPTION: main
08-23 11:20:47.385: E/AndroidRuntime(2931): java.lang.NullPointerException
08-23 11:20:47.385: E/AndroidRuntime(2931): at
com.example.iweenflightbookingpage.MainActivity$1.onClick(MainActivity.java:118)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
android.view.View.performClick(View.java:4091)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
android.view.View$PerformClick.run(View.java:17072)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
android.os.Handler.handleCallback(Handler.java:615)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
android.os.Handler.dispatchMessage(Handler.java:92)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
android.os.Looper.loop(Looper.java:153)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
android.app.ActivityThread.main(ActivityThread.java:4987)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
java.lang.reflect.Method.invokeNative(Native Method)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
java.lang.reflect.Method.invoke(Method.java:511)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
08-23 11:20:47.385: E/AndroidRuntime(2931): at
dalvik.system.NativeStart.main(Native Method)
classic asp query a recordset rather than a table
classic asp query a recordset rather than a table
So, you have a recordset created like this:
Set rs = Server.CreateObject("ADODB.Recordset")
And you fill it like this:
rs.Open queryString, AuthConn, adOpenKeyset, adLockReadOnly
My question is, I want a second recordset that is a subset of the first
(rs) recordset, can you do this in classic asp
Set rs2 = Server.CreateObject("ADODB.Recordset")
My immediate guess is that it would be something like this
rs2.Open queryString, rs, adOpenKeyset, adLockReadOnly
Why you ask? Well we have an older site that we are updating and adding
new features too and rather than change a LOT of code I was wondering if I
could be sneaky and use a setset of an already created (large) recordset,
to save on another query to the db etc. Just wondering if it can be done.
Thanks,
So, you have a recordset created like this:
Set rs = Server.CreateObject("ADODB.Recordset")
And you fill it like this:
rs.Open queryString, AuthConn, adOpenKeyset, adLockReadOnly
My question is, I want a second recordset that is a subset of the first
(rs) recordset, can you do this in classic asp
Set rs2 = Server.CreateObject("ADODB.Recordset")
My immediate guess is that it would be something like this
rs2.Open queryString, rs, adOpenKeyset, adLockReadOnly
Why you ask? Well we have an older site that we are updating and adding
new features too and rather than change a LOT of code I was wondering if I
could be sneaky and use a setset of an already created (large) recordset,
to save on another query to the db etc. Just wondering if it can be done.
Thanks,
why setInterval() cycle goes faster every time?
why setInterval() cycle goes faster every time?
I'm building a custom slider on Javascript , and I want that every time
the user clicks on a div of the slider, the slider should stop for X
seconds.
My code is:
$(document).ready(function () {
var ciclo;
var index_slide = 1;
function startSlidercicle() {
ciclo = setInterval( function() {
// Slider code goes here
}, 3000);
}
//Here I start the slider animation
startSlidercicle();
//When the user clicks on a div called 'slide', stop the cycle and
start again the animation cycle
$('.slide').on('click', function() {
clearInterval(ciclo);
setTimeout(startSlidercicle(), 3000);
});
});
But the problem is that everytime I click and stop the slider, the cycle
starts faster and faster. How can I fix it?
I'm building a custom slider on Javascript , and I want that every time
the user clicks on a div of the slider, the slider should stop for X
seconds.
My code is:
$(document).ready(function () {
var ciclo;
var index_slide = 1;
function startSlidercicle() {
ciclo = setInterval( function() {
// Slider code goes here
}, 3000);
}
//Here I start the slider animation
startSlidercicle();
//When the user clicks on a div called 'slide', stop the cycle and
start again the animation cycle
$('.slide').on('click', function() {
clearInterval(ciclo);
setTimeout(startSlidercicle(), 3000);
});
});
But the problem is that everytime I click and stop the slider, the cycle
starts faster and faster. How can I fix it?
Recognizing custom icon fonts?
Recognizing custom icon fonts?
over the past two days I've done very heavy research on the matter. The
issue is that my website doesn't recognize the custom icon fonts that I
feed it through css.
Here is the problem in detail: Basically, I've followed the tutorial from
over here: http://tympanus.net/Blueprints/ResponsiveIconGrid/ and I
successfully implemented it on my website. The functionality, the styles -
everything is in check. Except that in place of the icons, I see
rectangles/squares. I have already tried this with two other icon fonts.
My CSS and HTML For datailed/full CSS codes, please visit pastebin over
here: http://pastebin.com/94UgpN8B and over here
hxxp://pastebin.com/c7w1LEBf
My code in short Adding the fonts with @font-face
@font-face {
font-family: 'anyoldicon';
src:url('assets/anyoldicon.eot');
src:url('assets/anyoldicon.eot?#iefix') format('embedded-opentype'),
url('assets/anyoldicon.woff') format('woff'),
url('assets/anyoldicon.ttf') format('truetype'),
url('assets/anyoldicon.svg#anyoldicon') format('svg');
font-weight: normal;
font-style: normal;
unicode-range: U+00-FFFF;
}
And calling the via in HTML. Please refer to the above full files to check
out the CSS that takes care of inherting. It seems to work fine to me.
<li>
<a href="#">
<span class="cbp-ig-icon cbp-ig-icon-whippy"></span>
<h3 class="cbp-ig-title">George</h3>
<span class="cbp-ig-category">Smith</span>
</a>
WHAT I'VE TRIED:
I haven't received any 404 errors in console regarding the assets.
I also tried defining the icons styles separately, so as to remove the
possibility of incorrect inheriting of class properties (check out the
pastebin CSS)
I have tried adding my font-family like so: font-family: 'anyoldicon',
Calibri, Arial, sans-serif;?
My folder structure is basically that in the root of the website directory
there is a folder called assets and in that folder are all my css files
and font files. Not very clean, I know, but I am still testing the
website. There are other folders like css and images, but there reside
mostly Muse files, which have no relation to the specific issue. Also my
html files are in the root as well.
I have tried changing the paths to different folders, and putting ../
infront of them. The manner of linking to the fonts is the same way I link
to my other documents, which seems to work fine.
Cleared cahce inbetween every single attempt
Paths are linked correctly
More info I am using MUSE to compile the website, if there happen to be
any known issues with icon fonts. An extensive google search provided me
with nothing, though.
Finally... In the end, I would be tremendously thankful if you could
provide some insight, or offer your opinion on a way to work around this.
Thank you very much for your time.
over the past two days I've done very heavy research on the matter. The
issue is that my website doesn't recognize the custom icon fonts that I
feed it through css.
Here is the problem in detail: Basically, I've followed the tutorial from
over here: http://tympanus.net/Blueprints/ResponsiveIconGrid/ and I
successfully implemented it on my website. The functionality, the styles -
everything is in check. Except that in place of the icons, I see
rectangles/squares. I have already tried this with two other icon fonts.
My CSS and HTML For datailed/full CSS codes, please visit pastebin over
here: http://pastebin.com/94UgpN8B and over here
hxxp://pastebin.com/c7w1LEBf
My code in short Adding the fonts with @font-face
@font-face {
font-family: 'anyoldicon';
src:url('assets/anyoldicon.eot');
src:url('assets/anyoldicon.eot?#iefix') format('embedded-opentype'),
url('assets/anyoldicon.woff') format('woff'),
url('assets/anyoldicon.ttf') format('truetype'),
url('assets/anyoldicon.svg#anyoldicon') format('svg');
font-weight: normal;
font-style: normal;
unicode-range: U+00-FFFF;
}
And calling the via in HTML. Please refer to the above full files to check
out the CSS that takes care of inherting. It seems to work fine to me.
<li>
<a href="#">
<span class="cbp-ig-icon cbp-ig-icon-whippy"></span>
<h3 class="cbp-ig-title">George</h3>
<span class="cbp-ig-category">Smith</span>
</a>
WHAT I'VE TRIED:
I haven't received any 404 errors in console regarding the assets.
I also tried defining the icons styles separately, so as to remove the
possibility of incorrect inheriting of class properties (check out the
pastebin CSS)
I have tried adding my font-family like so: font-family: 'anyoldicon',
Calibri, Arial, sans-serif;?
My folder structure is basically that in the root of the website directory
there is a folder called assets and in that folder are all my css files
and font files. Not very clean, I know, but I am still testing the
website. There are other folders like css and images, but there reside
mostly Muse files, which have no relation to the specific issue. Also my
html files are in the root as well.
I have tried changing the paths to different folders, and putting ../
infront of them. The manner of linking to the fonts is the same way I link
to my other documents, which seems to work fine.
Cleared cahce inbetween every single attempt
Paths are linked correctly
More info I am using MUSE to compile the website, if there happen to be
any known issues with icon fonts. An extensive google search provided me
with nothing, though.
Finally... In the end, I would be tremendously thankful if you could
provide some insight, or offer your opinion on a way to work around this.
Thank you very much for your time.
Magento Admin System Config Image Upload
Magento Admin System Config Image Upload
I have been working on magento backend image upload functionality for
quite a few days.
The below code allows to upload an image in your specified upload directory.
<backend_model>adminhtml/system_config_backend_image</backend_model>
Screenshot:
Can we resize the image while uploading using system.xml settings ?
Is there any system config settings that allow us to do so. For eg:
<image_height>50</image_height> and <image_width>50</image_width>
Moreover can anyone pls shed some light on how the image is being
uploaded, checks for max image file size and how it resizes the image.
Thanks.
I have been working on magento backend image upload functionality for
quite a few days.
The below code allows to upload an image in your specified upload directory.
<backend_model>adminhtml/system_config_backend_image</backend_model>
Screenshot:
Can we resize the image while uploading using system.xml settings ?
Is there any system config settings that allow us to do so. For eg:
<image_height>50</image_height> and <image_width>50</image_width>
Moreover can anyone pls shed some light on how the image is being
uploaded, checks for max image file size and how it resizes the image.
Thanks.
Getting products from an order in Magento
Getting products from an order in Magento
In my magento project, under My Account > My Orders (logged on customer),
I am able to view the order details along with the products I ordered.
Now, for each of the ordered product, I'd like to retrieve a specific
attribute however, from my understanding, the code snippet at the
beginning of sales/order/items/renderer/default.phtml which is $_item =
$this->getItem(); is the order itself so if I use something like
$_item->getId(), I'm getting the order id and not the product's.
I tried researching and ended up with this code:
$orders = Mage::getModel('sales/order')->load($_item->getId());
foreach($orders as $order):
$is = $order->getAllItems();
foreach($is as $i):
echo $i->getProductId();
endforeach;
endforeach;
Hoping I could use the product id to get the other attributes of the said
product however, I 'm getting an error with this code with no way of
telling what the error is. I've also tried something like this:
$_productCollection = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->addAttributeToFilter('name', $name);
foreach($_productCollection as $_product):
$_temp =
$_product->getResource()->getAttribute('name_en')->getFrontend()->getValue($_product);
endforeach;
But I keep getting 0 when I try to check the count of items in the product
collection. How can I retrieve a custom attribute for the product in this
page?
In my magento project, under My Account > My Orders (logged on customer),
I am able to view the order details along with the products I ordered.
Now, for each of the ordered product, I'd like to retrieve a specific
attribute however, from my understanding, the code snippet at the
beginning of sales/order/items/renderer/default.phtml which is $_item =
$this->getItem(); is the order itself so if I use something like
$_item->getId(), I'm getting the order id and not the product's.
I tried researching and ended up with this code:
$orders = Mage::getModel('sales/order')->load($_item->getId());
foreach($orders as $order):
$is = $order->getAllItems();
foreach($is as $i):
echo $i->getProductId();
endforeach;
endforeach;
Hoping I could use the product id to get the other attributes of the said
product however, I 'm getting an error with this code with no way of
telling what the error is. I've also tried something like this:
$_productCollection = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->addAttributeToFilter('name', $name);
foreach($_productCollection as $_product):
$_temp =
$_product->getResource()->getAttribute('name_en')->getFrontend()->getValue($_product);
endforeach;
But I keep getting 0 when I try to check the count of items in the product
collection. How can I retrieve a custom attribute for the product in this
page?
Wednesday, 21 August 2013
ToC page numbering occasionally wrong after using vspace
ToC page numbering occasionally wrong after using vspace
I'm writing my dissertation and have a few sections that are small, less
than a page, each with a figure. I'm letting the figures float to the next
section to keep them from being on a page by themselves (they don't merit
a full page, and there are lots anyway). The problem comes when I end up
with a section starting on the last line or two of a page, with no text
following it before the page break which is a no-no. If I can, I use
\clearpage, but that doesn't allow a figure from a previous section to be
placed in the next section. If I can't use \clearpage without orphaning a
figure, I am using \vspace{3em} in front of the next section command just
to bump it to another page. When I do this, though, the Table of Contents
entry for the second section displays the page for the first section.
Here's the MWE:
\documentclass[12pt]{report}
\begin{document}
\pagenumbering{roman}
\pagestyle{plain}
Abstract
\addcontentsline{toc}{chapter}{Abstract}
\tableofcontents
\include{table_of_contents}
\pagenumbering{arabic}
\chapter{}
\section{First section}
This takes up just enough space so the section title of the NEXT section is a
line all by itself at the bottom of the last page of this section.
\vspace{30em}
\section{Second section}
\end{document}
I'm looking for a way to either get the ToC page numbers to be correct or
to bump the section title down in a way that lets the figures float around
still (which will presumably ALSO get the ToC numbers right).
I'm writing my dissertation and have a few sections that are small, less
than a page, each with a figure. I'm letting the figures float to the next
section to keep them from being on a page by themselves (they don't merit
a full page, and there are lots anyway). The problem comes when I end up
with a section starting on the last line or two of a page, with no text
following it before the page break which is a no-no. If I can, I use
\clearpage, but that doesn't allow a figure from a previous section to be
placed in the next section. If I can't use \clearpage without orphaning a
figure, I am using \vspace{3em} in front of the next section command just
to bump it to another page. When I do this, though, the Table of Contents
entry for the second section displays the page for the first section.
Here's the MWE:
\documentclass[12pt]{report}
\begin{document}
\pagenumbering{roman}
\pagestyle{plain}
Abstract
\addcontentsline{toc}{chapter}{Abstract}
\tableofcontents
\include{table_of_contents}
\pagenumbering{arabic}
\chapter{}
\section{First section}
This takes up just enough space so the section title of the NEXT section is a
line all by itself at the bottom of the last page of this section.
\vspace{30em}
\section{Second section}
\end{document}
I'm looking for a way to either get the ToC page numbers to be correct or
to bump the section title down in a way that lets the figures float around
still (which will presumably ALSO get the ToC numbers right).
Reducing time in the following code
Reducing time in the following code
I gave this solution at the codechef for the problem code : FCTRL.
I saw the compile time of others people using the same the language c ( i
am using c++ gcc 4.8.1) is somewhat less, mine is 0.46s while their is
0.23
Can somebody help me in reducing the time if possible?
#include<iostream>
using namespace std;
int main()
{
long int t,i,temp;
cin>>t;
long int n[t],a[t];
for(i=0;i<t;i++)
{
temp=1;
a[i]=0;
cin>>n[i];
while(temp)
{
temp=n[i]/5;
a[i]+=temp;
n[i]=n[i]/5;
}
}
for(i=0;i<t;i++)
cout<<a[i]<<"\n";
return(0);
}
I gave this solution at the codechef for the problem code : FCTRL.
I saw the compile time of others people using the same the language c ( i
am using c++ gcc 4.8.1) is somewhat less, mine is 0.46s while their is
0.23
Can somebody help me in reducing the time if possible?
#include<iostream>
using namespace std;
int main()
{
long int t,i,temp;
cin>>t;
long int n[t],a[t];
for(i=0;i<t;i++)
{
temp=1;
a[i]=0;
cin>>n[i];
while(temp)
{
temp=n[i]/5;
a[i]+=temp;
n[i]=n[i]/5;
}
}
for(i=0;i<t;i++)
cout<<a[i]<<"\n";
return(0);
}
How to create scrollable console application that support ANSI escape code sequences
How to create scrollable console application that support ANSI escape code
sequences
I am making some assumptions here on technology based on what I know, but
other technology recommendations are welcome.
My goal: Write an ANSI Art viewer that as closely as possible resembles
viewing on a DOS machine as possible, preferably without the overhead of
running dosbox. This will run on a Raspberry Pi.
I have gotten my console to properly cat an ANSI with proper characters,
colors, etc. The catch with the "viewer" is that I would like to be able
to use the arrow keys to scroll up and down through the document, much
like, say, the "less" command does.
From what I have been able to research, curses is a perfect candidate for
this. The problem is that curses does not support ANSI escape code
sequences. There is an ANSI editor written in C++ that uses curses, but it
builds its own support for parsing the escape code sequences. Right now
this is my last resort.
So my question is: Is there a better route to creating a scrollable
console-mode application for viewing ANSI Art (Code Page 437 + ANSI escape
code sequences) in python on linux?
sequences
I am making some assumptions here on technology based on what I know, but
other technology recommendations are welcome.
My goal: Write an ANSI Art viewer that as closely as possible resembles
viewing on a DOS machine as possible, preferably without the overhead of
running dosbox. This will run on a Raspberry Pi.
I have gotten my console to properly cat an ANSI with proper characters,
colors, etc. The catch with the "viewer" is that I would like to be able
to use the arrow keys to scroll up and down through the document, much
like, say, the "less" command does.
From what I have been able to research, curses is a perfect candidate for
this. The problem is that curses does not support ANSI escape code
sequences. There is an ANSI editor written in C++ that uses curses, but it
builds its own support for parsing the escape code sequences. Right now
this is my last resort.
So my question is: Is there a better route to creating a scrollable
console-mode application for viewing ANSI Art (Code Page 437 + ANSI escape
code sequences) in python on linux?
how to add ItemSet dynamically in c#
how to add ItemSet dynamically in c#
i am to add some data on ItemsetCollection dynamically.
string [][] d=new string[10][];
for(int i=0;i<10;i++)
{ int j=0;
if(a[i]<b[i])
c[j++]=a[i];
if(e[i]<f[i])
c[j++]=e[i];
if(g[i]<h[i])
c[j++]=f[i];
if(i[i]<j[i])
c[j++]=g[i];
d[i] = new string[j];
for(int k=0;k<j;k++)
d[i][k]=c[k];
}
ItemsetCollection db = new ItemsetCollection()
for(int i=0;i<10;i++){
db.Add(new Itemset() {................}
}
here i got to add ItemSet depending on result from for loop dynamically in c#
i am to add some data on ItemsetCollection dynamically.
string [][] d=new string[10][];
for(int i=0;i<10;i++)
{ int j=0;
if(a[i]<b[i])
c[j++]=a[i];
if(e[i]<f[i])
c[j++]=e[i];
if(g[i]<h[i])
c[j++]=f[i];
if(i[i]<j[i])
c[j++]=g[i];
d[i] = new string[j];
for(int k=0;k<j;k++)
d[i][k]=c[k];
}
ItemsetCollection db = new ItemsetCollection()
for(int i=0;i<10;i++){
db.Add(new Itemset() {................}
}
here i got to add ItemSet depending on result from for loop dynamically in c#
PHP - Implode multi-dimensional array for MySQL
PHP - Implode multi-dimensional array for MySQL
I'm attempting to implode a multi-dimensional array with the characters
),(, so that i can use a query similar to this:
insert into table temp (a,b,c) values ('a','b','c'),('d','e','f');
Here is an example of the multidimentional array:
$tmp = array(
array(0 => 'CompanyB',
1 => 'IndustryA',
2 => 'Sysadmin',
3 => '01',
4 => '2011',
5 => '12',
6 => '2012',
7 => 'aeere',
8 => 'R6000',
9 => 'asdfasdf'),
array(0 => 'CompanyC',
1 => 'IndustryC',
2 => 'Aabb',
3 => '02',
4 => '2012',
5 => '01',
6 => '2013',
7 => 'asdf',
8 => 'R7000',
9 => 'adfasdfeeeeeeeeeeeeeee'),
array(0 => 'CompanyD',
1 => 'IndustryARR',
2 => 'NJNNLK',
3 => '01',
4 => '2011',
5 => '01',
6 => '2012',
7 => 'Anotheron',
8 => 'R9000',
9 => 'qweqweqwe'));
this does not produce any result, print implode("),(",$tmp);
I'm not a professional php developer, maybe there's an easier way to do
this. Appreciate your input.
I'm attempting to implode a multi-dimensional array with the characters
),(, so that i can use a query similar to this:
insert into table temp (a,b,c) values ('a','b','c'),('d','e','f');
Here is an example of the multidimentional array:
$tmp = array(
array(0 => 'CompanyB',
1 => 'IndustryA',
2 => 'Sysadmin',
3 => '01',
4 => '2011',
5 => '12',
6 => '2012',
7 => 'aeere',
8 => 'R6000',
9 => 'asdfasdf'),
array(0 => 'CompanyC',
1 => 'IndustryC',
2 => 'Aabb',
3 => '02',
4 => '2012',
5 => '01',
6 => '2013',
7 => 'asdf',
8 => 'R7000',
9 => 'adfasdfeeeeeeeeeeeeeee'),
array(0 => 'CompanyD',
1 => 'IndustryARR',
2 => 'NJNNLK',
3 => '01',
4 => '2011',
5 => '01',
6 => '2012',
7 => 'Anotheron',
8 => 'R9000',
9 => 'qweqweqwe'));
this does not produce any result, print implode("),(",$tmp);
I'm not a professional php developer, maybe there's an easier way to do
this. Appreciate your input.
Preg_Match data outside of square brackets
Preg_Match data outside of square brackets
I have a string from MySQL and I want to get the data outside the square
brackets.
Here are my data:
[USERNAME] User [OS INFO] Microsoft Windows NT 6.1.7601 Service Pack 1
[MACHINE NAME] MACHINE-2[LANGUAGE_INFORMATION] 4.0.30319.1
How to get this:
Microsoft Windows NT 6.1.7601 Service Pack 1
Tried by this:
preg_match_all("/].*?\[/", $adat["INFORMATION"], $result_array);
After this I get:
print_r( $result_array[0][1] );
] Microsoft Windows NT 6.1.7601 Service Pack 1 [
How to get the data without the brackets?
I have a string from MySQL and I want to get the data outside the square
brackets.
Here are my data:
[USERNAME] User [OS INFO] Microsoft Windows NT 6.1.7601 Service Pack 1
[MACHINE NAME] MACHINE-2[LANGUAGE_INFORMATION] 4.0.30319.1
How to get this:
Microsoft Windows NT 6.1.7601 Service Pack 1
Tried by this:
preg_match_all("/].*?\[/", $adat["INFORMATION"], $result_array);
After this I get:
print_r( $result_array[0][1] );
] Microsoft Windows NT 6.1.7601 Service Pack 1 [
How to get the data without the brackets?
System of five linear equations but only one is knowing
System of five linear equations but only one is knowing
Let suppose that we have system of five linear equations with three unknow
$x,y,z$. We know that one of equation of this system is $x+y+z=3$ and
$(x,y,z)=(3,0,0),(x,y,z)=(0,3,0)$ are solutions for this system. Is it
true that:
$(x,y,z)=(0,2,1)$ isn't solution of the system
$(x,y,z)=(0,1,2)$ is solution of the system
$(x,y,z)=(3,3,0)$ isn't solution of the system
$(x,y,z) = (1,2,0)$ is solution of the system
As we can see in 3. we have $3+3+0 = 6 \neq 3$ so $(3,3,0)$ isn't solution
of this system. In 4. I can use simple lemma: if $x,y$ are solutions of
$AX=b$ then for any $\alpha \in \mathbb{R}$ $\alpha x + (1- \alpha)y$ is
also solution. For $\alpha = \frac{1}{3}$ we have
$(1,2,0)=\frac{1}{3}(3,0,0)+\frac{2}{3}(0,3,0)$ so it is solution of this
system.
But I have no idea for 1. and 2. I will grateful for your help.
Let suppose that we have system of five linear equations with three unknow
$x,y,z$. We know that one of equation of this system is $x+y+z=3$ and
$(x,y,z)=(3,0,0),(x,y,z)=(0,3,0)$ are solutions for this system. Is it
true that:
$(x,y,z)=(0,2,1)$ isn't solution of the system
$(x,y,z)=(0,1,2)$ is solution of the system
$(x,y,z)=(3,3,0)$ isn't solution of the system
$(x,y,z) = (1,2,0)$ is solution of the system
As we can see in 3. we have $3+3+0 = 6 \neq 3$ so $(3,3,0)$ isn't solution
of this system. In 4. I can use simple lemma: if $x,y$ are solutions of
$AX=b$ then for any $\alpha \in \mathbb{R}$ $\alpha x + (1- \alpha)y$ is
also solution. For $\alpha = \frac{1}{3}$ we have
$(1,2,0)=\frac{1}{3}(3,0,0)+\frac{2}{3}(0,3,0)$ so it is solution of this
system.
But I have no idea for 1. and 2. I will grateful for your help.
Tuesday, 20 August 2013
Unable to connect to Exchange 2010 using IMAP
Unable to connect to Exchange 2010 using IMAP
I have the service running, communication running just fine including
Telnet and the "Secure Login" option checked. I have also made sure the
mailbox is IMAP enabled but I just cant seem to be able to connect no
matter what. I even tried using just Windows Authentication but to no
avail. What could I be missing? A receive connector perhaps?
I have the service running, communication running just fine including
Telnet and the "Secure Login" option checked. I have also made sure the
mailbox is IMAP enabled but I just cant seem to be able to connect no
matter what. I even tried using just Windows Authentication but to no
avail. What could I be missing? A receive connector perhaps?
Is it possible to submit the time that's obtained by javascript to a Form?
Is it possible to submit the time that's obtained by javascript to a Form?
This button show the current elapsed time of video media
<button name="test"
onclick="alert(Math.floor(document.getElementById('video').currentTime) +
'secs elapsed!');">Show elapsed time</button>
This elapsed time obviously changes at every second.
Is it possible to submit this elapsed time to a form?
How can I customize the code below?
<form action="/comments" method="post" >
<input type="text" name="comment[body]" size="50" />
<input type="hidden" name="comment[elapsed_time]" value="???????" />
<button type="submit" >Submit!</button>
</form>
This button show the current elapsed time of video media
<button name="test"
onclick="alert(Math.floor(document.getElementById('video').currentTime) +
'secs elapsed!');">Show elapsed time</button>
This elapsed time obviously changes at every second.
Is it possible to submit this elapsed time to a form?
How can I customize the code below?
<form action="/comments" method="post" >
<input type="text" name="comment[body]" size="50" />
<input type="hidden" name="comment[elapsed_time]" value="???????" />
<button type="submit" >Submit!</button>
</form>
Deserializing one contract type to another with DataContractSerializer
Deserializing one contract type to another with DataContractSerializer
The model is fairly simple... two interfaces, two classes, 1 base.
public interface ISomeCar1, ICarBase
{
string x { get; set; }
string y { get; set; }
}
public class SomeCar1 : CarBase, ISomeCar1
{
public string x { get; set; }
public string y { get; set; }
}
public interface ISomeCar2, ICarBase
{
string x { get; set; }
string y { get; set; }
string z { get; set; }
}
public class SomeCar2 : CarBase, ISomeCar2
{
public string x { get; set; }
public string y { get; set; }
public string z { get; set; }
}
A third-party web service will return ArrayOfSomeCar1 or ArrayOfSomeCar2
depending upon the requested car type (1 or 2) passed into the service. In
reality, the third-party provider extended SomeCar1 to support z and
created SomeCar2. SomeCar1 is still there for backward compatibility. Long
story short, we have to pass in 1 or 2 depending on some local business
rules.
I would like to pass type 1 to the third-party web service, which will
respond with an XML root of ArrayOfSomeCar1, but I need to deserialize
this as SomeCar2 which supports all of the functionality of SomeCar1. The
extra feature in these cases would simply be ignored with business logic.
I've tried using KnownTypes, deriving one class from the other class,
adding the interface ISomeCar1 to the SomeCar2 class, deserializing to the
base class, etc... and nothing seems to work. I get back an error like
"ArrayOfSomeCar1 was unexpected" or "Expecting ArrayOfAnyType". I can
provide the specific errors if needed.
Our method calls to the service are 100% generic (i.e.
<TCollection<TEntity>, TEntity>) but I can't figure out which object needs
to derive from which interface/concrete class to make it deserialize as
Collection<SomeCar2> when I receive ArrayOfSomeCar1 as the root element.
We're using the DataContractSerializer and all of the classes are setup
properly to deserialize as the given type, but just not one type from
another type.
I have complete control over all the classes, brand-new project... Does
anyone have any suggestions/knowledge on how to make this work? I prefer
to use interfaces where ever possible.
The model is fairly simple... two interfaces, two classes, 1 base.
public interface ISomeCar1, ICarBase
{
string x { get; set; }
string y { get; set; }
}
public class SomeCar1 : CarBase, ISomeCar1
{
public string x { get; set; }
public string y { get; set; }
}
public interface ISomeCar2, ICarBase
{
string x { get; set; }
string y { get; set; }
string z { get; set; }
}
public class SomeCar2 : CarBase, ISomeCar2
{
public string x { get; set; }
public string y { get; set; }
public string z { get; set; }
}
A third-party web service will return ArrayOfSomeCar1 or ArrayOfSomeCar2
depending upon the requested car type (1 or 2) passed into the service. In
reality, the third-party provider extended SomeCar1 to support z and
created SomeCar2. SomeCar1 is still there for backward compatibility. Long
story short, we have to pass in 1 or 2 depending on some local business
rules.
I would like to pass type 1 to the third-party web service, which will
respond with an XML root of ArrayOfSomeCar1, but I need to deserialize
this as SomeCar2 which supports all of the functionality of SomeCar1. The
extra feature in these cases would simply be ignored with business logic.
I've tried using KnownTypes, deriving one class from the other class,
adding the interface ISomeCar1 to the SomeCar2 class, deserializing to the
base class, etc... and nothing seems to work. I get back an error like
"ArrayOfSomeCar1 was unexpected" or "Expecting ArrayOfAnyType". I can
provide the specific errors if needed.
Our method calls to the service are 100% generic (i.e.
<TCollection<TEntity>, TEntity>) but I can't figure out which object needs
to derive from which interface/concrete class to make it deserialize as
Collection<SomeCar2> when I receive ArrayOfSomeCar1 as the root element.
We're using the DataContractSerializer and all of the classes are setup
properly to deserialize as the given type, but just not one type from
another type.
I have complete control over all the classes, brand-new project... Does
anyone have any suggestions/knowledge on how to make this work? I prefer
to use interfaces where ever possible.
How to Incode HTML Codes?
How to Incode HTML Codes?
Hi I want to incode my codes like this!
Exactly like this
document.write('\u003c\u0063\u0065\u006e\u0074\u0065\u0072\u003e\u000a\u003c\u0069\u0066\u0072\u0061\u006d\u0065\u0020\u006e\u0061\u006d\u0065\u003d\u0022\u0045\u006e\u0074\u0065\u0072\u0077\u0065\u0062\u0022\u0020\u0077\u0069\u0064\u0074\u0068\u003d\u0022\u0034\u0036\u0038\u0022\u0020\u0068\u0065\u0069\u0067\u0068\u0074\u003d\u0022\u0036\u0030\u0022\u0020\u006d\u0061\u0072\u0067\u0069\u006e\u0068\u0065\u0069\u0067\u0068\u0074\u003d\u0022\u0030\u0022\u0020\u006d\u0061\u0072\u0067\u0069\u006e\u0077\u0069\u0064\u0074\u0068\u003d\u0022\u0030\u0022\u0020\u0073\u0072\u0063\u003d\u0022\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0065\u006e\u0074\u0065\u0072\u0077\u0065\u0062\u002e\u0069\u0072\u002f\u0070\u0061\u0067\u0065\u002f\u0074\u0061\u0062\u0061\u0064\u006f\u006c\u0062\u0061\u006e\u006e\u0065\u0072\u0065\u006e\u0074\u0065\u0072\u0077\u0065\u0062\u0022\u0020\u0073\u0074\u0079\u006c\u0065\u003d\u0022\u0062\u006f\u0072\u0064\u0065\u0072\u003a\u0020\u0030\u0070\u0078\u0020\u0064\u
006f\u0074\u0074\u0065\u0064\u0020\u0023\u0030\u0030\u0030\u0030\u0030\u0030\u003b\u0022\u0020\u0062\u006f\u0072\u0064\u0065\u0072\u003d\u0022\u0030\u0022\u0020\u0066\u0072\u0061\u006d\u0065\u0062\u006f\u0072\u0064\u0065\u0072\u003d\u0022\u0030\u0022\u0020\u0073\u0063\u0072\u006f\u006c\u006c\u0069\u006e\u0067\u003d\u0022\u006e\u006f\u0022\u003e\u003c\u002f\u0069\u0066\u0072\u0061\u006d\u0065\u003e\u000a\u003c\u002f\u0063\u0065\u006e\u0074\u0065\u0072\u003e')
Hi I want to incode my codes like this!
Exactly like this
document.write('\u003c\u0063\u0065\u006e\u0074\u0065\u0072\u003e\u000a\u003c\u0069\u0066\u0072\u0061\u006d\u0065\u0020\u006e\u0061\u006d\u0065\u003d\u0022\u0045\u006e\u0074\u0065\u0072\u0077\u0065\u0062\u0022\u0020\u0077\u0069\u0064\u0074\u0068\u003d\u0022\u0034\u0036\u0038\u0022\u0020\u0068\u0065\u0069\u0067\u0068\u0074\u003d\u0022\u0036\u0030\u0022\u0020\u006d\u0061\u0072\u0067\u0069\u006e\u0068\u0065\u0069\u0067\u0068\u0074\u003d\u0022\u0030\u0022\u0020\u006d\u0061\u0072\u0067\u0069\u006e\u0077\u0069\u0064\u0074\u0068\u003d\u0022\u0030\u0022\u0020\u0073\u0072\u0063\u003d\u0022\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0065\u006e\u0074\u0065\u0072\u0077\u0065\u0062\u002e\u0069\u0072\u002f\u0070\u0061\u0067\u0065\u002f\u0074\u0061\u0062\u0061\u0064\u006f\u006c\u0062\u0061\u006e\u006e\u0065\u0072\u0065\u006e\u0074\u0065\u0072\u0077\u0065\u0062\u0022\u0020\u0073\u0074\u0079\u006c\u0065\u003d\u0022\u0062\u006f\u0072\u0064\u0065\u0072\u003a\u0020\u0030\u0070\u0078\u0020\u0064\u
006f\u0074\u0074\u0065\u0064\u0020\u0023\u0030\u0030\u0030\u0030\u0030\u0030\u003b\u0022\u0020\u0062\u006f\u0072\u0064\u0065\u0072\u003d\u0022\u0030\u0022\u0020\u0066\u0072\u0061\u006d\u0065\u0062\u006f\u0072\u0064\u0065\u0072\u003d\u0022\u0030\u0022\u0020\u0073\u0063\u0072\u006f\u006c\u006c\u0069\u006e\u0067\u003d\u0022\u006e\u006f\u0022\u003e\u003c\u002f\u0069\u0066\u0072\u0061\u006d\u0065\u003e\u000a\u003c\u002f\u0063\u0065\u006e\u0074\u0065\u0072\u003e')
Database schema and logic for this
Database schema and logic for this
I am trying to create a timetable for classes in MySQL. The columns are
the days of the week and the rows are the time intervals ( i.e. 7:00 -
8:00 ). I am also trying to have 30-minute time intervals and when a
particular subject is 2 hours, it will span 4 rows. Each cell contains the
name of the course and room. This is part of a small program I am trying
to develop. So far, I know what data to insert but I'm stuck on creating
the right database schema. Really need the logic on how to get this
started (i.e. what data types should I use ). Thanks!
I am trying to create a timetable for classes in MySQL. The columns are
the days of the week and the rows are the time intervals ( i.e. 7:00 -
8:00 ). I am also trying to have 30-minute time intervals and when a
particular subject is 2 hours, it will span 4 rows. Each cell contains the
name of the course and room. This is part of a small program I am trying
to develop. So far, I know what data to insert but I'm stuck on creating
the right database schema. Really need the logic on how to get this
started (i.e. what data types should I use ). Thanks!
Intermittent null data returned by memcache on get method
Intermittent null data returned by memcache on get method
I'm running memcached and my application is using the php libmemcached.
The code itself is a simple check key exists, if not pull fresh from mysql
database with an 'x' amount of expiry time.
I have an array of data I pull from mysql which is returned via another
method as an array - this is stored into memcached under the key
'menudata_array'. Everything was fine until I noticed sometimes the
menudata was being returned from the caching method as null or empty???
The only bit of info I have is that when the menudata is returned
empty|null, the period of error is equal to the expiry timeout of 120
seconds ?? After which the next request for data is returned ok.
I'm sure i've misunderstood something here!
The code is as follows:
function getMenuData()
{
$menudata_array = array(); //init an empty array
$memcache = getMemcache(); //method returns an instance of memcache
(global) or false is failure
if($memcache)
{
//get from memcache
$menudata_array = $memcache->get('menudata_array');
//make sure something was returned
if($menudata_array === false)
{
$menudata_array = generate_menu_array(); // get from mysql db
$expire_seconds = 120;
$refresh = $memcache->add('menudata_array', $menudata_array, false,
$expire_seconds);
if($refresh === false)
{
//key already exists so replace instead ...
$memcache->replace('menudata_array', $menudata_array, false,
$expire_seconds);
}
}
}
else
{
//memcache not available|down... get from mysql db instead
$menudata_array = generate_menu_array();
}
//i added this line to track when this problem was happening ...
if(!$menudata_array || count($menudata_array)<=0)
{
logError();
}
return $menudata_array;
}
Any help/pointers appreciated!
I'm running memcached and my application is using the php libmemcached.
The code itself is a simple check key exists, if not pull fresh from mysql
database with an 'x' amount of expiry time.
I have an array of data I pull from mysql which is returned via another
method as an array - this is stored into memcached under the key
'menudata_array'. Everything was fine until I noticed sometimes the
menudata was being returned from the caching method as null or empty???
The only bit of info I have is that when the menudata is returned
empty|null, the period of error is equal to the expiry timeout of 120
seconds ?? After which the next request for data is returned ok.
I'm sure i've misunderstood something here!
The code is as follows:
function getMenuData()
{
$menudata_array = array(); //init an empty array
$memcache = getMemcache(); //method returns an instance of memcache
(global) or false is failure
if($memcache)
{
//get from memcache
$menudata_array = $memcache->get('menudata_array');
//make sure something was returned
if($menudata_array === false)
{
$menudata_array = generate_menu_array(); // get from mysql db
$expire_seconds = 120;
$refresh = $memcache->add('menudata_array', $menudata_array, false,
$expire_seconds);
if($refresh === false)
{
//key already exists so replace instead ...
$memcache->replace('menudata_array', $menudata_array, false,
$expire_seconds);
}
}
}
else
{
//memcache not available|down... get from mysql db instead
$menudata_array = generate_menu_array();
}
//i added this line to track when this problem was happening ...
if(!$menudata_array || count($menudata_array)<=0)
{
logError();
}
return $menudata_array;
}
Any help/pointers appreciated!
On the uniqueness of certain weak cluster point in Hilbert space
On the uniqueness of certain weak cluster point in Hilbert space
The problem goes as follows: Let $\mathcal{H}$ be real Hilbert space,
$C\subset \mathcal{H}$ be a subset. Let $\{x_n\}\subset\mathcal{H}$
satisfies the following property: $$||x_{n+1}-x||\leq||x_n-x||$$ holds for
all $x \in C$. Show that $\{x_n\}$ has at most one weak cluster point in
$C$.
I tried to use Mazur's theorem to find some convex combination of
$\{x_n\}$ making the weak convergence into strong one, but then the
contraction property does not hold anyway. Though it is an easy
observation that $\{||x_n-x||\}$ is convergent sequence for any $\forall x
\in C$, I had no idea of whether this may be of help or not.
The problem goes as follows: Let $\mathcal{H}$ be real Hilbert space,
$C\subset \mathcal{H}$ be a subset. Let $\{x_n\}\subset\mathcal{H}$
satisfies the following property: $$||x_{n+1}-x||\leq||x_n-x||$$ holds for
all $x \in C$. Show that $\{x_n\}$ has at most one weak cluster point in
$C$.
I tried to use Mazur's theorem to find some convex combination of
$\{x_n\}$ making the weak convergence into strong one, but then the
contraction property does not hold anyway. Though it is an easy
observation that $\{||x_n-x||\}$ is convergent sequence for any $\forall x
\in C$, I had no idea of whether this may be of help or not.
Monday, 19 August 2013
Comparing large text fiiles
Comparing large text fiiles
I have two files which are in GB I want to compare them for the
differences. How can i do it efficiently? I cant go for UNIX commands
because my files are too large(15-50 GB)
Can i use hadoop like tools for it?
Thanks and Regards
I have two files which are in GB I want to compare them for the
differences. How can i do it efficiently? I cant go for UNIX commands
because my files are too large(15-50 GB)
Can i use hadoop like tools for it?
Thanks and Regards
python sys.path versus code hack
python sys.path versus code hack
in distributing some python from an automation-orchestration host to a
remote-client and a remote-server I found that hacking on the path is
better than moving modules. However, this did not click well with another
dev and we had interference. I chose a bad hack, he chose another perhaps
equivalent hack. I think now both are wrong:
hack #1:
# on remote systems the dir is flat, on local automation host it is less
flat!
try:
from process import call_process
except:
from common.process import call_process
hack #2
# in deployment steps
ssh qa$host
mkdir common
touch common/__init__.py
cp common/process.py $HOST:common/process.py
I think the better thing would be to leave it as a PYTHONPATH or syspath
solution:
add_path( TEST_ROOT+'/common')
from process import call_process
Constructive perspectives welcome! /Mike
in distributing some python from an automation-orchestration host to a
remote-client and a remote-server I found that hacking on the path is
better than moving modules. However, this did not click well with another
dev and we had interference. I chose a bad hack, he chose another perhaps
equivalent hack. I think now both are wrong:
hack #1:
# on remote systems the dir is flat, on local automation host it is less
flat!
try:
from process import call_process
except:
from common.process import call_process
hack #2
# in deployment steps
ssh qa$host
mkdir common
touch common/__init__.py
cp common/process.py $HOST:common/process.py
I think the better thing would be to leave it as a PYTHONPATH or syspath
solution:
add_path( TEST_ROOT+'/common')
from process import call_process
Constructive perspectives welcome! /Mike
specializing a template on bool + integral + floating-point return types
specializing a template on bool + integral + floating-point return types
I'd like to write a function template which returns a random variable of
various types (bool, char, short, int, float, double, along with unsigned
versions of these).
I couldn't see how to do this using the latest C++11 standard library,
since I need to use either uniform_int_distribution or
uniform_real_distribution. I thought I could specialize the template:
template<typename T>
T randomPrimitive() { std::uniform_int_distribution<T> dst; std::mt19937
rng; return dst(rng); }
template<>
bool randomPrimitive() { std::uniform_int_distribution<char> dst;
std::mt19937 rng; return dst(rng) >= 0 ? true : false; }
template<typename T>
typename std::enable_if<std::is_floating_point<T>::value, T>::type
randomPrimitive() { std::uniform_real_distribution<T> dst; std::mt19937
rng; return dst(rng); }
Under Visual Studio 2012 Update 3, this gives:
error C2668: '`anonymous-namespace'::randomPrimitive' : ambiguous call to
overloaded function
Is there a way to specialize a function template so I can write three
different implementations for bool, other integral types, and
floating-point types?
I'd like to write a function template which returns a random variable of
various types (bool, char, short, int, float, double, along with unsigned
versions of these).
I couldn't see how to do this using the latest C++11 standard library,
since I need to use either uniform_int_distribution or
uniform_real_distribution. I thought I could specialize the template:
template<typename T>
T randomPrimitive() { std::uniform_int_distribution<T> dst; std::mt19937
rng; return dst(rng); }
template<>
bool randomPrimitive() { std::uniform_int_distribution<char> dst;
std::mt19937 rng; return dst(rng) >= 0 ? true : false; }
template<typename T>
typename std::enable_if<std::is_floating_point<T>::value, T>::type
randomPrimitive() { std::uniform_real_distribution<T> dst; std::mt19937
rng; return dst(rng); }
Under Visual Studio 2012 Update 3, this gives:
error C2668: '`anonymous-namespace'::randomPrimitive' : ambiguous call to
overloaded function
Is there a way to specialize a function template so I can write three
different implementations for bool, other integral types, and
floating-point types?
Subscribe to:
Posts (Atom)