Having trouble starting a gnome session over ssh
I have a headless box running 12.04 and I want to pipe a gnome session
over x11. I connect via ssh -X -l name -p port 192.168.1.14, then run
gnome-session
This prints out without opening a window:
GNOME_KEYRING_CONTROL=/tmp/keyring-5cLMRd
SSH_AUTH_SOCK=/tmp/keyring-5cLMRd/ssh
GNOME_KEYRING_PID=2534
GNOME_KEYRING_CONTROL=/tmp/keyring-5cLMRd
SSH_AUTH_SOCK=/tmp/keyring-5cLMRd/ssh
GPG_AGENT_INFO=/tmp/keyring-5cLMRd/gpg:0:1
GNOME_KEYRING_CONTROL=/tmp/keyring-5cLMRd
SSH_AUTH_SOCK=/tmp/keyring-5cLMRd/ssh
GPG_AGENT_INFO=/tmp/keyring-5cLMRd/gpg:0:1
GNOME_KEYRING_CONTROL=/tmp/keyring-5cLMRd
SSH_AUTH_SOCK=/tmp/keyring-5cLMRd/ssh
GPG_AGENT_INFO=/tmp/keyring-5cLMRd/gpg:0:1
** (gnome-settings-daemon:2537): WARNING **: You can only run one
xsettings manager at a time; exiting
** (gnome-settings-daemon:2537): WARNING **: Unable to start xsettings
manager: Could not initialize xsettings manager.
[1380764298,000,xklavier.c:xkl_engine_start_listen/] The backend does
not require manual layout management - but it is provided by the
application
compiz (core) - Error: Screen 0 on display "localhost:10.0" already has a
window manager; try using the --replace option to replace the current
window manager.
(bluetooth-applet:2549): Bluetooth-WARNING **: Could not open RFKILL
control device, please verify your installation
Initializing nautilus-gdu extension
** (nm-applet:2551): WARNING **: Could not initialize NMClient
/org/freedesktop/NetworkManager: Rejected send message, 2 matched rules;
type="method_call", sender=":1.98" (uid=1000 pid=2551 comm="nm-applet ")
interface="org.freedesktop.DBus.Properties" member="GetAll" error
name="(unset)" requested_reply="0"
destination="org.freedesktop.NetworkManager" (uid=0 pid=872
comm="NetworkManager ")
** Message: applet now removed from the notification area
** Message: using fallback from indicator to GtkStatusIcon
(gnome-settings-daemon:2537): keyboard-plugin-WARNING **: Failed to set
the keyboard layouts:
GDBus.Error:org.freedesktop.Accounts.Error.PermissionDenied: Not
authorized
** (gnome-settings-daemon:2537): WARNING **: Failed to connect context:
Connection refused
(gnome-settings-daemon:2537): clipboard-plugin-WARNING **: Clipboard
manager is already running.
(gnome-settings-daemon:2537): color-plugin-WARNING **: failed to get edid:
unable to get EDID for output
(gnome-settings-daemon:2537): color-plugin-WARNING **: failed to create
device: GDBus.Error:org.freedesktop.ColorManager.Failed: failed to obtain
org.freedesktop.color-manager.create-device auth
(gnome-settings-daemon:2537): color-plugin-WARNING **:
GDBus.Error:org.freedesktop.ColorManager.Failed: failed to obtain
org.freedesktop.color-manager.create-profile auth
Shutting down nautilus-gdu extension
** (gnome-settings-daemon:2537): WARNING **: Failed to connect context:
Connection refused
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
** (update-notifier:2635): WARNING **: already running?
I'm not really sure where to go from here, all solutions I've found were
in regards to weird edge cases that don't apply to me.
Wednesday, 2 October 2013
does inherited class can access base class
does inherited class can access base class
If I have ThumbPhoto entity which inherits Photo entity and Photo entity
inherits Entity<int> is it enough to use
public class ThumbnailPhoto : Photo
or should I use
public class ThumbnailPhoto : Photo, Entity<int>
If I have ThumbPhoto entity which inherits Photo entity and Photo entity
inherits Entity<int> is it enough to use
public class ThumbnailPhoto : Photo
or should I use
public class ThumbnailPhoto : Photo, Entity<int>
phpspec. checking key for array
phpspec. checking key for array
Exist some class:
class A{
protected $options;
public function setDefaults($defaults){
$this->options=$defaults;
}
public function getOptions(){
return $this->options;
}
}
And other class:
class B{
public function setDefaultOptions(A $options){
$options->setDefaults('foo'=>'bar')
}
}
Uses:
$a=new A();
$b=new B();
$b->setDefaultsOptions(a);
How I can check in spec for B that $a->options['foo'] is set?
Exist some class:
class A{
protected $options;
public function setDefaults($defaults){
$this->options=$defaults;
}
public function getOptions(){
return $this->options;
}
}
And other class:
class B{
public function setDefaultOptions(A $options){
$options->setDefaults('foo'=>'bar')
}
}
Uses:
$a=new A();
$b=new B();
$b->setDefaultsOptions(a);
How I can check in spec for B that $a->options['foo'] is set?
#EANF#
#EANF#
am just a newbie in PHP and i am trying to create a forgot password
function i do have this following code
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("inventory", $con);
$a=$_POST['password'];
$b=$_POST['newpassword'];
$c=$_POST['retypepassword'];
$result = mysql_query("SELECT * from admins " );
while($row = mysql_fetch_array($result))
{
$password = $row['password'] ;
}
if($_POST['retypepassword'] != $b){
echo "<script type='text/javascript'>alert('Password Not
match');
window.location.href='forgotpass.php?id=0';
</script>";
exit();
}
if($_POST['password'] != $password){
echo "<script type='text/javascript'>alert('You
Provide wrong Password');
window.location.href='forgotpass.php?id=0';
</script>";
exit();
}
else {
mysql_query("UPDATE admins SET password = '$b'
WHERE password = '$a' ");
header("location: index.php?id=0");
};
?>
now, the problem is i can only update the last account inserted in
database. let say for example i have this following account from my
database, and i would like to change "greeg" there is no any problem with
this. BUT if i change "gejel" ("first value in database") it show me this
"You Provide wrong Password" i don't know why i always get here. i guess
there is something wrong with "WHERE" ? pls help help help me :D
id |password |
1 | gejel |
2 | greeg |
am just a newbie in PHP and i am trying to create a forgot password
function i do have this following code
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("inventory", $con);
$a=$_POST['password'];
$b=$_POST['newpassword'];
$c=$_POST['retypepassword'];
$result = mysql_query("SELECT * from admins " );
while($row = mysql_fetch_array($result))
{
$password = $row['password'] ;
}
if($_POST['retypepassword'] != $b){
echo "<script type='text/javascript'>alert('Password Not
match');
window.location.href='forgotpass.php?id=0';
</script>";
exit();
}
if($_POST['password'] != $password){
echo "<script type='text/javascript'>alert('You
Provide wrong Password');
window.location.href='forgotpass.php?id=0';
</script>";
exit();
}
else {
mysql_query("UPDATE admins SET password = '$b'
WHERE password = '$a' ");
header("location: index.php?id=0");
};
?>
now, the problem is i can only update the last account inserted in
database. let say for example i have this following account from my
database, and i would like to change "greeg" there is no any problem with
this. BUT if i change "gejel" ("first value in database") it show me this
"You Provide wrong Password" i don't know why i always get here. i guess
there is something wrong with "WHERE" ? pls help help help me :D
id |password |
1 | gejel |
2 | greeg |
Tuesday, 1 October 2013
how to automatically run a macro at a given hour
how to automatically run a macro at a given hour
I'm wondering if anyone here has experience with setting up a macro to run
automatically at a given time... lets say 5AM.
There are some posts on mr excel but most of what I find is simply OnTime
"x time" based code, and I'm unsure how this executes.
Do you have to open the sheet, run the macro and then expect it to run at
the given time? Once it is open, will it run every day at that time or can
you run it whenever?
I'm wondering if anyone here has experience with setting up a macro to run
automatically at a given time... lets say 5AM.
There are some posts on mr excel but most of what I find is simply OnTime
"x time" based code, and I'm unsure how this executes.
Do you have to open the sheet, run the macro and then expect it to run at
the given time? Once it is open, will it run every day at that time or can
you run it whenever?
Adding a legend to PyPlot in Matplotlib
Adding a legend to PyPlot in Matplotlib
TL;DR -> How can one create a legend for a line graph in Matplotlib's
PyPlot without creating any extra variables?
Please consider the graphing script below:
if __name__ == '__main__':
PyPlot.plot(total_lengths, sort_times_bubble, 'b-',
total_lengths, sort_times_ins, 'r-',
total_lengths, sort_times_merge_r, 'g+',
total_lengths, sort_times_merge_i, 'p-', )
PyPlot.title("Combined Statistics")
PyPlot.xlabel("Length of list (number)")
PyPlot.ylabel("Time taken (seconds)")
PyPlot.show()
As you can see, this is a very basic use of matplotlib's PyPlot. This
ideally generates a graph like the one below:
Nothing special, I know. However, it is unclear as to what data is being
plotted where (I'm trying to plot the data of some sorting algorithms,
length against time taken, and I'd like to make sure people know which
line is which). Thus, I need a legend, however, taking a look at the
following example below(from the official site):
ax = subplot(1,1,1)
p1, = ax.plot([1,2,3], label="line 1")
p2, = ax.plot([3,2,1], label="line 2")
p3, = ax.plot([2,3,1], label="line 3")
handles, labels = ax.get_legend_handles_labels()
# reverse the order
ax.legend(handles[::-1], labels[::-1])
# or sort them by labels
import operator
hl = sorted(zip(handles, labels),
key=operator.itemgetter(1))
handles2, labels2 = zip(*hl)
ax.legend(handles2, labels2)
You will see that I need to create an extra variable ax. How can I add a
legend to my graph without having to create this extra variable and
retaining the simplicity of my current script.
TL;DR -> How can one create a legend for a line graph in Matplotlib's
PyPlot without creating any extra variables?
Please consider the graphing script below:
if __name__ == '__main__':
PyPlot.plot(total_lengths, sort_times_bubble, 'b-',
total_lengths, sort_times_ins, 'r-',
total_lengths, sort_times_merge_r, 'g+',
total_lengths, sort_times_merge_i, 'p-', )
PyPlot.title("Combined Statistics")
PyPlot.xlabel("Length of list (number)")
PyPlot.ylabel("Time taken (seconds)")
PyPlot.show()
As you can see, this is a very basic use of matplotlib's PyPlot. This
ideally generates a graph like the one below:
Nothing special, I know. However, it is unclear as to what data is being
plotted where (I'm trying to plot the data of some sorting algorithms,
length against time taken, and I'd like to make sure people know which
line is which). Thus, I need a legend, however, taking a look at the
following example below(from the official site):
ax = subplot(1,1,1)
p1, = ax.plot([1,2,3], label="line 1")
p2, = ax.plot([3,2,1], label="line 2")
p3, = ax.plot([2,3,1], label="line 3")
handles, labels = ax.get_legend_handles_labels()
# reverse the order
ax.legend(handles[::-1], labels[::-1])
# or sort them by labels
import operator
hl = sorted(zip(handles, labels),
key=operator.itemgetter(1))
handles2, labels2 = zip(*hl)
ax.legend(handles2, labels2)
You will see that I need to create an extra variable ax. How can I add a
legend to my graph without having to create this extra variable and
retaining the simplicity of my current script.
Representing a strange number as a fraction
Representing a strange number as a fraction
Can this decimal with special patterns be expressed as a fraction? Is it a
rational number?
$$0.101001000100001000001...$$
Where the number of zeros after every 1 is increased by 1.
Ty.
Can this decimal with special patterns be expressed as a fraction? Is it a
rational number?
$$0.101001000100001000001...$$
Where the number of zeros after every 1 is increased by 1.
Ty.
Copy latest created directory
Copy latest created directory
I would like to make a second backup from the latest created backup. So I
tried the shell command:
last='ls -tr | tail -1'
cp -r /path/.../"$last" /path/.../backup/
but it copies a randome backup.
It is working perfect with .zip and .tar files but not with folders as I
need it here.
I googled for a solution but couldn´t find anything related to this, I
hope you can help me.
It would also be possible to use the name of directory which is for example:
2013-09-27-05-22-45
I would like to make a second backup from the latest created backup. So I
tried the shell command:
last='ls -tr | tail -1'
cp -r /path/.../"$last" /path/.../backup/
but it copies a randome backup.
It is working perfect with .zip and .tar files but not with folders as I
need it here.
I googled for a solution but couldn´t find anything related to this, I
hope you can help me.
It would also be possible to use the name of directory which is for example:
2013-09-27-05-22-45
Monday, 30 September 2013
How to get virtualized SR-IOV Infiniband interface UP?
How to get virtualized SR-IOV Infiniband interface UP?
I've spent several days on this now and I've managed to get SR-IOV working
with the Mellanox Infiniband card using the latest firmware.
The Virtual Functions appear in Dom0 as
06:00.1 Network controller: Mellanox Technologies MT27500 Family
[ConnectX-3 Virtual Function] 06:00.2 Network controller: Mellanox
Technologies MT27500 Family [ConnectX-3 Virtual Function] 06:00.3 Network
controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual
Function] 06:00.4 Network controller: Mellanox Technologies MT27500 Family
[ConnectX-3 Virtual Function]
I've then detached 06:00.1 from Dom0 and assigned it to xen-pciback.
I've passed this into a Xen test domain.
lspci inside the test DomU shows:
00:01.1 Network controller: Mellanox Technologies MT27500 Family
[ConnectX-3 Virtual Function]
I have the following modules loaded in DomU
mlx4_ib
rdma_ucm
ib_umad
ib_uverbs
ib_ipoib
dmesg output for mlx4 drivers shows:
[ 11.956787] mlx4_core: Mellanox ConnectX core driver v1.1 (Dec, 2011)
[ 11.956789] mlx4_core: Initializing 0000:00:01.1
[ 11.956859] mlx4_core 0000:00:01.1: enabling device (0000 -> 0002)
[ 11.957242] mlx4_core 0000:00:01.1: Xen PCI mapped GSI0 to IRQ30
[ 11.957581] mlx4_core 0000:00:01.1: Detected virtual function - running
in slave mode
[ 11.957606] mlx4_core 0000:00:01.1: Sending reset
[ 11.957699] mlx4_core 0000:00:01.1: Sending vhcr0
[ 11.976090] mlx4_core 0000:00:01.1: HCA minimum page size:512
[ 11.976672] mlx4_core 0000:00:01.1: Timestamping is not supported in
slave mode.
[ 12.068079] <mlx4_ib> mlx4_ib_add: mlx4_ib: Mellanox ConnectX
InfiniBand driver v1.0 (April 4, 2008)
[ 12.184072] mlx4_core 0000:00:01.1: mlx4_ib: multi-function enabled
[ 12.184075] mlx4_core 0000:00:01.1: mlx4_ib: operating in qp1 tunnel mode
I've even got the ib0 device appearing.
ib0 Link encap:UNSPEC HWaddr
80-00-05-49-FE-80-00-00-00-00-00-00-00-00-00-00
inet addr:10.10.10.10 Bcast:10.10.10.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:2044 Metric:1
RX packets:117303 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:256
RX bytes:6576132 (6.5 MB) TX bytes:0 (0.0 B)
I can even locally ping 10.10.10.10.
However, those pings aren't sent out on the infiniband fabric.
It appears to be because the link is down. ibstat shows:
CA 'mlx4_0'
CA type: MT4100
Number of ports: 1
Firmware version: 2.30.3000
Hardware version: 0
Node GUID: 0x001405005ef41f25
System image GUID: 0x002590ffff175727
Port 1:
State: Down
Physical state: LinkUp
Rate: 10
Base lid: 9
LMC: 0
SM lid: 1
Capability mask: 0x02514868
Port GUID: 0x0000000000000000
How do I get it UP? the domU link is UP but not the VF one?
I've spent several days on this now and I've managed to get SR-IOV working
with the Mellanox Infiniband card using the latest firmware.
The Virtual Functions appear in Dom0 as
06:00.1 Network controller: Mellanox Technologies MT27500 Family
[ConnectX-3 Virtual Function] 06:00.2 Network controller: Mellanox
Technologies MT27500 Family [ConnectX-3 Virtual Function] 06:00.3 Network
controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual
Function] 06:00.4 Network controller: Mellanox Technologies MT27500 Family
[ConnectX-3 Virtual Function]
I've then detached 06:00.1 from Dom0 and assigned it to xen-pciback.
I've passed this into a Xen test domain.
lspci inside the test DomU shows:
00:01.1 Network controller: Mellanox Technologies MT27500 Family
[ConnectX-3 Virtual Function]
I have the following modules loaded in DomU
mlx4_ib
rdma_ucm
ib_umad
ib_uverbs
ib_ipoib
dmesg output for mlx4 drivers shows:
[ 11.956787] mlx4_core: Mellanox ConnectX core driver v1.1 (Dec, 2011)
[ 11.956789] mlx4_core: Initializing 0000:00:01.1
[ 11.956859] mlx4_core 0000:00:01.1: enabling device (0000 -> 0002)
[ 11.957242] mlx4_core 0000:00:01.1: Xen PCI mapped GSI0 to IRQ30
[ 11.957581] mlx4_core 0000:00:01.1: Detected virtual function - running
in slave mode
[ 11.957606] mlx4_core 0000:00:01.1: Sending reset
[ 11.957699] mlx4_core 0000:00:01.1: Sending vhcr0
[ 11.976090] mlx4_core 0000:00:01.1: HCA minimum page size:512
[ 11.976672] mlx4_core 0000:00:01.1: Timestamping is not supported in
slave mode.
[ 12.068079] <mlx4_ib> mlx4_ib_add: mlx4_ib: Mellanox ConnectX
InfiniBand driver v1.0 (April 4, 2008)
[ 12.184072] mlx4_core 0000:00:01.1: mlx4_ib: multi-function enabled
[ 12.184075] mlx4_core 0000:00:01.1: mlx4_ib: operating in qp1 tunnel mode
I've even got the ib0 device appearing.
ib0 Link encap:UNSPEC HWaddr
80-00-05-49-FE-80-00-00-00-00-00-00-00-00-00-00
inet addr:10.10.10.10 Bcast:10.10.10.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:2044 Metric:1
RX packets:117303 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:256
RX bytes:6576132 (6.5 MB) TX bytes:0 (0.0 B)
I can even locally ping 10.10.10.10.
However, those pings aren't sent out on the infiniband fabric.
It appears to be because the link is down. ibstat shows:
CA 'mlx4_0'
CA type: MT4100
Number of ports: 1
Firmware version: 2.30.3000
Hardware version: 0
Node GUID: 0x001405005ef41f25
System image GUID: 0x002590ffff175727
Port 1:
State: Down
Physical state: LinkUp
Rate: 10
Base lid: 9
LMC: 0
SM lid: 1
Capability mask: 0x02514868
Port GUID: 0x0000000000000000
How do I get it UP? the domU link is UP but not the VF one?
Weird consistent EC2 CPU spikes
Weird consistent EC2 CPU spikes
One of our m1.small EC2 instances, running a Node.js web server, regularly
gets some CPU spikes. It doesn't seem to matter what the peak CPU reaches,
but whenever our traffic approaches the max for the day, it spikes, and
the same happens when it starts to decline.
This happens when it approaches 80% on a weekday, or even if it appraoches
40% at the weekend.
Does anyone have any idea what could be causing this? Or how I could debug
this and stop it from happening? I've checked the cron jobs and theres
nothing that would cause this.
I've attached a graph to help me explain the scenario.
Thanks.
One of our m1.small EC2 instances, running a Node.js web server, regularly
gets some CPU spikes. It doesn't seem to matter what the peak CPU reaches,
but whenever our traffic approaches the max for the day, it spikes, and
the same happens when it starts to decline.
This happens when it approaches 80% on a weekday, or even if it appraoches
40% at the weekend.
Does anyone have any idea what could be causing this? Or how I could debug
this and stop it from happening? I've checked the cron jobs and theres
nothing that would cause this.
I've attached a graph to help me explain the scenario.
Thanks.
Users in hawt.io in an standalone java app
Users in hawt.io in an standalone java app
I would like to know how can I have users for hawt.io when using it in an
standalone java app. I believe that you need to define a realm like
containers do, but is there any guide or easy way to do this? I just want
to protect my hawt.io instance with user and password.
I would like to know how can I have users for hawt.io when using it in an
standalone java app. I believe that you need to define a realm like
containers do, but is there any guide or easy way to do this? I just want
to protect my hawt.io instance with user and password.
XSLT string replace, multiple variables
XSLT string replace, multiple variables
I know there is already a question out there about replacing strings in
XSLT, but I need a conditional statement to replace one string with
multiple variables.
Here is my code:
<xsl:template name="section-01">
<xsl:call-template name="table-open"/>
<xsl:text disable-output-escaping="yes"><table
style="text-align=center;"></xsl:text>
<xsl:call-template name="display-gen">
<xsl:with-param name="value" select="./z30-collection"/>
<xsl:with-param name="width" select="'30%'"/>
</xsl:call-template>
<xsl:call-template name="display-gen">
<xsl:with-param name="value" select="./call-no-piece-01"/>
<xsl:with-param name="width" select="'30%'"/>
</xsl:call-template>
<xsl:call-template name="table-close"/>
</xsl:template>
I need a statement to replace "./z30-collection"
If ./z30-collection = "Deposit" replace with "DEP"
if ./z30-collection = "General" replace with "GEN"
if ./z30-collection = "Storage" replace with "STORE"
etc...
Any help would be greatly appreciated!
I know there is already a question out there about replacing strings in
XSLT, but I need a conditional statement to replace one string with
multiple variables.
Here is my code:
<xsl:template name="section-01">
<xsl:call-template name="table-open"/>
<xsl:text disable-output-escaping="yes"><table
style="text-align=center;"></xsl:text>
<xsl:call-template name="display-gen">
<xsl:with-param name="value" select="./z30-collection"/>
<xsl:with-param name="width" select="'30%'"/>
</xsl:call-template>
<xsl:call-template name="display-gen">
<xsl:with-param name="value" select="./call-no-piece-01"/>
<xsl:with-param name="width" select="'30%'"/>
</xsl:call-template>
<xsl:call-template name="table-close"/>
</xsl:template>
I need a statement to replace "./z30-collection"
If ./z30-collection = "Deposit" replace with "DEP"
if ./z30-collection = "General" replace with "GEN"
if ./z30-collection = "Storage" replace with "STORE"
etc...
Any help would be greatly appreciated!
Sunday, 29 September 2013
PageViewer NullPointer on Adding views
PageViewer NullPointer on Adding views
Hello fellow programmers.
Just a glitch here as I am new to these Pageviewer.
Im following this tutorial Android View Pager
and having quite issue
Ive change the required parameters of the Adapter and just past the cursor
(which im quite sure that has 14 counts)
Code are as follows for my Adapter:
public class PagerAdapterInVenue extends PagerAdapter{
private LayoutInflater inflater;
private Context context;
private Cursor cursorFeatured;
public PagerAdapterInVenue(Cursor cursorFeatured, Context context) {
this.cursorFeatured = cursorFeatured;
this.context = context;
}
@Override
public int getCount() {
return cursorFeatured.getCount();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == ((RelativeLayout) object);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
// Declare Variables
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.viewpager_item, container,
false);
cursorFeatured.moveToNext();
ImageView fullImage = (ImageView) itemView.findViewById(R.id.imageFull);
if (cursorFeatured.getString(7).toString().equals("")){
}
else
{
ImageLoaderUtil.getInstance(context).displayImage(cursorFeatured.getString(7).toString(),
fullImage);
}
((ViewPager) container).addView(itemView);
return itemView;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
// Remove viewpager_item.xml from ViewPager
((ViewPager) container).removeView((RelativeLayout) object);
}
}
binding it to my activity was
pagerAdapter = new PagerAdapterInVenue(cursorFeatured, MainPage.this);
pagerFeatured.setAdapter(pagerAdapter);
But still Im getting a weird error saying on my Logcat
09-30 09:53:24.650: E/AndroidRuntime(2268): FATAL EXCEPTION: main
09-30 09:53:24.650: E/AndroidRuntime(2268): java.lang.NullPointerException
09-30 09:53:24.650: E/AndroidRuntime(2268): at
com.example.androidinvenue.PagerAdapterInVenue.instantiateItem(PagerAdapterInVenue.java:48)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.support.v4.view.ViewPager.addNewItem(ViewPager.java:829)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.support.v4.view.ViewPager.populate(ViewPager.java:1044)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.support.v4.view.ViewPager.populate(ViewPager.java:911)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1432)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.view.View.measure(View.java:15518)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.view.View.measure(View.java:15518)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
My XML is
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:padding="10dp" >
<ImageView
android:id="@+id/imageFull"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:background="#000000"
android:padding="1dp" />
</RelativeLayout>
Sorry for posting long codes
Thanks in advance
Hello fellow programmers.
Just a glitch here as I am new to these Pageviewer.
Im following this tutorial Android View Pager
and having quite issue
Ive change the required parameters of the Adapter and just past the cursor
(which im quite sure that has 14 counts)
Code are as follows for my Adapter:
public class PagerAdapterInVenue extends PagerAdapter{
private LayoutInflater inflater;
private Context context;
private Cursor cursorFeatured;
public PagerAdapterInVenue(Cursor cursorFeatured, Context context) {
this.cursorFeatured = cursorFeatured;
this.context = context;
}
@Override
public int getCount() {
return cursorFeatured.getCount();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == ((RelativeLayout) object);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
// Declare Variables
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.viewpager_item, container,
false);
cursorFeatured.moveToNext();
ImageView fullImage = (ImageView) itemView.findViewById(R.id.imageFull);
if (cursorFeatured.getString(7).toString().equals("")){
}
else
{
ImageLoaderUtil.getInstance(context).displayImage(cursorFeatured.getString(7).toString(),
fullImage);
}
((ViewPager) container).addView(itemView);
return itemView;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
// Remove viewpager_item.xml from ViewPager
((ViewPager) container).removeView((RelativeLayout) object);
}
}
binding it to my activity was
pagerAdapter = new PagerAdapterInVenue(cursorFeatured, MainPage.this);
pagerFeatured.setAdapter(pagerAdapter);
But still Im getting a weird error saying on my Logcat
09-30 09:53:24.650: E/AndroidRuntime(2268): FATAL EXCEPTION: main
09-30 09:53:24.650: E/AndroidRuntime(2268): java.lang.NullPointerException
09-30 09:53:24.650: E/AndroidRuntime(2268): at
com.example.androidinvenue.PagerAdapterInVenue.instantiateItem(PagerAdapterInVenue.java:48)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.support.v4.view.ViewPager.addNewItem(ViewPager.java:829)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.support.v4.view.ViewPager.populate(ViewPager.java:1044)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.support.v4.view.ViewPager.populate(ViewPager.java:911)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1432)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.view.View.measure(View.java:15518)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.view.View.measure(View.java:15518)
09-30 09:53:24.650: E/AndroidRuntime(2268): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
My XML is
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:padding="10dp" >
<ImageView
android:id="@+id/imageFull"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:background="#000000"
android:padding="1dp" />
</RelativeLayout>
Sorry for posting long codes
Thanks in advance
I expect the program prints the numbers 0 to 99, but when I run the code I see 100 lines of 99
I expect the program prints the numbers 0 to 99, but when I run the code I
see 100 lines of 99
I have a class foo:
class foo{
public:
int i;
};
And a class bar:
class bar{
public:
foo* foo_;
};
And a code similar to:
int i=0;
vector<bar*> fs;
while(i<100){
foo f;
f.i = i;
bar* b = new bar;
b->foo_ = &f;
fs.push_back(b);
i++;
}
I expect that each bar->foo_ refer to a different foo, so when i have:
for(i=0;i<fs.size();i++){
cout << (fs[i]->foo_->i) << "\n";
}
I expect the program prints the numbers 0 to 99, but when i run the code i
see 100 lines of 99!!
why all pointers refers to the last object?
see 100 lines of 99
I have a class foo:
class foo{
public:
int i;
};
And a class bar:
class bar{
public:
foo* foo_;
};
And a code similar to:
int i=0;
vector<bar*> fs;
while(i<100){
foo f;
f.i = i;
bar* b = new bar;
b->foo_ = &f;
fs.push_back(b);
i++;
}
I expect that each bar->foo_ refer to a different foo, so when i have:
for(i=0;i<fs.size();i++){
cout << (fs[i]->foo_->i) << "\n";
}
I expect the program prints the numbers 0 to 99, but when i run the code i
see 100 lines of 99!!
why all pointers refers to the last object?
Transparent hierarchical data frames in JavaScript
Transparent hierarchical data frames in JavaScript
Not sure about terminology.
I have a JavaScript "object" with some data:
var parent = { foo: 42, bar: 2.71, baz: 3.14 };
I need to create another JavaScript object that will provide access to the
parent object, while supporting local overrides for parent's entries:
var child = extend(parent, { foo: 1, quo: 2 });
child.bar = 3;
parent.qux = 4;
assert(parent.foo === 42);
assert(child.foo === 1);
assert(parent.bar === 2.71);
assert(child.bar === 3);
assert(parent.baz === 3.14);
assert(child.baz === 3.14);
assert(parent.quo === undefined);
assert(child.quo === 2);
assert(parent.qux === 4);
assert(child.qux === 4);
// NB: I don't care about iteration on these objects.
I need the solution to be as low-overhead as possible while being
cross-browser enough. Copying parent values to the child is too much
overhead.
That is, I'm looking for something akin to Lua metatable chains, but in
JavaScript.
I was reading about [[Prototype]] chains. It looks like the way to go, but
I did not figure out a lightweight way to use them here yet. (__proto__,
as I understand it, is not cross-browser enough.)
Any clues?
Not sure about terminology.
I have a JavaScript "object" with some data:
var parent = { foo: 42, bar: 2.71, baz: 3.14 };
I need to create another JavaScript object that will provide access to the
parent object, while supporting local overrides for parent's entries:
var child = extend(parent, { foo: 1, quo: 2 });
child.bar = 3;
parent.qux = 4;
assert(parent.foo === 42);
assert(child.foo === 1);
assert(parent.bar === 2.71);
assert(child.bar === 3);
assert(parent.baz === 3.14);
assert(child.baz === 3.14);
assert(parent.quo === undefined);
assert(child.quo === 2);
assert(parent.qux === 4);
assert(child.qux === 4);
// NB: I don't care about iteration on these objects.
I need the solution to be as low-overhead as possible while being
cross-browser enough. Copying parent values to the child is too much
overhead.
That is, I'm looking for something akin to Lua metatable chains, but in
JavaScript.
I was reading about [[Prototype]] chains. It looks like the way to go, but
I did not figure out a lightweight way to use them here yet. (__proto__,
as I understand it, is not cross-browser enough.)
Any clues?
SQL Server Join based on max value
SQL Server Join based on max value
I was wondering how I can left join a table to itself or use a case
statement to assign max values within a view. Say I have the following
table:
Lastname Firstname Filename
Smith John 001
Smith John 002
Smith Anna 003
Smith Anna 004
I want to create a view that lists all the values but also has another
column that displays whether the current row is the max row, such as:
Lastname Firstname Filename Max_Filename
Smith John 001 NULL
Smith John 002 002
Smith Anna 003 NULL
Smith Anna 004 NULL
Is this possible? I have tried the following query:
SELECT Lastname, Firstname, Filename, CASE WHEN Filename = MAX(FileName)
THEN Filename ELSE NULL END AS Max_Filename
but I am told that Lastname is not in the group by clause. However, if I
group on Lastname, firstname, filename, then everything in the
max_filename is the same as filename.
Can you please help me understand what I'm doing wrong and how to make
this query work?
Thanks in advance!
I was wondering how I can left join a table to itself or use a case
statement to assign max values within a view. Say I have the following
table:
Lastname Firstname Filename
Smith John 001
Smith John 002
Smith Anna 003
Smith Anna 004
I want to create a view that lists all the values but also has another
column that displays whether the current row is the max row, such as:
Lastname Firstname Filename Max_Filename
Smith John 001 NULL
Smith John 002 002
Smith Anna 003 NULL
Smith Anna 004 NULL
Is this possible? I have tried the following query:
SELECT Lastname, Firstname, Filename, CASE WHEN Filename = MAX(FileName)
THEN Filename ELSE NULL END AS Max_Filename
but I am told that Lastname is not in the group by clause. However, if I
group on Lastname, firstname, filename, then everything in the
max_filename is the same as filename.
Can you please help me understand what I'm doing wrong and how to make
this query work?
Thanks in advance!
Saturday, 28 September 2013
How to save the state of a iPhone Switch and print it out?
How to save the state of a iPhone Switch and print it out?
I have a switch on my ViewController, and whenever I press the save
button, I want to use NSLog to print out if the switch is On/Off.
My question is, What data type saves the state of a switch? And how would
I print out that variable with the state?
EDIT:
If it was a DatePicker, it would be
@property (nonatomic, strong) NSDate *pickerDate;
I need the Switch version of this. NSSwitch doesn't seem to work.
I have a switch on my ViewController, and whenever I press the save
button, I want to use NSLog to print out if the switch is On/Off.
My question is, What data type saves the state of a switch? And how would
I print out that variable with the state?
EDIT:
If it was a DatePicker, it would be
@property (nonatomic, strong) NSDate *pickerDate;
I need the Switch version of this. NSSwitch doesn't seem to work.
css causing hyperlink to not work
css causing hyperlink to not work
I have a website that I have been working on and all the pages are working
fine except for some hyperlinks on my event registration. The first link
on the page would work and then the next one would not. I created a test
page that didn't have anything else on it except for the two links and the
same problem happened. It has to be something with the CSS because if I
use a blank master page that doesn't tie to my CSS then the links work.
However, I don't have trouble with the rest of my site and I only have one
master page and one CSS. Here is a link to the page. If someone can tell
me what the problem, I would greatly appreciate it. I have the same issue
in Chrome and IE. Browser doesn't seem to matter.
http://www.wmmpa.com/NewsEvents/event_regtest.aspx
I have a website that I have been working on and all the pages are working
fine except for some hyperlinks on my event registration. The first link
on the page would work and then the next one would not. I created a test
page that didn't have anything else on it except for the two links and the
same problem happened. It has to be something with the CSS because if I
use a blank master page that doesn't tie to my CSS then the links work.
However, I don't have trouble with the rest of my site and I only have one
master page and one CSS. Here is a link to the page. If someone can tell
me what the problem, I would greatly appreciate it. I have the same issue
in Chrome and IE. Browser doesn't seem to matter.
http://www.wmmpa.com/NewsEvents/event_regtest.aspx
Why can I cast implicitly an integer to a char in C
Why can I cast implicitly an integer to a char in C
I was wondering, why is casting implicitly from an integer to a char
possible in C ?
If for example :
int i = 2789;
printf("%c\n",i);
would give me a char back, because it would have truncated the bits
starting from the most significant ones. But usually you can't really cast
implicitly if it means you'll lose in precision so why can I do it here ?
I was wondering, why is casting implicitly from an integer to a char
possible in C ?
If for example :
int i = 2789;
printf("%c\n",i);
would give me a char back, because it would have truncated the bits
starting from the most significant ones. But usually you can't really cast
implicitly if it means you'll lose in precision so why can I do it here ?
R - ggplot - stat_contour not able to generate contour lines
R - ggplot - stat_contour not able to generate contour lines
I am trying to add contour lines via stat_contour() to my
ggplot/ggplot2-plot. Unfortunately, I can not give you the real data from
which point values should be evaluated. However, another easily
repreducably example behaves the same:
testPts <- data.frame(x=rep(seq(7.08, 7.14, by=0.005), 200))
testPts$y <- runif(length(testPts$x), 50.93, 50.96)
testPts$z <- sin(testPts$y * 500)
(ggplot(data=testPts, aes(x=x, y=y, z=z))
+ geom_point(aes(colour=z))
+ stat_contour()
)
This results in the following error message:
Error in if (nrow(layer_data) == 0) return() : argument is of length zero
In addition: Warning message:
Not possible to generate contour data
The example looks not different to others posted on stackoverflow or in
the official manual/tutorial to me, and it seeminlgy doesn't matter if I
provide more specifications to stat_contour.
Thank you for your ideas and advice!
I am trying to add contour lines via stat_contour() to my
ggplot/ggplot2-plot. Unfortunately, I can not give you the real data from
which point values should be evaluated. However, another easily
repreducably example behaves the same:
testPts <- data.frame(x=rep(seq(7.08, 7.14, by=0.005), 200))
testPts$y <- runif(length(testPts$x), 50.93, 50.96)
testPts$z <- sin(testPts$y * 500)
(ggplot(data=testPts, aes(x=x, y=y, z=z))
+ geom_point(aes(colour=z))
+ stat_contour()
)
This results in the following error message:
Error in if (nrow(layer_data) == 0) return() : argument is of length zero
In addition: Warning message:
Not possible to generate contour data
The example looks not different to others posted on stackoverflow or in
the official manual/tutorial to me, and it seeminlgy doesn't matter if I
provide more specifications to stat_contour.
Thank you for your ideas and advice!
Subscribe to:
Posts (Atom)