Monday, 30 September 2013

Baseball metaphor=?iso-8859-1?Q?=2C_equivalent_to_'lay_your_body_on_the_line'_=96_english.?=stackexchange.com

Baseball metaphor, equivalent to 'lay your body on the line' –
english.stackexchange.com

The English expression 'you need to be prepared to lay your body on the
line' is a football metaphor, referring to the potentially painful act of
lying down on the goal line to prevent a goal being …

Windows 7 DHCP Inform/Discover packet HLen=0

Windows 7 DHCP Inform/Discover packet HLen=0

After introducing a Windows 7 machine onto my network, my DHCP server
began to complain about receiving DHCP packets with an invalid mac length.
It did not take very long to figure out that once Windows 7 got it's DHCP
address, it would start to look for NTP servers or other time servers
using DHCP inform/discover packets where the hardware address length was
set to zero. For the most part this is just noise in the logs, but I'm
looking to avoid having anyone above me claiming the end is nigh when they
browse the logs.
So far my Google-fu has failed me and I have been unable to find anything
stating that this is expected, seen elsewhere or how to deal with it on
the client side. It would not be hard to handle these specific packets
differently on the server side without loosing logging for packets that
are actually broken, but I would like a little more information about
what/why Windows is doing what it's doing.
Help is greatly appreciated.

How to take screen shot of whole desktop without background/wallpaper picture in Windows

How to take screen shot of whole desktop without background/wallpaper
picture in Windows

I need to capture screen shot without background picture (wallpaper). I
can try to disable wallpaper, take screen shot and then enable it back,
but:
At moment i don't know how to disable/restore wallpaper (in simple case it
is picture file assigned as desktop with some tiling options, but can it
be in modern versions of Windows something different?).
If user kills application before i switch wallpaper back, then wallpaper
remain disabled and it is not good.
Does anyone know solution or ideas where to search for solution ? Maybe it
is possible to disable wallpaper temporarily ?

C# Nested Class

C# Nested Class

I have a class Animal. Within the class Animal I have a list of another
class called Dogs.
class Animal
{
List<Dog> Dogs;
int CountNeutedDogs;
class Dog
{
// some properties
boolean neuted;
}
}
It's possible that the list can contain about 500 dogs at any one time. I
want to have an event so that if the value of neuted property in a dog
changes the CountNeutedDogs is informed and updated. How do I do this?

Sunday, 29 September 2013

Determine the position of node using XSLT

Determine the position of node using XSLT

Given the following XML:
<data>
<content>
<section link-id="32">
<entry id="9">
<title handle="apples">Apples</title>
</entry>
<entry id="1">
<title handle="oranges">Oranges</title>
</entry>
<entry id="4">
<title handle="pears">Pears</title>
</entry>
</section>
<section link-id="23">
<entry id="59">
<title handle="chevrolet">Chevrolet</title>
</entry>
<entry id="31">
<title handle="toyota">Toyota</title>
</entry>
<entry id="54">
<title handle="bmw">BMW</title>
</entry>
</section>
</content>
</data>
Styled by this XSL:
<xsl:template match="data">
<html>
<body>
<xsl:apply-templates select="content/section" />
</body>
</html>
</xsl:template>
<xsl:template match="content/section">
<ul>
<li>
Title: <xsl:value-of select="entry/title"/>
</li>
<li>
entry position: <xsl:value-of select="entry/@entry-position"/>
</li>
</ul>
</xsl:template>
How would I display the position (1-6) of the selected entry nodes? The
expected values would be 1 and 4.

Raspberry Pi wireless Password issue

Raspberry Pi wireless Password issue

I am setting up a Pi with wireless. One of the parameters is "wpa-psk ". I
live in the boonies and my wireless is running without a password. Can I
simply skip this or may be say "wpa-psk none"
de W8CCW

User defined destroy (free) function

User defined destroy (free) function

This is my first question here. I'm unable to understand a couple line of
codes in this program.
The custom destroy function pointer is what I'm unable to understand.
I've commented with "need help #1 and need help #2" where I need help with
the codes.
Any help would be greatly appreciated and I will be really grateful to
anyone who could help me understand these codes.
#ifndef LIST_H
#define LIST_H
#include <stdio.h>
typedef struct _ListElmt
{
void *data;
struct ListElmt *next;
} ListElmt;
typedef struct _List
{
int size;
int (*match)(const void *key1, const void *key2);
void (*destroy)(void *data);
ListElmt *head;
ListElmt *tail;
} List;
void list_init(List *list, void (*destroy)(void *data));
void list_destroy(List *list);
int list_ins_next(List *list, ListElmt *element, const void *data);
int list_rem_next(List *list, ListElmt *element, void **data);
int list_size(const List *list);
ListElmt *list_head(const List *list);
ListElmt *list_tail(const List *list);
int list_is_head(const ListElmt *element);
int list_is_tail(const ListElmt *element);
void *list_data(const ListElmt *element);
ListElmt *list_next(const ListElmt *element);

Google Analytics Site Totals

Google Analytics Site Totals

is it possible to create a custom report which gives me the totals only
for a report based on Site Content - All pages.
My current report is exported to me in csv and includes View, Unique Page
Views, Unique visitors etc. But it returns thousands of rows and i'm only
after the totals for these site values.
How can this be done
thanks

Saturday, 28 September 2013

Can not install Mono Runtime 2.10.11 on my OSX 10.8.5 macs.

Can not install Mono Runtime 2.10.11 on my OSX 10.8.5 macs.

I have a program that I need to run and it requires Runtime 2.10.11. I can
download and run the installer until install is complete but when I open
the program I need to run, I get an error warning saying that Mono Runtime
2.10.11 is required, otherwise the program may not run correctly. The
program does open but as soon as I enter a command, it disappears and
shuts down. I have the security preferences set so the program does
install or at least it says it does. But I cannot find the Mono.framework
folder anywhere on the computer and not in the root library folder.
Kevin

install FosUserBundle in symphony 2.3

install FosUserBundle in symphony 2.3

I started to work in this famous framework, I want Know if i can install
FosUserBundle in symphony 2.3 and the how i do this "install the bundle
manually, without composer" if yes, if no can you give me the link to
download version 2.1 with vendor(the official link does not work).

How to make a search engine in PHP?

How to make a search engine in PHP?

I have a MySQL database with a table that looks like this
FName |LName|Info
---------------------------------------------------------------
John |Doe |Enjoys eating food
---------------------------------------------------------------
Jennifer |Doe |Likes asking stupid questions on sack overflow
---------------------------------------------------------------
Sonny |Doe |Son of John and Jennifer
---------------------------------------------------------------
Using PHP, I want to make a search engine that searches all columns and
rows, but where if I search "sonny", it shows me
First Name:
Last Name
Info:
Any help would be appreciated.

How to sub-class with E.F. Database First

How to sub-class with E.F. Database First

Historically I have used database first in my applications. In cases where
I have a base class and multiple derived classes I end up having a lot of
'if' statements in my code.
I have just now started using Code First and I have noticed that the key
to E.F. mapping back to the derived classes is with the 'Discriminator'
field in the base class Sql table.
My question is, with regards to some of the existing applications I have
that use database first, how can I begin to create my POCO class in true
OO fashion? Am I able to add this Discriminator field to the database
table and the E.F. will create my subclasses for me? I guess this wouldn't
work as that is not enough information for E.F. to know which fields
belong to which class.
So perhaps the question becomes, is there any way to implement
polymorphism with database first or do I have to switch over to code
first. If this is the case, is it possible to turn db first into code
first and not lose any data?
Thanks.

Friday, 27 September 2013

Load pdf obtained as event.data from cross document messaging

Load pdf obtained as event.data from cross document messaging

Unique problem, as far as my research shows. My code successfully
downloads a pdf from a website via cross document messaging. However, I
want to now display the pdf in the browser, possibly in an iframe or data
object. Possibly I would need to know the local url that the pdf is stored
as once downloaded. Please help, probably easy points. See the fiddle here
for my code.
HTML code:
<input type="button" onclick="runit()" value="runit"></input>
<iframe width=100 height=100 id="client"
src="http://ops.epo.org/3.0/xss/crosssitescript.html" />
Javascript code:
function runit() {
// Get the iframe window object
var client = document.getElementById('client');
// Create the data string to be passed to the OPS JavaScript
var data = "{'url' :
'http://ops.epo.org/3.0/rest-services/published-data/images/US/7123345/B2/thumbnail.pdf?Range=1',
" + "'method' : 'GET', " + "'requestHeaders' : {'Accept':
'application/pdf' } " + "}";
// Use the postMessage() method in order to send the data to the
// iframe object
client.contentWindow.postMessage(data, 'http://ops.epo.org');
}
// Add event listener for your window
window.addEventListener("message", receiveMessage, false);
// Method handling window events
function receiveMessage(event) {
// Check origin of the event!
if (event.origin == "http://ops.epo.org") {
alert("How do I display the event.data as a pdf on the page?");
} else {
alert("Got message from unknown source.");
}
}

UncaughtExceptionHandler behaves unexpectedly, then freezes

UncaughtExceptionHandler behaves unexpectedly, then freezes

