Will changing an events Time-Zone affect other people on shared events?
If I were to normalize an EKEvent 's startDate property using a
NSFormatter or by setting the time zone with
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"hh:mm a"];
[formatter setTimeZone:[NSTimeZone systemTimeZone]];
event.startDate = [formatter dateFromString:[NSString
stringWithFormat:@"%@", [event.startDate]]];
and I later make a change to that event requiring me to call
[self.event.eventStore saveEvent:currentEvent span:EKSpanThisEvent
commit:YES error:nil];
Would it override the time-zone on the server, causing issues for the
person (whom uses GCal) in another state that originally created that
shared calendar event, or is it just a local change?
Saturday, 31 August 2013
Printed page information within PDF file
Printed page information within PDF file
I just opened my PDF file using the default PDF reader on Ubuntu, and when
I tried to print it, the "Pages" box was already filled with "108-115". I
was surprised, because that's the page number that I printed from this
file last time, which was many days ago!
I wonder where the "last printed page information" is stored. Is it in the
PDF file itself, or is it somewhere else in the computer?
I just opened my PDF file using the default PDF reader on Ubuntu, and when
I tried to print it, the "Pages" box was already filled with "108-115". I
was surprised, because that's the page number that I printed from this
file last time, which was many days ago!
I wonder where the "last printed page information" is stored. Is it in the
PDF file itself, or is it somewhere else in the computer?
Learning R - progression path from apprentice to guru
Learning R - progression path from apprentice to guru
Inspired by this thread on stackoverflow about learning Python, I want to
ask about how to constantly improve my R programming skills. I am a
stat-focused social science PhD who has fallen in love with R for a year
and who is looking to push my R skills to the level of package writers.
While I understand the importance of "learning by doing," I also feel that
we need a road map to even know what is possible to do, and hence, learn.
(For example, I wish I knew about ggplot2 / plyr much sooner). Another
important reason for a road map is that I want to have a vision of good
coding practices / techniques rather than learning inefficiently by fixing
each bug / inelegant piece of code.
Like the stackoverflow thread,
I don't want to know how to QUICKLY learn R
Nor do I want to find out the best way to get acquainted with the language
Finally, I don't want to know a 'one trick that does it all' approach.
A good road map may look like this:
Read this, pay attention to that kind of details
Code for so manytime/problems/lines of code
Then, read this (eg: this or that book), but this time, pay attention to this
Tackle a few real-life problems
Then, proceed to reading Y.
Be sure to grasp these concepts
Code for X time
Come back to such and such basics or move further to...
I'm sure that, like me, many are more than happy to spend serious time
with R. We just need a road map for that journey.
Inspired by this thread on stackoverflow about learning Python, I want to
ask about how to constantly improve my R programming skills. I am a
stat-focused social science PhD who has fallen in love with R for a year
and who is looking to push my R skills to the level of package writers.
While I understand the importance of "learning by doing," I also feel that
we need a road map to even know what is possible to do, and hence, learn.
(For example, I wish I knew about ggplot2 / plyr much sooner). Another
important reason for a road map is that I want to have a vision of good
coding practices / techniques rather than learning inefficiently by fixing
each bug / inelegant piece of code.
Like the stackoverflow thread,
I don't want to know how to QUICKLY learn R
Nor do I want to find out the best way to get acquainted with the language
Finally, I don't want to know a 'one trick that does it all' approach.
A good road map may look like this:
Read this, pay attention to that kind of details
Code for so manytime/problems/lines of code
Then, read this (eg: this or that book), but this time, pay attention to this
Tackle a few real-life problems
Then, proceed to reading Y.
Be sure to grasp these concepts
Code for X time
Come back to such and such basics or move further to...
I'm sure that, like me, many are more than happy to spend serious time
with R. We just need a road map for that journey.
Knockout + Moment.js Update relative dates inside an observable
Knockout + Moment.js – Update relative dates inside an observable
Inside my list of completed tasks, I used Moment.js's fromNow() to list
the relative date of completion for each task. Here's the task model:
Task.Model = function(data) {
this.id = data.id;
this.title = ko.observable(data.title);
this.status = ko.observable(data.status);
this.completed = ko.observable(moment(data.date_completed).fromNow());
};
The relative date shows up, but the minutes never update, unless I
refresh. Is there any way to update that observable?
Inside my list of completed tasks, I used Moment.js's fromNow() to list
the relative date of completion for each task. Here's the task model:
Task.Model = function(data) {
this.id = data.id;
this.title = ko.observable(data.title);
this.status = ko.observable(data.status);
this.completed = ko.observable(moment(data.date_completed).fromNow());
};
The relative date shows up, but the minutes never update, unless I
refresh. Is there any way to update that observable?
H1's are floating into post above in Wordpress theme
H1's are floating into post above in Wordpress theme
I just noticed that on the Wordpress theme I created the H1 article titles
are floating up into the subsequent article when you start to shrink the
browser window. I can't seem to find the reason for this. Any insights
would be greatly appreciated.
ul.info li, .excerpt, .post-link {
float: left;
}
The styles above seem to be pushing the title of the article up but if I
remove it then "posted by, written on, date" all turn into a horizontal
list. Which I don't want.
I don't know if they're related by I noticed when I look at single post
pages if I shrink the browser window the content of the article flows off
the screen.
Thanks in advance for you help everyone. Really confused.
I just noticed that on the Wordpress theme I created the H1 article titles
are floating up into the subsequent article when you start to shrink the
browser window. I can't seem to find the reason for this. Any insights
would be greatly appreciated.
ul.info li, .excerpt, .post-link {
float: left;
}
The styles above seem to be pushing the title of the article up but if I
remove it then "posted by, written on, date" all turn into a horizontal
list. Which I don't want.
I don't know if they're related by I noticed when I look at single post
pages if I shrink the browser window the content of the article flows off
the screen.
Thanks in advance for you help everyone. Really confused.
Kyoto2006+ Dataset or other label network/host security datasets
Kyoto2006+ Dataset or other label network/host security datasets
Does anyone know how to access the Kyoto2006+ data set or another labeled
security dataset? An email to the Japanese authors of the set has not been
returned. The DARPA and KDD sets are outdated.
If anyone else is interested, here is the running list of some sets: -UNB
ISCX 2012 Intrusion Detection Evaluation Dataset -iCTF (unlabeled) -DEFCON
(unlabled)
Does anyone know how to access the Kyoto2006+ data set or another labeled
security dataset? An email to the Japanese authors of the set has not been
returned. The DARPA and KDD sets are outdated.
If anyone else is interested, here is the running list of some sets: -UNB
ISCX 2012 Intrusion Detection Evaluation Dataset -iCTF (unlabeled) -DEFCON
(unlabled)
How insert a image in canvas and after insert text in these canvas
How insert a image in canvas and after insert text in these canvas
I'm trying to insert a image in a canvas and after I want to insert a
input text in the same canvas but I cant do it, Anybody can help me?
thanks.
I'm trying to insert a image in a canvas and after I want to insert a
input text in the same canvas but I cant do it, Anybody can help me?
thanks.
Kruchten 4+1 Architecture View Model - Logical View is Domain Model?
Kruchten 4+1 Architecture View Model - Logical View is Domain Model?
I try to apply the 4+1 Architecture View Model by Kruchten. Does the
Logical View contain the Context Map and a Domain Model (entities, value
objects, aggregates, domain events) from DDD?
I'm not quite sure since the level of abstraction seems to be wrong: a
Domain Model wont influence my architecture. Parts of the Domain Model are
very detailed ... Or is a Context Map enough?
Thanks BR
I try to apply the 4+1 Architecture View Model by Kruchten. Does the
Logical View contain the Context Map and a Domain Model (entities, value
objects, aggregates, domain events) from DDD?
I'm not quite sure since the level of abstraction seems to be wrong: a
Domain Model wont influence my architecture. Parts of the Domain Model are
very detailed ... Or is a Context Map enough?
Thanks BR
Friday, 30 August 2013
OpenGL ES 2.0 Scene Lighting iOS
OpenGL ES 2.0 Scene Lighting iOS
I have been looking online and cannot find an example of scene lighting.
Scene lighting meaning there is a light on the wall and all objects which
pass this light get lighted appropriately on the faces which face the
light. Can anyone provide me with an example of such? Or some good reading
on how to do such. I would like to get to the point of using multiple
lights and shadows and possibly lights such as fire which flicker? Is this
possible?
My code below is shading my character but as he rotates (the model view
matrix is rotating), the faces are not changing any lighting.
Vertex Shader precision highp float;
attribute vec4 a_position;
attribute vec3 a_normal;
attribute vec2 a_texCoord;
uniform mat4 u_mvMatrix;
uniform mat4 u_mvpMatrix;
varying lowp vec2 v_texCoord;
varying vec3 v_ecNormal;
varying vec4 v_position;
void main()
{
vec4 mcPosition = a_position;
vec3 mcNormal = a_normal;
vec3 ecNormal = vec3(u_mvMatrix * vec4(mcNormal, 0.0));
v_ecNormal = ecNormal;
v_position = a_position;
v_texCoord = vec2(a_texCoord.x, 1.0 - a_texCoord.y);
gl_Position = u_mvpMatrix * mcPosition;
}
Frag Shader
precision highp float;
uniform sampler2D u_texture;
varying lowp vec2 v_texCoord;
struct DirectionalLight {
vec3 position;
vec3 halfplane;
vec4 ambientColor;
vec4 diffuseColor;
vec4 specularColor;
};
struct Material {
vec4 ambientFactor;
vec4 diffuseFactor;
vec4 specularFactor;
float shininess;
};
uniform DirectionalLight u_directionalLight;
uniform Material u_material;
varying vec3 v_ecNormal;
varying vec4 v_position;
void main()
{
//gl_FragColor = colorVarying * texture2D(texture, texCoordOut);
// normalize
vec3 ecNormal = v_ecNormal / length(v_ecNormal);
vec3 lightPosition = u_directionalLight.position;
vec3 lightDirection;
lightDirection.x = v_position.x - lightPosition.x;
lightDirection.y = v_position.y - lightPosition.y;
lightDirection.z = v_position.z - lightPosition.z;
float ecNormalDotLightDirection = max(0.0, dot(ecNormal,
lightDirection));
float ecNormalDotLightHalfplane = max(0.0, dot(ecNormal,
u_directionalLight.halfplane));
// calc ambient light
vec4 ambientLight = u_directionalLight.ambientColor *
u_material.ambientFactor;
// calc diffuse light
vec4 diffuseLight = ecNormalDotLightDirection *
u_directionalLight.diffuseColor * u_material.diffuseFactor;
// calc specular light
vec4 specularLight = vec4(0.0);
if (ecNormalDotLightHalfplane > 0.0) {
specularLight = pow(ecNormalDotLightHalfplane,
u_material.shininess) * u_directionalLight.specularColor *
u_material.specularFactor;
}
vec4 light = ambientLight + diffuseLight + specularLight;
gl_FragColor = light * texture2D(u_texture, v_texCoord);
}
I have been looking online and cannot find an example of scene lighting.
Scene lighting meaning there is a light on the wall and all objects which
pass this light get lighted appropriately on the faces which face the
light. Can anyone provide me with an example of such? Or some good reading
on how to do such. I would like to get to the point of using multiple
lights and shadows and possibly lights such as fire which flicker? Is this
possible?
My code below is shading my character but as he rotates (the model view
matrix is rotating), the faces are not changing any lighting.
Vertex Shader precision highp float;
attribute vec4 a_position;
attribute vec3 a_normal;
attribute vec2 a_texCoord;
uniform mat4 u_mvMatrix;
uniform mat4 u_mvpMatrix;
varying lowp vec2 v_texCoord;
varying vec3 v_ecNormal;
varying vec4 v_position;
void main()
{
vec4 mcPosition = a_position;
vec3 mcNormal = a_normal;
vec3 ecNormal = vec3(u_mvMatrix * vec4(mcNormal, 0.0));
v_ecNormal = ecNormal;
v_position = a_position;
v_texCoord = vec2(a_texCoord.x, 1.0 - a_texCoord.y);
gl_Position = u_mvpMatrix * mcPosition;
}
Frag Shader
precision highp float;
uniform sampler2D u_texture;
varying lowp vec2 v_texCoord;
struct DirectionalLight {
vec3 position;
vec3 halfplane;
vec4 ambientColor;
vec4 diffuseColor;
vec4 specularColor;
};
struct Material {
vec4 ambientFactor;
vec4 diffuseFactor;
vec4 specularFactor;
float shininess;
};
uniform DirectionalLight u_directionalLight;
uniform Material u_material;
varying vec3 v_ecNormal;
varying vec4 v_position;
void main()
{
//gl_FragColor = colorVarying * texture2D(texture, texCoordOut);
// normalize
vec3 ecNormal = v_ecNormal / length(v_ecNormal);
vec3 lightPosition = u_directionalLight.position;
vec3 lightDirection;
lightDirection.x = v_position.x - lightPosition.x;
lightDirection.y = v_position.y - lightPosition.y;
lightDirection.z = v_position.z - lightPosition.z;
float ecNormalDotLightDirection = max(0.0, dot(ecNormal,
lightDirection));
float ecNormalDotLightHalfplane = max(0.0, dot(ecNormal,
u_directionalLight.halfplane));
// calc ambient light
vec4 ambientLight = u_directionalLight.ambientColor *
u_material.ambientFactor;
// calc diffuse light
vec4 diffuseLight = ecNormalDotLightDirection *
u_directionalLight.diffuseColor * u_material.diffuseFactor;
// calc specular light
vec4 specularLight = vec4(0.0);
if (ecNormalDotLightHalfplane > 0.0) {
specularLight = pow(ecNormalDotLightHalfplane,
u_material.shininess) * u_directionalLight.specularColor *
u_material.specularFactor;
}
vec4 light = ambientLight + diffuseLight + specularLight;
gl_FragColor = light * texture2D(u_texture, v_texCoord);
}
Thursday, 29 August 2013
Why do I get the layout alongwith the ajax result
Why do I get the layout alongwith the ajax result
I am using Ajax to search some posts tagged under some word. What I am
using is just an input; no form. The event is onKeyUp so ajax request is
made when there is a keyup.
Result: The ajax do send back a response.
Problem: The layout is also sent back. When I am even using the code
Layout = null; too.
Language I use: I am using ASP.NET Web Pages.
What I have tried: I have tried to search for some corrections, first I
was not using the layout for the page, then I was told to use Layout =
null; to make sure, the layout is not used for the code.
But now the layout is sent back, whether I use this or not.
Other wise the code is perfect! You can have a look at the layout issue here:
The logo and all this nav menu is provided under the main page. Almost
just above the footer where the result has to be pasted! But instead of
posts or some query, the layout is being posted back.
I am using Ajax to search some posts tagged under some word. What I am
using is just an input; no form. The event is onKeyUp so ajax request is
made when there is a keyup.
Result: The ajax do send back a response.
Problem: The layout is also sent back. When I am even using the code
Layout = null; too.
Language I use: I am using ASP.NET Web Pages.
What I have tried: I have tried to search for some corrections, first I
was not using the layout for the page, then I was told to use Layout =
null; to make sure, the layout is not used for the code.
But now the layout is sent back, whether I use this or not.
Other wise the code is perfect! You can have a look at the layout issue here:
The logo and all this nav menu is provided under the main page. Almost
just above the footer where the result has to be pasted! But instead of
posts or some query, the layout is being posted back.
WCF webHttpBinding & Encryption
WCF webHttpBinding & Encryption
I currently have a WCF service exposed via webHttpBinding &
basicHttpBinding. The SOAP side of things is consumed via a web
application while REST is used for mobile apps. I need to add a level of
encryption to the mobile communication and have read that i need to use a
custom message encoder on my webhttpbinding.
I have an encryption library I wish to use. I have looked at the sample
applications in WCF under extensibility & message encoders but these have
confused me.
Does anyone have a simple example i could follow?
I currently have a WCF service exposed via webHttpBinding &
basicHttpBinding. The SOAP side of things is consumed via a web
application while REST is used for mobile apps. I need to add a level of
encryption to the mobile communication and have read that i need to use a
custom message encoder on my webhttpbinding.
I have an encryption library I wish to use. I have looked at the sample
applications in WCF under extensibility & message encoders but these have
confused me.
Does anyone have a simple example i could follow?
Wednesday, 28 August 2013
Build errors in eclipse
Build errors in eclipse
i have a big problem, i can't compile my eclipse projects.
Idon't understand whta is the problem. I have already searched for answer
but i stay helpless!
Hier the build error in eclipse:
Thank you!
i have a big problem, i can't compile my eclipse projects.
Idon't understand whta is the problem. I have already searched for answer
but i stay helpless!
Hier the build error in eclipse:
Thank you!
Is it possible to have a Linux box with 2 Ethernet adapters, connected to 2 networks with same IP range (no routing needed)?
Is it possible to have a Linux box with 2 Ethernet adapters, connected to
2 networks with same IP range (no routing needed)?
Bear with me. This relates to this Stack Overflow question.
My Linux thing (actually a BeagleBoard) has two interfaces, eth0 and eth1.
It needs to connect to a client's network on eth0 (address range unknown,
may be DHCP, probably 192.168.0.x). My software also needs to connect to
another device on eth1 via a private link (i.e. just device to device). I
want to keep the private network totally separate - it should NOT be
visible on the main network. Only my own code on the Beagle will be
talking to the device on eth1.
I've figured out how to make my C code bind a socket to a specific
interface as well as IP address. I can also put the private link on a
separate subnet to the main network and everything is happy.
However, given that I don't know the address range of the main network,
and I want to use fixed IP addresses for my private link (for simplicity),
how do I ensure that the address ranges don't clash? I tried putting the
private device on the same IP address as something on the main network
(for a test), which caused routing issues.
Is it possible to set up routing so that duplicate IP addresses (on the
main network and my private network) would work (given that I can specify
the interface as well as IP address)? Or is that crazy talk? I don't need
to actually "route" anything between the networks and my private device
doesn't need to see the main network. I just need it to still work even if
the IP addresses happen to be the same.
Alternatively, can I use one of the reserved IP address ranges on my
private so that I know it won't clash with the main network?
I've been searching a lot for an answer to this, but it seems like an
unusual thing to do and all the answers assume the two ethernet interfaces
will connect to different subnets.
Any ideas? Including doing it some other way... Thanks!
2 networks with same IP range (no routing needed)?
Bear with me. This relates to this Stack Overflow question.
My Linux thing (actually a BeagleBoard) has two interfaces, eth0 and eth1.
It needs to connect to a client's network on eth0 (address range unknown,
may be DHCP, probably 192.168.0.x). My software also needs to connect to
another device on eth1 via a private link (i.e. just device to device). I
want to keep the private network totally separate - it should NOT be
visible on the main network. Only my own code on the Beagle will be
talking to the device on eth1.
I've figured out how to make my C code bind a socket to a specific
interface as well as IP address. I can also put the private link on a
separate subnet to the main network and everything is happy.
However, given that I don't know the address range of the main network,
and I want to use fixed IP addresses for my private link (for simplicity),
how do I ensure that the address ranges don't clash? I tried putting the
private device on the same IP address as something on the main network
(for a test), which caused routing issues.
Is it possible to set up routing so that duplicate IP addresses (on the
main network and my private network) would work (given that I can specify
the interface as well as IP address)? Or is that crazy talk? I don't need
to actually "route" anything between the networks and my private device
doesn't need to see the main network. I just need it to still work even if
the IP addresses happen to be the same.
Alternatively, can I use one of the reserved IP address ranges on my
private so that I know it won't clash with the main network?
I've been searching a lot for an answer to this, but it seems like an
unusual thing to do and all the answers assume the two ethernet interfaces
will connect to different subnets.
Any ideas? Including doing it some other way... Thanks!
JMX Connection time out
JMX Connection time out
My Thread pool is becoming full because, most of the threads are waiting
for the socket connection. How to add timeout for jmx connect
java.lang.Thread.State: RUNNABLE
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
- locked <0x05671ad0> (a java.net.SocksSocketImpl)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:548)
at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:351)
at
com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:71)
at
javax.rmi.ssl.SslRMIClientSocketFactory.createSocket(SslRMIClientSocketFactory.java:105)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at
com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:97)
at
com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at
javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1871)
at
javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1841)
at
javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:257)
My Thread pool is becoming full because, most of the threads are waiting
for the socket connection. How to add timeout for jmx connect
java.lang.Thread.State: RUNNABLE
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
- locked <0x05671ad0> (a java.net.SocksSocketImpl)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:548)
at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:351)
at
com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:71)
at
javax.rmi.ssl.SslRMIClientSocketFactory.createSocket(SslRMIClientSocketFactory.java:105)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at
com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:97)
at
com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at
javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1871)
at
javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1841)
at
javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:257)
Root Nexus 7 with 4.2.2
Root Nexus 7 with 4.2.2
I'm trying to root a Nexus 7 with Android 4.2.2 (1st generation). I am
following instructions here:
http://honai-android.blogspot.com/2013/06/how-to-root-nexus-7-on-android-422.html?showComment=1377379346836#c8791363668077143555
I get to Step 4 in in which it says to wait until windows has finished
installing drivers. I am on OS X. The Nexus 7 is in fast boot mode. It has
an image of the green Android lying on its back with a panel open, in the
upper right is "Start >" and just below that up and down arrows. I plugged
in the USB and nothing happens, ie no indication of drivers being
installed. What do I do?
I'm trying to root a Nexus 7 with Android 4.2.2 (1st generation). I am
following instructions here:
http://honai-android.blogspot.com/2013/06/how-to-root-nexus-7-on-android-422.html?showComment=1377379346836#c8791363668077143555
I get to Step 4 in in which it says to wait until windows has finished
installing drivers. I am on OS X. The Nexus 7 is in fast boot mode. It has
an image of the green Android lying on its back with a panel open, in the
upper right is "Start >" and just below that up and down arrows. I plugged
in the USB and nothing happens, ie no indication of drivers being
installed. What do I do?
Monitoring software for Debian on ARM chip?
Monitoring software for Debian on ARM chip?
I want to monitor a lot microcontrollers, supplied with a 400MHz ARM chip.
I want to monitor disk space, certain processes, SSH login attempts. Does
lightweight monitoring software exists which runs on ARM?
I want to monitor a lot microcontrollers, supplied with a 400MHz ARM chip.
I want to monitor disk space, certain processes, SSH login attempts. Does
lightweight monitoring software exists which runs on ARM?
How to search an array in Jquery like SQL LIKE value% statement
How to search an array in Jquery like SQL LIKE value% statement
I have an array with some values. How can I search that array using jQuery
for a value which is matched or close to it?
var a = ["foo","fool","cool","god","acl"];
If I want to search for c, then it should return cool but not acl.
How I can achieve that?
I have an array with some values. How can I search that array using jQuery
for a value which is matched or close to it?
var a = ["foo","fool","cool","god","acl"];
If I want to search for c, then it should return cool but not acl.
How I can achieve that?
How to convert "DOMNodeInserted" to Mutation observers?
How to convert "DOMNodeInserted" to Mutation observers?
I am trying to convert DOMNodeInserted to Mutation observers, because I
heard that Mutation events is deprecated, but I can't.
This is the original code;
//works well
document.body.addEventListener('DOMNodeInserted', function (event)
{Container(event.target);}, false);
I wrote this in reference to this page;
Are DOM Mutation Observers slower than DOM Mutation Events? , but it
doesn't work;
// does not work(tested with chrome 28)
var observer = new MutationObserver(function (event) {
observer.disconnect();
Container(event.target);
});
observer.observe(document, {subtree: true, childList: true })
What is the problem? What should I do?
I am trying to convert DOMNodeInserted to Mutation observers, because I
heard that Mutation events is deprecated, but I can't.
This is the original code;
//works well
document.body.addEventListener('DOMNodeInserted', function (event)
{Container(event.target);}, false);
I wrote this in reference to this page;
Are DOM Mutation Observers slower than DOM Mutation Events? , but it
doesn't work;
// does not work(tested with chrome 28)
var observer = new MutationObserver(function (event) {
observer.disconnect();
Container(event.target);
});
observer.observe(document, {subtree: true, childList: true })
What is the problem? What should I do?
How to cat
How to cat
In bash if pasted text data contains tabs, they cause autocomplete.
If I start bash with '--noediting', on some systems the length of pasted
line is limited to 256 chars.
If instead I paste directly to cat's input (without <<'EOF'), the max line
is also 256.
If I do 'stty raw', the line length is no longer limited, but there's no
way to send EOF to cat's input.
In bash if pasted text data contains tabs, they cause autocomplete.
If I start bash with '--noediting', on some systems the length of pasted
line is limited to 256 chars.
If instead I paste directly to cat's input (without <<'EOF'), the max line
is also 256.
If I do 'stty raw', the line length is no longer limited, but there's no
way to send EOF to cat's input.
Tuesday, 27 August 2013
add and tag to collections in applicationHost.config or web.config using Powershell webadministration module
add and tag to collections in applicationHost.config or web.config using
Powershell webadministration module
as per title, can someone help?
just an example:
<system.ftpServer>
<security>
<ipSecurity>
<add ipAddress="1.2.3.4" subnetMask="255.255.255.0" />
</ipSecurity>
</security>
</system.ftpServer>
I would like to add a tag as the first element to stop the elements
delegated from its parent. and a after as well.
So it will look like this:
<system.ftpServer>
<security>
<ipSecurity>
<clear />
<remove ipAddress="1.1.1.1" />
<add ipAddress="1.2.3.4" subnetMask="255.255.255.0" />
</ipSecurity>
</security>
</system.ftpServer>
Powershell webadministration module
as per title, can someone help?
just an example:
<system.ftpServer>
<security>
<ipSecurity>
<add ipAddress="1.2.3.4" subnetMask="255.255.255.0" />
</ipSecurity>
</security>
</system.ftpServer>
I would like to add a tag as the first element to stop the elements
delegated from its parent. and a after as well.
So it will look like this:
<system.ftpServer>
<security>
<ipSecurity>
<clear />
<remove ipAddress="1.1.1.1" />
<add ipAddress="1.2.3.4" subnetMask="255.255.255.0" />
</ipSecurity>
</security>
</system.ftpServer>
Clarification about usage of undefined in this code?
Clarification about usage of undefined in this code?
I was reading some code for a js library and I saw this:
// make sure undefined is undefined
var undefined;
I have looked up the proper way to check for undefined things in
javascript a few times before and found things posts such as:
How to check for "undefined" in JavaScript?
How to determine if variable is 'undefined' or 'null'
typeof !== "undefined" vs. != null
Is that piece of code a good thing to add on or is it unnecessary or
something in the middle?
I was reading some code for a js library and I saw this:
// make sure undefined is undefined
var undefined;
I have looked up the proper way to check for undefined things in
javascript a few times before and found things posts such as:
How to check for "undefined" in JavaScript?
How to determine if variable is 'undefined' or 'null'
typeof !== "undefined" vs. != null
Is that piece of code a good thing to add on or is it unnecessary or
something in the middle?
Changing the Binding Order of network interfaces does not affect routing decesions
Changing the Binding Order of network interfaces does not affect routing
decesions
I have a computer with two network interfaces. The main one, which leads
to our main network, and a secondary one, which leads to its own little
network. When both are enabled, the traffic intended for the main network
wanders off into the secondary card and is lost. I tried changing the
binding order on the interfaces, but this did not help.
decesions
I have a computer with two network interfaces. The main one, which leads
to our main network, and a secondary one, which leads to its own little
network. When both are enabled, the traffic intended for the main network
wanders off into the secondary card and is lost. I tried changing the
binding order on the interfaces, but this did not help.
iOS: Compare two less or equal NSDates
iOS: Compare two less or equal NSDates
I want to compare two dates and do something when one is less or equal
than the other, I tried to do it this way:
if ([self.system.systemInbetriebnahme compare:date] == NSOrderedDescending)
return nil;
But this removes the case when they are both equal is there a way to
compare dates with >= ?
Thank you
I want to compare two dates and do something when one is less or equal
than the other, I tried to do it this way:
if ([self.system.systemInbetriebnahme compare:date] == NSOrderedDescending)
return nil;
But this removes the case when they are both equal is there a way to
compare dates with >= ?
Thank you
Avoiding Proxy Auto Detection when using HTTPWebRequest
Avoiding Proxy Auto Detection when using HTTPWebRequest
I understand that when using the WebRequest class you have to set the
proxy property to null to stop the framework from trying to auto-detect
the proxy settings - causing a delay in request time.
Does the same hold true when using HTTPWebRequest? I.E:
HttpWebRequest client =
(HttpWebRequest)WebRequest.Create("http://google.com");
Should I be setting the proxy to null or does the Framework not try to
attempt to get the default proxy settings when using HTTPWebRequest?
client.proxy = null;
I understand that when using the WebRequest class you have to set the
proxy property to null to stop the framework from trying to auto-detect
the proxy settings - causing a delay in request time.
Does the same hold true when using HTTPWebRequest? I.E:
HttpWebRequest client =
(HttpWebRequest)WebRequest.Create("http://google.com");
Should I be setting the proxy to null or does the Framework not try to
attempt to get the default proxy settings when using HTTPWebRequest?
client.proxy = null;
Receiving org.hibernate.ResourceClosedException "This TransactionCoordinator has been closed"
Receiving org.hibernate.ResourceClosedException "This
TransactionCoordinator has been closed"
I have a servlet, running on Tomcat 6, that uses Hibernate 4.1.6 and c3p0
0.9.1.2, and I am getting too much org.hibernate.ResourceClosedException,
with the message "This TransactionCoordinator has been closed".
I've already checked that beginTransaction() and rollback() or commit()
are done before the thread is reused by another call.
At hibernate.cfg.xml, I have
<hibernate-configuration>
<session-factory>
<property
name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">password</property>
<property
name="hibernate.connection.url">jdbc:mysql://host/database</property>
<property name="hibernate.connection.username">username</property>
<property
name="hibernate.connection.zeroDateTimeBehavior">convertToNull</property>
<property
name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="show_sql">true</property>
<property name="current_session_context_class">thread</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">1800</property>
<property name="hibernate.c3p0.max_statements">50</property>
<!-- mappings start here -->
...
</session-factory>
</hibernate-configuration>
and I am using a HibernateUtil.java to create a static sessionFactory for
my application and I use it to control my transactions:
public class HibernateUtil {
private static final SessionFactory sessionFactory =
buildSessionFactory();
private static SessionFactory buildSessionFactory() {
try {
Configuration configuration = new Configuration();
configuration.configure();
ServiceRegistry serviceRegistry = new
ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
SessionFactory sessionFactory =
configuration.buildSessionFactory(serviceRegistry);
return sessionFactory;
}
catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
public static void shutdown() {
getSessionFactory().close();
}
public static void beginTransaction() {
HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();
}
public static void commit() {
HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit();
}
public static void rollback() {
HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().rollback();
}
}
When I start using the database in a servlet, my code is basically this:
try {
HibernateUtil.beginTransaction();
// do stuffs
HibernateUtil.commit();
} catch (RuntimeException e) {
HibernateUtil.rollback();
throw e;
} catch (Exception e) {
HibernateUtil.rollback();
throw e;
}
Where am I doing wrong?
TransactionCoordinator has been closed"
I have a servlet, running on Tomcat 6, that uses Hibernate 4.1.6 and c3p0
0.9.1.2, and I am getting too much org.hibernate.ResourceClosedException,
with the message "This TransactionCoordinator has been closed".
I've already checked that beginTransaction() and rollback() or commit()
are done before the thread is reused by another call.
At hibernate.cfg.xml, I have
<hibernate-configuration>
<session-factory>
<property
name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">password</property>
<property
name="hibernate.connection.url">jdbc:mysql://host/database</property>
<property name="hibernate.connection.username">username</property>
<property
name="hibernate.connection.zeroDateTimeBehavior">convertToNull</property>
<property
name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="show_sql">true</property>
<property name="current_session_context_class">thread</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">1800</property>
<property name="hibernate.c3p0.max_statements">50</property>
<!-- mappings start here -->
...
</session-factory>
</hibernate-configuration>
and I am using a HibernateUtil.java to create a static sessionFactory for
my application and I use it to control my transactions:
public class HibernateUtil {
private static final SessionFactory sessionFactory =
buildSessionFactory();
private static SessionFactory buildSessionFactory() {
try {
Configuration configuration = new Configuration();
configuration.configure();
ServiceRegistry serviceRegistry = new
ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
SessionFactory sessionFactory =
configuration.buildSessionFactory(serviceRegistry);
return sessionFactory;
}
catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
public static void shutdown() {
getSessionFactory().close();
}
public static void beginTransaction() {
HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();
}
public static void commit() {
HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit();
}
public static void rollback() {
HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().rollback();
}
}
When I start using the database in a servlet, my code is basically this:
try {
HibernateUtil.beginTransaction();
// do stuffs
HibernateUtil.commit();
} catch (RuntimeException e) {
HibernateUtil.rollback();
throw e;
} catch (Exception e) {
HibernateUtil.rollback();
throw e;
}
Where am I doing wrong?
Monday, 26 August 2013
vb6 create an object twice, will cause memory leakage or not?
vb6 create an object twice, will cause memory leakage or not?
I just what to check if I write following codes with vb6:
dim a as new b
dim a as new b
will it cause the memory leak or not?
I just what to check if I write following codes with vb6:
dim a as new b
dim a as new b
will it cause the memory leak or not?
adding items to list string but getting null reference exception
adding items to list string but getting null reference exception
I am adding items to string list and i know there is data that exists to
insert but i keep getting the null reference error message Object
reference not set to an instance of an object.
public class ExcelRow
{
public List<String> lstCells;
public byte[] rowHash;
......
}
public class ExcelInfo
{
public List<ExcelRow> excelRows;
}
public ExcelInfo ReadExcel(OpenFileDialog openFileDialog)
{
var _excelFile = new ExcelQueryFactory(openFileDialog.FileName);
var _info = from c in _excelFile.WorksheetNoHeader() select c;
ExcelRow excelRow;
ExcelInfo resp;
resp = new ExcelInfo();
foreach (var item in _info)
{
excelRow = new ExcelRow();
excelRow.lstCells.Add(item.ElementAt(0));
excelRow.lstCells.Add(item.ElementAt(1));
excelRow.lstCells.Add(item.ElementAt(2));
excelRow.lstCells.Add(item.ElementAt(3));
.....
excelRow.CalculateHash();
resp.excelRows.Add(excelRow);
}
return resp;
}
This is where i am getting the error:
excelRow.lstCells.Add(item.ElementAt(0));
I am adding items to string list and i know there is data that exists to
insert but i keep getting the null reference error message Object
reference not set to an instance of an object.
public class ExcelRow
{
public List<String> lstCells;
public byte[] rowHash;
......
}
public class ExcelInfo
{
public List<ExcelRow> excelRows;
}
public ExcelInfo ReadExcel(OpenFileDialog openFileDialog)
{
var _excelFile = new ExcelQueryFactory(openFileDialog.FileName);
var _info = from c in _excelFile.WorksheetNoHeader() select c;
ExcelRow excelRow;
ExcelInfo resp;
resp = new ExcelInfo();
foreach (var item in _info)
{
excelRow = new ExcelRow();
excelRow.lstCells.Add(item.ElementAt(0));
excelRow.lstCells.Add(item.ElementAt(1));
excelRow.lstCells.Add(item.ElementAt(2));
excelRow.lstCells.Add(item.ElementAt(3));
.....
excelRow.CalculateHash();
resp.excelRows.Add(excelRow);
}
return resp;
}
This is where i am getting the error:
excelRow.lstCells.Add(item.ElementAt(0));
error class interface or enum expected
error class interface or enum expected
i am trying to compile the following simple code and receiving the error
that, error class interface or enum expected please help me to find out my
error.
public class Scores
{
public static final int maxEntries =5;
int numEntries;
protected GameEntry[] entries;
public Scores()
{
entries = new GameEntry[maxEntries];
numEntries = 0;
}
public String toString()
{
String s = "[";
for (int i=0 ; i < numEntries; i++)
{
if (i > 0) s = ","; // separate entries by commas
s = s + entries[i].toString() ;
}
return s + "]";
}
public void add(GameEntry e)
{
entries[numEntries]=e;
numEntries++;
}
public void add(GameEntry e)
{
int newScore = e.getScore();
if (numEntries == maxEntries)
{
if (newScore <= entries[numEntries-l].getScore())
return;
}
else
return numEntries++;
int i = numEntries-l;
for ( ; (i >= 1) && (newScore > entries[i-1].getScore()); i--)
entries[i] = entries[i-1];
entries[i] = e;
}
}
public static void main(String args[])
{
Scores s1=new Scores();
GameEntry e1=new GameEntry("Paul",750);
s1.add(e1);
GameEntry e2=new GameEntry("John",770);
s1.add(e2);
system.out.println(s1.toString());
GameEntry e1=new GameEntry("Sam",600);
s1.add(e1);
GameEntry e2=new GameEntry("Raj",800);
s1.add(e2);
system.out.println(s1.toString());
GameEntry e1=new GameEntry("Gobi",550);
s1.add(e1);
GameEntry e2=new GameEntry("Raj",580);
s1.add(e2);
system.out.println(s1.toString());
}
i am trying to compile the following simple code and receiving the error
that, error class interface or enum expected please help me to find out my
error.
public class Scores
{
public static final int maxEntries =5;
int numEntries;
protected GameEntry[] entries;
public Scores()
{
entries = new GameEntry[maxEntries];
numEntries = 0;
}
public String toString()
{
String s = "[";
for (int i=0 ; i < numEntries; i++)
{
if (i > 0) s = ","; // separate entries by commas
s = s + entries[i].toString() ;
}
return s + "]";
}
public void add(GameEntry e)
{
entries[numEntries]=e;
numEntries++;
}
public void add(GameEntry e)
{
int newScore = e.getScore();
if (numEntries == maxEntries)
{
if (newScore <= entries[numEntries-l].getScore())
return;
}
else
return numEntries++;
int i = numEntries-l;
for ( ; (i >= 1) && (newScore > entries[i-1].getScore()); i--)
entries[i] = entries[i-1];
entries[i] = e;
}
}
public static void main(String args[])
{
Scores s1=new Scores();
GameEntry e1=new GameEntry("Paul",750);
s1.add(e1);
GameEntry e2=new GameEntry("John",770);
s1.add(e2);
system.out.println(s1.toString());
GameEntry e1=new GameEntry("Sam",600);
s1.add(e1);
GameEntry e2=new GameEntry("Raj",800);
s1.add(e2);
system.out.println(s1.toString());
GameEntry e1=new GameEntry("Gobi",550);
s1.add(e1);
GameEntry e2=new GameEntry("Raj",580);
s1.add(e2);
system.out.println(s1.toString());
}
How to convert payment_date in Paypal IPN for the format d.m.Y?
How to convert payment_date in Paypal IPN for the format d.m.Y?
I installed IPN PayPal as payment method for my web-site. And I made SQL
Base for receiving IPN history from PayPal system. But I want to convert
payment_data from PayPal in the following format (d.m.Y) incase of Y-m-d
H:i:s
I installed IPN PayPal as payment method for my web-site. And I made SQL
Base for receiving IPN history from PayPal system. But I want to convert
payment_data from PayPal in the following format (d.m.Y) incase of Y-m-d
H:i:s
my Alarm doen't start activity when phone lock is
my Alarm doen't start activity when phone lock is
I try to do alarm clock in my aplication, but when phone lock is there
activity doest't start as in standart alarm clock. What I can do for
decide this problem?
Calendar cal = Calendar.getInstance();
cal.add(Calendar.SECOND, 5);
Intent intent = new Intent(this, AlarmReceiverActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,
12345, intent, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager am =
(AlarmManager)getSystemService(Activity.ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),
pendingIntent);
I try to do alarm clock in my aplication, but when phone lock is there
activity doest't start as in standart alarm clock. What I can do for
decide this problem?
Calendar cal = Calendar.getInstance();
cal.add(Calendar.SECOND, 5);
Intent intent = new Intent(this, AlarmReceiverActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,
12345, intent, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager am =
(AlarmManager)getSystemService(Activity.ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),
pendingIntent);
MSSQL: How to document stored procedures without auto-documenter?
MSSQL: How to document stored procedures without auto-documenter?
There has been a few questions on SO about how to's and best practices of
documenting stored procedures in Microsoft SQL Server. However, most of
them relate to auto-documenting tools and using third-party services in
order to do so.
Intent
I have a online wiki that's attached to my software versioning and bug
tracking software (JIRA). They link together both in task/issues and the
wiki (really beneficial to us overall). Now I want to start going through
about a hundred stored procedures and start documenting them in our online
wiki.
Question
How do you document procedures through external documentation without
simply copying over the code and without using auto-documenting tools?
What information about the procedure at the core level should I provide in
that documentation? For example, the parameters, columns and joins it
executes on top of it's intent? Or the bare minimum of just the intent?
Clarity Details
I know this may be broad, but I'm not looking for the best practice. I'm
looking for a good method to build into a best practice. Something that
any DBA could read and know exactly what is going on in that procedure as
well enough detail to trigger someone to find what they are looking for
during tasks.
There has been a few questions on SO about how to's and best practices of
documenting stored procedures in Microsoft SQL Server. However, most of
them relate to auto-documenting tools and using third-party services in
order to do so.
Intent
I have a online wiki that's attached to my software versioning and bug
tracking software (JIRA). They link together both in task/issues and the
wiki (really beneficial to us overall). Now I want to start going through
about a hundred stored procedures and start documenting them in our online
wiki.
Question
How do you document procedures through external documentation without
simply copying over the code and without using auto-documenting tools?
What information about the procedure at the core level should I provide in
that documentation? For example, the parameters, columns and joins it
executes on top of it's intent? Or the bare minimum of just the intent?
Clarity Details
I know this may be broad, but I'm not looking for the best practice. I'm
looking for a good method to build into a best practice. Something that
any DBA could read and know exactly what is going on in that procedure as
well enough detail to trigger someone to find what they are looking for
during tasks.
site will not redirect to custome page and throw 404 error in asp.net site
site will not redirect to custome page and throw 404 error in asp.net site
I don't know this question is already asked or not. But i am stuck in one
problem.
I have one CMS application in that some page are static and some are dynamic.
When i access url using http://abc.com/abc.aspx
Now in this case if abc.aspx is cms page then it will redirect me to that
page but if it is not cms page then this will redirect me to the my custom
page http://abc.com/page-not-found.aspx
Now my question is that if i write only http://abc.com/abc then it will
didn't redirect me to the http://abc.com/page-not-found.aspx but it will
throw me the error 404 page or directory not found.
Now I have to check two things
1) if any custome page is not there then it will display
http://abc.com/page-not-found.aspx
2) when http://abc.com/page then it will also redirect me to
http://abc.com/page-not-found.aspx
Please help me our from this.
Thanks in advance.
Regards AB Vyas
I don't know this question is already asked or not. But i am stuck in one
problem.
I have one CMS application in that some page are static and some are dynamic.
When i access url using http://abc.com/abc.aspx
Now in this case if abc.aspx is cms page then it will redirect me to that
page but if it is not cms page then this will redirect me to the my custom
page http://abc.com/page-not-found.aspx
Now my question is that if i write only http://abc.com/abc then it will
didn't redirect me to the http://abc.com/page-not-found.aspx but it will
throw me the error 404 page or directory not found.
Now I have to check two things
1) if any custome page is not there then it will display
http://abc.com/page-not-found.aspx
2) when http://abc.com/page then it will also redirect me to
http://abc.com/page-not-found.aspx
Please help me our from this.
Thanks in advance.
Regards AB Vyas
$\sum_{k=1}^{\infty}\frac1{(3k+1)(3k+2)}$
$\sum_{k=1}^{\infty}\frac1{(3k+1)(3k+2)}$
What is the value of $\sum_{k=1}^{\infty}\frac1{(3k+1)(3k+2)}$
What is the value of $\sum_{k=1}^{\infty}\frac1{(3k+1)(3k+2)}$
Sunday, 25 August 2013
java sample program scanner with hashmap sample program
java sample program scanner with hashmap sample program
java sample program scanner with hashmap java sample program scanner with
hashmap java sample program scanner with hashmap copy the full code and
paste it there is no error
sampe proaram
running in eclipse
import java.util.*;
import java.util.Map.Entry;
public class ExampleWithScannerAndHashMap {
public static void main(String[] args) {
int count = 0;// stores the number of names
// Scanner the reads the user input from standard input stream
Scanner in = new Scanner(System.in);
// Request user input till getting a valid number
System.out.println("Enter the Number of Names U wants to display :");
while (true) {
try {
// Read the user input and convert into integer
count = in.nextInt();
// If it is a valid number break the loop
break;
} catch (InputMismatchException e) {
// If it is not a valid number show the error msg
System.out.println("Please enter a valid number : ");
}
}
in.nextLine(); // reads the enter char from buffer
// Hashmap to store the names
Map<String, String> hashMap = new HashMap<String, String>();
for (int i = 1; i <= count; i++) {
System.out.println("Enter Name " + i + " : ");
// Add the names to hashmap with different keys
hashMap.put("name" + i, in.nextLine());
}
// Print the names in the hashmap
printValues(hashMap);
System.out.println("Enter a key to delete : ");
String key = in.nextLine();
if (hashMap.containsKey(key)) {
hashMap.remove(key);
System.out.println("The element with key " + key
+ " has been removed successfully");
} else {
System.out.println("The entered key does not exists");
}
//Clears the hashmap
hashMap.clear();
// close the scanner to release the resource
in.close();
}
public static void printValues(Map<String, String> hashMap) {
Iterator<Entry<String, String>> iterator = hashMap.entrySet()
.iterator();
System.out.println("There are " + hashMap.size() + " elements in
HashMap. They are ");
System.out.println("Key : Value");
while (iterator.hasNext()) {
Entry<String,String> entry = iterator.next();
System.out.println(entry.getKey() + " : "
+ entry.getValue());
}
}
}
java sample program scanner with hashmap java sample program scanner with
hashmap java sample program scanner with hashmap copy the full code and
paste it there is no error
sampe proaram
running in eclipse
import java.util.*;
import java.util.Map.Entry;
public class ExampleWithScannerAndHashMap {
public static void main(String[] args) {
int count = 0;// stores the number of names
// Scanner the reads the user input from standard input stream
Scanner in = new Scanner(System.in);
// Request user input till getting a valid number
System.out.println("Enter the Number of Names U wants to display :");
while (true) {
try {
// Read the user input and convert into integer
count = in.nextInt();
// If it is a valid number break the loop
break;
} catch (InputMismatchException e) {
// If it is not a valid number show the error msg
System.out.println("Please enter a valid number : ");
}
}
in.nextLine(); // reads the enter char from buffer
// Hashmap to store the names
Map<String, String> hashMap = new HashMap<String, String>();
for (int i = 1; i <= count; i++) {
System.out.println("Enter Name " + i + " : ");
// Add the names to hashmap with different keys
hashMap.put("name" + i, in.nextLine());
}
// Print the names in the hashmap
printValues(hashMap);
System.out.println("Enter a key to delete : ");
String key = in.nextLine();
if (hashMap.containsKey(key)) {
hashMap.remove(key);
System.out.println("The element with key " + key
+ " has been removed successfully");
} else {
System.out.println("The entered key does not exists");
}
//Clears the hashmap
hashMap.clear();
// close the scanner to release the resource
in.close();
}
public static void printValues(Map<String, String> hashMap) {
Iterator<Entry<String, String>> iterator = hashMap.entrySet()
.iterator();
System.out.println("There are " + hashMap.size() + " elements in
HashMap. They are ");
System.out.println("Key : Value");
while (iterator.hasNext()) {
Entry<String,String> entry = iterator.next();
System.out.println(entry.getKey() + " : "
+ entry.getValue());
}
}
}
[ Singles & Dating ] Open Question : Can I love somebody I've never been with?
[ Singles & Dating ] Open Question : Can I love somebody I've never been
with?
Well I guess I shouldn't be talking about love since I don't really know
what it is. I have been with a couple girls but I have never felt this
feeling I have right now with them. In 9th grade after my girlfriend broke
up with me, I didn't really feel anything like with every girl I'm with,
and then this girl started talking to me. I didn't get it, I didnt even
know this girl but i always have the same blank expression on my face yet
when she talked to me I knew I was smiling. I never asked her out, even
when she made this small little paper heart for me that had her name and
mine on it. Never did. Before 9th grade ended she stopped talking to me
completely ignored me actually. I Have had her for classes over the years
and I acted like I didn't care but I feel like I do care. Every time she
entered the room I had that bored expression but my heart skipped a beat
and I smiled inside. And now in 12th grade when I thought it be the same
she sat right next to me when she could have sat anywhere else I know that
dosent mean anything but she had talked to me and mind was a mess, I didnt
know what to say to her, I studered words. I don't know about the
situation but I know I was smiling inside. And it's weird even till this
day I kept that paper heart with me all this time and I hope I can tell
her that one day... Just wondering if that was love ...probably not.
with?
Well I guess I shouldn't be talking about love since I don't really know
what it is. I have been with a couple girls but I have never felt this
feeling I have right now with them. In 9th grade after my girlfriend broke
up with me, I didn't really feel anything like with every girl I'm with,
and then this girl started talking to me. I didn't get it, I didnt even
know this girl but i always have the same blank expression on my face yet
when she talked to me I knew I was smiling. I never asked her out, even
when she made this small little paper heart for me that had her name and
mine on it. Never did. Before 9th grade ended she stopped talking to me
completely ignored me actually. I Have had her for classes over the years
and I acted like I didn't care but I feel like I do care. Every time she
entered the room I had that bored expression but my heart skipped a beat
and I smiled inside. And now in 12th grade when I thought it be the same
she sat right next to me when she could have sat anywhere else I know that
dosent mean anything but she had talked to me and mind was a mess, I didnt
know what to say to her, I studered words. I don't know about the
situation but I know I was smiling inside. And it's weird even till this
day I kept that paper heart with me all this time and I hope I can tell
her that one day... Just wondering if that was love ...probably not.
CSS select first child only if two children
CSS select first child only if two children
Is there any way to select the first child only if there is a second
child? I'd like to hide the first
tag only if there is a second one. Is there any way to do this with CSS?
My code is this
<div>
<p></p>
<p>something</p>
</div>
Thanks!
Is there any way to select the first child only if there is a second
child? I'd like to hide the first
tag only if there is a second one. Is there any way to do this with CSS?
My code is this
<div>
<p></p>
<p>something</p>
</div>
Thanks!
How can I set the path to Instruments on Appium
How can I set the path to Instruments on Appium
I'm trying to run Appium for an iOS application, but it seems that the
path to instruments is invalid. How can I set it? Is there an environment
variable I should use? Or some argument? Even I could change that in the
source code it would be useful for me :)
Here's the relevant part of the log I receive from Appium:
debug: Creating instruments info: instruments is: info: [INSTSERVER]
Instruments socket server started at /tmp/instruments_sock info: Spawning
instruments with command: -t
/usr/local/lib/node_modules/appium/app/uiauto/Automation.tracetemplate
/var/folders/rd/z5t93lfj0cx0wm2_hqmthnkr0000gn/T/TestApp.app -e UIASCRIPT
/usr/local/lib/node_modules/appium/app/uiauto/bootstrap.js -e
UIARESULTSPATH /tmp/appium-instruments/
Thanks!
I'm trying to run Appium for an iOS application, but it seems that the
path to instruments is invalid. How can I set it? Is there an environment
variable I should use? Or some argument? Even I could change that in the
source code it would be useful for me :)
Here's the relevant part of the log I receive from Appium:
debug: Creating instruments info: instruments is: info: [INSTSERVER]
Instruments socket server started at /tmp/instruments_sock info: Spawning
instruments with command: -t
/usr/local/lib/node_modules/appium/app/uiauto/Automation.tracetemplate
/var/folders/rd/z5t93lfj0cx0wm2_hqmthnkr0000gn/T/TestApp.app -e UIASCRIPT
/usr/local/lib/node_modules/appium/app/uiauto/bootstrap.js -e
UIARESULTSPATH /tmp/appium-instruments/
Thanks!
WebBrowser Navigating function doesn't work and handlers are not called
WebBrowser Navigating function doesn't work and handlers are not called
Code below.
I am trying to navigate to a website and read information, the problem is
that Navigate doesn't work, the only event that is called is Navigating
and the printed Url is empty, the other events are never called. what am I
missing? do I have to use Form class in order to navigate? can't I use it
programatically from a Console application?
Please help.
class WebNavigator
{
private readonly WebBrowser webBrowser;
public WebNavigator()
{
webBrowser = new WebBrowser
{
AllowNavigation = true
};
webBrowser.Navigated += webBrowser_Navigated;
webBrowser.Navigating += webBrowser_Navigating;
webBrowser.DocumentCompleted += webBrowser_DocumentCompleted;
}
// Navigates to the given URL if it is valid.
public void Navigate(string address)
{
if (String.IsNullOrEmpty(address)) return;
if (address.Equals("about:blank")) return;
if (!address.StartsWith("http://") &&
!address.StartsWith("https://"))
{
address = "http://" + address;
}
try
{
Trace.TraceInformation("Navigate to {0}", address);
webBrowser.Navigate(new Uri(address));
}
catch (System.UriFormatException)
{
Trace.TraceError("Error");
return;
}
}
// Occurs when the WebBrowser control has navigated to a new document
and has begun loading it.
private void webBrowser_Navigated(object sender,
WebBrowserNavigatedEventArgs e)
{
Trace.TraceInformation("Navigated to {0}", webBrowser.Url);
}
// Occurs before the WebBrowser control navigates to a new document.
private void webBrowser_Navigating(object sender,
WebBrowserNavigatingEventArgs e)
{
Trace.TraceInformation("Navigating to {0}", webBrowser.Url);
}
private void webBrowser_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
var wb = sender as WebBrowser;
Trace.TraceInformation("DocumentCompleted {0}", wb.Url);
}
}
Code below.
I am trying to navigate to a website and read information, the problem is
that Navigate doesn't work, the only event that is called is Navigating
and the printed Url is empty, the other events are never called. what am I
missing? do I have to use Form class in order to navigate? can't I use it
programatically from a Console application?
Please help.
class WebNavigator
{
private readonly WebBrowser webBrowser;
public WebNavigator()
{
webBrowser = new WebBrowser
{
AllowNavigation = true
};
webBrowser.Navigated += webBrowser_Navigated;
webBrowser.Navigating += webBrowser_Navigating;
webBrowser.DocumentCompleted += webBrowser_DocumentCompleted;
}
// Navigates to the given URL if it is valid.
public void Navigate(string address)
{
if (String.IsNullOrEmpty(address)) return;
if (address.Equals("about:blank")) return;
if (!address.StartsWith("http://") &&
!address.StartsWith("https://"))
{
address = "http://" + address;
}
try
{
Trace.TraceInformation("Navigate to {0}", address);
webBrowser.Navigate(new Uri(address));
}
catch (System.UriFormatException)
{
Trace.TraceError("Error");
return;
}
}
// Occurs when the WebBrowser control has navigated to a new document
and has begun loading it.
private void webBrowser_Navigated(object sender,
WebBrowserNavigatedEventArgs e)
{
Trace.TraceInformation("Navigated to {0}", webBrowser.Url);
}
// Occurs before the WebBrowser control navigates to a new document.
private void webBrowser_Navigating(object sender,
WebBrowserNavigatingEventArgs e)
{
Trace.TraceInformation("Navigating to {0}", webBrowser.Url);
}
private void webBrowser_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
var wb = sender as WebBrowser;
Trace.TraceInformation("DocumentCompleted {0}", wb.Url);
}
}
How to Refresh Canvas in windows phone silverlight?
How to Refresh Canvas in windows phone silverlight?
I want to refresh canvas in windows phone, I already had write code to
remove the element of array when user touch the line, now I want to remove
the line, for that I had used array, but the problem is the Line is not
erasing, I think the code I have written is right, but the problem is I am
not getting function in Silverlight or C#, which refresh the canvas, like
as in android or Java,
public void checkIntersection()
{
for (int i = 0; i < gameData.Count(); i++)
{
for (int j = 0; j < gameData.ElementAt(i).Path.Count(); j++)
{
if (gameData.ElementAt(i).Path.Contains(new
Point(selectedRow, selectedCol)))
{
int index = gameData.ElementAt(i).Path.IndexOf(new
Point(selectedRow, selectedCol));
while (gameData.ElementAt(i).Path.Count() > index)
{
gameData.ElementAt(i).Path.RemoveAt(gameData.ElementAt(i).Path.Count()
- 1);
}
return;
}
}
}
drawPath();
}
I want to refresh canvas in windows phone, I already had write code to
remove the element of array when user touch the line, now I want to remove
the line, for that I had used array, but the problem is the Line is not
erasing, I think the code I have written is right, but the problem is I am
not getting function in Silverlight or C#, which refresh the canvas, like
as in android or Java,
public void checkIntersection()
{
for (int i = 0; i < gameData.Count(); i++)
{
for (int j = 0; j < gameData.ElementAt(i).Path.Count(); j++)
{
if (gameData.ElementAt(i).Path.Contains(new
Point(selectedRow, selectedCol)))
{
int index = gameData.ElementAt(i).Path.IndexOf(new
Point(selectedRow, selectedCol));
while (gameData.ElementAt(i).Path.Count() > index)
{
gameData.ElementAt(i).Path.RemoveAt(gameData.ElementAt(i).Path.Count()
- 1);
}
return;
}
}
}
drawPath();
}
Saturday, 24 August 2013
pass variable script argument to another script then pass to program
pass variable script argument to another script then pass to program
After reading through numerous bash script threads and help sites, I
cannot find a solution that works.
I want to pass a variable argument 'i' from a script to another script $i,
then pass this to a program "$1". In the program I read the variable from
the argument vector (**argv) and then use this variable to modify the name
of output files as *_0, *_1, *_2, ..., *_n.
The idea is so I can have a unique output file for each instance of a
program. The program is parallel but due to limitations of the computing
resources, I need to submit one job for a maximum of four computing nodes
- or it will never pass through the que. So, I'd like to spin off 64
4-node jobs.
So far I have read topic on:
"-C option" Passing arguments to /bin/bash via a bash script
"pass arguments"
http://linux.about.com/od/Bash_Scripting_Solutions/a/How-To-Pass-Arguments-To-A-Bash-Script.htm
"start with argument $0 or #1" How can I pass a file argument to my bash
script using a Terminal command in Linux?
"pass arguments"
http://how-to.wikia.com/wiki/How_to_read_command_line_arguments_in_a_bash_script
After reading these, I feel comfortable with the concept but still it is
confusing how exactly the -C and -S command are used, or if they are used
at all; most examples exclude these.
This is my spinoff pre-script
#
#$ -cwd
#$ -S /bin/bash
#$ -pe fah 1
for((i=0; i < 2; i++)); do qsub test_S17_script.sh $i; done
side info: what is qsub
And this is my script
#
#$ -M duser@acme_u.edu
#$ -m bae
#$ -cwd
#$ -S /bin/bash
#$ -pe fah 1
./daedalus_linux_1.3_64 1 "$1"
So, the spinoff works fine, and generates the files. And, the script works
fine passing a constant ./daedalus_linux_1.3_64 1 1 but passing the
variable does not work. I do not know if the prescript correctly passes
variable i to the script. I don't know how to write to a error file from a
script - or if this is even how I want to check if the variable is passed.
The computing has no user interface so once it is in the queue I must rely
on error file outputs.
Thank you in advance for your help.
After reading through numerous bash script threads and help sites, I
cannot find a solution that works.
I want to pass a variable argument 'i' from a script to another script $i,
then pass this to a program "$1". In the program I read the variable from
the argument vector (**argv) and then use this variable to modify the name
of output files as *_0, *_1, *_2, ..., *_n.
The idea is so I can have a unique output file for each instance of a
program. The program is parallel but due to limitations of the computing
resources, I need to submit one job for a maximum of four computing nodes
- or it will never pass through the que. So, I'd like to spin off 64
4-node jobs.
So far I have read topic on:
"-C option" Passing arguments to /bin/bash via a bash script
"pass arguments"
http://linux.about.com/od/Bash_Scripting_Solutions/a/How-To-Pass-Arguments-To-A-Bash-Script.htm
"start with argument $0 or #1" How can I pass a file argument to my bash
script using a Terminal command in Linux?
"pass arguments"
http://how-to.wikia.com/wiki/How_to_read_command_line_arguments_in_a_bash_script
After reading these, I feel comfortable with the concept but still it is
confusing how exactly the -C and -S command are used, or if they are used
at all; most examples exclude these.
This is my spinoff pre-script
#
#$ -cwd
#$ -S /bin/bash
#$ -pe fah 1
for((i=0; i < 2; i++)); do qsub test_S17_script.sh $i; done
side info: what is qsub
And this is my script
#
#$ -M duser@acme_u.edu
#$ -m bae
#$ -cwd
#$ -S /bin/bash
#$ -pe fah 1
./daedalus_linux_1.3_64 1 "$1"
So, the spinoff works fine, and generates the files. And, the script works
fine passing a constant ./daedalus_linux_1.3_64 1 1 but passing the
variable does not work. I do not know if the prescript correctly passes
variable i to the script. I don't know how to write to a error file from a
script - or if this is even how I want to check if the variable is passed.
The computing has no user interface so once it is in the queue I must rely
on error file outputs.
Thank you in advance for your help.
Operator '
Operator '
I have been debugging this for some time but even though I knew what to
do, I don't know what kind of code to put
this is the error message that I always recieve
Assets/scripts/JavaScripts/PerformanceTweak.js(220,32): BCE0051: Operator
'<' cannot be used with a left hand side of type 'Object' and a right hand
side of type 'float'.
Although I know that i need to convert the object to float, I am having
hard time coding for it. while this is the code I have.
var fpsCounter : FPSCounter;
var terrain : Terrain;
var messageTime = 10.0;
var scrollTime = 0.7;
private var messages = new Array();
private var times = new Array();
private var lastTime = 0.0;
private var doneNotes = false;
private var origDetailDist = 0.0;
private var origSplatDist = 0.0;
private var origTreeDist = 0.0;
private var origMaxLOD = 0;
private var softVegetationOff = false;
private var splatmapsOff = false;
private var lowFPS = 15.0;
private var highFPS = 35.0;
private var skipChangesTimeout = 1.0;
private var nextTerrainChange = 0;
function Start()
{
if( !fpsCounter || !terrain ) {
Debug.LogWarning("Some of performance objects are not set up");
enabled = false;
return;
}
origDetailDist = terrain.detailObjectDistance;
origSplatDist = terrain.basemapDistance;
origTreeDist = terrain.treeDistance;
origMaxLOD = terrain.heightmapMaximumLOD;
skipChangesTimeout = 0.0;
var distances : float[] = new float[32];
distances[16] = Camera.main.farClipPlane;
Camera.main.layerCullDistances = distances;
}
function Update ()
{
if( !fpsCounter || !terrain )
return;
if( !doneNotes && !Application.isEditor )
{
var gfxCard = SystemInfo.graphicsDeviceName.ToLower();
var gfxVendor = SystemInfo.graphicsDeviceVendor.ToLower();
if( gfxVendor.Contains("intel") )
{
// on pre-GMA950, increase fog and reduce far plane by 4x :)
softVegetationOff = true;
QualitySettings.softVegetation = false;
AddMessage( "Note: turning off soft vegetation (Intel video card
detected)" );
}
else if( gfxVendor == "sis" )
{
softVegetationOff = true;
QualitySettings.softVegetation = false;
AddMessage( "Note: turning off soft vegetation (SIS video card
detected)" );
}
else if( gfxCard.Contains("geforce") && (gfxCard.Contains("5200")
|| gfxCard.Contains("5500") || gfxCard.Contains("6100")) )
{
// on slow/old geforce cards, increase fog and reduce far plane
by 2x
ReduceDrawDistance( 2.0, "Note: reducing draw distance (slow
GeForce card detected)" );
softVegetationOff = true;
QualitySettings.softVegetation = false;
AddMessage( "Note: turning off soft vegetation (slow GeForce card
detected)" );
}
else
{
// on other old cards, increase fog and reduce far plane by 2x
// if( hwWater == IslandWater.WaterMode.Simple )
// {
// ReduceDrawDistance( 2.0, "Note: reducing draw distance (old
video card detected)" );
// }
}
skipChangesTimeout = 0.0;
doneNotes = true;
}
DoTweaks();
UpdateMessages();
}
function ReduceDrawDistance( factor : float, message : String )
{
AddMessage( message );
// RenderSettings.fogDensity *= factor;
// Camera.main.farClipPlane /= factor;
var distances : float[] = Camera.main.layerCullDistances;
for(var i : int = 0; i < distances.Length; i++)
distances[i] /= factor;
Camera.main.layerCullDistances = distances;
}
function OnDisable()
{
QualitySettings.softVegetation = true;
}
function DoTweaks()
{
if( !fpsCounter.HasFPS() )
return; // enough time did not pass yet to get decent FPS count
var fps : float = fpsCounter.GetFPS();
// don't do too many adjustments at time... allow one per
// FPS update interval
skipChangesTimeout -= Time.deltaTime;
if( skipChangesTimeout < 0.0 )
skipChangesTimeout = 0.0;
if( skipChangesTimeout > 0.0 )
return;
// terrain tweaks
if( fps > 25.0 )
{
// bump up!
++nextTerrainChange;
if( nextTerrainChange >= 4 )
nextTerrainChange = 0;
if( nextTerrainChange == 0 && terrain.detailObjectDistance <
origDetailDist )
{
terrain.detailObjectDistance *= 2.0;
if( !softVegetationOff )
QualitySettings.softVegetation = true;
AddMessage( "Framerate ok, increasing vegetation detail" );
return;
}
if( nextTerrainChange == 1 && !splatmapsOff &&
terrain.basemapDistance < origSplatDist )
{
terrain.basemapDistance *= 2.0;
AddMessage( "Framerate ok, increasing terrain texture detail" );
return;
}
if( nextTerrainChange == 2 && terrain.treeDistance < origTreeDist )
{
terrain.treeDistance *= 2.0;
AddMessage( "Framerate ok, increasing tree draw distance" );
return;
}
}
if( fps < lowFPS )
{
// lower it
++nextTerrainChange;
if( nextTerrainChange >= 4 ) {
nextTerrainChange = 0;
lowFPS = 10.0; // ok, this won't be fast...
}
if( nextTerrainChange == 0 && terrain.detailObjectDistance >=
origDetailDist / 16.0 ) {
terrain.detailObjectDistance *= 0.5;
QualitySettings.softVegetation = false;
AddMessage( "Framerate low, reducing vegetation detail" );
return;
}
if( nextTerrainChange == 1 && !splatmapsOff &&
terrain.basemapDistance >= origSplatDist / 16.0 )
{
terrain.basemapDistance *= 0.5;
AddMessage( "Framerate low, reducing terrain texture detail" );
return;
}
if( nextTerrainChange == 2 && terrain.treeDistance >= origTreeDist
/ 16.0 )
{
terrain.treeDistance *= 0.5;
AddMessage( "Framerate low, reducing tree draw distance" );
return;
}
}
if(fps < 20)
{
if(QualitySettings.currentLevel > QualityLevel.Fastest)
QualitySettings.DecreaseLevel();
}
else if(fps > highFPS)
{
if(QualitySettings.currentLevel < QualityLevel.Fantastic)
QualitySettings.IncreaseLevel();
}
if(QualitySettings.currentLevel < QualityLevel.Good)
{
var sh : Shader = Shader.Find("VertexLit");
var bumpedObjects : GameObject[] =
GameObject.FindGameObjectsWithTag("Bumped");
for(var i : int = 0; i < bumpedObjects.length; i++)
{
bumpedObjects[i].renderer.material.shader = sh;
}
}
}
function AddMessage( t : String )
{
messages.Add( t );
times.Add( messageTime );
lastTime = scrollTime;
skipChangesTimeout = fpsCounter.updateInterval * 3.0;
}
function UpdateMessages()
{
var dt = Time.deltaTime;
for( var t in times )
parseFloat(t.ToString());
parseFloat -= dt;
var example = times.length;
var exam = times[0];
parseFloat(exam.ToString());
while( example > 0 && exam < 0.0 ) {
times.Shift();
messages.Shift();
}
lastTime -= dt;
if( lastTime < 0.0 )
lastTime = 0.0;
}
function OnGUI()
{
var height = 15;
var n : int = messages.length;
var rc = Rect( 2, Screen.height - 2 - n * height +
(lastTime/scrollTime*height), 600, 20 );
for( var i = 0; i < n; ++i )
{
var text : String = messages[i];
var time : float = times[i];
var alpha = time / messageTime;
if( alpha < 0.2 )
GUI.color.a = alpha / 0.2;
else if( alpha > 0.9 )
GUI.color.a = 1.0 - (alpha-0.9) / (1-0.9);
else
GUI.color.a = 1.0;
GUI.Label( rc, text );
rc.y += height;
}
}
cab you guys please help me?
I have been debugging this for some time but even though I knew what to
do, I don't know what kind of code to put
this is the error message that I always recieve
Assets/scripts/JavaScripts/PerformanceTweak.js(220,32): BCE0051: Operator
'<' cannot be used with a left hand side of type 'Object' and a right hand
side of type 'float'.
Although I know that i need to convert the object to float, I am having
hard time coding for it. while this is the code I have.
var fpsCounter : FPSCounter;
var terrain : Terrain;
var messageTime = 10.0;
var scrollTime = 0.7;
private var messages = new Array();
private var times = new Array();
private var lastTime = 0.0;
private var doneNotes = false;
private var origDetailDist = 0.0;
private var origSplatDist = 0.0;
private var origTreeDist = 0.0;
private var origMaxLOD = 0;
private var softVegetationOff = false;
private var splatmapsOff = false;
private var lowFPS = 15.0;
private var highFPS = 35.0;
private var skipChangesTimeout = 1.0;
private var nextTerrainChange = 0;
function Start()
{
if( !fpsCounter || !terrain ) {
Debug.LogWarning("Some of performance objects are not set up");
enabled = false;
return;
}
origDetailDist = terrain.detailObjectDistance;
origSplatDist = terrain.basemapDistance;
origTreeDist = terrain.treeDistance;
origMaxLOD = terrain.heightmapMaximumLOD;
skipChangesTimeout = 0.0;
var distances : float[] = new float[32];
distances[16] = Camera.main.farClipPlane;
Camera.main.layerCullDistances = distances;
}
function Update ()
{
if( !fpsCounter || !terrain )
return;
if( !doneNotes && !Application.isEditor )
{
var gfxCard = SystemInfo.graphicsDeviceName.ToLower();
var gfxVendor = SystemInfo.graphicsDeviceVendor.ToLower();
if( gfxVendor.Contains("intel") )
{
// on pre-GMA950, increase fog and reduce far plane by 4x :)
softVegetationOff = true;
QualitySettings.softVegetation = false;
AddMessage( "Note: turning off soft vegetation (Intel video card
detected)" );
}
else if( gfxVendor == "sis" )
{
softVegetationOff = true;
QualitySettings.softVegetation = false;
AddMessage( "Note: turning off soft vegetation (SIS video card
detected)" );
}
else if( gfxCard.Contains("geforce") && (gfxCard.Contains("5200")
|| gfxCard.Contains("5500") || gfxCard.Contains("6100")) )
{
// on slow/old geforce cards, increase fog and reduce far plane
by 2x
ReduceDrawDistance( 2.0, "Note: reducing draw distance (slow
GeForce card detected)" );
softVegetationOff = true;
QualitySettings.softVegetation = false;
AddMessage( "Note: turning off soft vegetation (slow GeForce card
detected)" );
}
else
{
// on other old cards, increase fog and reduce far plane by 2x
// if( hwWater == IslandWater.WaterMode.Simple )
// {
// ReduceDrawDistance( 2.0, "Note: reducing draw distance (old
video card detected)" );
// }
}
skipChangesTimeout = 0.0;
doneNotes = true;
}
DoTweaks();
UpdateMessages();
}
function ReduceDrawDistance( factor : float, message : String )
{
AddMessage( message );
// RenderSettings.fogDensity *= factor;
// Camera.main.farClipPlane /= factor;
var distances : float[] = Camera.main.layerCullDistances;
for(var i : int = 0; i < distances.Length; i++)
distances[i] /= factor;
Camera.main.layerCullDistances = distances;
}
function OnDisable()
{
QualitySettings.softVegetation = true;
}
function DoTweaks()
{
if( !fpsCounter.HasFPS() )
return; // enough time did not pass yet to get decent FPS count
var fps : float = fpsCounter.GetFPS();
// don't do too many adjustments at time... allow one per
// FPS update interval
skipChangesTimeout -= Time.deltaTime;
if( skipChangesTimeout < 0.0 )
skipChangesTimeout = 0.0;
if( skipChangesTimeout > 0.0 )
return;
// terrain tweaks
if( fps > 25.0 )
{
// bump up!
++nextTerrainChange;
if( nextTerrainChange >= 4 )
nextTerrainChange = 0;
if( nextTerrainChange == 0 && terrain.detailObjectDistance <
origDetailDist )
{
terrain.detailObjectDistance *= 2.0;
if( !softVegetationOff )
QualitySettings.softVegetation = true;
AddMessage( "Framerate ok, increasing vegetation detail" );
return;
}
if( nextTerrainChange == 1 && !splatmapsOff &&
terrain.basemapDistance < origSplatDist )
{
terrain.basemapDistance *= 2.0;
AddMessage( "Framerate ok, increasing terrain texture detail" );
return;
}
if( nextTerrainChange == 2 && terrain.treeDistance < origTreeDist )
{
terrain.treeDistance *= 2.0;
AddMessage( "Framerate ok, increasing tree draw distance" );
return;
}
}
if( fps < lowFPS )
{
// lower it
++nextTerrainChange;
if( nextTerrainChange >= 4 ) {
nextTerrainChange = 0;
lowFPS = 10.0; // ok, this won't be fast...
}
if( nextTerrainChange == 0 && terrain.detailObjectDistance >=
origDetailDist / 16.0 ) {
terrain.detailObjectDistance *= 0.5;
QualitySettings.softVegetation = false;
AddMessage( "Framerate low, reducing vegetation detail" );
return;
}
if( nextTerrainChange == 1 && !splatmapsOff &&
terrain.basemapDistance >= origSplatDist / 16.0 )
{
terrain.basemapDistance *= 0.5;
AddMessage( "Framerate low, reducing terrain texture detail" );
return;
}
if( nextTerrainChange == 2 && terrain.treeDistance >= origTreeDist
/ 16.0 )
{
terrain.treeDistance *= 0.5;
AddMessage( "Framerate low, reducing tree draw distance" );
return;
}
}
if(fps < 20)
{
if(QualitySettings.currentLevel > QualityLevel.Fastest)
QualitySettings.DecreaseLevel();
}
else if(fps > highFPS)
{
if(QualitySettings.currentLevel < QualityLevel.Fantastic)
QualitySettings.IncreaseLevel();
}
if(QualitySettings.currentLevel < QualityLevel.Good)
{
var sh : Shader = Shader.Find("VertexLit");
var bumpedObjects : GameObject[] =
GameObject.FindGameObjectsWithTag("Bumped");
for(var i : int = 0; i < bumpedObjects.length; i++)
{
bumpedObjects[i].renderer.material.shader = sh;
}
}
}
function AddMessage( t : String )
{
messages.Add( t );
times.Add( messageTime );
lastTime = scrollTime;
skipChangesTimeout = fpsCounter.updateInterval * 3.0;
}
function UpdateMessages()
{
var dt = Time.deltaTime;
for( var t in times )
parseFloat(t.ToString());
parseFloat -= dt;
var example = times.length;
var exam = times[0];
parseFloat(exam.ToString());
while( example > 0 && exam < 0.0 ) {
times.Shift();
messages.Shift();
}
lastTime -= dt;
if( lastTime < 0.0 )
lastTime = 0.0;
}
function OnGUI()
{
var height = 15;
var n : int = messages.length;
var rc = Rect( 2, Screen.height - 2 - n * height +
(lastTime/scrollTime*height), 600, 20 );
for( var i = 0; i < n; ++i )
{
var text : String = messages[i];
var time : float = times[i];
var alpha = time / messageTime;
if( alpha < 0.2 )
GUI.color.a = alpha / 0.2;
else if( alpha > 0.9 )
GUI.color.a = 1.0 - (alpha-0.9) / (1-0.9);
else
GUI.color.a = 1.0;
GUI.Label( rc, text );
rc.y += height;
}
}
cab you guys please help me?
Using selenium to save images from page
Using selenium to save images from page
I'm using Selenium & Google Chrome Driver to open pages programatically.
On each page there is a dynamically generated image which I'd like to
download. At the moment, I'm waiting for the page to finish loading, then
I grab the image URL and download it using System.Net.WebClient.
That works fine except I'm downloading the images twice - once in the
browser, once with WebClient. The problem is that each image is roughly
15MB and downloading twice adds up quickly.
So - is it possible to grab the image straight from Google Chrome?
I'm using Selenium & Google Chrome Driver to open pages programatically.
On each page there is a dynamically generated image which I'd like to
download. At the moment, I'm waiting for the page to finish loading, then
I grab the image URL and download it using System.Net.WebClient.
That works fine except I'm downloading the images twice - once in the
browser, once with WebClient. The problem is that each image is roughly
15MB and downloading twice adds up quickly.
So - is it possible to grab the image straight from Google Chrome?
Why can't I override the * method in Ruby?
Why can't I override the * method in Ruby?
I'm working on a Ruby Gem for creating presentations, and I would like to
create a syntax for defining slides that is simple and intuitive. I'm
making use of instance_eval so I can call methods on self. Here's what I
originally planned to do:
slide {
title 'What is Ruby?'
* 'a programming language'
* 'with lots of interpreters'
* 'lots of fun!'
}
Even though I've defined a * method, I get the error:
in `instance_eval': ... syntax error, unexpected '\n', expecting :: or '['
or '.' (SyntaxError)
I have compromised by creating a short method called b for creating
bullets, but it's not as nice:
slide {
title 'What is Ruby?'
b 'a programming language'
b 'with lots of interpreters'
b 'lots of fun!'
}
Is this just a limitation of the interpreter? Or is there a way to get
around it?
I'm working on a Ruby Gem for creating presentations, and I would like to
create a syntax for defining slides that is simple and intuitive. I'm
making use of instance_eval so I can call methods on self. Here's what I
originally planned to do:
slide {
title 'What is Ruby?'
* 'a programming language'
* 'with lots of interpreters'
* 'lots of fun!'
}
Even though I've defined a * method, I get the error:
in `instance_eval': ... syntax error, unexpected '\n', expecting :: or '['
or '.' (SyntaxError)
I have compromised by creating a short method called b for creating
bullets, but it's not as nice:
slide {
title 'What is Ruby?'
b 'a programming language'
b 'with lots of interpreters'
b 'lots of fun!'
}
Is this just a limitation of the interpreter? Or is there a way to get
around it?
breaking lines in listings enviroment
breaking lines in listings enviroment
I am trying to make listing enviroment brake lines. Unfortunately
breaklines=true does not work for me. Here is my code:
\usepackage{listings}
\begin{document}
\lstset{language=matlab,breaklines=true, extendedchars=true, numbers=left,
numberstyle=\tiny, stepnumber=1, numbersep=5pt, basicstyle=\footnotesize,
frame=lines, keywordstyle=\bfseries\color{blue},
commentstyle=\color{green!50!black}}
\lstset{emph={classdef, properties,
methods},emphstyle={\color{blue}\bfseries}}
\renewcommand{\lstlistingname}{Algorytm}
\begin{lstlisting}[caption=Funkcja \emph{createFoR} klasy \emph{row}.,
label=func_createFoR, float=ht]
classdef row < handle
properties
rp %promien rownoleznika
end
methods
function [T1 T2] = createFoR(obj,hT,Alpha,Beta,DeltaAlpha,DeltaBeta)
P1(1,1) = obj.r * cosd(Beta);
P1(1,2) = obj.r * cosd(90 - Beta);
P1(1,3) = obj.r * tand(90 - (Alpha + DeltaAlpha));
P1(2,:) = hT.P(1,:);
%hT - trojkat z wyzszego wiersza
P1(3,1) = obj.r * cosd(Beta + DeltaBeta);
P1(3,2) = obj.r * cosd(90 - (Beta + DeltaBeta));
P1(3,3) = obj.r * tand(90 - (Alpha + DeltaAlpha));
T1 = triangle(P1);
P2(1,:) = hT.P(1,:);
P2(2,:) = hT.P(3,:);
P2(3,:) = P1(3,:);
T2 = triangle(P2);
end
end
\end{lstlisting}
This is how it looks:
May I kindly ask you for help?
I am trying to make listing enviroment brake lines. Unfortunately
breaklines=true does not work for me. Here is my code:
\usepackage{listings}
\begin{document}
\lstset{language=matlab,breaklines=true, extendedchars=true, numbers=left,
numberstyle=\tiny, stepnumber=1, numbersep=5pt, basicstyle=\footnotesize,
frame=lines, keywordstyle=\bfseries\color{blue},
commentstyle=\color{green!50!black}}
\lstset{emph={classdef, properties,
methods},emphstyle={\color{blue}\bfseries}}
\renewcommand{\lstlistingname}{Algorytm}
\begin{lstlisting}[caption=Funkcja \emph{createFoR} klasy \emph{row}.,
label=func_createFoR, float=ht]
classdef row < handle
properties
rp %promien rownoleznika
end
methods
function [T1 T2] = createFoR(obj,hT,Alpha,Beta,DeltaAlpha,DeltaBeta)
P1(1,1) = obj.r * cosd(Beta);
P1(1,2) = obj.r * cosd(90 - Beta);
P1(1,3) = obj.r * tand(90 - (Alpha + DeltaAlpha));
P1(2,:) = hT.P(1,:);
%hT - trojkat z wyzszego wiersza
P1(3,1) = obj.r * cosd(Beta + DeltaBeta);
P1(3,2) = obj.r * cosd(90 - (Beta + DeltaBeta));
P1(3,3) = obj.r * tand(90 - (Alpha + DeltaAlpha));
T1 = triangle(P1);
P2(1,:) = hT.P(1,:);
P2(2,:) = hT.P(3,:);
P2(3,:) = P1(3,:);
T2 = triangle(P2);
end
end
\end{lstlisting}
This is how it looks:
May I kindly ask you for help?
Using PhantomJS in webdriver, what are ways to work around and debug lack of "existing" data returned?
Using PhantomJS in webdriver, what are ways to work around and debug lack
of "existing" data returned?
I have left the website off, as not to give anyone ideas on scraping, but
I can return a full page using Firefox webdriver, but not PhantomJS. The
html "exists" in a standard browser, but not while using the headless. My
script is in Python. Example...
from selenium import webdriver
driver = webdriver.PhantomJS()
spec = "xproduct123"
base_url = "https://www.xxx.com/products/%s" % spec
driver.get(base_url)
selector = driver.find_element_by_tag_name("html").text
print selector
driver.close()
returns Process finished with exit code 0
If I change the webdriver to driver = webdriver.Firefox() I will get a
full html page (at least the text content) in my terminal. This does not
happen on all sites, so I have to figure a workaround without sharing the
site I am scraping if possible.
of "existing" data returned?
I have left the website off, as not to give anyone ideas on scraping, but
I can return a full page using Firefox webdriver, but not PhantomJS. The
html "exists" in a standard browser, but not while using the headless. My
script is in Python. Example...
from selenium import webdriver
driver = webdriver.PhantomJS()
spec = "xproduct123"
base_url = "https://www.xxx.com/products/%s" % spec
driver.get(base_url)
selector = driver.find_element_by_tag_name("html").text
print selector
driver.close()
returns Process finished with exit code 0
If I change the webdriver to driver = webdriver.Firefox() I will get a
full html page (at least the text content) in my terminal. This does not
happen on all sites, so I have to figure a workaround without sharing the
site I am scraping if possible.
Radio buttons and hidden fields
Radio buttons and hidden fields
I am trying to create a list that appears when the radio buttons are
clicked, I am having a problem with the way the list appears once the
button is clicked.
Here is the example http://jsfiddle.net/c2webdev/4bpKE/
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<style>
.none {
display:none;
}
</style>
</head>
<body>
<input type="radio" name='thing' value='valuable' data-id="bank" />Running
Event
<input type="radio" name='thing' value='valuable' data-id="school" />Other
challenges
<input type="radio" name='thing' value='valuable' data-id="bakery" />Baking
<div id="school" class="none">
<label for="name">What was the activity called?</label>
<select id = "myList">
<option value = "1">List item 1</option>
<option value = "2">List item 2</option>
<option value = "3">List item 3</option>
<option value = "4">List item 4</option>
</select>
</div>
<div id="bank" class="none">
<label for="name">What was the activity called?</label>
<select id = "myList">
<option value = "1">Pancake Making</option>
<option value = "2">Egg and spoon race</option>
<option value = "3">Sack race </option>
<option value = "4">Three leg race</option>
</select></div>
<div id="bakery" class="none">
<label for="name">What was the activity called?</label>
<select id = "myList">
<option value = "1">Pancake Making</option>
<option value = "2">Egg and spoon race</option>
<option value = "3">Sack race </option>
<option value = "4">Three leg race</option>
</select></div>
<script>
$(':radio').change(function (event) {
var id = $(this).data('id');
$('#' + id).addClass('none').siblings().removeClass('none');
});
</script>
</body>
</html>
Please help
I am trying to create a list that appears when the radio buttons are
clicked, I am having a problem with the way the list appears once the
button is clicked.
Here is the example http://jsfiddle.net/c2webdev/4bpKE/
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<style>
.none {
display:none;
}
</style>
</head>
<body>
<input type="radio" name='thing' value='valuable' data-id="bank" />Running
Event
<input type="radio" name='thing' value='valuable' data-id="school" />Other
challenges
<input type="radio" name='thing' value='valuable' data-id="bakery" />Baking
<div id="school" class="none">
<label for="name">What was the activity called?</label>
<select id = "myList">
<option value = "1">List item 1</option>
<option value = "2">List item 2</option>
<option value = "3">List item 3</option>
<option value = "4">List item 4</option>
</select>
</div>
<div id="bank" class="none">
<label for="name">What was the activity called?</label>
<select id = "myList">
<option value = "1">Pancake Making</option>
<option value = "2">Egg and spoon race</option>
<option value = "3">Sack race </option>
<option value = "4">Three leg race</option>
</select></div>
<div id="bakery" class="none">
<label for="name">What was the activity called?</label>
<select id = "myList">
<option value = "1">Pancake Making</option>
<option value = "2">Egg and spoon race</option>
<option value = "3">Sack race </option>
<option value = "4">Three leg race</option>
</select></div>
<script>
$(':radio').change(function (event) {
var id = $(this).data('id');
$('#' + id).addClass('none').siblings().removeClass('none');
});
</script>
</body>
</html>
Please help
grunt no target found issue
grunt no target found issue
I have written a following file grunt.js
var _path = require('path');
module.exports = function (grunt) {
var config = {
};
function addProject(project) {
grunt.helper('addProject', config, project);
}
addProject({
name:'mytest',
type:'module',
sourcePath:'../source',
outputPath:'../test/',
version : grunt.option('ver')||'0.1.0.0'
});
grunt.registerTask('default', 'module closureCompiler');
grunt.initConfig(config);
};
when i run it using a command in my bat file module closureCompiler sync,
it gives an error saying
Running "sync" task
>> No "sync" targets found.
<WARN> Task "sync" failed. Use --force
What does this mean?
I have written a following file grunt.js
var _path = require('path');
module.exports = function (grunt) {
var config = {
};
function addProject(project) {
grunt.helper('addProject', config, project);
}
addProject({
name:'mytest',
type:'module',
sourcePath:'../source',
outputPath:'../test/',
version : grunt.option('ver')||'0.1.0.0'
});
grunt.registerTask('default', 'module closureCompiler');
grunt.initConfig(config);
};
when i run it using a command in my bat file module closureCompiler sync,
it gives an error saying
Running "sync" task
>> No "sync" targets found.
<WARN> Task "sync" failed. Use --force
What does this mean?
Is there something like a scope of \NewDocumentCommand?
Is there something like a scope of \NewDocumentCommand?
Following along the line of my (confused) post on xparse and expl3, but
this time hopefully with no typos or missing characters, I've devised a
small package just to check a l3keys-based definition and setting of
options. My issue is not (so far) with the passing of options, but with an
unexpected (to me) behavior of a command.
I have a file tmpkgl3.sty with this content:
\ProvidesPackage{tmpkgl3}[2013/08/20 LaTeX2e/LaTeX3 wannabe package]
\RequirePackage{xparse,l3keys2e}
\ExplSyntaxOn
% Some of the variants are already declared in LaTeX3
\cs_generate_variant:Nn \bool_new:N {c}
\cs_generate_variant:Nn \bool_if:NTF {cTF}
\cs_generate_variant:Nn \bool_set_true:N {c}
% I have in mind egreg's remarks in my linked post regarding not using
this as I do.
\tl_const:Nn \c_prefix_tl {g_amod_}
\tl_const:Nn \c_postfix_tl {_bool}
\NewDocumentCommand\MakeBool { m }
{
\bool_new:c
{ \tl_use:N \c_prefix_tl #1 \tl_use:N \c_postfix_tl }
}
\NewDocumentCommand\SetTBool { m }
{
\bool_set_true:c
{ \tl_use:N \c_prefix_tl #1 \tl_use:N \c_postfix_tl }
}
\NewDocumentCommand\WelcherWegBool { m m m }
{
\bool_if:cTF
{ \tl_use:N \c_prefix_tl #1 \tl_use:N \c_postfix_tl }
{ #2 } { #3 }
}
\MakeBool{esp}
\keys_define:nn { amod }
{
lang .choice_code:n =
{ \SetTBool { \tl_use:N \l_keys_choice_tl }
\WelcherWegBool { esp } { True } { False } \par
},
lang .generate_choices:n = { esp },
}
\DeclareDocumentCommand\DocumentSetup { +m }
{ \keys_set:nn { amod }{#1} }
%\ProcessKeysOptions { amod }
\ExplSyntaxOff
Then, I have the next content in a .tex file l3tryout.tex:
\documentclass{memoir}
\usepackage{tmpkgl3}
%\ExplSyntaxOn
%\ProvideDocumentCommand\WelcherWegBool { m m m }
% {
% \bool_if:cTF
% { \tl_use:N \c_prefix_tl #1 \tl_use:N \c_postfix_tl }
% { #2 } { #3 }
% }
\AtBeginDocument{%
\DocumentSetup{ lang = esp }
}
\begin{document}
\WelcherWegBool { esp } { T }{ F }
\end{document}
%\ExplSyntaxOff
With the files like above I get True F, whereas I should get True T (in
two different paragraphs due to the \par in the options definition).
Nonetheless, if I uncomment the commented lines in the l3tryout.tex file,
I get the right result. It's as though the command \WelcherWegBool worked
fine in the package but not so in the tex file. May this have something to
do with having switched off the ExplSyntax switch?
Following along the line of my (confused) post on xparse and expl3, but
this time hopefully with no typos or missing characters, I've devised a
small package just to check a l3keys-based definition and setting of
options. My issue is not (so far) with the passing of options, but with an
unexpected (to me) behavior of a command.
I have a file tmpkgl3.sty with this content:
\ProvidesPackage{tmpkgl3}[2013/08/20 LaTeX2e/LaTeX3 wannabe package]
\RequirePackage{xparse,l3keys2e}
\ExplSyntaxOn
% Some of the variants are already declared in LaTeX3
\cs_generate_variant:Nn \bool_new:N {c}
\cs_generate_variant:Nn \bool_if:NTF {cTF}
\cs_generate_variant:Nn \bool_set_true:N {c}
% I have in mind egreg's remarks in my linked post regarding not using
this as I do.
\tl_const:Nn \c_prefix_tl {g_amod_}
\tl_const:Nn \c_postfix_tl {_bool}
\NewDocumentCommand\MakeBool { m }
{
\bool_new:c
{ \tl_use:N \c_prefix_tl #1 \tl_use:N \c_postfix_tl }
}
\NewDocumentCommand\SetTBool { m }
{
\bool_set_true:c
{ \tl_use:N \c_prefix_tl #1 \tl_use:N \c_postfix_tl }
}
\NewDocumentCommand\WelcherWegBool { m m m }
{
\bool_if:cTF
{ \tl_use:N \c_prefix_tl #1 \tl_use:N \c_postfix_tl }
{ #2 } { #3 }
}
\MakeBool{esp}
\keys_define:nn { amod }
{
lang .choice_code:n =
{ \SetTBool { \tl_use:N \l_keys_choice_tl }
\WelcherWegBool { esp } { True } { False } \par
},
lang .generate_choices:n = { esp },
}
\DeclareDocumentCommand\DocumentSetup { +m }
{ \keys_set:nn { amod }{#1} }
%\ProcessKeysOptions { amod }
\ExplSyntaxOff
Then, I have the next content in a .tex file l3tryout.tex:
\documentclass{memoir}
\usepackage{tmpkgl3}
%\ExplSyntaxOn
%\ProvideDocumentCommand\WelcherWegBool { m m m }
% {
% \bool_if:cTF
% { \tl_use:N \c_prefix_tl #1 \tl_use:N \c_postfix_tl }
% { #2 } { #3 }
% }
\AtBeginDocument{%
\DocumentSetup{ lang = esp }
}
\begin{document}
\WelcherWegBool { esp } { T }{ F }
\end{document}
%\ExplSyntaxOff
With the files like above I get True F, whereas I should get True T (in
two different paragraphs due to the \par in the options definition).
Nonetheless, if I uncomment the commented lines in the l3tryout.tex file,
I get the right result. It's as though the command \WelcherWegBool worked
fine in the package but not so in the tex file. May this have something to
do with having switched off the ExplSyntax switch?
What should I start with when making a game?
What should I start with when making a game?
I am going to make a game in 2D or 3D. But I have a problem I can't decide
if I should do the AI, physics, graphics or level designs first and if I
should use 2D or 3D.
If I use 2D I will use eclipse to program in Java. It will be a smaller
job and won't require highly detailed graphics, but it could be that
people won't like it as much as 3D. With 3D it is a bigger job, but I am
using unity to make my job easier. Unity is good, but I don't know if you
can stretch the limits as long as in programming. It is no way I will
program the whole 3D game.
And to the second question: What should I start with? AI, physics,
graphics, level designs? That would be good to know that too.
If I am going to make a 2D game I think I will make a platform game with
basic physics like gravity, and basic graphics. I don't think people will
be very impressed over that.
If I am going to make a 3D game I think it will be more like a big project
with a first person shooter camera and a big environment with high
detailed graphics. People would like that a little more
I can just a little bit about making textures to 3D objects. I have maked
textures to 2D objects so I have a little more experience about that. And
I can do much with programming with my experience, but it is limited of
course. 3D games will be very hard to work with.
I am going to make a game in 2D or 3D. But I have a problem I can't decide
if I should do the AI, physics, graphics or level designs first and if I
should use 2D or 3D.
If I use 2D I will use eclipse to program in Java. It will be a smaller
job and won't require highly detailed graphics, but it could be that
people won't like it as much as 3D. With 3D it is a bigger job, but I am
using unity to make my job easier. Unity is good, but I don't know if you
can stretch the limits as long as in programming. It is no way I will
program the whole 3D game.
And to the second question: What should I start with? AI, physics,
graphics, level designs? That would be good to know that too.
If I am going to make a 2D game I think I will make a platform game with
basic physics like gravity, and basic graphics. I don't think people will
be very impressed over that.
If I am going to make a 3D game I think it will be more like a big project
with a first person shooter camera and a big environment with high
detailed graphics. People would like that a little more
I can just a little bit about making textures to 3D objects. I have maked
textures to 2D objects so I have a little more experience about that. And
I can do much with programming with my experience, but it is limited of
course. 3D games will be very hard to work with.
Friday, 23 August 2013
How to create menus in eclipse or android studio
How to create menus in eclipse or android studio
I'm new in android programming. I'm editing an android project that has 20
buttons on first page. How can I edit layout codes or anything to divide
this buttons to 4 items on first page that everyone have 5 buttons on
their own page.
I'm new in android programming. I'm editing an android project that has 20
buttons on first page. How can I edit layout codes or anything to divide
this buttons to 4 items on first page that everyone have 5 buttons on
their own page.
Login System Error - PDO
Login System Error - PDO
I'm having an issue with my login system using PDO. When you login with
the correct password, it will just refresh the page even though the form
is linked to another page & when you login you'll be redirected to
"home.php" not "index.php"
include('./includes/connect.php');
$submit = $_POST['submit'];
$email = sanitize($_POST['email']);
$password = nCrypt(sanitize($_POST['password']));
if(isset($submit)) {
if(isset($email) && isset($password)) {
$query = $pdo->prepare("SELECT password FROM users WHERE email = ?");
$query->bindValue(1, $email);
$query->execute();
$r = $query->fetch();
$pass2 = $r['password'];
$first = $r['first'];
$last = $r['lastname'];
$username = $r['username'];
if(strcasecmp($password, $pass2) == 0) {
$_SESSION['user'] = $r['user'];
$_SESSION['first'] = $r['first'];
$_SESSION['last'] = $r['last'];
$_SESSION['id'] = $r['id'];
header('Location: home.php');
} else {
header('Location: index.php?e=incorrect');
}
} else {
header('Location: index.php?e=empty');
}
}
?>
Basically, when you enter the correct password nothing happens. My form is:
<!-- index.php -->
<form action="login.php" method="POST">
<legend>Email Address</legend>
<input type="email" name="email" placeholder="Email Address"
required><br>
<legend>Password</legend>
<input type="password" name="password" placeholder="Password"
required><br>
<input class="btn btn-info" type="submit" name="submit" value="Login">
</form>
As you can see it links to another page, yet when when you enter in the
correct password, it'll just refresh the page the form is on, when it
suppose to redirect you to "home.php".
I'm having an issue with my login system using PDO. When you login with
the correct password, it will just refresh the page even though the form
is linked to another page & when you login you'll be redirected to
"home.php" not "index.php"
include('./includes/connect.php');
$submit = $_POST['submit'];
$email = sanitize($_POST['email']);
$password = nCrypt(sanitize($_POST['password']));
if(isset($submit)) {
if(isset($email) && isset($password)) {
$query = $pdo->prepare("SELECT password FROM users WHERE email = ?");
$query->bindValue(1, $email);
$query->execute();
$r = $query->fetch();
$pass2 = $r['password'];
$first = $r['first'];
$last = $r['lastname'];
$username = $r['username'];
if(strcasecmp($password, $pass2) == 0) {
$_SESSION['user'] = $r['user'];
$_SESSION['first'] = $r['first'];
$_SESSION['last'] = $r['last'];
$_SESSION['id'] = $r['id'];
header('Location: home.php');
} else {
header('Location: index.php?e=incorrect');
}
} else {
header('Location: index.php?e=empty');
}
}
?>
Basically, when you enter the correct password nothing happens. My form is:
<!-- index.php -->
<form action="login.php" method="POST">
<legend>Email Address</legend>
<input type="email" name="email" placeholder="Email Address"
required><br>
<legend>Password</legend>
<input type="password" name="password" placeholder="Password"
required><br>
<input class="btn btn-info" type="submit" name="submit" value="Login">
</form>
As you can see it links to another page, yet when when you enter in the
correct password, it'll just refresh the page the form is on, when it
suppose to redirect you to "home.php".
Using a template callback function in C++
Using a template callback function in C++
I want to have a function that checks certain conditions based on a given
callback function.
Considers this code:
class Foo{
template <class ParamType>
struct IsGood
{
typedef bool (*Check)(typename const ParamType, int other);
};
template< typename ParamType >
void DoSmth(IsGood<ParamType>::Check isGood, const ParamType param){
//...
if(isGood(param, some_int_calculated_here)) doSmthElse();
}
What I want is to call it with:
bool checkEqualInt(int i, int j){return i==j;}
bool checkEqualFloat(float i, float j){return i==j;}
DoSmth(checkEqualInt, 5);
DoSmth(checkEqualFloat, 2.5);
(All constructed examples to show the problem)
The compiler won't get that and throws me error C2664 "converting param 1
from bool(int,int) in bool(ParamType,int) not possible"
I there a solution without using
template< typename ParamType, Check >
void DoSmth(Check isGood, const ParamType param)
Which ommits the necessary declaration of the check function?
I want to have a function that checks certain conditions based on a given
callback function.
Considers this code:
class Foo{
template <class ParamType>
struct IsGood
{
typedef bool (*Check)(typename const ParamType, int other);
};
template< typename ParamType >
void DoSmth(IsGood<ParamType>::Check isGood, const ParamType param){
//...
if(isGood(param, some_int_calculated_here)) doSmthElse();
}
What I want is to call it with:
bool checkEqualInt(int i, int j){return i==j;}
bool checkEqualFloat(float i, float j){return i==j;}
DoSmth(checkEqualInt, 5);
DoSmth(checkEqualFloat, 2.5);
(All constructed examples to show the problem)
The compiler won't get that and throws me error C2664 "converting param 1
from bool(int,int) in bool(ParamType,int) not possible"
I there a solution without using
template< typename ParamType, Check >
void DoSmth(Check isGood, const ParamType param)
Which ommits the necessary declaration of the check function?
Can you recommend a good book on algorithms?
Can you recommend a good book on algorithms?
I've read 'Instruction for algorithms', and I wanna study more about
algorithms. There are many ways to study algorithms, but I can just use a
book since I'm a soldier.
So I hope to find a book that I can read for a long time. I want the book
have contents that I haven't seen before. Can you recommend such a book?
I've read 'Instruction for algorithms', and I wanna study more about
algorithms. There are many ways to study algorithms, but I can just use a
book since I'm a soldier.
So I hope to find a book that I can read for a long time. I want the book
have contents that I haven't seen before. Can you recommend such a book?
BiBeTeX to endnote biblography
BiBeTeX to endnote biblography
I was working with a software called KNIME and I needed to cite this
software for, the citation provided by the website is in the BiBeTeX
format.
@INPROCEEDINGS{BCDG+07, author = {Michael R. Berthold and Nicolas Cebron
and Fabian Dill and Thomas R. Gabriel and Tobias K\"{o}tter and Thorsten
Meinl and Peter Ohl and Christoph Sieb and Kilian Thiel and Bernd
Wiswedel}, title = {{KNIME}: The {K}onstanz {I}nformation {M}iner},
booktitle = {Studies in Classification, Data Analysis, and Knowledge
Organization (GfKL 2007)}, publisher = {Springer}, ISBN =
{978-3-540-78239-1}, ISSN = {1431-8814}, year = {2007} }
I am not a BiBeTeX or eveb a LaTeX user. But I would like to convert this
citation into the endnote format. I tried to find a way to do that online
but failed. Can anyone help me with this?
Thanks,
I was working with a software called KNIME and I needed to cite this
software for, the citation provided by the website is in the BiBeTeX
format.
@INPROCEEDINGS{BCDG+07, author = {Michael R. Berthold and Nicolas Cebron
and Fabian Dill and Thomas R. Gabriel and Tobias K\"{o}tter and Thorsten
Meinl and Peter Ohl and Christoph Sieb and Kilian Thiel and Bernd
Wiswedel}, title = {{KNIME}: The {K}onstanz {I}nformation {M}iner},
booktitle = {Studies in Classification, Data Analysis, and Knowledge
Organization (GfKL 2007)}, publisher = {Springer}, ISBN =
{978-3-540-78239-1}, ISSN = {1431-8814}, year = {2007} }
I am not a BiBeTeX or eveb a LaTeX user. But I would like to convert this
citation into the endnote format. I tried to find a way to do that online
but failed. Can anyone help me with this?
Thanks,
Column tag of css is not working in internet explorer
Column tag of css is not working in internet explorer
.threeColulmn{
columns:170px 3;
-webkit-columns:170px 3;
-moz-columns:170px 3;
}
I am trying to dividing div into three columns it works porperly in mozila
and chrome but in internet explorer its not working. kindly give me some
solution.
.threeColulmn{
columns:170px 3;
-webkit-columns:170px 3;
-moz-columns:170px 3;
}
I am trying to dividing div into three columns it works porperly in mozila
and chrome but in internet explorer its not working. kindly give me some
solution.
Thursday, 22 August 2013
Retrieving multiple data from db and grouping them
Retrieving multiple data from db and grouping them
I'm looking for a sql command solution for this problem. I want to
retrieve all the rows that have the same atribute and list them. I've
tried group by, but it merges the results into one row per chosen field. I
want to retrieve the multiple results to do something like:
black
nissan
toyota
red
ferrari
yellow
porsche
lambo
I'm looking for a sql command solution for this problem. I want to
retrieve all the rows that have the same atribute and list them. I've
tried group by, but it merges the results into one row per chosen field. I
want to retrieve the multiple results to do something like:
black
nissan
toyota
red
ferrari
yellow
porsche
lambo
How to write simple routes in PHP
How to write simple routes in PHP
I'm working on a project using Cloud9 IDE, running PHP5 on Apache 2.0. I'm
primarily a front-end developer, but I have decent experience with PHP.
I'm familiar with MVC frameworks, and to a lesser degree, this
functionality is what I'm trying to emulate, but simpler. I tried
implementing CakePHP, but found it was a little too robust for what I
needed -- I don't want a backend-heavy setup. I want to write some custom
sort of routing mechanism for my application.
Ideally, I would like every request to my site to come through one page
(this custom "Controller"), and from there I can write my own logic to
figure out the appropriate templates, http codes, errors, etc., to
include. My question is, how do I make this happen? In other words, how do
I make a request to http://mysite.c9.io/user/view/2 get channeled through
http://mysite.c9.io/index.php , and not try to request the /user/view/2
directory on my server?
I'm vaguely familiar with mod_rewrite and .htaccess rules, but I suspect
they may play a role here.
I'm working on a project using Cloud9 IDE, running PHP5 on Apache 2.0. I'm
primarily a front-end developer, but I have decent experience with PHP.
I'm familiar with MVC frameworks, and to a lesser degree, this
functionality is what I'm trying to emulate, but simpler. I tried
implementing CakePHP, but found it was a little too robust for what I
needed -- I don't want a backend-heavy setup. I want to write some custom
sort of routing mechanism for my application.
Ideally, I would like every request to my site to come through one page
(this custom "Controller"), and from there I can write my own logic to
figure out the appropriate templates, http codes, errors, etc., to
include. My question is, how do I make this happen? In other words, how do
I make a request to http://mysite.c9.io/user/view/2 get channeled through
http://mysite.c9.io/index.php , and not try to request the /user/view/2
directory on my server?
I'm vaguely familiar with mod_rewrite and .htaccess rules, but I suspect
they may play a role here.
Excel - How to build pick lists dynamically
Excel - How to build pick lists dynamically
Here's worksheet A:
Parent Kid Age
------ --- ---
John Scott 5
John Lucas 7
John Elisabeth 12
Victoria Jason 3
Victoria Amy 5
Jenifer Ashely 13
Jenifer Jared 17
And worksheet B:
Parent Kid Team
------ --- ----
John Elisabeth Lions
Jenifer Ashely Sharks
Jenifer Jared Panters
In worksheet B, I want my users to be able to choose the kid's name from a
pick list (using data validation). The values of that pick list should be
driven by the kid names entered for this parent in worksheet A. For
example, if I select cell A2, the pick list should contain:
Scott
Lucas
Elisabeth
Can I do this with a regular formula or should I use VBA?
Here's worksheet A:
Parent Kid Age
------ --- ---
John Scott 5
John Lucas 7
John Elisabeth 12
Victoria Jason 3
Victoria Amy 5
Jenifer Ashely 13
Jenifer Jared 17
And worksheet B:
Parent Kid Team
------ --- ----
John Elisabeth Lions
Jenifer Ashely Sharks
Jenifer Jared Panters
In worksheet B, I want my users to be able to choose the kid's name from a
pick list (using data validation). The values of that pick list should be
driven by the kid names entered for this parent in worksheet A. For
example, if I select cell A2, the pick list should contain:
Scott
Lucas
Elisabeth
Can I do this with a regular formula or should I use VBA?
Cannot read configuration file due to insufficient permissions while publish web pages in IIS 7.5 Windows 7 64 bit
Cannot read configuration file due to insufficient permissions while
publish web pages in IIS 7.5 Windows 7 64 bit
I am encountering Cannot read configuration file due to insufficient
permissions while publish web pages in IIS 7.5 Windows 7 64 bit. I
checked, IIS_USR has all the rights except full control even then I am
getting this error. I am trying to publish pages that are in ASP.NET C#.
Can some one help me on this ?
publish web pages in IIS 7.5 Windows 7 64 bit
I am encountering Cannot read configuration file due to insufficient
permissions while publish web pages in IIS 7.5 Windows 7 64 bit. I
checked, IIS_USR has all the rights except full control even then I am
getting this error. I am trying to publish pages that are in ASP.NET C#.
Can some one help me on this ?
Add callback to the class or individual elements
Add callback to the class or individual elements
I use JQuery, and I have a collection of buttons all of which have class
btnClass. Some (or all) of them are toggled visible/invisible repeatedly
based on some changing condition.
I want to add a callback to the click event when any of these buttons are
clicked. I have two options:
Add a callback to all of them statically and upfront using the class
selector: $(".btnClass").on("click", function(e) { ... });
Or add a callback dynamically and individually when a button is toggled
visible: btn.toggle(true).on("click", function(e) { ... });
Performance wise, which is better and why? Is there some other approach
that is better than both?
I use JQuery, and I have a collection of buttons all of which have class
btnClass. Some (or all) of them are toggled visible/invisible repeatedly
based on some changing condition.
I want to add a callback to the click event when any of these buttons are
clicked. I have two options:
Add a callback to all of them statically and upfront using the class
selector: $(".btnClass").on("click", function(e) { ... });
Or add a callback dynamically and individually when a button is toggled
visible: btn.toggle(true).on("click", function(e) { ... });
Performance wise, which is better and why? Is there some other approach
that is better than both?
Why my JSON can't successfully parse to a NSDictionary
Why my JSON can't successfully parse to a NSDictionary
Here is my code:
decodeMenuValue = @"{\"receipts\":[\"Mother\",\"Father\",\"Grand
Parent\",\"Carer\"]}";
NSError *e = nil;
NSObject *jsonObj = [NSJSONSerialization
JSONObjectWithData:[decodeMenuValue JSONData]
options:NSJSONReadingMutableContainers
error:&e];
I got an NSCocoaErrorDomain what does it means? And why it is happen? Thanks.
Here is my code:
decodeMenuValue = @"{\"receipts\":[\"Mother\",\"Father\",\"Grand
Parent\",\"Carer\"]}";
NSError *e = nil;
NSObject *jsonObj = [NSJSONSerialization
JSONObjectWithData:[decodeMenuValue JSONData]
options:NSJSONReadingMutableContainers
error:&e];
I got an NSCocoaErrorDomain what does it means? And why it is happen? Thanks.
Wednesday, 21 August 2013
Is there any point in using the ArrayList class anymore?
Is there any point in using the ArrayList class anymore?
I realize that if you are running .NET 1.1, then generics aren't
available. But, if you are using .NET 2.0+, then are there any advantages
to using the ArrayList class over List<object>?
I realize that if you are running .NET 1.1, then generics aren't
available. But, if you are using .NET 2.0+, then are there any advantages
to using the ArrayList class over List<object>?
Check if user exists in database
Check if user exists in database
I'm making a registration page and need to check if the username entered
in the form is a username that already exists in the database. How is this
done?
I'm making a registration page and need to check if the username entered
in the form is a username that already exists in the database. How is this
done?
Vertically center image with text midpoint
Vertically center image with text midpoint
I want to vertically align the center of an image with the vertical center
of the text on the same line using \raisebox. Using a macro is a must
since it will be used many times (and multiple times on the same line).
This implementation works, but requires the use of temporary lengths. I'd
like to do the calculation directly without these, but am having trouble
finding the right syntax. \raisebox{0.5\heightof{E}-0.25in} does not work.
The closest question seems to be the one here, but this approach doesn't
align properly. I want the vertical image center to be aligned with the
midpoint between the text baseline and the letter top (in this case "E").
MWE:
\documentclass{article}
\usepackage{calc}
\begin{document}
\newlength{\lenA}
\newlength{\lenB}
\setlength{\lenA}{\heightof{E}}
\setlength{\lenB}{0.25in}
Text \raisebox{0.5\lenA-0.5\lenB}{\rule{0.25in}{0.25in}} Testing
\end{document}
I want to vertically align the center of an image with the vertical center
of the text on the same line using \raisebox. Using a macro is a must
since it will be used many times (and multiple times on the same line).
This implementation works, but requires the use of temporary lengths. I'd
like to do the calculation directly without these, but am having trouble
finding the right syntax. \raisebox{0.5\heightof{E}-0.25in} does not work.
The closest question seems to be the one here, but this approach doesn't
align properly. I want the vertical image center to be aligned with the
midpoint between the text baseline and the letter top (in this case "E").
MWE:
\documentclass{article}
\usepackage{calc}
\begin{document}
\newlength{\lenA}
\newlength{\lenB}
\setlength{\lenA}{\heightof{E}}
\setlength{\lenB}{0.25in}
Text \raisebox{0.5\lenA-0.5\lenB}{\rule{0.25in}{0.25in}} Testing
\end{document}
Python: Internal Information of Function calls and Automated Logging
Python: Internal Information of Function calls and Automated Logging
I want to write a class that will show me the tree of currently working
functions, that means:
Let's say I have function A call function B first and then function C, and
function C calls function D. At time t = 1, B is running, so I want the
stdout to be:
Root: function A -> running properly, called B
2-nd: function B -> running properly
At time t = 2, B has returned to A, so the stdout becomes:
Root: function A -> running properly, B returned
At time t = 3, A has called C. At time t = 4, C has called D. The stdout
should be:
Root: function A -> running properly, B returned, called C
2-nd: function C -> running properly, called D
3-rd: function D -> running properly
At time t = 5, D returned. At time t = 6, C returned. The stdout should be:
Root: function A -> running properly, B returned, C returned
At time t = 7, function A returned:
Root: function A -> Done
Besides creating a logger object and passing it around, is there a more
elegant way to automate this? What if A or B is a multithreaded process?
Any suggestions is much appreciated. Thank you!
I want to write a class that will show me the tree of currently working
functions, that means:
Let's say I have function A call function B first and then function C, and
function C calls function D. At time t = 1, B is running, so I want the
stdout to be:
Root: function A -> running properly, called B
2-nd: function B -> running properly
At time t = 2, B has returned to A, so the stdout becomes:
Root: function A -> running properly, B returned
At time t = 3, A has called C. At time t = 4, C has called D. The stdout
should be:
Root: function A -> running properly, B returned, called C
2-nd: function C -> running properly, called D
3-rd: function D -> running properly
At time t = 5, D returned. At time t = 6, C returned. The stdout should be:
Root: function A -> running properly, B returned, C returned
At time t = 7, function A returned:
Root: function A -> Done
Besides creating a logger object and passing it around, is there a more
elegant way to automate this? What if A or B is a multithreaded process?
Any suggestions is much appreciated. Thank you!
Can I have two form's in diffrent places which triggers one request to server?
Can I have two form's in diffrent places which triggers one request to
server?
I am beginner to HTML. I found there is something like form which is used
to pass data to server. I know what is the basic usage.
Last time I cut children of my initial form between two HTML files (some
reorganization to include later in JSP). Personally I don't like to start
tag <form> in one file, and close the </form> in other file. And I know I
could do something like this (I will use this probably):
<form>
// include file1
// include file2
</form>
But now I am just thinking... Is it possible to do something totally
different? like this:
// first file
<form name="input" action="index.html" method="get">
User: <input type="text" name="user">
</form>
// second file
<form name="input">
Data: <input type="text" name="data">
<input type="submit" value="Submit">
</form>
I want to submit both inputs with button inside second form. I know above
doesn't work even if I set the same name attribute. But maybe I missed
something?
server?
I am beginner to HTML. I found there is something like form which is used
to pass data to server. I know what is the basic usage.
Last time I cut children of my initial form between two HTML files (some
reorganization to include later in JSP). Personally I don't like to start
tag <form> in one file, and close the </form> in other file. And I know I
could do something like this (I will use this probably):
<form>
// include file1
// include file2
</form>
But now I am just thinking... Is it possible to do something totally
different? like this:
// first file
<form name="input" action="index.html" method="get">
User: <input type="text" name="user">
</form>
// second file
<form name="input">
Data: <input type="text" name="data">
<input type="submit" value="Submit">
</form>
I want to submit both inputs with button inside second form. I know above
doesn't work even if I set the same name attribute. But maybe I missed
something?
How to implement XPCOM component (nsIContentPolicy) in bootstrapped Firefox extension
How to implement XPCOM component (nsIContentPolicy) in bootstrapped
Firefox extension
I have a bootstrapped extension for Firefox. And now I want to implement
nsIContentPolicy XPCOM component. I wrote a component module code. And now
I want to register this component. The reason to register component is
that I want to add my component to nsICategoryManager.addCategoryEntry
with "content-policy" category.
var {Cc, Ci, Cu} = require("chrome");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
//console.error("Running interceptor");
function Interceptor()
}
Interceptor.prototype = {
classDescription: "DeferredTo HTTP requests Interceptor",
classID: "{B5B3D9A0-08FC-11E3-8253-5EF06188709B}",
contractID: "@deferredto.com/Interceptor;1",
QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPolicy]),
shouldLoad : function dt_shouldLoad(aContentType, aContentLocation,
aRequestOrigin, aContext, aMimeTypeGuess, aExtra) {
console.log("dt_shouldLoad");
if (contentLocation.scheme != "http" && contentLocation.scheme !=
"https")
return Ci.nsIContentPolicy.ACCEPT;
let result = Ci.nsIContentPolicy.ACCEPT;
// we should check for TYPE_SUBDOCUMENT as well if we want frames.
if ((Ci.nsIContentPolicy.TYPE_DOCUMENT == aContentType) &&
SOME_REGULAR_EXPRESSION.test(aContentLocation.spec)) {
// do stuff here, possibly changing result.
}
return result;
},
shouldProcess: function ILO_shouldProcess() Ci.nsIContentPolicy.ACCEPT,
_xpcom_categories: [
{ category: "content-policy", service: true }
],
classInfo: XPCOMUtils.generateCI(
{classID: Components.ID("{B5B3D9A0-08FC-11E3-8253-5EF06188709B}"),
contractID: "@deferredto.com/Interceptor;1",
classDescription: "Interceptor implements nsIContentPolicy to block
images that are not yet at screen @DeferredTo",
interfaces: [
Ci.nsIContentPolicy,
],
flags: Ci.nsIClassInfo.SINGLETON})
}
var components = [Interceptor];
var NSGetFactory = XPCOMUtils.generateNSGetFactory([Interceptor]);
Questions: Is it possible to register the component from bootstrapped
extension? Is it possible to register the component from restartless
extension? Is it nsICategoryManager.addCategoryEntry "content-policy"
without component? How to register the component or somehow add
"content-policy" category entry?
Thank you.
I've added to harness-options.js "requirements": { "sdk/page-mod":
"sdk/page-mod", "sdk/self": "sdk/self", "chrome": "chrome"},
That is how I try import module: var {Cc, Ci, Cu} = require("chrome");
Cu.import("resource://deferredto/lib/interceptor.js");
I' ve tried many paths ))) But none works. resource entry in
chrome.manifest file does not allowed for bootstrapped extensions. The
path to component module file is: resources/deferredto/lib/interceptor.js
Firefox extension
I have a bootstrapped extension for Firefox. And now I want to implement
nsIContentPolicy XPCOM component. I wrote a component module code. And now
I want to register this component. The reason to register component is
that I want to add my component to nsICategoryManager.addCategoryEntry
with "content-policy" category.
var {Cc, Ci, Cu} = require("chrome");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
//console.error("Running interceptor");
function Interceptor()
}
Interceptor.prototype = {
classDescription: "DeferredTo HTTP requests Interceptor",
classID: "{B5B3D9A0-08FC-11E3-8253-5EF06188709B}",
contractID: "@deferredto.com/Interceptor;1",
QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPolicy]),
shouldLoad : function dt_shouldLoad(aContentType, aContentLocation,
aRequestOrigin, aContext, aMimeTypeGuess, aExtra) {
console.log("dt_shouldLoad");
if (contentLocation.scheme != "http" && contentLocation.scheme !=
"https")
return Ci.nsIContentPolicy.ACCEPT;
let result = Ci.nsIContentPolicy.ACCEPT;
// we should check for TYPE_SUBDOCUMENT as well if we want frames.
if ((Ci.nsIContentPolicy.TYPE_DOCUMENT == aContentType) &&
SOME_REGULAR_EXPRESSION.test(aContentLocation.spec)) {
// do stuff here, possibly changing result.
}
return result;
},
shouldProcess: function ILO_shouldProcess() Ci.nsIContentPolicy.ACCEPT,
_xpcom_categories: [
{ category: "content-policy", service: true }
],
classInfo: XPCOMUtils.generateCI(
{classID: Components.ID("{B5B3D9A0-08FC-11E3-8253-5EF06188709B}"),
contractID: "@deferredto.com/Interceptor;1",
classDescription: "Interceptor implements nsIContentPolicy to block
images that are not yet at screen @DeferredTo",
interfaces: [
Ci.nsIContentPolicy,
],
flags: Ci.nsIClassInfo.SINGLETON})
}
var components = [Interceptor];
var NSGetFactory = XPCOMUtils.generateNSGetFactory([Interceptor]);
Questions: Is it possible to register the component from bootstrapped
extension? Is it possible to register the component from restartless
extension? Is it nsICategoryManager.addCategoryEntry "content-policy"
without component? How to register the component or somehow add
"content-policy" category entry?
Thank you.
I've added to harness-options.js "requirements": { "sdk/page-mod":
"sdk/page-mod", "sdk/self": "sdk/self", "chrome": "chrome"},
That is how I try import module: var {Cc, Ci, Cu} = require("chrome");
Cu.import("resource://deferredto/lib/interceptor.js");
I' ve tried many paths ))) But none works. resource entry in
chrome.manifest file does not allowed for bootstrapped extensions. The
path to component module file is: resources/deferredto/lib/interceptor.js
Tuesday, 20 August 2013
How to install an init.d script in ubuntu?
How to install an init.d script in ubuntu?
i am trying to install an init.d script, to run celery for scheduling
tasks. Here is the steps i followed:
copied the file celeryd and pasted it in folder /etc/init.d/
created a configuration file celeryd in folder /etc/default/
now when i tried to start it by sudo /etc/init.d/celeryd, it throws error
sudo: /etc/init.d/celeryd: command not found
I googled about how to install init.d, i got this SO-question.
it says to issue a uname -a and when i does i get this:
Linux capsonesystem8-desktop 3.2.0-43-generic-pae
#68-Ubuntu SMP Wed May 15 03:55:10 UTC
2013 i686 i686 i386 GNU/Linux
and also it says use utils like "insserv" to enable this init.d script so
tried:
insserv /etc/init.d/celeryd but it throws error insserv: command not found
so i tried to install insserv sudo apt-get install insserv. but it say
aleady installed:
insserv is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 222 not upgraded.
So how to install init.d script?? Any help will be appreciated.
i am trying to install an init.d script, to run celery for scheduling
tasks. Here is the steps i followed:
copied the file celeryd and pasted it in folder /etc/init.d/
created a configuration file celeryd in folder /etc/default/
now when i tried to start it by sudo /etc/init.d/celeryd, it throws error
sudo: /etc/init.d/celeryd: command not found
I googled about how to install init.d, i got this SO-question.
it says to issue a uname -a and when i does i get this:
Linux capsonesystem8-desktop 3.2.0-43-generic-pae
#68-Ubuntu SMP Wed May 15 03:55:10 UTC
2013 i686 i686 i386 GNU/Linux
and also it says use utils like "insserv" to enable this init.d script so
tried:
insserv /etc/init.d/celeryd but it throws error insserv: command not found
so i tried to install insserv sudo apt-get install insserv. but it say
aleady installed:
insserv is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 222 not upgraded.
So how to install init.d script?? Any help will be appreciated.
How to get the represented character for an encoding in Racket?
How to get the represented character for an encoding in Racket?
From an HTML file I got 使. I know it represent the Chinese
character g. But how to convert them in Racket?
From an HTML file I got 使. I know it represent the Chinese
character g. But how to convert them in Racket?
Cross fade background-image with jQuery
Cross fade background-image with jQuery
so I have some images and I would like to show them as a slideshow in the
background. However, I want the image to cross-fade between the current
image and the next image. So far, I have only been able to switch between
the images:
$(document).ready(function () {
var images = ["landing_background_1.jpg", "landing_background_2.jpg",
"landing_background_3.jpg", "landing_background_4.jpg"];
var currentImage = 0;
function changeBackgroundImage() {
$("html").fadeIn().css({
"background-image": "url('img/backgrounds/" +
images[++currentImage] + "')",
});
if (currentImage >= images.length - 1) {
//set it back to the begining
currentImage -= images.length;
}
}
setInterval(changeBackgroundImage, 1500);
});
Any help would be much appreciated! :)
so I have some images and I would like to show them as a slideshow in the
background. However, I want the image to cross-fade between the current
image and the next image. So far, I have only been able to switch between
the images:
$(document).ready(function () {
var images = ["landing_background_1.jpg", "landing_background_2.jpg",
"landing_background_3.jpg", "landing_background_4.jpg"];
var currentImage = 0;
function changeBackgroundImage() {
$("html").fadeIn().css({
"background-image": "url('img/backgrounds/" +
images[++currentImage] + "')",
});
if (currentImage >= images.length - 1) {
//set it back to the begining
currentImage -= images.length;
}
}
setInterval(changeBackgroundImage, 1500);
});
Any help would be much appreciated! :)
C Casting from pointer to uint32_t to a pointer to a union containing uint32_t
C Casting from pointer to uint32_t to a pointer to a union containing
uint32_t
I'd like to know if casting a pointer to uint32_t to a pointer of a union
containing a uint32_t will lead to defined behavior in C, i.e.
typedef union
{
uint8_t u8[4];
uint32_t u32;
} T32;
void change_value(T32 *t32)
{
t32->u32 = 5678;
}
int main()
{
uint32_t value = 1234;
change_value((T32 *)&value); // value is 5678 afterwards
return EXIT_SUCCESS;
}
Is this valid C? Many thanks in advance.
uint32_t
I'd like to know if casting a pointer to uint32_t to a pointer of a union
containing a uint32_t will lead to defined behavior in C, i.e.
typedef union
{
uint8_t u8[4];
uint32_t u32;
} T32;
void change_value(T32 *t32)
{
t32->u32 = 5678;
}
int main()
{
uint32_t value = 1234;
change_value((T32 *)&value); // value is 5678 afterwards
return EXIT_SUCCESS;
}
Is this valid C? Many thanks in advance.
get the operating system of an Amazon image via Fog
get the operating system of an Amazon image via Fog
My end goal is to get the operating system of an Amazon image. When I do:
connection = Fog::Compute.new(provider: 'AWS',
aws_access_key_id: 'blah',
aws_secret_access_key: 'thing')
images = connection.describe_images('Owner' => 'self').body['imagesSet']
The data I get returned does not include platform, as this documentation
suggests. However, I do get values like:
architecture: "x86_64",
imageType: "machine",
kernelId: "aki-825ea7eb",
And if I Google for that kernel ID I find this page saying it's Linux. Is
there a way I can pass kernelId to Amazon via Fog and get back data about
that kernelId, such as linux?
On a separate note, sometimes my images don't have kernelId, so are there
any other fields in a <DescribeImagesResponse
xmlns="http://ec2.amazonaws.com/doc/2012-12-01/"> that are definite
indicators of operating system?
My end goal is to get the operating system of an Amazon image. When I do:
connection = Fog::Compute.new(provider: 'AWS',
aws_access_key_id: 'blah',
aws_secret_access_key: 'thing')
images = connection.describe_images('Owner' => 'self').body['imagesSet']
The data I get returned does not include platform, as this documentation
suggests. However, I do get values like:
architecture: "x86_64",
imageType: "machine",
kernelId: "aki-825ea7eb",
And if I Google for that kernel ID I find this page saying it's Linux. Is
there a way I can pass kernelId to Amazon via Fog and get back data about
that kernelId, such as linux?
On a separate note, sometimes my images don't have kernelId, so are there
any other fields in a <DescribeImagesResponse
xmlns="http://ec2.amazonaws.com/doc/2012-12-01/"> that are definite
indicators of operating system?
segmentation fault (core dumped) in g++
segmentation fault (core dumped) in g++
iam trying to optimize a code i want to run code for arm_no=1000, its
running for 100 arms but further increasing causes segmentation fault core
dumped. to run the code use
$ g++ Epsilon_greed.cpp -lm `gsl-config --libs`
$ ./a.out>greed.txt
but you'll have to install libgsl0 i.e gnu scientific library.
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<gsl/gsl_randist.h>
using namespace std;
const gsl_rng_type * T;
gsl_rng * r;
double Epsilon;
const int arm_no=1000; //change this to 10, 100 to see it working
const int play_no=1000;
const int bandit_no=2000;
//Action class
//Each actuion corresponds to one arm
class Action
{
private:
double mean_reward;//its for calculating Qt(a)
int no_chosen;//no of times an action is been chosen
double cur_rewrd;// gives the current reward on that play
double Q_reward; // its the Q*(a)
public:
//constructor for Action
Action()
{
mean_reward=0;
no_chosen=0;
cur_rewrd=0;
Q_reward=gsl_ran_gaussian(r, 1);
}
//every time action gets selected Qt(a) is calculated and returned
double selected()
{
no_chosen++;
mean_reward=((mean_reward*(no_chosen-1))+get_current_reward())/no_chosen;
return mean_reward;
}
// returns the current reward
double get_current_reward()
{
cur_rewrd=gsl_ran_gaussian (r, 1)+ Q_reward;
return cur_rewrd;
}
//returns the Qt(a)
double get_mean_reward()
{return mean_reward;}
//returns Q*(a)
double get_Q_reward()
{
return Q_reward;
}
}; //end of class action
//class bandit
class Bandit
{ private:
int optimal, optimalcount;//optimal stores the current max Qt(a)
value action
int optimalval;//optimal count is flag whether action with
maxQ*(a) {optimalval } is chosen or not
Action action[arm_no];//each bandit having 10 actions
public:
Bandit()
{
optimal=0;
optimalcount=0;
optimalval=getmaxval();
}
//setting the max of Qt(a)
void set_optimal()
{
int max=-80000;//large -ve value
for(int i=0;i<arm_no;i++)
{
if(action[i].get_mean_reward()>max)
{ int x=tiebreak(i);//calling tiebreaker in case
of same Qt(a)
if(x)
{
max=action[x].get_mean_reward();
optimal=x;
}
else
{
max=action[i].get_mean_reward();
optimal=i;
}
}
}
}
//function for getting max Q*(a) value
int getmaxval()
{ int k=0;
int max=-800000;
for(int i=0;i<arm_no;i++)
{
if(action[i].get_Q_reward()>max)
{
k=i;
max=action[i].get_Q_reward();
}
}
return k;
}
//tie breaker
int tiebreak(int i)
{
int n=0;
int aux[arm_no];//storing the action nos. as index whose
estimated reward is same
int k=0;
for(int j=0;j<arm_no;j++)
{
if(action[i].get_mean_reward()==action[k].get_mean_reward())
{
aux[n]=k;
n++;
}
k=(k+1)%arm_no;//for checking all the actions
}
if(n==0)
return 0;
else
return aux[rand()%n];//returning random action of same Qt(a) value
}
//function for each play
double play()
{ set_optimal();//setting the optimal i.e max Q(a)
int choice;
choice=probab();//choosing choice with probability
double ret = action[choice].selected();
if(choice==optimalval)
optimalcount++;//setting the flag that selected action has max
Q*(a)
return ret;
}
//returning whether chosen action is the one having Q*(a)?
int is_optimal_count()
{
if(optimalcount!=0)
{
optimalcount--;//resetting the flag
return 1;
}
else
return 0;
}
//choosic action according to the probability
int probab()
{
if(gsl_rng_uniform(r)<=::Epsilon)
{
return (int)(gsl_rng_uniform(r)*arm_no);
}
else
return optimal;
}
};//end of bandit class
//driver code
int main()
{ gsl_rng_env_setup ();
::T = gsl_rng_default;
::r = gsl_rng_alloc (T);
//creating object of 3 bandir problem each for different epsilon
int i,j;
Bandit bandit1[bandit_no];
// Bandit bandit2[bandit_no];
// Bandit bandit3[bandit_no];
//plot arrays containing data poins for plotting graph
double plot1[play_no],plotpercent1[play_no];
// double plot2[play_no],plotpercent2[play_no];
// double plot3[play_no],plotpercent3[play_no];
double mean[play_no];
//sampling over 2000 bandits for 1000 plays
::Epsilon=0.10;
for(i=0;i<play_no;i++)
{
mean[i]=0;
plotpercent1[i]=0;
for(j=0;j<bandit_no;j++)
{
mean[i]=mean[i] + bandit1[j].play();
plotpercent1[i]+=bandit1[j].is_optimal_count();
}
plot1[i]=mean[i]/bandit_no;
plotpercent1[i]=plotpercent1[i]/bandit_no;
}
/*
::Epsilon=0.01;
for(i=0;i<play_no;i++)
{
mean[i]=0;
plotpercent2[i]=0;
for(j=0;j<bandit_no;j++)
{
mean[i]=mean[i] + bandit2[j].play();
plotpercent2[i]+=bandit2[j].is_optimal_count();
}
plot2[i]=mean[i]/bandit_no;
plotpercent2[i]=plotpercent2[i]/bandit_no;
}
::Epsilon=0.00;
for(i=0;i<play_no;i++)
{
mean[i]=0;
plotpercent3[i]=0;
for(j=0;j<bandit_no;j++)
{
mean[i]=mean[i] + bandit3[j].play();
plotpercent3[i]+=bandit3[j].is_optimal_count();
}
plot3[i]=mean[i]/bandit_no;
plotpercent3[i]= plotpercent3[i]/bandit_no;
}
for(int i=0;i<play_no;i++)
{
cout<<plot1[i]<<"\t"<<plot2[i]<<"\t"<<plot3[i]<<"\t"<<plotpercent1[i]*100<<"\t"<<plotpercent2[i]*100<<"\t"<<plotpercent3[i]*100<<endl;
}
*/
for(int i=0;i<1000;i++)
{
cout<<plot1[i]<<"\t"<<plotpercent1[i]*100<<endl;
}
return 0;
}//end of main
iam trying to optimize a code i want to run code for arm_no=1000, its
running for 100 arms but further increasing causes segmentation fault core
dumped. to run the code use
$ g++ Epsilon_greed.cpp -lm `gsl-config --libs`
$ ./a.out>greed.txt
but you'll have to install libgsl0 i.e gnu scientific library.
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<gsl/gsl_randist.h>
using namespace std;
const gsl_rng_type * T;
gsl_rng * r;
double Epsilon;
const int arm_no=1000; //change this to 10, 100 to see it working
const int play_no=1000;
const int bandit_no=2000;
//Action class
//Each actuion corresponds to one arm
class Action
{
private:
double mean_reward;//its for calculating Qt(a)
int no_chosen;//no of times an action is been chosen
double cur_rewrd;// gives the current reward on that play
double Q_reward; // its the Q*(a)
public:
//constructor for Action
Action()
{
mean_reward=0;
no_chosen=0;
cur_rewrd=0;
Q_reward=gsl_ran_gaussian(r, 1);
}
//every time action gets selected Qt(a) is calculated and returned
double selected()
{
no_chosen++;
mean_reward=((mean_reward*(no_chosen-1))+get_current_reward())/no_chosen;
return mean_reward;
}
// returns the current reward
double get_current_reward()
{
cur_rewrd=gsl_ran_gaussian (r, 1)+ Q_reward;
return cur_rewrd;
}
//returns the Qt(a)
double get_mean_reward()
{return mean_reward;}
//returns Q*(a)
double get_Q_reward()
{
return Q_reward;
}
}; //end of class action
//class bandit
class Bandit
{ private:
int optimal, optimalcount;//optimal stores the current max Qt(a)
value action
int optimalval;//optimal count is flag whether action with
maxQ*(a) {optimalval } is chosen or not
Action action[arm_no];//each bandit having 10 actions
public:
Bandit()
{
optimal=0;
optimalcount=0;
optimalval=getmaxval();
}
//setting the max of Qt(a)
void set_optimal()
{
int max=-80000;//large -ve value
for(int i=0;i<arm_no;i++)
{
if(action[i].get_mean_reward()>max)
{ int x=tiebreak(i);//calling tiebreaker in case
of same Qt(a)
if(x)
{
max=action[x].get_mean_reward();
optimal=x;
}
else
{
max=action[i].get_mean_reward();
optimal=i;
}
}
}
}
//function for getting max Q*(a) value
int getmaxval()
{ int k=0;
int max=-800000;
for(int i=0;i<arm_no;i++)
{
if(action[i].get_Q_reward()>max)
{
k=i;
max=action[i].get_Q_reward();
}
}
return k;
}
//tie breaker
int tiebreak(int i)
{
int n=0;
int aux[arm_no];//storing the action nos. as index whose
estimated reward is same
int k=0;
for(int j=0;j<arm_no;j++)
{
if(action[i].get_mean_reward()==action[k].get_mean_reward())
{
aux[n]=k;
n++;
}
k=(k+1)%arm_no;//for checking all the actions
}
if(n==0)
return 0;
else
return aux[rand()%n];//returning random action of same Qt(a) value
}
//function for each play
double play()
{ set_optimal();//setting the optimal i.e max Q(a)
int choice;
choice=probab();//choosing choice with probability
double ret = action[choice].selected();
if(choice==optimalval)
optimalcount++;//setting the flag that selected action has max
Q*(a)
return ret;
}
//returning whether chosen action is the one having Q*(a)?
int is_optimal_count()
{
if(optimalcount!=0)
{
optimalcount--;//resetting the flag
return 1;
}
else
return 0;
}
//choosic action according to the probability
int probab()
{
if(gsl_rng_uniform(r)<=::Epsilon)
{
return (int)(gsl_rng_uniform(r)*arm_no);
}
else
return optimal;
}
};//end of bandit class
//driver code
int main()
{ gsl_rng_env_setup ();
::T = gsl_rng_default;
::r = gsl_rng_alloc (T);
//creating object of 3 bandir problem each for different epsilon
int i,j;
Bandit bandit1[bandit_no];
// Bandit bandit2[bandit_no];
// Bandit bandit3[bandit_no];
//plot arrays containing data poins for plotting graph
double plot1[play_no],plotpercent1[play_no];
// double plot2[play_no],plotpercent2[play_no];
// double plot3[play_no],plotpercent3[play_no];
double mean[play_no];
//sampling over 2000 bandits for 1000 plays
::Epsilon=0.10;
for(i=0;i<play_no;i++)
{
mean[i]=0;
plotpercent1[i]=0;
for(j=0;j<bandit_no;j++)
{
mean[i]=mean[i] + bandit1[j].play();
plotpercent1[i]+=bandit1[j].is_optimal_count();
}
plot1[i]=mean[i]/bandit_no;
plotpercent1[i]=plotpercent1[i]/bandit_no;
}
/*
::Epsilon=0.01;
for(i=0;i<play_no;i++)
{
mean[i]=0;
plotpercent2[i]=0;
for(j=0;j<bandit_no;j++)
{
mean[i]=mean[i] + bandit2[j].play();
plotpercent2[i]+=bandit2[j].is_optimal_count();
}
plot2[i]=mean[i]/bandit_no;
plotpercent2[i]=plotpercent2[i]/bandit_no;
}
::Epsilon=0.00;
for(i=0;i<play_no;i++)
{
mean[i]=0;
plotpercent3[i]=0;
for(j=0;j<bandit_no;j++)
{
mean[i]=mean[i] + bandit3[j].play();
plotpercent3[i]+=bandit3[j].is_optimal_count();
}
plot3[i]=mean[i]/bandit_no;
plotpercent3[i]= plotpercent3[i]/bandit_no;
}
for(int i=0;i<play_no;i++)
{
cout<<plot1[i]<<"\t"<<plot2[i]<<"\t"<<plot3[i]<<"\t"<<plotpercent1[i]*100<<"\t"<<plotpercent2[i]*100<<"\t"<<plotpercent3[i]*100<<endl;
}
*/
for(int i=0;i<1000;i++)
{
cout<<plot1[i]<<"\t"<<plotpercent1[i]*100<<endl;
}
return 0;
}//end of main
Xcode Autoresize Subviews Not Working
Xcode Autoresize Subviews Not Working
I have a .xib with a UIViewController sized for the iPhone 5 (4" screen).
The problem is when I go on the iPhone 4 (3.5" screen) simulator the view
does not autoresize. The bottom part of the view just gets cut off. I know
.storyboards autoresize so why not .xibs? How can I autoresize the view? I
created a custom ViewController class which check if the phone is a 3.5"
screen and then adjusts the main view accordingly, but this complains with
a long warning about conflicting constraints and it doesn't change the
subviews. Is there a better way or should I continue with what I am doing?
I have a .xib with a UIViewController sized for the iPhone 5 (4" screen).
The problem is when I go on the iPhone 4 (3.5" screen) simulator the view
does not autoresize. The bottom part of the view just gets cut off. I know
.storyboards autoresize so why not .xibs? How can I autoresize the view? I
created a custom ViewController class which check if the phone is a 3.5"
screen and then adjusts the main view accordingly, but this complains with
a long warning about conflicting constraints and it doesn't change the
subviews. Is there a better way or should I continue with what I am doing?
Monday, 19 August 2013
tallpdf.net background color
tallpdf.net background color
I cant seem to figure out how to add a background color to a cell for my
pdf document. I am using an xsl template to transform my xml.
If I cant do this directly, has anybody got any ideas on how to do it?
e.g. adding a thick black border etc.
I am trying to replicate this functionality, it is very basic for a pdf
document.
<html>
<body>
<table >
<thead>
<tr>
<th bgcolor="black"><font color="white">Header 1</font></th>
<th bgcolor="black"><font color="white">Header 2</font></th>
<th bgcolor="black"><font color="white">Header 3</font></th>
</tr>
</thead>
</table>
</body>
I am trying to get the fragment with the text "Job Work Order" to have a
black background with white text.
<paragraph type="table" preferredwidth="180mm">
<row >
<cell preferredwidth="70mm" fixed="true">
<paragraph type="textparagraph" spacingbefore="24"
leftindentation="5" rightindentation="2"
horizontalalignment="left">
<fragment fontsize="16">Job Work Order</fragment>
</paragraph>
</cell>
</row>
Thank you.
I cant seem to figure out how to add a background color to a cell for my
pdf document. I am using an xsl template to transform my xml.
If I cant do this directly, has anybody got any ideas on how to do it?
e.g. adding a thick black border etc.
I am trying to replicate this functionality, it is very basic for a pdf
document.
<html>
<body>
<table >
<thead>
<tr>
<th bgcolor="black"><font color="white">Header 1</font></th>
<th bgcolor="black"><font color="white">Header 2</font></th>
<th bgcolor="black"><font color="white">Header 3</font></th>
</tr>
</thead>
</table>
</body>
I am trying to get the fragment with the text "Job Work Order" to have a
black background with white text.
<paragraph type="table" preferredwidth="180mm">
<row >
<cell preferredwidth="70mm" fixed="true">
<paragraph type="textparagraph" spacingbefore="24"
leftindentation="5" rightindentation="2"
horizontalalignment="left">
<fragment fontsize="16">Job Work Order</fragment>
</paragraph>
</cell>
</row>
Thank you.
Python script that print its source
Python script that print its source
Is it possible (not necessarly using python introspection) to print the
sorce code of a script?
I want to execute a short python script that also print its source (so I
can see which commands are executed).
The script is something like this:
command1()
#command2()
command3()
print some_variable_that_contain_src
The real application is that I want to run a script from IPython with the
run -i magic and have as output the source (i.e. the commands executed).
In this way I can check which commands are commented at every execution.
Moreover, if executed in a Notebook I leave a trace of which commands have
been used.
Is it possible (not necessarly using python introspection) to print the
sorce code of a script?
I want to execute a short python script that also print its source (so I
can see which commands are executed).
The script is something like this:
command1()
#command2()
command3()
print some_variable_that_contain_src
The real application is that I want to run a script from IPython with the
run -i magic and have as output the source (i.e. the commands executed).
In this way I can check which commands are commented at every execution.
Moreover, if executed in a Notebook I leave a trace of which commands have
been used.
How do I track, pull, etc. from an existing git branch on Github
How do I track, pull, etc. from an existing git branch on Github
I have the master branch from a repository on Github cloned on my machine.
There are other existing branches in this repository that I would like to
be able to switch to and use. I'm trying to use the command:
git branch --track nameOfBranch origin/nameOfBranch
This isn't working for me. I get the error:
error: the requested upstream branch (URL) does not exist
Basically I need to create the branch on my local machine and tie it to an
existing branch. Thank you for your help!
I have the master branch from a repository on Github cloned on my machine.
There are other existing branches in this repository that I would like to
be able to switch to and use. I'm trying to use the command:
git branch --track nameOfBranch origin/nameOfBranch
This isn't working for me. I get the error:
error: the requested upstream branch (URL) does not exist
Basically I need to create the branch on my local machine and tie it to an
existing branch. Thank you for your help!
How to define namespace for imported project
How to define namespace for imported project
I'm getting really stuck trying to refer to methods in a project imported
into a blank project. The exact steps to recreate this are as follows
Download and Extract into a temp folder http://mywsat.codeplex.com/
Create a new project in VS - Asp.Net Empty Web Application .NET 3.5 named
WebApplication1
Copy all files from MYWSAT35 folder across to the new project
In VS solution explorer, select Show all files
If you now build and run the project runs fine with no errors.
5 In VS solution explorer, for all of the imported files right click and
select Include in Project
Now try rebuilding the project I get the error
The type or namespace name 'GetAdminMasterPage' could not be found
(are you missing a using directive or an assembly reference?)
GetAdminMasterPage.cs is located in
WebApplication1\App_Code\class\GetAdminMasterPage.cs and looks like this
#region using references
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.Caching;
using System.Web.UI;
I'm getting really stuck trying to refer to methods in a project imported
into a blank project. The exact steps to recreate this are as follows
Download and Extract into a temp folder http://mywsat.codeplex.com/
Create a new project in VS - Asp.Net Empty Web Application .NET 3.5 named
WebApplication1
Copy all files from MYWSAT35 folder across to the new project
In VS solution explorer, select Show all files
If you now build and run the project runs fine with no errors.
5 In VS solution explorer, for all of the imported files right click and
select Include in Project
Now try rebuilding the project I get the error
The type or namespace name 'GetAdminMasterPage' could not be found
(are you missing a using directive or an assembly reference?)
GetAdminMasterPage.cs is located in
WebApplication1\App_Code\class\GetAdminMasterPage.cs and looks like this
#region using references
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.Caching;
using System.Web.UI;
Subscribe to:
Comments (Atom)