My consumer doesn't work the way I expect it to. Below is an sscce of what
happens in my real program.
Expected:
Print In finally!
Print About to print stacktrace
Print a NullPointerException stacktrace.
Actual:
Print In finally!
Hang, in sun.misc.Unsafe
Program:
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
public class ThreadTest implements Runnable {
public static void main(String... args) {
ExecutorService service = Executors.newSingleThreadExecutor(new
ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread newThread = new Thread(r);
newThread.setUncaughtExceptionHandler(new
MyExceptionHandler());
return newThread;
}
});
service.submit(new ThreadTest());
}
private static class MyExceptionHandler implements
UncaughtExceptionHandler {
@Override
public void uncaughtException(Thread t, Throwable e) {
System.out.println("About to print stacktrace");
e.printStackTrace();
}
}
@Override
public void run() {
Object foo = null;
try {
while(!Thread.interrupted()) {
Thread.sleep(1000);
System.out.println(foo.toString());
System.out.println("After npe!");
}
} catch(InterruptedException e) {
} finally {
System.out.println("In finally!");
}
}
}

Executing bash commands automatically under sudo is not working

Executing bash commands automatically under sudo is not working

I need a script to execute sudo commands without requesting a password. In
the following scripts I have a strange bash stdin behaviour:
username@username-laptop:~$ sudo -Si | echo "password"
password
root@username-laptop:~# exit
username@username-laptop:~$ sudo -Si | echo "password"
password
[sudo] password for rootname:
(password is a root password on my machine)
Why the password has not been requested in the first time, and has been in
the second (and always after that)? Also I don't understand how stdin
works in bash, where is an error in my code?
I know this is a very bad idea to put a root password to the command
directly, but I need it to execute correctly.

Why output showing 0 instead of 0.0?

Why output showing 0 instead of 0.0?

I declared an array of 10 elements and initialized it with 0.0 .. 9.9 ,
its output is perfect except 0.0 has been changed into 0, why is it so?
#include <iostream>
using namespace std;
int main(void)
{
int const SIZE = 10;
double number[SIZE] = {0.0,1.1,2.2,3.3,4.4,5.5,6.6,7.7,8.8,9.9};
for(int i(0) ; i < SIZE ; i++)
{
cout << number[i] << endl ;
}
system("PAUSE");
}
Thanks,

type of input cSharp

type of input cSharp

actually I am trying to write small program that read input from user to
decide whether is it intger or not.
object x=Console.ReadLine();
check(x);
static void check(object x)
{
if (x.GetType() == typeof(int))
Console.WriteLine("int");
else
Console.WriteLine("not int");
}

DER input, Integer tag error in push notifications sender

DER input, Integer tag error in push notifications sender

We use JavAPNS for sending push notifications to iOS devices. Push
notifications to iOS devices are sent and recieved, when I am in Windows
or OS X,but when I am in Linux environment this error occurs:
javapns.communication.exceptions.KeystoreException: Keystore exception:
DER input, Integer tag error
at
javapns.communication.KeystoreManager.wrapKeystoreException(KeystoreManager.java:178)
at
javapns.communication.KeystoreManager.loadKeystore(KeystoreManager.java:66)
at
javapns.communication.KeystoreManager.ensureReusableKeystore(KeystoreManager.java:87)
at
javapns.communication.AppleServerBasicImpl.<init>(AppleServerBasicImpl.java:37)
at
javapns.notification.AppleNotificationServerBasicImpl.<init>(AppleNotificationServerBasicImpl.java:57)
at
javapns.notification.AppleNotificationServerBasicImpl.<init>(AppleNotificationServerBasicImpl.java:42)
at
javapns.notification.AppleNotificationServerBasicImpl.<init>(AppleNotificationServerBasicImpl.java:28)
at javapns.Push.sendPayload(Push.java:170)
at javapns.Push.payload(Push.java:149)
at com.myproj(class.java:80)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662) Caused by:
java.io.IOException: **DER input, Integer tag error**
at sun.security.util.DerInputStream.getInteger(DerInputStream.java:151)
at
com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1202)
at java.security.KeyStore.load(KeyStore.java:1185)
at
javapns.communication.KeystoreManager.loadKeystore(KeystoreManager.java:64)
... 11 more
This is my code:
public void run() {
List<PushedNotification> notifications = new
ArrayList<PushedNotification>();
String keystorePath = "/cert/cert.p12";
InputStream keystore = this.getClass().getResourceAsStream(keystorePath);
try {
//Some code..
payload = constructMessagePayload();
notifications = Push.payload(payload, keystore,"password",
false, iphoneTargets);
logger.info("Notification list size:" + notifications.size());
} catch (CommunicationException e) {
logger.error("Exception",e);
} catch (KeystoreException e) {
logger.error("Exception",e);
} catch (JSONException e) {
logger.error("Exception",e);
}
for (PushedNotification notification : notifications) {
if (pn.isSuccessful()) {
logger.info("Push ok: "
+ pn.getPayload().toString());
} else {
logger.info("Push not ok: "
+ pn.getException().toString());
}
}
}
If I specify absolute path of file everything works, but I want to have it
in src/main/resources, not to log into server every time when I need to
change file. If I correctly understand this is problem related with
private key.Is there a way this to be fixed.What is different in Linux
here? Any advices?

Thursday, 26 September 2013

Error while attempting to find an element in a map

Error while attempting to find an element in a map

I am using the following code
void SomeClass::Update(const std::string& symbol, const int& volume)
{
std::map<std::string,int>& Refcontainer = BTracker;
//The two conditionals below seem to cause a problem here
if(Refcontainer.find(symbol) != Refcontainer.end())
{
Refcontainer[symbol] = Refcontainer[symbol] + volume;
}
else
{
Refcontainer[symbol] = 0 + volume;
}
}
The errors i am getting are:
Error 16 error C2676: binary '<' : 'const std::string' does not define
this operator or a conversion to a type acceptable to the predefined
operator c:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\include\xfunctional 125 1 " "
Error 10 error C2784: 'bool std::operator <(const
std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' :
could not deduce template argument for 'const std::_Revranit<_RanIt,_Base>
&' from 'const std::string' c:\Program Files (x86)\Microsoft Visual
Studio 10.0\VC\include\xfunctional 125 1 " "
Error 11 error C2784: 'bool std::operator <(const
std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' :
could not deduce template argument for 'const std::_Revranit<_RanIt,_Base>
&' from 'const std::string' c:\Program Files (x86)\Microsoft Visual
Studio 10.0\VC\include\xfunctional 125 1 " "
Error 12 error C2784: 'bool std::operator <(const
std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' :
could not deduce template argument for 'const std::_Revranit<_RanIt,_Base>
&' from 'const std::string' c:\Program Files (x86)\Microsoft Visual
Studio 10.0\VC\include\xfunctional 125 1 " "
Error 1 error C2784: 'bool std::operator <(const std::_Tree<_Traits>
&,const std::_Tree<_Traits> &)' : could not deduce template argument for
'const std::_Tree<_Traits> &' from 'const std::string' c:\Program Files
(x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional 125 1 " "
Error 2 error C2784: 'bool std::operator <(const std::_Tree<_Traits>
&,const std::_Tree<_Traits> &)' : could not deduce template argument for
'const std::_Tree<_Traits> &' from 'const std::string' c:\Program Files
(x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional 125 1 " "
Error 3 error C2784: 'bool std::operator <(const std::_Tree<_Traits>
&,const std::_Tree<_Traits> &)' : could not deduce template argument for
'const std::_Tree<_Traits> &' from 'const std::string' c:\Program Files
(x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional 125 1 " "
Error 13 error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2>
&,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for
'const std::pair<_Ty1,_Ty2> &' from 'const std::string' c:\Program Files
(x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional 125 1 " "
Error 14 error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2>
&,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for
'const std::pair<_Ty1,_Ty2> &' from 'const std::string' c:\Program Files
(x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional 125 1 " "
Error 15 error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2>
&,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for
'const std::pair<_Ty1,_Ty2> &' from 'const std::string' c:\Program Files
(x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional 125 1 " "
Error 7 error C2784: 'bool std::operator <(const
std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' :
could not deduce template argument for 'const
std::reverse_iterator<_RanIt> &' from 'const std::string' c:\Program Files
(x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional 125 1 " "
Error 8 error C2784: 'bool std::operator <(const
std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' :
could not deduce template argument for 'const
std::reverse_iterator<_RanIt> &' from 'const std::string' c:\Program Files
(x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional 125 1 " "
Error 9 error C2784: 'bool std::operator <(const
std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' :
could not deduce template argument for 'const
std::reverse_iterator<_RanIt> &' from 'const std::string' c:\Program Files
(x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional 125 1 " "
Error 4 error C2784: 'bool std::operator <(const
std::unique_ptr<_Ty,_Dx> &,const std::unique_ptr<_Ty2,_Dx2> &)' : could
not deduce template argument for 'const std::unique_ptr<_Ty,_Dx> &' from
'const std::string' c:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\include\xfunctional 125 1 " "
Error 5 error C2784: 'bool std::operator <(const
std::unique_ptr<_Ty,_Dx> &,const std::unique_ptr<_Ty2,_Dx2> &)' : could
not deduce template argument for 'const std::unique_ptr<_Ty,_Dx> &' from
'const std::string' c:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\include\xfunctional 125 1 " "
Error 6 error C2784: 'bool std::operator <(const
std::unique_ptr<_Ty,_Dx> &,const std::unique_ptr<_Ty2,_Dx2> &)' : could
not deduce template argument for 'const std::unique_ptr<_Ty,_Dx> &' from
'const std::string' c:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\include\xfunctional 125 1 " "
Any suggestion on why I am getting this error and how to resolve it ?

Wednesday, 25 September 2013

Oracle: join local index to global index results in error?

Oracle: join local index to global index results in error?

Suppose you have two partitioned tables:
table1:
- id (primary key = global index)
- created (timestamp of creation)
table2:
- id (primary key = global index)
- t1_id (foreign key to table1.id, a local index was created for this
field)
The partitioning is done on table1.created and table2 is partitioned by
reference on table2.t1_id.
Now if I run this query:
select * from table1 t1 join table2 t2 on t1.id=t2.t1_id
I get the ever awesome error: ORA-03113
I do not have access to the actual server running the oracle instance so I
can't check the alert logs. Google turned up nothing useful so after some
fiddling I thought that maybe the local index was the problem. I tried
adding the necessary clauses to limit the range of partitions that should
be targeted to no avail.
I replaced the local index on table2.t1_id with a global index and the
query works.
Now my question: is this a feature/bug? Or a logical consequence of how
local indexes work? Is it some other problem entirely which I accidently
fixed by recreating the index?
Oracle version: 11.2.0.2.0 - 64bit

Thursday, 19 September 2013

www version loads much faster than non-www. What is happening here?

www version loads much faster than non-www. What is happening here?

My website has a strange thing happening to it... When I load the www
version, it loads very quickly. If I load the non-www version, it loads
very, very slowly.
http://www.hiddenchamberstudio.com
http://hiddenchamberstudio.com
Does anyone know what scenario is happening here?

Excel VBA Macros Using Checkboxes To Hide Rows - If Else Statements

Excel VBA Macros Using Checkboxes To Hide Rows - If Else Statements

I have 60 check boxes on one worksheet. They are form control checkboxes.
They all do a similar function which is hide rows. When you click the
check box it shows the rows When unchecked the rows are hidden. Is there
an easy if else or case statement I could write for this:
Sub CheckBox1_Click()
If Range("B4").Value = True Then
Rows("5:62").EntireRow.Hidden = False
Else
Rows("5:62").EntireRow.Hidden = True
End If
End Sub
Sub CheckBox2_Click()
If Range("B63").Value = True Then
Rows("64:102").EntireRow.Hidden = False
Else
Rows("64:102").EntireRow.Hidden = True
End If
End Sub
Sub CheckBox3_Click()
If Range("B103").Value = True Then
Rows("104:129").EntireRow.Hidden = False
Else
Rows("104:129").EntireRow.Hidden = True
End If
End Sub
Sub CheckBox4_Click()
If Range("B130").Value = True Then
Rows("131:160").EntireRow.Hidden = False
Else
Rows("131:160").EntireRow.Hidden = True
End If
End Sub
Sub CheckBox5_Click()
If Range("B161").Value = True Then
Rows("162:183").EntireRow.Hidden = False
Else
Rows("162:183").EntireRow.Hidden = True
End If
End Sub
Sub CheckBox6_Click()
If Range("B184").Value = True Then
Rows("185:222").EntireRow.Hidden = False
Else
Rows("185:222").EntireRow.Hidden = True
End If
End Sub
Sub CheckBox7_Click()
If Range("B223").Value = True Then
Rows("224:244").EntireRow.Hidden = False
Else
Rows("224:244").EntireRow.Hidden = True
End If
End Sub
........etc etc
Also, if I need to add more rows in or delete rows, how would I code that in?
I would appreciate a format that I could use to create my own check boxes
in the future without having to manually fix and edit them individually

Python script for changing Feature & Raster projection

Python script for changing Feature & Raster projection

I have a number of feature classes and rasters in a folder ('Data') which
need to be projected to WGS84 from another projection and saved on a
geodatabase ('WGS84.gdb'). I started with the script below and succeeded
to print the Spatial Reference descriptions of both features an rasters -
but only until that point.
I get an error code and can't really tell what's wrong with the last part
of the script. I'm also having difficulty incorporating another loop to
make sure the raster files also get projected (using arcpy.project raster
management).
Any suggestions? Thanks!
import arcpy
import os
from arcpy import env
arcpy.env.workspace=r'C:\Data'
arcpy.env.overwriteOutput = True
output=r'C:\Results\WGS84.gdb'
FClist=arcpy.ListFeatureClasses('*','all')
print FClist
for FClist in arcpy.ListFeatureClasses():
dsc=arcpy.Describe(FClist)
if dsc.spatialReference.Name is 'WGS 1984 UTM Zone 32N':
print 'WGS84'
else:
print 'Not WGS84'
outfc= os.path.join(r'C:\Results\WGS84.gdb', FClist)
outCS= arcpy.SpatialReference('WGS 1984 UTM Zone 32N')
arcpy.Project_management(FClist, outfc, 'WGS 1984 UTM Zone 32N')
print 'OK'

Executing python script in android terminal emulator

Executing python script in android terminal emulator

I installed python 2.7 in my Android device and I tried executing a python
script by typing the command in terminal emulator. The problem is that
although I use the full path for python the following error appears:
link_image[1997]: failed to link ./python CANNOT LINK EXECUTABLE. I tried
to add environment variables in ./~bashrc but I didn't make it. Any idea ?

copying strings from 2d array into 1d array

copying strings from 2d array into 1d array

Im having some trouble dealing with pointers in C.
My code loads in a large string of characters from a text file
1378251369.691375 84:1b:5e:a8:bf:7f 68:94:23:4b:e8:35 100
1378251374.195670 00:8e:f2:c0:13:cc 00:11:d9:20:aa:4e 397
1378251374.205047 00:8e:f2:c0:13:cc 00:11:d9:20:aa:4e 397
1378251374.551604 00:8e:f2:c0:13:cc 00:11:d9:20:aa:4e 157
1378251375.551618 84:1b:5e:a8:bf:7c cc:3a:61:df:4b:61 37
and then copies each line into an array (fullinfo[200][BUFSIZ]).
im then trying to asses the last two pieces of info and put them into
there own array e.g.
cut2line[0] = 68:94:23:4b:e8:35 100
cut2line[1] = 00:11:d9:20:aa:4e 397
to do this I have tried strcpy and memcpy
fullinfo[200][BUFSIZ];
char cutline[BUFSIZ];
char cut2line[BUFSIZ];
while( fgets(line, sizeof line, pi) != NULL) {
strcpy(fullinfo[infoline], line);
strcpy(cutline,fullinfo[infoline]);
memcpy(cut2line,*cutline[25],100);
printf("%s",cutline);
infoline ++;
}
both of which give either
invalid type of argument of unary '*' (have 'int')
or something involving wrong pointer types.
any help is appreciated.
Edit to clarrify: cutline contains the whole line fromthe input file which
is correct, but when i try to copy the second part of the line into its
own array i get the errors

add placeholder jquery to textarea too?

add placeholder jquery to textarea too?

I have this code witch adds IE support for placeholder input types, i
wan`t that it supports also tags with placeholder. Link to the js query
code...
http://placeholder-fixer.googlecode.com/svn/trunk/placeholder_fixer.js
function PlaceholderFixer(){
var tmp_input = document.createElement("input");
this.is_placeholder_supported = "placeholder" in tmp_input;
this.is_onpropertychange_supported = "onpropertychange" in tmp_input;
this.init();
}
PlaceholderFixer.prototype._addEvent = function(element, type, handler){
if (element.addEventListener){
element.addEventListener(type, handler, false);
} else if (element.attachEvent){
element.attachEvent("on" + type, handler);
} else {
element["on" + type] = handler;
}
};
PlaceholderFixer.prototype.init = function(){
var me = this;
var inputs = document.getElementsByTagName("input");
for(var i=0, len=inputs.length; i<len; i++){
var input = inputs[i],
text = input.getAttribute("placeholder");
if(text && !this.is_placeholder_supported){
me._fix(input, text);
}
me._addChangedProperty(input);
}
}; all code is in the given link....

Converting this date into time ago

Converting this date into time ago

Looking for a lightweight function that would convert this date as it is
displayed "Thu Sep 19 08:43:29 +0000 2013"
Any ideas?

How to enable zoom for two different scroll view in single view?

How to enable zoom for two different scroll view in single view?

I am displaying two images on single view where both images must have zoom
functionality.My page height is around 1000 pixels and images must be
display on top and bottom of page. For that I have added two different
scroll view and added image views on scroll views.
Now Zoom is working properly for second image .But first image is getting
displayed in top left corner of scroll view once zoomed out. It seems
there are two images.
Here is the delegate method i am using:
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
return [[scrollView subviews] objectAtIndex:0];
}
Is there anything i am missing ? or is this not really possible to enable
zoom when there are two scroll views for single page.

Wednesday, 18 September 2013

When using android:autoLink, non-linked text changes color on click

When using android:autoLink, non-linked text changes color on click

I have a TextView that I have set android:autoLink="web" on, and it works
just fine, but the non-linked text changes from whitish to black when i
click on it, for example if i have the text "Check out Google's site:
www.google.com", the "Check out Google" part changes color.
I have this TextView inside a LinearLayout inside a ScrollView that I set
as the view of an AlertDialog, perhaps that has something to do with it
since this does not happen when I use android:autoLink="web" outside of an
AlertDialog... Anyone know what might be happening here??

Browser Automation testing

Browser Automation testing

I have browser automation framework which is using Selenium Web Driver.It
currently runs all the tests which I have in an excel with commands which
the framework understands and generates reports with snapshots.
What else can I do with the Selenium? Like what other features can be
added to improve testing?
Please provide your suggestions.

Replaceing Backbone sync on an Application level -- not via Model or Xollection

Replaceing Backbone sync on an Application level -- not via Model or
Xollection

How does one replace Backbone.sync using backbone.basicauth library found
here.
Can that be done on an Application level -- on App.init in main.js for
example -- and avoid overriding the "synch" on every Model or Collection
project
source

cant preform an if statement correctly

cant preform an if statement correctly

This has been bugging me for a long time, I've been making a program that
simply preforms an action if you type in a certain password. I keep
getting a error saying ":4: '' expected or "if statement expected" Please
help!
textutils.SlowPrint("type the password")
--This is a W.I.P and it is in a basic stage!
pass = ImCool
setCursorPos.(4,5)
input.read(*)
--problem is here
if input = pass then
print("You did it"!)

Regex URL in django doesnt work

Regex URL in django doesnt work

i have this in my URL config:
url(r'^fotogalerie/(?P<nazev_slozky>([^/]+/)+)/$', fotogalerie_slozka),
I want to work for all URL that begin at fotogalerie, so for
"fotogalerie/something/","fotogalerie/so/on/","fotogalerie/i/don't
know/anything/". Why this isnt work?

Docx4j Convert to PDF, FOP Issues/ Cannot perform the transformation error

Docx4j Convert to PDF, FOP Issues/ Cannot perform the transformation error

Docx4j version 2.8.1.3
The docx is a very simple one with just some text, it doesn't seem to work
for any docx though.
May be easier to view source/exception at docx4j forums.
http://www.docx4java.org/forums/pdf-output-f27/docx4j-to-pdf-fop-issues-cannot-perform-the-transformation-t1652.html
If answered at one place I will update both with answer
Here is the exception
fourseasons.general.conversionservice.converter.AbstractConverter FOP issues
org.docx4j.openpackaging.exceptions.Docx4JException: FOP issues
Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Cannot
perform the transformation
at org.docx4j.XmlUtils.transform(XmlUtils.java:911)
at org.docx4j.XmlUtils.transform(XmlUtils.java:802)
at
org.docx4j.convert.out.pdf.viaXSLFO.Conversion.output(Conversion.java:349)
... 230 more
Caused by: javax.xml.transform.TransformerException:
java.lang.NullPointerException
at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2405)
at
org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1376)
at
org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
at
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178)
at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
at
org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2270)
at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1356)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:709)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1273)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1251)
at org.docx4j.XmlUtils.transform(XmlUtils.java:909)
... 232 more
Caused by: java.lang.NullPointerException
at
org.apache.xalan.templates.ElemVariable.getValue(ElemVariable.java:282)
at
org.apache.xalan.templates.ElemVariable.execute(ElemVariable.java:248)
at
org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
at
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178)
at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
Code to create the bytes:
Mapper fontMapper = new IdentityPlusMapper();
wordmlPackage.setFontMapper(fontMapper);
org.docx4j.convert.out.pdf.viaXSLFO.Conversion c = new
org.docx4j.convert.out.pdf.viaXSLFO.Conversion(
wordmlPackage);
ByteArrayOutputStream os = new ByteArrayOutputStream();
c.output(os, new PdfSettings());
os.close();
binarypdf = os.toByteArray();

Cron create error with rails runner

Cron create error with rails runner

I have rails app, but I have problem with scheduled work.
My crontable(by whenever):
0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58
* * * * /bin/bash -l -c 'cd
/home/oliver/apps/parovanie/releases/20130918135145 && bin/rails runner -e
production '\''SheduleRunner.check_mail'\'' >> log/cron_log.log 2>&1'
My ruby(rails) class:
require 'pairing'
class SheduleRunner
def self.check_mail
Mailman.config.logger = CustomLogger.new("log/mailman.log")
Mailman.config.imap = {
server: Figaro.env.email_host, port: Figaro.env.email_imap_port,
ssl: false,
username: Figaro.env.email_name,
password: Figaro.env.email_password
}
Mailman.config.poll_interval = 0
Mailman::Application.run do
from Figaro.env.pairing_from do
begin
if message.has_attachments?
if message.attachments[0].filename.include?('.ZIP')
p = Pairing.new
Mailman.logger.info("Email receive with attachment:
#{message.attachments[0].filename}")
p.load_attachment_from_email(message.attachments[0].filename,message.attachments[0].body.decoded)
Mailman.logger.info("Email processed.")
end
end
rescue Exception => e
Mailman.logger.error "Exception occurred while receiving
message:\n#{message}"
Mailman.logger.error [e, *e.backtrace].join("\n")
end
end
default do
Mailman.logger.info("Default route: #{message.from} -
attachments:#{message.has_attachments?}")
end
end
nil
end
end
My cron log:
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands/runner.rb:53:in
`eval': undefined method `each' for nil:NilClass (NoMethodError)
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/bundler/gems/mailman-bb897b1d81e2/lib/mailman/route.rb:29:in
`block in match!'
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/bundler/gems/mailman-bb897b1d81e2/lib/mailman/route.rb:28:in
`each'
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/bundler/gems/mailman-bb897b1d81e2/lib/mailman/route.rb:28:in
`match!'
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/bundler/gems/mailman-bb897b1d81e2/lib/mailman/router.rb:48:in
`block in route'
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/bundler/gems/mailman-bb897b1d81e2/lib/mailman/router.rb:47:in
`each'
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/bundler/gems/mailman-bb897b1d81e2/lib/mailman/router.rb:47:in
`route'
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/bundler/gems/mailman-bb897b1d81e2/lib/mailman/message_processor.rb:23:in
`block in process'
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/bundler/gems/mailman-bb897b1d81e2/lib/mailman/middleware.rb:33:in
`call'
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/bundler/gems/mailman-bb897b1d81e2/lib/mailman/middleware.rb:33:in
`block in run'
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/bundler/gems/mailman-bb897b1d81e2/lib/mailman/middleware.rb:38:in
`call'
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/bundler/gems/mailman-bb897b1d81e2/lib/mailman/middleware.rb:38:in
`run'
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/bundler/gems/mailman-bb897b1d81e2/lib/mailman/message_processor.rb:22:in
`process'
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/bundler/gems/mailman-bb897b1d81e2/lib/mailman/application.rb:71:in
`run'
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/bundler/gems/mailman-bb897b1d81e2/lib/mailman/application.rb:11:in
`run'
from
/home/oliver/apps/parovanie/releases/20130918135145/lib/sheduler_runner.rb:19:in
`check_mail'
from (eval):1:in `<top (required)>'
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands/runner.rb:53:in
`eval'
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands/runner.rb:53:in
`<top (required)>'
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:86:in
`require'
from
/home/oliver/apps/parovanie/shared/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:86:in
`<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
When I run code from crontab in command line(via ssh) :
oliver@rubypro:~$ /bin/bash -l -c 'cd
/home/oliver/apps/parovanie/releases/20130918135145 && bin/rails runner -e
production '\''SheduleRunner.check_mail'\'' >> log/cron_log.log 2>&1'
It worked.
Figaro works without problems, I checked it.
Cron use right ruby(rvm). I checked it with cron jobs: puts RbConfig.ruby
When I clean my code and check_mail method looks like:
def self.check_mail
Mailman.config.logger = CustomLogger.new("log/mailman.log")
Mailman.config.imap = {
server: Figaro.env.email_host, port: Figaro.env.email_imap_port,
ssl: false,
username: Figaro.env.email_name,
password: Figaro.env.email_password
}
Mailman.config.poll_interval = 0
Mailman::Application.run do
end
nil
end
I have no errors, but I need read email from email and others.
I don't know where can be problem. Anybody help? PS:Sorry for my english.

Printed Books VS E-Books

Printed Books VS E-Books

As an a professional Developer what is the best way you use for reading
and Learning are this through Printed Books or E-Books

Joomla pagination - click on footer doesn´t work

Joomla pagination - click on footer doesn´t work

I´m using Joomla and want to use pagination at my backend. I added some
code and the footer in my view, but if I click onto the footer there
happens nothing. I dont get my fault there.
If I click on a the second page at the footer the link gets an hash behind.
Any Ideas how to fix that?
Controller: function display(){
$mainframe =& JFactory::getApplication();
$limit = $mainframe->getUserStateFromRequest('limit', 'limit',
$mainframe->getCfg('list_limit'), 'int' );
$limitstart = $mainframe->getUserStateFromRequest('limitstart',
'limitstart', 0, 'int' );
$jshopConfig = &JSFactory::getConfig();
$statistic = &$this->getModel("statistic_sells");
$total = $statistic->getCountAllStatistic();
jimport('joomla.html.pagination');
$pagination = new JPagination($total, $limitstart, $limit);
$rows =
$statistic->getAllStatisticOrderByAnzahl($pagination->limitstart,
$pagination->limit);
$view=&$this->getView("statistic_sells", 'html');
$view->assign('pagination', $pagination);
$view->assign('rows', $rows);
$view->display();
}
model:
function getAllStatisticOrderByAnzahl($limitstart=null, $limit=null) {
$db =& JFactory::getDBO();
$lang = &JSFactory::getLang();
if($limit > 0){
$limit = " LIMIT ".$limitstart." , ".$limit;
}else{
$limit = "";
}
$query = "SELECT pr.`name_de-DE` as produkt, pr.orders,
pr.min_price , pr.product_date_added, mf.`name_de-DE` as
hersteller
FROM #__jshopping_products pr
LEFT JOIN #__jshopping_manufacturers mf
ON pr.product_manufacturer_id = mf.manufacturer_id
ORDER BY orders DESC" . $limit;
$db->setQuery($query);
return $db->loadAssocList();
}
function getCountAllStatistic(){
$db =& JFactory::getDBO();
$lang = &JSFactory::getLang();
$query = "SELECT count(*) FROM #__jshopping_products";
$db->setQuery($query);
return $db->loadResult();
}
view:
<form action = "index.php?option=com_jshopping&controller=statistic_sells"
method = "post" name = "adminForm">
<table class = "adminlist">
<thead>
<tr>
<th class = "title" width = "10">#</th>
<th width = "200" align = "left">
<?php echo _JSHOP_STATISTIK_PRODUCT;?>
</th>
<th>
<?php echo _JSHOP_STATISTIK_PRODUCER;?>
</th>
<th align = "left">
<?php echo _JSHOP_STATISTIK_COUNT;?>
</th>
<th width = "80" align = "left">
<?php echo _JSHOP_STATISTIK_PRICE;?>
</th>
<th width = "80" align = "left">
<?php echo _JSHOP_STATISTIK_ADD_DATE;?>
</th>
</tr>
<?php foreach ($rows as $row){
?>
<tr class="row<?php echo $i % 2;?>">
<td>
<?php $i++;
echo $i;
?>
</td>
<td align="left">
<?php echo $row['produkt']?>
</td>
<td>
<?php echo $row['hersteller']?>
</td>
<td>
<?php echo $row['orders']?>
</td>
<td>
<?php echo $row['min_price'] . " €"?>
</td>
<td>
<?php echo $row['product_date_added']?>
</td>
</tr>
<?php
}
?>
</thead>
<tfoot>
<tr>
<td colspan="18"><?php echo $pageNav->getListFooter();?></td>
</tr>
</tfoot>
</table>
<input type = "hidden" name = "task" value = "" />
<input type = "hidden" name = "hidemainmenu" value = "0" />
</form>

Tuesday, 17 September 2013

dropdownlist server side event not called when client side event is also defined

dropdownlist server side event not called when client side event is also
defined

There is a dropdownlist and an ImageButton in a .aspx page. When user
selects the country Australia, There is the need to show an ImageButton (
a Flag Image), which takes the user to its respective website on clicking
it. Rest other websites are internally hosted so no need to display Image
Button.
There is a Client side as well as server side event defined for the
dropdownlist.
Problem is that the server side event of this dropdownlist :
OnSelectedIndexChanged="ddlSortBy_SelectedIndexChanged" is not getting
called. What went wrong ?
Also, as observed when the Client side event is removed, then Server side
event is getting called. Why so ?
<asp:DropDownList ID="ddlCountries" runat="server"
AutoPostBack="true" onchange="return ddlCountriesSelected();"
OnSelectedIndexChanged="ddlCountries_IndexChanged">
<asp:ListItem Text="_Select_" Selected="True"></asp:ListItem>
<asp:ListItem Text="Australia"></asp:ListItem>
<asp:ListItem Text="Spain"></asp:ListItem>
<asp:ListItem Text="England"></asp:ListItem>
<asp:ListItem Text="India"></asp:ListItem>
<asp:ListItem Text="Germany"></asp:ListItem>
</asp:DropDownList>
<asp:ImageButton ID="CountriesImage" runat="server" />
Client side:
<body>
<form id="form1" runat="server" >
<script type="text/javascript">
function ddlCountriesSelected() {
var ddlCntrs = document.getElementById('<%=ddlCountries.ClientID %>');
// alert(ddlCntrs.selectedIndex); // debug purpose
if (ddlCntrs.selectedIndex == "1")
{
var img = document.getElementById('<%=ImageButton1.ClientID%>');
img.src
='Images/'+ddlCntrs.options[ddlCntrs.selectedIndex].value+'.png';
return true;
}
else
{
// code to hide the ImageButton
return false;
}
}
</script>
...
...
</body>
// Code Behind
protected void ddlCountries_IndexChanged(object sender,System.EventArgs e)
{
lbl1.Text = ddlSortBy.SelectedValue;
}

How to select data whose column_name data has digits only in PostgreSQL?

How to select data whose column_name data has digits only in PostgreSQL?

How to select row data whose column_name has digits only in PostreSQL?
Like when table has:
ID | Column_name
1 | 000012
2 | ABC001
The expected result on select should only be the ID 1 wherein the
Column_name has only digits.
I have tried this code but does not work:
select * from table Where not Column_name like '%[^0-9]%'
Can anybody give me advice? Thanks

Manually add a comment in JComments

Manually add a comment in JComments

Anybody know if there's a function I can call to add a comment quickly to
a certain object_id in JComments?
I have been looking through the JComments classes, but don't see anything
apparent.
It would be great if I don't have to manually do the SQL insert.
Thanks in advance.

Sorting a PFQuery by counting objects in array

Sorting a PFQuery by counting objects in array

What I am doing is in my Parse query, I check to see which posts have been
check marked (liked) in the last 7 days. I then remove the dates of those
that haven't. This is working fine. Now my problem is that I need to sort
them in my UITableView in descending order of how many dates are in the
array but my sortedArrayUsingComparator isn't working. Im new to Objective
C so its probably something easy but idk. Here's my code
- (PFQuery *)queryForParse {
PFQuery *query1 = [PFQuery queryWithClassName:self.parseClassName];
//[query1 selectKeys: [NSArray arrayWithContentsOfFile:[ NSString
@"checkMark"]]];
[query1 whereKey:@"location" nearGeoPoint:[PFGeoPoint
geoPointWithLatitude:[LocationController
sharedSingleton].locationManager.location.coordinate.latitude
longitude:[LocationController
sharedSingleton].locationManager.location.coordinate.longitude]
withinMiles:50];
[query1 findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError
*error) {
if (!error){
placesArray = [[NSMutableArray alloc] initWithArray:objects];
NSMutableArray *toDelete = [NSMutableArray array];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyyMMdd"];
for (PFObject *tempObject in placesArray){
checkDates = [[NSMutableArray alloc] initWithArray:[tempObject
objectForKey:@"checkMarkDates"]];
for (NSString *dateString in checkDates) {
NSDate *date = [dateFormat dateFromString: dateString];
if ([date timeIntervalSinceNow] > -604800){
[toDelete addObject:dateString];
}
}
[checkDates removeObjectsInArray:toDelete];
[tempObject removeObjectsInArray:checkDates
forKey:@"checkMarkDates"];
sortedArray = [placesArray
sortedArrayUsingComparator:^NSComparisonResult(id obj1, id
obj2) {
NSUInteger *first = [[obj1 objectForKey:@"checkMarkDates"]
count];
NSNumber *f = [[NSNumber alloc] initWithInteger:first];
NSUInteger *second = [[obj2
objectForKey:@"checkMarkDates"] count];
NSNumber *s = [[NSNumber alloc] initWithInteger:second];
return [f compare:s];
}];
}
NSLog(@"%@", sortedArray);
}
[placesTable reloadData];
}];
return query1;
}

OCIEnvCreate failed with return code -1 + Windows Form + Windows 7 64bits

OCIEnvCreate failed with return code -1 + Windows Form + Windows 7 64bits

I have this situation:
An old windows forms system (from a client), done with VS 2008 and
Framework 3.5, accessing Oracle Database ERP (12g)
Cause we don't have VS 2008, the solution was migrating to VS 2010, and it
is now installed on a notebook running Win 7 64Bits. It continues to use
framework 3.5, but now it is compatible with VS 2010.
The original project, was using Oracle 32 bits OTP driver. My notebook is
Win 7 64 bits, but it has the 32 bits version installed (from
ODTwithODAC1120320_32bit.zip package). This package was installed cause
other system uses it. I Think this is the correct drive.
The original application was done by an employee that is out of client's
company, and they need to inscrease functionalities in this application.
The migration process was 100% and the project is compiling in VS 2010.
The only problem is that when we run the system, it tries to execute the
first query and the error below appears:
OCIEnvCreate failed with return code -1 but error message text was not
available
I have already searched google, and get so many suggestions. I have
already done:
have installed 64 bits version of Oracle Odac (from file
ODAC1120320_x64.zip).
have changed permission access to Oracle Home folder (in my notebook is
ORACLE_HOME=C:\app\marcelo.oliveira\product\11.2.0, to garantee correct
permissions
inserted the user 'network services' with the same permissions as
'authenticated users'
inserted all oracle paths (32 and 64 bits) on environment variable PATH
Nothing take effects.
Some questions:
My client needs to be 12g as the database ? If this is the problem, may I
have 11.2 and 12 living together in my Win 7 ?
Is it necessary to have both 32 and 64 bit versions installed ? I have
installed, but I am not sure this is necessary
The migration to VS 2010 could be the reason for this problem ?
Some notes:
I have SQL Developer program installed and I can access the oracle ERP
from there.
I am using TNS file to connect. Cause I can access from SQL Developer with
this TNS file, I understand it is correct.
I have lost 3 days up to now, and I really dont know what more is
necessary to resolve it... I really appreciate any help.
Thanks, Marcelo de Oliveira.

How I return array of my class type object?

How I return array of my class type object?

public EventData getEventDetails(String evtId, String Status) {
return EventData;
}
public EventData[] getAdminAuthEvtDetails(String evtId, String Status) {
String eid=evtId;
String status=Status;
EventData[] eData=new EventData[2];
EventData[0] eData=getEventDetails(eid,"Verified");
EventData[1] eData=getEventDetails(eid,"Modified");
return EventData;
}
EventData is my java data class. In there I set getters and setters. I
want get call getEventDetails method two time one status as verified and
other as modified for requested ID and set both eData into one array. Is
this correct? I'm new to java.

Sunday, 15 September 2013

sorting based on key from a file

sorting based on key from a file

I need to sort stuff read from a file similar to the following:
Key: 2 rec:1 2 3 4 5 6 ...
Key: 3 rec:7 8 9 10 11 ...
Key: 1 rec:A B C D E F ...
becomes
Key: 1 rec:A B C D E F ...
Key: 2 rec:1 2 3 4 5 6 ...
Key: 3 rec:7 8 9 10 11 ...
and if we have something unsorted in rec (record ) of a key, it will
remain unchanged! as sorting is based on the key. I want to use qsort()
defined in C for sorting. I have an idea to use strtok for breaking each
line read from file into manageable arrays but I am not if it's the best
way to find the key number so as to sort them with qsort from C library.
P.S.: Each line of the input file includes one key like Key: 1 rec:A B C D
E F ... Also we won't sort records within a key.

Why this code not continue?

Why this code not continue?

I would like to know why this code does not start from the word that is
stored in the file.txt.
The code compiles but can not find the error
I wonder why the function "scanf" fails to capture the characters and
passes them to the variable
Thanks for responding
#include <stdio.h>
#include <stdlib.h>
int main(int main, char *argv[]){
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
int f = 0;
int g = 0;
int h = 0;
char var[] = {'1','A','2','B','3','C','4','D','5','E','6'};
char caracteres[9];
char caracteres_txt[9];
FILE *fp, *sesion;
sesion = fopen("Save_Sesion.txt","r");
if (sesion == NULL)
{
printf("\nNo sesion saved.\n");
}
else
{
printf("\nlast word was:\n\n");
fgets(caracteres,9,sesion);
printf("%s\n",caracteres);
fscanf(sesion, "%s", caracteres_txt);
}
if(caracteres_txt[1] == var[0]){
a = 0;
}
else{
if(caracteres_txt[1] == var[1]){
a = 1;
}
else{
if(caracteres_txt[1] == var[2]){
a = 2;
}
else{
if(caracteres_txt[1] == var[3]){
a = 3;
}
else{
if(caracteres_txt[1] == var[4]){
a = 4;
}
else{
if(caracteres_txt[1] == var[5]){
a = 5;
}
else{
if(caracteres_txt[1] == var[6]){
a = 6;
}
else{
if(caracteres_txt[1] == var[7]){
a = 7;
}
else{
if(caracteres_txt[1] == var[8]){
a = 8;
}
else{
if(caracteres_txt[1] == var[9]){
a = 9;
}
else{
if(caracteres_txt[1] == var[10]){
a = 10;
}
}
}
}
}
}
}
}
}
}
}
if(caracteres_txt[2] == var[0]){
b = 0;
}
else{
if(caracteres_txt[2] == var[1]){
b = 1;
}
else{
if(caracteres_txt[2] == var[2]){
b = 2;
}
else{
if(caracteres_txt[2] == var[3]){
b = 3;
}
else{
if(caracteres_txt[2] == var[4]){
b = 4;
}
else{
if(caracteres_txt[2] == var[5]){
b = 5;
}
else{
if(caracteres_txt[2] == var[6]){
b = 6;
}
else{
if(caracteres_txt[2] == var[7]){
b = 7;
}
else{
if(caracteres_txt[2] == var[8]){
b = 8;
}
else{
if(caracteres_txt[2] == var[9]){
b = 9;
}
else{
if(caracteres_txt[2] == var[10]){
b = 10;
}
}
}
}
}
}
}
}
}
}
}
if(caracteres_txt[3] == var[0]){
c = 0;
}
else{
if(caracteres_txt[3] == var[1]){
c = 1;
}
else{
if(caracteres_txt[3] == var[2]){
c = 2;
}
else{
if(caracteres_txt[3] == var[3]){
c = 3;
}
else{
if(caracteres_txt[3] == var[4]){
c = 4;
}
else{
if(caracteres_txt[3] == var[5]){
c = 5;
}
else{
if(caracteres_txt[3] == var[6]){
c = 6;
}
else{
if(caracteres_txt[3] == var[7]){
c = 7;
}
else{
if(caracteres_txt[3] == var[8]){
c = 8;
}
else{
if(caracteres_txt[3] == var[9]){
c = 9;
}
else{
if(caracteres_txt[3] == var[10]){
c = 10;
}
}
}
}
}
}
}
}
}
}
}
if(caracteres_txt[4] == var[0]){
d = 0;
}
else{
if(caracteres_txt[4] == var[1]){
d = 1;
}
else{
if(caracteres_txt[4] == var[2]){
d = 2;
}
else{
if(caracteres_txt[4] == var[3]){
d = 3;
}
else{
if(caracteres_txt[4] == var[4]){
d = 4;
}
else{
if(caracteres_txt[4] == var[5]){
d = 5;
}
else{
if(caracteres_txt[4] == var[6]){
d = 6;
}
else{
if(caracteres_txt[4] == var[7]){
d = 7;
}
else{
if(caracteres_txt[4] == var[8]){
d = 8;
}
else{
if(caracteres_txt[4] == var[9]){
d = 9;
}
else{
if(caracteres_txt[4] == var[10]){
d = 10;
}
}
}
}
}
}
}
}
}
}
}
printf("\nPress Enter to continue\n");
getchar();
while( a <= 10 ){
while( b <= 10 ){
while( c <= 10 ){
while( d <= 10 ){
while( e <= 10 ){
while( f <= 10 ){
while( g <= 10 ){
while( h <= 10 ){
printf("%c%c%c%c%c%c%c%c\n",var[a],var[b],var[c],var[d],var[e],var[f],var[g],var[h]);
++h;
}
h = 0;
++g;
}
g = 0;
++f;
}
f = 0;
++e;
}
e = 0;
++d;
fp = fopen("Save_Sesion.txt","w");
fprintf(fp,
"%c%c%c%c%c%c%c%c\n",var[a],var[b],var[c],var[d],var[e],var[f],var[g],var[h]);
fclose(fp);
}
d = 0;
++c;
}
c = 0;
++b;
}
b = 0;
++a;
}
return 0;
}

ECHO program in C#

ECHO program in C#

i'm trying to make a program in C# that behaves like the well-known echo
command. Everything works fine except when I try to print a quoted String.
For example, in the echo command you type:
echo "Hello, world!"
And you get as output:
"Hello, world"
But when I run my program I get:
Hello, world!
This is the code:
using System;
namespace CSharpEcho
{
public class Echo
{
public static void Main(String[] argv)
{
Int32 ArgsLength = argv.Length;
if(ArgsLength == 0)
Console.WriteLine("You have to write something!");
else
{
String Str = "";
foreach(String args in argv)
{
Str += args + " ";
}
Console.WriteLine(String.Format("{0}", Str));
}
}
}
}

Geolocation for an Hybrid iOS app

Geolocation for an Hybrid iOS app

I am currently developing an hybrid iOS app under xCode with UIWebView.
I would appreciate your help on that issue which is giving me an headache!
Does anyone know whether it is possible to trigger the Corelocation
Framework of iOS from a jQuery event?
Basically, i'd like to do stuff like that:
$('button').click(function(){
*//get position using corelocation framework*
};
If not, can I solve this issue by adding an API like Google Maps?
Thanks a lot!

Correct location for Ajax Scripts in Wordpress?

Correct location for Ajax Scripts in Wordpress?

I am trying to Ajax up an admin screen (admin.php) in a Wordpress plugin
I'm experimenting with which currently just reads the contents of a table,
and should allows a row to be entered into the table. At the moment I'm
getting the following error when submitting the new row. It doesn't seem
to matter where I put the ajax script in the files.
Uncaught ReferenceError: addtablerow is not defined
So, within my class-plugin.php, I create a new page under the Settings
menu (views/admin.php), and I have a function which pulls out the contents
of a table and displays it. I then create a new blank row row of input
fields the bottom of the table, and add a div to put the ajax feedback:
<form action="" method="post" id="new_wp_pop_date_modifiers">
<input type="hidden" name="action" value="pop_addtablerow_php"/>
<input type="hidden" name="table" value="wp_pop_date_modifiers"/>
<tr class="manage-column">
<td><input type="text" name="name" placeholder="name"></td>
<td><input type="text" name="description" placeholder="description"></td>
<td><input type="text" name="sort_order" placeholder="sort_order"></td>
<td><input type="Submit"></td>
</tr>
</form>
<div id="feedback_wp_pop_date_modifiers">Feedback:</div>
<script type="text/javascript">
jQuery('#new_wp_pop_date_modifiers').submit(addtablerow);
</script>
The php handler is the file pop_addtablerow_php:
function pop_addtablerow_php(){
global $wpdb;
$data =array();
foreach($_POST as $key=>$value) {
if (($key != 'table') && ($key !='action')) {
$data[$key] .= $value;
}
}
if($wpdb->insert($_POST['table'],$data)===FALSE){
echo "Error";
} else {
echo "Value '".$name. "' successfully added to '".$table."', row ID
is ".$wpdb->insert_id;
}
die();
}
add_action('wp_ajax_pop_addtablerow_php', 'pop_addtablerow_php');
add_action('wp_ajax_nopriv_pop_addtablerow_php', 'pop_addtablerow_php');
And then I have my ajax stuff, which, no matter where I put it, gives me
the above error:
<script type="javascript/text">
function addtablerow(){
var rowdata = jQuery(this).serialize();
jQuery.ajax({
type:"POST",
url: "/wp-admin/admin-ajax.php",
data: rowdata,
success:function(data){
jQuery("#feedback_wp_pop_date_modifiers_").html(data);
}
});
return false;
}
</script>
Even if I just place this inline in admin.php - thhe admin screen I am
creating for the plugin - is still gives me the Uncaught ReferenceError.
I'm not sure if I've just got something in the wrong place, or if there is
a bigger error somewhere
This is my first stab at using Ajax, so any pointers as to where I'm going
wrong would be much appreciated

Cache engine default is not properly configured

Cache engine default is not properly configured

Error is:
Error: [CacheException] Cache engine default is not properly configured.
Defaul cache engine is "File".
Please help.

OpenGL FrameBuffer texture error

OpenGL FrameBuffer texture error

i tried to find a reason for my Problem but i could not find anything like
that in the Internet.
My Problem is the framebuffer or his texture.
It Looks something like a White texture with randomly generated black
Points, they Change the Position when i add for example
"glClearColor(0,0,0,0);".
Here is a direct link to the Image, it is uploadet to ImageShack
Image
Here is my FrameBufferObj.java
public int buffId;
public int tex_0;
public int depth_tex;
public int width;
public int height;
ByteBuffer buf = BufferUtils.createByteBuffer(1);
public void createFrameBuffer(int width, int height)
{
this.width = width;
this.height = height;
buffId = glGenFramebuffersEXT();
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, buffId);
/*init color texture*/
tex_0 = glGenTextures();
glBindTexture(GL_TEXTURE_2D, tex_0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA,
GL_UNSIGNED_BYTE, (java.nio.ByteBuffer)null);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_2D, 0);
/*init depth texture*/
depth_tex = glGenRenderbuffersEXT();
glBindTexture(GL_TEXTURE_2D, depth_tex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, width, height,
0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, (java.nio.ByteBuffer)null);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE,
GL_COMPARE_R_TO_TEXTURE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LESS);
glBindTexture(GL_TEXTURE_2D, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, buffId);
// Associate the depth and color rendering textures to the FBO
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex_0, 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, depth_tex, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
int framebuffer = glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
switch ( framebuffer ) {
case GL_FRAMEBUFFER_COMPLETE_EXT:
break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
throw new RuntimeException( "FrameBuffer: " + buffId
+ ", has caused a
GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT exception" );
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
throw new RuntimeException( "FrameBuffer: " + buffId
+ ", has caused a
GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT
exception" );
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
throw new RuntimeException( "FrameBuffer: " + buffId
+ ", has caused a
GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT exception" );
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
throw new RuntimeException( "FrameBuffer: " + buffId
+ ", has caused a
GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT exception"
);
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
throw new RuntimeException( "FrameBuffer: " + buffId
+ ", has caused a
GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT exception" );
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
throw new RuntimeException( "FrameBuffer: " + buffId
+ ", has caused a
GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT exception"
);
default:
throw new RuntimeException( "Unexpected reply from
glCheckFramebufferStatusEXT: " + framebuffer );
}
}
public void bind()
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, buffId);
}
public void unbind()
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
public ByteBuffer getPixelColor(int x, int y)
{
buf = BufferUtils.createByteBuffer(3);
glReadPixels(x, y, 1, 1, GL_BGR, GL_UNSIGNED_BYTE, buf);
return buf;
}
public ByteBuffer getTexture()
{
buf = BufferUtils.createByteBuffer(width * height);
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
glReadPixels(0, 0, width, height, GL_BGR, GL_UNSIGNED_BYTE, buf);
return buf;
}
}
And here is how i call it
public void preRenderPicking()
{
picker_screen.bind();
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
GL11.glClearDepth(1.0f);
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
camera.applyPerspectiveMatrix();
GL11.glLoadIdentity();
picking_colorizer.enableShader();
picker.processPicking(picking_colorizer,renderables);
picking_colorizer.disableShader();
updatePickedObject(Mouse.getX(), Mouse.getY());
picker_screen.unbind();
}
Then i just created the final quad with the framebuffer texture (look at
the Image)
When i remove the quad renderer there is just a black Screen.
Thanks for helping =)

Saturday, 14 September 2013

Is it possible to determine verify the client_id with an access_token

Is it possible to determine verify the client_id with an access_token

Is it possible to determine the originating client_id of an access_token
by calling a google api with the access_token?

How to call a jinternalframe using the string name of the class

How to call a jinternalframe using the string name of the class

I want to call jinternalframe from its string name, for example if I have
a jinternalframe call it frmMain, I wanna call just using "frmMain"
string.
I think with reflection I can do that but I'm not sure.

UVa Online Judge - Graphical Editor [on hold]

UVa Online Judge - Graphical Editor [on hold]

I am having problem solving a UVa Online Judge problem. So the sample
input is
F 1 1 D
I 5 3
I 10 1
H 2 6 1 M
V 2 1 1 G
F 4 1 P
K 5 1 6 1 D
F 8 1 W
H 9 4 1 G
L 3 1 J
S d.bmp
X
My code gives the following answer:
WGJGGGGGGW
While the answer given by some guy whose code has been accepted by the
system is:
OGJGGGGGGW
I manually went through the commands step by step and the result I got is
the same as my code gave me. Can someone tell me what is wrong here? I
keep getting Wrong Answer. Thanks in advance!
My code:
#include <iostream>
#include <set>
#include <sstream>
using namespace std;
int main() {
char product[250][250];
for(int j = 0; j < 250; j++) {
for(int i = 0; i < 250; i++) {
product[j][i] = 'O';
}
}
while(true) {
string line;
getline(cin, line);
istringstream in (line.c_str());
char cmd;
// int[y][x] corresponds to (x, y) (m, n)
int m, n;
in >> cmd;
switch (cmd) {
int x, y, x1, x2, y1, y2;
char color;
case 'X': {
return 0;
}
case 'I':{
in >> m >> n;
for(int j = 0; j < n; j++) {
for(int i = 0; i < m; i++) {
product[j][i] = 'O';
}
}
break;
}
case 'C': {
for(int j = 0; j < n; j++) {
for(int i = 0; i < m; i++) {
product[j][i] = 'O';
}
}
break;
}
case 'L': {
in >> x >> y >> color;
if(y <= n && x <= m)
product[y-1][x-1] = color;
break;
}
case 'V': {
in >> x >> y1 >> y2 >> color;
if(y2 < y1) {
int temp = y1;
y1 = y2;
y2 = temp;
}
if(x <= m) {
for(int j = y1-1; j < y2 && j < n; j++)
product[j][x-1] = color;
}
break;
}
case 'H': {
in >> x1 >> x2 >> y >> color;
if(x2 < x1) {
int temp = x1;
x1 = x2;
x2 = temp;
}
if(y <= n) {
for(int i = x1-1; i < x2 && i < m; i++)
product[y-1][i] = color;
}
break;
}
case 'K': {
in >> x1 >> y1 >> x2 >> y2 >> color;
if(y2 < y1) {
int temp = y1;
y1 = y2;
y2 = temp;
}
if(x2 < x1) {
int temp = x1;
x1 = x2;
x2 = temp;
}
for(int j = y1-1; j < y2 && j < n; j++) {
for(int i = x1-1; i < x2 && i < m; i++)
product[j][i] = color;
}
break;
}
case 'F': {
in >> x >> y >> color;
if(x <= m && y <= n) {
set<int> row;
row.insert(y);
set<int> col;
col.insert(x);
int roworigsize, colorigsize;
char currentcolor = product[y-1][x-1];
do {
roworigsize = row.size();
colorigsize = col.size();
for(set<int>::iterator itr = row.begin(); itr != row.end(); ++itr) {
int currentrow = *itr;
for(int i = 0; i < m; i++) {
if(product[currentrow-1][i] == currentcolor)
col.insert(i+1);
}
}
for(set<int>::iterator itr = col.begin(); itr != col.end(); ++itr) {
int currentcol = *itr;
for(int j = 0; j < n; j++) {
if(product[j][currentcol - 1] == currentcolor)
row.insert(j+1);
}
}
} while (roworigsize != row.size() || colorigsize != col.size());
for(int j = 0; j < n; j++) {
for(int i = 0; i < m; i++) {
if(row.count(j+1) != 0 || col.count(i+1) != 0) {
if(product[j][i] == currentcolor)
product[j][i] = color;
}
}
}
break;
}
}
case 'S':{
string name;
in >> name;
cout << name << endl;
for(int j = 0; j < n; j++) {
for(int i = 0; i < m; i++) {
cout << product[j][i];
}
cout << endl;
}
break;
}
}
}
return 0;
}

Need help searching an array... very hard for me

Need help searching an array... very hard for me

Got a small problem. I don't know how to search one array so I can pull
that same array number from the other 2 arrays. I know how to test for a
lot of stuff so that won't be a problem.
The end result on this project is the user will place the amount they are
willing to pay for a make of the car and the page will display the data.
HOWEVER I don't know how to search the carArray() to find the index number
and use that index number to find the other stuff. I did find something
that did this (somewhat) earlier but I don't know how to modify it for me
to keep that index number as a int and use it to search and display the
other arrays.
I will need this in future projects later.
Public Class paymentPage
Private Sub car_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles car.TextChanged
End Sub
Private Sub price_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles price.TextChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim carArray() As String = {"Ford", "Chevy", "Mazda"}
Dim sellAmount() As Decimal = {32700, 35625, 24780}
Dim leaseAmount() As Decimal = {425, 505, 385}
End Sub
End Class

My App crashes when I entered nothing on edittext. What's missing in code?

My App crashes when I entered nothing on edittext. What's missing in code?

I have a problem here. I have here 2 edittext. One for amount and one for
password. My app works like a charm except when I entered NONE on the
edittexts, IT CRASHES (Unfortunately stop). Am I missing any code on my
activity? Please help. Here's my code.
public class MainActivity extends Activity {
Button REDIRECT;
private EditText txtbox1,txtbox2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
REDIRECT = (Button) findViewById(R.id.button1);
txtbox1= (EditText) findViewById(R.id.editText1);
txtbox2= (EditText) findViewById(R.id.editText2);
REDIRECT.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int Amount = Integer.parseInt(txtbox1.getText().toString());
String Password = txtbox2.getText().toString();
if(Amount<=50&&Amount>=1 & Password.equals("TUBOL"))
{
final Intent i = new Intent(MainActivity.this,
Redirect.class);
startActivity(i);
}
else
{
Toast.makeText(MainActivity.this, "INVALID",
Toast.LENGTH_LONG).show();
}
}
});
}

How to compile doT.js partials from a file into a string?

How to compile doT.js partials from a file into a string?

Hi I'm new to node and I'm trying to figure out how to compile partials
from a file into a string using doT.js
(http://olado.github.io/doT/index.html).
I have the following code:
var util = require( 'util' ),
fs = require( 'fs' );
function System( ) {
this.name = 'system';
}
System.prototype._loadFile = function( path ) {
return fs.readFileSync( process.argv[ 1 ].replace( /\/[^\/]*$/, path ) );
};
System.prototype._getHeaderContent = function( ) {
return this._loadFile( '/controllers/system/views/header.html' );
};
System.prototype._getBodyContent = function( ) {
return this._loadFile( '/controllers/system/views/main.html' );
};
System.prototype._getFooterContent = function( ) {
return this._loadFile( '/controllers/system/views/footer.html' );
};
System.prototype.index = function( req, res, next ) {
res.render( __dirname + '/../system/views/template', {
name: this.name,
header: this._getHeaderContent( ),
body: this._getBodyContent( ),
footer: this._getFooterContent( )
});
next ? next( ): '';
};
module.exports = System;
/system/views/template.html:
{{=it.header}}
{{=it.body}}
{{=it.footer}}
/system/views/header.html:
<!doctype html>
<html lang="en">
<head>
<title>app | {{=it.name}}</title>
</head>
<body>
In System.index when I call res.render template.html is being compiled but
header.html is not. From that I assume render doesn't recursively render
files and I need to manually compile header.html before I pass it in to
res.render.
I found this tutorial: http://olado.github.io/doT/tutorial.html#compile
but both .template and .compile return functions? Attempting to pass them
in to res.render throws an error.
How do I compile them into strings? Or am I going about this the wrong way?
Thanks!

External Style Sheet does not work with `h1` in XAMPP

External Style Sheet does not work with `h1` in XAMPP

I am trying to make a navigation bar in a separate file, so that I may
include it with php later. The file, nav_menu.php, contains a h1 tag, a p
tag, and an ul containing a tags.I made the CSS in an External Style
Sheet. I styled all the elements. The h1 tag didn't work. Why?
nav_menu.php:
<html>
<head>
<link rel="stylesheet" type="text/css" href="nav_menu.css">
</head>
<body>
<h1 title="School Helping Program">------ S.H.P. ------</h1>
<p title="S.H.P.">School Helping Program</p>
<ul>
<li><a href="home.php">home</a></li>
<li><a href="marks.php">marks</a></li>
<li><a onclick="logout()">log out</a></li>
</ul>
</body>
</html>
nav_menu.css:
<style>
h1{text-align:center;color:#CC0000;}/*Here's the prolbem*/
p{font-style:italic;text-align:center;}
li{float:left;}
ul{list-style-type:none;margin:0;padding:0;}
a{
display:block;
width:180px;
text-align:center;
background-color:#5CB8E6;
text-transform:uppercase;
color:#CC0000;
text-decoration:none;
padding:10px 135px;
cursor: pointer;
}

How to capture Flash rendering in C#?

How to capture Flash rendering in C#?

Is there a way to screen capture a movie rendered by Flash Player in
Internet Explorer?
Can I get a Device Context for Flash Player ActiveX and capture it?

Friday, 13 September 2013

Matrix solution with Numpy: no solution?

Matrix solution with Numpy: no solution?

Ran a simple script in Numpy to solve a system of 3 equations:
from numpy import *
a = matrix('1 4 1; 4 13 7; 7 22 13')
b = matrix('0;0;1')
print linalg.solve(a,b)
But when I ran it through the command prompt, I somehow got:
[[ 3.46430741e+15]
[ -6.92861481e+14]
[ -6.92861481e+14]]
although Wolfram Alpha says there's no solution.
Does anyone know why there seems to be this difference between the
Numpy/WRA answers?

ADB commands not executing through Java program

ADB commands not executing through Java program

I've searched through google and on this site to similar questions, but
none of their answers yielded any results for me.
I am currently creating a small tool to help me test some Android
applications. I want to be able to load APK(s), clear app data, etc (with
a GUI!), which are mostly 1-line adb commands or small shell scripts. I
can use the commands and shell scripts via the terminal just fine,
however, when I start using the commands in my Java program, I get the
following error:
java.io.IOException: Cannot run program "adb": java.io.IOException:
error=2, No such file or directory
from this line of code:
Runtime.getRuntime().run.exec("adb shell pm clear " +
selectedApp.getPackage());
I have a co-worker who is writing something similar, and uses this exact
line in his code successfully.
A few things to note:
I have already installed the 32bit lib.
I am not even sure that using this .exec() method is the way to go.
Your help is greatly appreciated! I'd like to be done with this by the end
of the weekend so I can use it at work on Monday.
Thanks, Chryis

Apple iPhone 5S navigation - how is it done?

Apple iPhone 5S navigation - how is it done?

Apples iPhone 5S micro site is awesome (http://www.apple.com/uk/iphone-5s/).
I want to do the same with the navigation element of the page, ie if a
user uses their mouse scroll it takes them to the next section instead of
free scrolling. As well as the right hand side navigation (the dots).
I've seen this done a few times recently, what is the libraries / plug-ins
that are used (as its very samey as other sites I'm presuming this isn't
custom code).
Any tips or pointers will be appreciated.
Cheers
Carl

Credit card check exercise python

Credit card check exercise python

for an online free online Pyhton tutorial I need to:
to write a function which checks if a given credit card number is valid.
The function check(S) should take a string S as input. First, if the
string does not follow the format "#### #### #### ####" where each # is a
digit, then it should return False. Then, if the sum of the digits is
divisible by 10 (a "checksum" method), then the procedure should return
True, else it should return False. For example, if S is the string "9384
3495 3297 0123" then although the format is correct, the digit sum is 72
so you should return False.
The following shows what I have come up with. I think my logic is correct
but don't quite understand why it is giving me the wrong value. Is there a
structural issue in my code, or am I using a method incorrectly?
def check(S):
if len(S) != 19 and S[4] != '' and S[9] != '' and S[14] != '':
return False # checking if the format is correct
S = S.replace(" ",'') # Taking away spaces in the string
if not S.isdigit():
return False # checking that the string has only numbers
L = []
for i in S:
i = int(i) # Making a list out of the string and
converting each character to an integer so that it the list can be
summed
L.append(i)
if sum(L)//10 != 0: # checking to see if the sum of the list
is divisible by 10
return False

SignalR - How to PUSH data from one page to second page?

SignalR - How to PUSH data from one page to second page?

I am completely new to SignalR and need to develop a web application.
My Scenario-
I have two aspx page. 1) ActionPage.aspx 2) DispalyPage.aspx
Inside the DispalyPage.aspx, I have one div 'displayDiv'
Inside the ActionPage.aspx, I have one button 'btnaction'
If I click on btnaction(ActionPage.aspx), that time I want to PUSH data in
displayDiv (DispalyPage.aspx).
Question- Is it possible that data PUSH from one page to second page?
Any hint on this would be great help. Thanks in advance.

Thursday, 12 September 2013

Convert RGB to black OR white

Convert RGB to black OR white

How would I take an RGB image in Python and convert it to black OR white?
Not black AND white, I want each pixel to be either fully black (0, 0, 0)
or fully white (255, 255, 255).
Is there any built-in functionality for this in the popular Python image
processing libraries? If not, would the best way be just to loop through
each pixel, see if it's closer to white or black, and if it's closer to
white set it to white, if it's closer to black set it to black?

watir-webdriver error using chrome browser

watir-webdriver error using chrome browser

I am using watir-webdriver and are getting this error message when opening
a chrome browser:
C:\chromeDriver>irb
DL is deprecated, please use Fiddle
irb(main):001:0> require "watir-webdriver"
=> true
irb(main):002:0> a = Watir::Browser.new (:chrome)
Started ChromeDriver
port=9515
version=0.8
log=C:\chromeDriver\chromedriver.log
Selenium::WebDriver::Error::UnknownError: unknown error: unrecognized
chrome option:
detach
(Driver info: chromedriver=0.8,platform=Windows NT 6.2 x86_64)
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/response.rb:51:in
`assert_ok'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/response.rb:15:in
`initialize'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/common.rb:59:in
`new'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/common.rb:59:in
`create_response'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/default.rb:66:in
`request'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/common.rb:40:in
`call'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:629:in
`raw_execute'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:98:in
`create_session'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:68:in
`initialize'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/chrome/bridge.rb:29:in
`initialize'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/common/driver.rb:37:in
`new'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/common/driver.rb:37:in
`for'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver.rb:67:in
`for'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/watir-webdriver-0.6.4/lib/watir-webd
river/browser.rb:46:in `initialize'
from (irb):2:in `new'
from (irb):2
Environment:
Windows 8
Ruby version = ruby 2.0.0p247 (2013-06-27) [i386-mingw32]