Saturday, 31 August 2013

Table alias scope in informix SQL

Table alias scope in informix SQL

In the following example SQL
select * from (
select col
from myTable mt
inner join anotherMyTable amt on mt.id = amt.id
) as t
where
exists (select amt.colX from anotherMyTable amt where amt.id = 42)
The 'amt' alias is defined in two places. Is it correct to declare the
second table alias with the same name as the first or I should use another
name (amt2) ?
In this example I assume that both aliases are located in different scopes
so it's okay to use the same name. I use Informix DBMS.
p.s. it's an example SQL, the question is only about table alias scope.

Mysql subquery sum of votes

Mysql subquery sum of votes

I've got a table of votes, alongside a table of 'ideas' (entries)
Basically, I want to retrieve an object that can be read as:
id,
name,
title,
votes : {
up : x,
down : y
}
So it's simple enough until I get to the subquery and need to do two sets
of SUMs on the positive and negative values of votes.
SELECT id,name,title FROM ideas
LEFT JOIN votes ON ideas.id = votes.idea_id
My (simplified) votes table looks something like:
id
idea_id
value
Where value can be either a positive or negative int.
How would I go about getting the above object in a single query?
Bonus point: How would I also get an aggregate field, where positive and
negative votes are added together?

Intersecting two dictionaries in Python

Intersecting two dictionaries in Python

I am working on a search program over an inverted index. The index itself
is a dictionary whose keys are terms and whose values are themselves
dictionaries of short documents, with ID numbers as keys and their text
content as values.
To perform an 'AND' search for two terms, I thus need to intersect their
postings lists (dictionaries). What is a clear (not necessarily overly
clever) way to do this in Python? I started out by trying it the long way
with iter:
p1 = index[term1]
p2 = index[term2]
i1 = iter(p1)
i2 = iter(p2)
while ... # not sure of the 'iter != end 'syntax in this case
...

This jQuery code won't work. Beginner Here.

This jQuery code won't work. Beginner Here.

Just started practicing with jQuery, but I can't seem to get any of the
functions to work. This code below is an exercise I've been trying to run,
but it won't output the desired result. Does anyone know why? Thanks.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="EN" dir="ltr" xmlns="http://www/w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type"
content="text/xml; charset=utf-8" />
<title>change2.html</title>
<script type = "text/javascript"
src = "jquery-1.4.2.min.js">
</script>
<script type = "text/javascript">
//<![CDATA[
$(document).ready(changeMe);
function changeMe(){
$("#output").html("I've changed");
}
//]]>
</script>
</head>
<body>
<h1>Using the document.ready mechanism</h1>
<div id = "output">
Did this change?
</div>
</body>
</html>

Permission denied (publickey) when SSH Access to Amazon EC2 instance

Permission denied (publickey) when SSH Access to Amazon EC2 instance

Hi I want to use my Amazon ec2 instancce but faced error
Permission denied (publickey).
I have create my key pair and download "pem" file.
Give
chmod 600 pem file.
Then this command
ssh -i /home/kashif/serverkey.pem
ubuntu@ec2-54-227-242-179.compute-1.amazonaws.com
But have this error.
Permission denied (publickey)
Any help please?
Also how can i connect with filezilla to upload/download files.
Many Many Thanks.

Backbone: Scroll event not firing after back button is pressed

Backbone: Scroll event not firing after back button is pressed

I'm using the following function to change the primary view of my Backbone
application:
changeView: function(view, options) {
if (this.contentView) {
this.contentView.undelegateEvents();
this.contentView.stopListening();
this.contentView = null;
}
this.contentView = view;
if (!options || (options && !options.noScroll)) {
$(document).scrollTop(0);
}
this.contentView.render();
},
As you can see, I'm resetting the scroll position every time the primary
view changes (so that the user doesn't land on the middle of a view after
scrolling down on the previous view). However, when the user presses the
back button, the scroll event isn't firing at all if you try to scroll
down. If you try to scroll up, however, then the scroll positions seems to
get reset to a position further down the page, after which scrolling works
normally.
Any ideas on what the cause might be?

is it compulsory to make @repository and Interface in spring mvc

is it compulsory to make @repository and Interface in spring mvc

I am using Spring MVC + Hibernate.
@Serice
@Service("PersistenceTemplate")
@Transactional(readOnly = false, rollbackFor = Exception.class)
public class PersistenceTemplate {
@Resource(name = "sessionFactory")
private SessionFactory sessionFactory;
protected Logger logger = Logger.getLogger(PersistenceTemplate.class
.getName());
public PersistenceTemplate() {
super();
}
// save
public <T> long save(T entity) throws DataAccessException {
Session session = sessionFactory.getCurrentSession();
long getGenVal = (Long) session.save(entity);
return getGenVal;
}
}
@Controller
@Resource(name = "PersistenceTemplate")
private PersistenceTemplate pt;
pt.save(entityFoo);
My Project is running well. But is it compulsory to make @repository Class
and Interface for implementation like following, which is alternative to
above
Interface
public interface IOperations{
<T> long save(final T e);
}
@repository
@Repository
public class PersistenceTemplate implements IOperations {
@Resource(name = "sessionFactory")
private SessionFactory sessionFactory;
protected Logger logger = Logger.getLogger(PersistenceTemplate.class
.getName());
public PersistenceTemplate() {
super();
}
// saveE
public <T> long save(T entity) throws DataAccessException {
Session session = sessionFactory.getCurrentSession();
long getGenVal = (Long) session.save(entity);
return getGenVal;
}
Service
@Service("serviceLayer")
public class ServiceLayer {
@Autowired
IOperations op = null;
public ServiceLayer() {
super();
}
@Transactional(readOnly = false, rollbackFor = Exception.class)
public <T> long save(T e) {
op.save(e);
return 0;
}
}
Now I think interface is no matter for spring mvc because it manage proxy
by default if no found!
which implementation will u prefer either with @repository and interface
or without @repository and interface.

Nginx : Proxy everything to s3 ( Error in configuration )?

Nginx : Proxy everything to s3 ( Error in configuration )?

I want to serve all my files from S3 except a few. Here is my config :
server_name website.com;
# DNS
resolver 8.8.8.8;
# Variables
set $s3 "https://s3.amazonaws.com/my_bucket";
location / {
proxy_pass $s3;
}
location ~* ^/others/*.php$ {
root /var/abc/
}
Now,
I am able to visit http://website.com/others/index.php [ OK ]
I have already applied s3 policy to allow GET Object. [ S3 Permission added ]
I am able to visit https://s3.amazonaws.com/my_bucket/file.jpg and see my
image. [ OK ]
But, getting 403 access-denied from http://website.com/file.jpg
What am I doing wrong ?

Friday, 30 August 2013

query/shred large xml document into sql server

query/shred large xml document into sql server

I'm looking to query an xml file that's in excess of 80GB (and insert the
results into a pre-existing db). This prevents me from simply declaring it
as an xml variable and using openrowset. I am NOT looking to use a CLR and
would prefer an entirely TSQL approach if possible (looking to do this on
SQL Server 2012/Windows Server 2008)
With the 2Gb limit on the XML datatype, I realize the obvious approach is
to split the file into say 1GB pieces. However, it would simply be too
messy to be worthwhile (Elements in the document are of varying sizes and
not all elements have the same sub-elements. Only looking to keep some
common elements though).
Anyone have a suggestion?

how to get list of user defined tables in the specific database in sybase

how to get list of user defined tables in the specific database in sybase

I need to list the name of all tables in the specific database in sybase
and then filter these table name according some string in the name.
this gives current database but i cant specify specific database
select name from sysobjects where type = 'U'
this gives more than tables, it includes trigger and stored procedure
Select name from sysobjects
WHERE db_name()='pad_orr_db'
does any body know how to do it and also filter the name of tables by some
string in the name for example only the table with the SASSA in the name
be displayed?
thanks in advanced

Thursday, 29 August 2013

WCF service fails to call another WCF service on same machine

WCF service fails to call another WCF service on same machine

I have a website hosted in IIS7 in server A. The website calls a web
service that is also hosted in server A, but the call returns an error
401. I tried referencing to the web service by IP address, host
(A.domain.com), and fully qualified dsn. None worked.
After some research, I found out about the loopback check, and the
BackConnectionHostNames.
Refer to this article
Disabling the loopback check fixes the problem, but is not a desirable
solution.
For the BackConnectionHostNames, I tried adding:
A
A.domain.com
A.full.domain.com
But it didn't work.
I played some with IIS http bindings for the website, I tried adding
A.domain.com to the host name, and I also tried setting the IP, but still
got the same error.
Am I missing something? (I clearly am...) Where else should I be looking at?
Any help appreciated. Thanks

font-family not showing in IE8

font-family not showing in IE8

I'm just trying to add a regular font-family to my website, but IE8 won't
display it. It just displays its default Times New Roman. This is my CSS:
body {
font-family: Arial, Helvetica, sans-serif;
}
This appears fine on IE7, 9 and obviously Chrome and Firefox but I'm not
sure why IE8 is having issues?
My doctype is:
<!DOCTYPE HTML>
I'm really stuck on this. It's such a simple thing, I'm not sure why IE8
is not liking it. Any help would be very much appreciated.
Thanks, Julie

custom font Flicks due to iframe in IE

custom font Flicks due to iframe in IE

I have used Custom Font. Header text font flickers when container loads
which is a iframe. Flickering is inconsistent on Internet Explorer(IE7)
only. Please help me.

Wednesday, 28 August 2013

Download to root directory

Download to root directory

Okay, so I have been searching for ages to find this but no luck.
I am using:
Me.downloader.DownloadFileAsync(New Uri(fileUrl),
Path.GetFileName(fileUrl), Stopwatch.StartNew)
To download a file but I want it to save to the root directory of my
program in a file called launcher.
So for example, if my program is on the desktop and I open it and click
start I want it to create the launcher folder if it's missing then
download the files into that and if it's not then just download the files
into it.
I've been looking everywhere to find code which would allow me to do this
and I have tried lots of different things.
At the moment, it justs saves in the root directory of where the program is.
Thanks.

How to find the class name within a method

How to find the class name within a method

How can we get the name of the class inside a method in Groovy? For
example, given a class definition like below
class Foo {
def bar() {
// def className = <some magic>
// println className
}
}
the class name will be printed out with
new Foo().bar()

macro for copy and paste data by matching one cell

macro for copy and paste data by matching one cell

I'm a bit stumped with this and wondered if anyone could help please? i
wants to put data in main excel sheet that should be paste to other sheets
by matching only one cell.in picture sheet 1 is main sheet and sheet 2 is
sub sheet, in sheet 2 the yellow highlighted cells are those which i wants
to extract from sheet 1 by matching only 1 cell which is highlighted in
red color. Urgent reply will be appreciated.![enter image description
here][1]

How to provide alignment to chunk or phrases in itext?

How to provide alignment to chunk or phrases in itext?

In my case, i have two chunks,added in phrases and and then in paragraph.
following are the my loc.
Chunk reportTitle= new Chunk("Candidate Login Report ",catFont);
Chunk divisiontitle = new Chunk("Division : \t\t"+divisionName);
Phrase phrase = new Phrase();
phrase.add(reportTitle);
phrase.add(divisiontitle);
Paragraph para = new Paragraph();
para.add(phrase);
i have to set chunk divisiontitle to right aligned.is there any provision
to do this in itext.if it possible let me know the solution.Thanx in
advance.

Getting global Javascrip variable in another Javascrip file

Getting global Javascrip variable in another Javascrip file

Lets say I have a variable:
<script type="text/javascript">
var myVariable = "something";
</script>
After this js global variable declaration I have another javascript:
<script type="text/javascript" src="myScriptFile.js"></script>
In this file I need to use the value of my global myVariable variable. I
know that I can do it by setting this value in some HTML, then using DOM
or jQuery or something else get this value in the file, but I want to
avoid creating those kind of hidden fields in my HTML. Is there any better
way to do this?

Tuesday, 27 August 2013

Background image wont appear in E10

Background image wont appear in E10

My background image in my CCS style sheet will not appear in
E10/safari/firefox/chrome but will appear in EI 8 and lower. Just
wondering is the HTML code needs to updated or I need to add something to
this..
Below is the HTML code I have been using..
body {
background-image: url("https://linktographicetc.jpg");
background-position: center top;
background-repeat: no-repeat;
background-color:#DAE4E5;

Direct Oracle Access cuts off the end of unicode (wide) strings

Direct Oracle Access cuts off the end of unicode (wide) strings

I am encountering a problem with unicode (wide) string field in Delphi XE2
is not returning last part of string and any database control component
also is not showing whole string completely to the end.
You can see the simple test below.
with TOracleDataSet.Create(self) do
try
Session := OraSession;
SQL.Text := 'CREATE TABLE test1 (fsString10 VARCHAR2(10))');
ExecSQL;
SQL.Text := 'INSERT INTO test1 (fsString10) VALUES ('1234567890')');
ExecSQL;
SQL.Text := 'INSERT INTO test1 (fsString10) VALUES ('é234567890')');
ExecSQL;
SQL.Text := 'INSERT INTO test1 (fsString10) VALUES ('éöóêåíãøùç')');
ExecSQL;
SQL.Text := 'SELECT fsString10 FROM test1';
Open;
while not Eof do
ShowMessage(FieldByName('fsString10').AsString);
// '1234567890' turned into '1234567890'
// 'é234567890' turned into 'é23456789'
// 'éöóêåíãøùç' turned into 'éöóêå'
SQL.Text := 'DROP TABLE test1');
ExecSQL;
finally
Free;
end;
As you can see unicode strings is not properly loaded.
On the other hand the "Direct Oracle Access 4.1.3" component didn't save
chars in the string after half one on post record. Anyway it saves only
first half-string.
Is there a way to fix it?
BytesPerCharacter is set to bcAutoDetect.
I have tried toggling NoUnicodeSupport and all other options with no luck.
Does anyone have any ideas on how to fix this?

Parsing XML with Python ignoring parts

Parsing XML with Python ignoring parts

I'm having difficulty parsing a particular style of XML.
The XML file looks like:
<channels>
<genre type = blah1>
<channel name="Channel 1">
<show>
<title>hello</title>
</show>
</channel>
<channel name="Channel 2">
<show>
<title>hello</title>
</show>
</channel>
</genre>
<genre type="blah2">
<channel name="Channel 3">
<show>
<title>hello</title>
</show>
</channel>
</genre>
<channels>
So my problem is as follows:
channelList = rootElem.find(".//channel[@name]")
howManyChannels = len(channelList)
for x in range(1, howManyChannels):
print x
print rootElem.find(".//channel[@name]["+str(x)+"]").get('name')
for y in rootElem.find(".//channel[@name]["+str(x)+"]"):
print y.findtext('title')
This gets to Channel 2 and then errors with:
Traceback (most recent call last):
File "parse.py", line 17, in <module>
print rootElem.find(".//channel[@name]["+str(x)+"]").get('name')
AttributeError: 'NoneType' object has no attribute 'get'
Why doesn't the code:
for y in rootElem.find(".//channel[@name]["+str(x)+"]"):
include the 3rd channel, why is it being isolated as it is in another
genre tab? How do I change the code to accommodate for this?
Thanks

Is there a way to host my asp.net page through visual studio 2013 (globally)?

Is there a way to host my asp.net page through visual studio 2013 (globally)?

I'm working on a www page that is gonna communicate with outside server (I
need outside service for payment purposes).
I would like to test messages my page is gonna receive from outside
server, but I'm not sure how to do it. I can of course run my page in
debugging mode using VS 2013 and set up a breakpoint somewhere, but I
don't know how to make my page visible on the internet. It is visible on
my pc, but I'd like to make it visbie globally. Is that even possible
using visual studio? Is there an easy way to accomplish what I need?
Thanks.

Connect and read data from third-party site

Connect and read data from third-party site

It's a little bit hard to explain it but I'll try. I want to make an app
that connects to a third-party website, that displays some data. I HAVE NO
access to that site and I have NO idea how this site works.
The only thing I know is that it requires a username and a password to
connect to the site and then it displays some data.
My question is how to "read" that data (and how to connect to that site),
if it's possible.
I'm just asking generally, some tip or tutorial will be great.
Thank you.

how to loop through each node of HTML using HTMLAgilitypack?

how to loop through each node of HTML using HTMLAgilitypack?

I need to identify each node and compare if it contains certain text..
Need to loop through following html using HTMLAgilityPack,
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><META content="IE=5.0000" http-equiv="X-UA-Compatible">
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
</HEAD>
<BODY bgcolor="white"><text><TITLE>ABCD</TITLE>
<P style="page-break-before: always;">
<HR width="100%" size="3" align="CENTER" style="color: rgb(153, 153, 153);">
<fieldset>
<legend>Personalia:</legend>
Name: <input type="text"><br>
Email: <input type="text"><br>
Date of birth: <input type="text">
</fieldset>
<P style="margin-top: 0px; margin-bottom: 0px;"><FONT
size="1">&nbsp;</FONT></P>
<P align="center" style="margin-top: 0px; margin-bottom: 0px;"><FONT size="2"
style="font-family: Times New Roman;">B-17 </FONT></P></text>
</BODY></HTML>

Android graphics user interaction ie. balloon popper

Android graphics user interaction ie. balloon popper

I'm more wondering how to go about implementing my very simple game.
For anyone who has played Angry Birds Star Wars, you know that on the
screen where you select the stage, you can tap on the piggies in the
background, and they will explode.
My daughter likes to tap on these piggies more than actually playing the
game... so I thought it'd be fun to write a simple app that displays
bouncing pigs on the screen for her to tap and explode. I know such apps
already exist, but I also wanted to expand my own programming experience.
So I think I have an idea on how to implement tapping on static graphical
elements. You could simply keep track of the xy coordinates of where the
picture is, and as long as the user taps somewhere in the vicinity, it'll
trigger the picture to be replaced by an explosion animation. Or something
like that.
But how about moving graphics? I've found tutorials that teach how to
write a bouncing ball thread on a canvas. For my idea, should each
bouncing ball (piggy) have it's own thread?
Or should I take it a step further, and try using OpenGL instead of just
the android Canvas function?
What would you guys suggest?
-Mercy

Monday, 26 August 2013

How to unbind from active directory while preserving a user account?

How to unbind from active directory while preserving a user account?

My account is associated with an active directory of a previous company i
was working at.
What is the best way to unbind my account from the AD without losing my
files?
The account is admin/managed and mobile.

Why this boost::signals2 template class doesn't work?

Why this boost::signals2 template class doesn't work?

Here is the code:
#ifndef EVENTSYSTEM_HPP
#define EVENTSYSTEM_HPP
#include <boost/signals2.hpp>
#include <boost/bind.hpp>
using namespace boost;
using namespace boost::signals2;
template<class T>
class EventMain
{
public:
//typedef void (*_func)(T);
template <typename Slot>
void connect( Slot func, T interface ) { _signal.connect( bind( func,
interface ) ); }
void emitSignal( T data ) { _signal(data); }
private:
signal<void (T)> _signal;
};

Error in git install from source on Ubuntu

Error in git install from source on Ubuntu

I had git previously installed using ubuntu apt-get installed. Recently
uninstalled it and installed git from source to get version 1.8.4 .
However now whenever I open a new termial on Ubuntu, I get the following
error:
-bash: /usr/lib/git-core/git-sh-prompt: No such file or directory
I have tried to search various bash start files like .bashrc ,
.bash_profile or .profile, but can't find any reference to any git based
setup.
How can I remove this error. I do not have /usr/lib/git_core folder, but
do have /usr/libexec/git-core folder.

Adding Form to Tabs in LWUIT

Adding Form to Tabs in LWUIT

Is it possible to add Form to Tabs Class in LWUIT ?? As per the API tabs
contain method to add only component. If yes please provide a sample code
how to add it..
Will it be like - new Tabs.addTab("Title", form.show()) or how it is ??

Removing from middle of the linked list c++

Removing from middle of the linked list c++

i have a problem with my RemoveMid function in my linked list.. the code
seems ok and there's no syntax error, but when i call this function, the
program stops working.. i think there's something wrong with the logic of
the function. i hope you may help me to correct it. this is the
implementation of the RemoveMid function
template<typename T>
bool LinkedList<T>::RemoveMid(T& target)
{
Node<T> *current = new Node<T>;
bool found = false;
current = start;
while(current != NULL && !found)
{
if(current->next->info == target)
found = true;
if(!found)
current = current->next;
}
if(found)
{
Node<T> *Ptr;
Ptr = current->next;
current = current->next;
delete Ptr;
return true;
}
else
cout<<"target not found\n";
}

increment width from right to left

increment width from right to left

in html, i want to increment the width from right to left.
<div dir="rtl" id="progress">
<dt id='dt'></dt>
<dd id='dd'></dd>
</div>
the main goal is to make this progress bar moves from right to left when i
use Arabic language in my website (default direction of Arabic language is
from right to left)
i tried the attribute dir as i wrote , but it didn't fix the problem.
I have an idea, but it will change the html, but that's not the correct
thing to do, because my website supports English & Arabic, and i don't
want to change the html, i just want to change the style, or a javascript
code.

Dummy questions about setting up git on amazon cloud ec2

Dummy questions about setting up git on amazon cloud ec2

first of all, apologize for dummy questions that I might throw here. It
would be nice if you could point the directions where should I go from
here.
I'm totally new to version control(as well as git) and cloud system.
However, it came to the point that I have to develop php web based
application on AWS EC2 instance and make codes contributable for future
developers.
I did successfully create EC2 instance that run PHP/MySQL and map the
domain with Elastic IP. So the website is now publicly accessible via port
80.
I also installed git using $sudo yum install git and configed user.name
and user.email
I then, go to root folder of the website (e.g. public_html) and run 'git
init' which create the fold ".git" and I then add file using "git add ."
and commit "git commit -m 'initial upload'"
Is that the right way to go? Would it be ok to have the project folder
sitting on /public_html (where accessible from anyone).
If above is ok, then where should I go from here? I would like to have git
server running on EC2 that allow developers to connect from their local
machines (e.g. Eclipse) while being able to keep the backup and compare
the different between codes.
What detail do I suppose to give developers so that they can connect to
git server and working on project?
I quick direction or few keywords to do more research would help.

Sunday, 25 August 2013

Issues with OpenGL referencing when compiling in Ubuntu terminal

Issues with OpenGL referencing when compiling in Ubuntu terminal

I am working on compiling a directory of c++ files and headers. I thought
that I installed openGL, Glut and Glew properly but I keep getting
referencing errors when running it. I am not sure what I need to do and
would really appreciate help on this. Here is what I am doing and the
errors that the compiler is sending back to me:
user@Linux-machine:~/Documents/HW$ make
g++ -g framework.o poly_line.o shader_program.o circle.o controller.o
main.o scene.o view.o -lGLEW -lglut -lGLU -o HW
framework.cpp:84: error: undefined reference to 'glGetError'
check_gl.h:30: error: undefined reference to 'glGetError'
check_gl.h:43: error: undefined reference to 'glGetError'
poly_line.cpp:23: error: undefined reference to 'glGenBuffers'
poly_line.cpp:28: error: undefined reference to 'glBindBuffer'
poly_line.cpp:29: error: undefined reference to 'glBufferData'
poly_line.cpp:54: error: undefined reference to 'glEnable'
poly_line.cpp:55: error: undefined reference to 'glEnable'
poly_line.cpp:56: error: undefined reference to 'glBlendFunc'
poly_line.cpp:57: error: undefined reference to 'glHint'
poly_line.cpp:59: error: undefined reference to 'glDisable'
poly_line.cpp:60: error: undefined reference to 'glDisable'
poly_line.cpp:68: error: undefined reference to 'glBindBuffer'
poly_line.cpp:69: error: undefined reference to 'glEnableVertexAttribArray'
poly_line.cpp:70: error: undefined reference to 'glVertexAttribPointer'
poly_line.cpp:78: error: undefined reference to 'glDrawArrays'
poly_line.cpp:80: error: undefined reference to 'glDrawArrays'
shader_program.cpp:104: error: undefined reference to 'glCreateProgram'
shader_program.cpp:113: error: undefined reference to 'glGetProgramiv'
shader_program.cpp:115: error: undefined reference to 'glGetProgramiv'
shader_program.cpp:120: error: undefined reference to 'glGetProgramInfoLog'
shader_program.cpp:135: error: undefined reference to 'glGetShaderiv'
shader_program.cpp:137: error: undefined reference to 'glGetShaderiv'
shader_program.cpp:142: error: undefined reference to 'glGetShaderInfoLog'
shader_program.cpp:155: error: undefined reference to 'glDeleteShader'
shader_program.cpp:163: error: undefined reference to 'glDeleteShader'
shader_program.cpp:185: error: undefined reference to 'glCreateShader'
shader_program.cpp:195: error: undefined reference to 'glShaderSource'
shader_program.cpp:200: error: undefined reference to 'glCompileShader'
shader_program.cpp:214: error: undefined reference to 'glAttachShader'
shader_program.cpp:219: error: undefined reference to 'glLinkProgram'
shader_program.cpp:238: error: undefined reference to 'glUseProgram'
shader_program.cpp:249: error: undefined reference to 'glUniform1f'
shader_program.cpp:257: error: undefined reference to 'glUniform1i'
shader_program.cpp:270: error: undefined reference to 'glGetUniformLocation'
shader_program.cpp:290: error: undefined reference to 'glUseProgram'
shader_program.cpp:304: error: undefined reference to 'glGetProgramiv'
shader_program.cpp:308: error: undefined reference to 'glGetProgramiv'
shader_program.cpp:315: error: undefined reference to 'glGetActiveUniform'
view.cpp:28: error: undefined reference to 'glClearColor'
view.cpp:29: error: undefined reference to 'glClear'
collect2: error: ld returned 1 exit status
make: *** [HW] Error 1

Passing Data from a View Controller to a First Detail Controller and then to a Second Detail Controller

Passing Data from a View Controller to a First Detail Controller and then
to a Second Detail Controller

Posting my first question here on stackoverflow! Hope my question is
clear, here it is...
I have a Navigation Controller embedded in a First View Controller that
has a table view. From the table view I have a segue that pushes to a
First Detail Controller. Everything works fine, the segue passes the data
to the First Detail Controller, however I would like to push again from a
button to a Second Detail Controller.
The layout in the storyboard looks like this Image of storyboard
I set-up a Second Detail Controller and pushed to that from a button on
the First Detail Controller. However I can not figure out how to pass the
data I have in an array along to the Second Detail Controller. I added an
NSLog line to see what was being passed along and the debug panel is
outputing "(null)"
Here is my viewdidload and segue code from the .m First View Controller
named ColorBookViewController:
- (void)viewDidLoad
{
[super viewDidLoad];
Color *color1 = [Color new];
color1.name = @"Red";
color1.hexnumber = @"FF0000";
color1.spanishname =@"Rojo";
Color *color2 = [Color new];
color2.name = @"Green";
color2.hexnumber = @"00FF00";
color2.spanishname =@"Verde";
Color *color3 = [Color new];
color3.name = @"Blue";
color3.hexnumber = @"0000FF";
color3.spanishname = @"Azul";
colors = [NSArray arrayWithObjects: color1,color2,color3, nil];
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"showColorDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
ColorDetailViewController *destViewController =
segue.destinationViewController;
destViewController.color = [colors objectAtIndex:indexPath.row];
}
}
Here is the view did load from the .m of the First Detail Controller named
ColorDetailController:
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"This is...%@", color.name);
self.nameLabel.text = color.name;
self.hexnumberLabel.text = color.hexnumber;
}
My .h for the SecondDetailController:
#import <UIKit/UIKit.h>
#import "Color.h"
@interface SecondDetailViewController : UIViewController
@property (nonatomic,weak) IBOutlet UILabel *spanishnameLabel;
@property (nonatomic, strong) Color *color;
@end
Here is the view did load from the .m of the Second Detail Controller
named SecondDetailController:
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = color.name;
NSLog(@"This is...%@", color.spanishname);
self.spanishnameLabel.text = color.spanishname;
}
The app runs fine in the simulator, but I get a blank screen for the
Second Detail Controller and I get the "null" result from NSLog(@"This
is...%@", color.spanishname);
Any suggestions as to why the segue passes and holds the instance for the
first Detail View but not the Second Detail View? Or am I missing
something more fundamental here? I tried setting up a second segue on the
First Detail Controller and the NSLog produces the correct result (the
color name in Spanish), but I am not sure how I would pass this onto the
Second Detail Controller:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showMoreDetail"]) {
NSLog(@"This is... %@",color.spanishname); //works fine
self.spanishnameLabel.text = color.spanishname; //throws error
}
}
Thanks for any help or insight!

[ Cooking & Recipes ] Open Question : What foods have high gluten?

[ Cooking & Recipes ] Open Question : What foods have high gluten?

Which processes do contribute to "commit charge"?

Which processes do contribute to "commit charge"?

I want to put the question squarely: what is the contribution of every
process into commited memory. Process Explorer refers to the total memory
committed and commit charge but only Private bytes, Working Set and
Virtual Memory is reported for the processes. I see no process that has
the commit column. Yet, I want to know who committed all my memory.

Saturday, 24 August 2013

Shortcut to compile the .tex and .bib in one go with Texmaker?

Shortcut to compile the .tex and .bib in one go with Texmaker?

As known, Texmaker requires the user to PDFLaTeX first, then BibTeX, and
then PDFLaTeX twice.
This is really tedious. Is there any shortcut that allows me to do it in
one go?

How to do 64 bit multiply on 16 bit machine?

How to do 64 bit multiply on 16 bit machine?

I have an embedded 16 bit CPU. On this machine ints are 16 bit wide and it
supports longs that are 32 bits wide. I need to do some multiplications
that will need to be stored in 64 bits. How can I do that with the given
constraints?

ListView performance is slow

ListView performance is slow

I have a custom ListView where I display some weapons which are retrieved
from a local database. I have a total of 88 rows, for each row a text and
an image is set each time getView() is called. The ListView lags while
scrolling fast and the garbage collector is going insane, deleting some 1M
objects per second. I'm not getting why.
Before I post my Adapter implementation, some explanation about how the
Image is set. My Weapon class is simply a data holder with setters and
getters. This is how names and images are getting set when the database
gets created (yeah it might seem very strange, but all other solutions
work even more slowly):
Weapon w = new Weapon();
w.setId(cursor.getLong(0));
w.setName(cursor.getString(1));
w.setImage(Constants.ALL_WEAPON_IMAGES[(int) cursor.getLong(0)-1]);
So I have an Array containing all weapon images in the form of
R.drawable.somegun. The data structure is implemented such way that ID-1
always points to the right drawable reference in my Array. The image field
in the Weapon class is an Integer. Now you have an idea how my getImage()
method works and below goes my Adapter:
public class Weapon_Adapter extends BaseAdapter {
private List<Weapon> items;
private LayoutInflater inflater = null;
private WeaponHolder weaponHolder;
private Weapon wp;
static class WeaponHolder {
public TextView text;
public ImageView image;
}
// Context and all weapons of specified class are passed here
public Weapon_Adapter(List<Weapon> items, Context c) {
this.items = (List<Weapon>) items;
inflater = LayoutInflater.from(c);
Log.d("Adapter:", "Adapter created");
}
@Override
public int getCount() {
return items.size();
}
@Override
public Weapon getItem(int position) {
return items.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
wp = (Weapon) getItem(position);
if (convertView == null) {
convertView = inflater.inflate(R.layout.category_row, null);
weaponHolder = new WeaponHolder();
weaponHolder.text = (TextView) convertView
.findViewById(R.id.tvCatText);
weaponHolder.image = (ImageView) convertView
.findViewById(R.id.imgCatImage);
convertView.setTag(weaponHolder);
}
weaponHolder = (WeaponHolder) convertView.getTag();
weaponHolder.text.setText(wp.getName());
weaponHolder.image.setImageResource(wp.getImage());
// weaponHolder.image.setImageResource(R.drawable.ak74m);
return convertView;
}}
Now the strange thing: using the outcommented line to statically set the
same image for all items removes all lags and GC in not even called once!
I'm not getting it.. wp.getImage() returns exactly the same thing, only
R.drawable.name is different for each weapon. But GC removes tons of
objects and the ListView lags while scrolling. Any ideas what I'm doing
wrong?
P.S. I've tried all possible ways of saving the Image to database, and all
possible ways to set it, including setImageBitmap(), setImageDrawable()..
the one I posted above is the fastest, though it also causes lag and many
GC calls

How can i create fancy app indicator with custom widgets in python?

How can i create fancy app indicator with custom widgets in python?

I want to create App Indicator that would contain buttons and entries. How
can i do that? I see there are some indicators that are complicated like
that.

Java HttpURLConnection post method not working

Java HttpURLConnection post method not working

I am using HttpURLConnection to send data to a server via POST. I set the
headers then get the output stream and write some bytes then close the
output stream.
I am trying to get the next page for schedule details from given url. But
some how i am not getting the result. Please help anybody if you know any
issue in this code.
public static void main(String[] args) throws Exception {
String url = "http://lirr42.mta.info";
String cookie = retrieveCookies(url);
String urlParameters =
"FromStation=56&ToStation=8&RequestDate=08/24/2013&RequestTime=01:00&RequestAMPM=PM&sortBy=1&schedules=schedules";
String page = postHttpPage(url + "/index.php", urlParameters,
cookie);
System.out.println(page);
System.out.println();
}
public static String postHttpPage(String url, String urlParameters,
String cookie) throws Exception {
System.out.println("\nSending 'POST' request to URL : " + url);
URL obj = new URL(url);
HttpURLConnection conn = (HttpURLConnection) obj.openConnection();
return postPage(conn, urlParameters, cookie);
}
private static String postPage(HttpURLConnection conn, String
urlParameters, String cookie) throws Exception {
conn.setRequestMethod("POST");
conn.setRequestProperty("User-Agent", "User-Agent: Mozilla/5.0
(Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/29.0.1547.57 Safari/537.36");
conn.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length",
String.valueOf(urlParameters.getBytes().length));
conn.setRequestProperty("Content-Language", "en-US");
conn.setRequestProperty("Cookie", cookie);
//conn.setInstanceFollowRedirects(true);
// Send post request
//conn.setDoInput(true);
conn.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
wr.writeBytes(urlParameters);
//System.out.println("wr : " + wr.size());
wr.flush();
wr.close();
StringBuffer response = new StringBuffer();
int responseCode = conn.getResponseCode();
System.out.println("Post parameters : " + urlParameters);
System.out.println("Response Code : " + responseCode);
BufferedReader in = new BufferedReader(new
InputStreamReader(conn.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
return response.toString();
}
public static String retrieveCookies(String url) throws IOException{
URL obj = new URL(url);
HttpURLConnection conn = (HttpURLConnection) obj.openConnection();
String cookies=conn.getHeaderField("Set-Cookie");
System.out.print("cookies: " + cookies);
conn.disconnect();
return cookies;
}

Android Application Google maps MapFragment

Android Application Google maps MapFragment

I get a error message on MapFragment and i don't know how to fix it. I am
using the Navigation drawer and want this to be the code for fragment one.
If you have questions about how the files are layed out and everything
else just write a comment
`public class FragmentOne extends Fragment {
private final LatLng LOCATION_NEERSEN = new LatLng(51.254341,6.47471);
private final LatLng LOCATION_DUSS = new LatLng(51.237417,6.773651);
private final LatLng LOCATION_COL = new LatLng(50.942421,6.959045);
private GoogleMap mMap;
public static Fragment newInstance(Context context) {
FragmentOne f = new FragmentOne();
return f;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup
container,Bundle savedInstanceState) {
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_one,
null);
return root;
mMap = ((MapFragment)
getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
Marker marker = mMap.addMarker(new
MarkerOptions().position(LOCATION_NEERSEN).title("Neersen").snippet("Beautiful
small
town.").icon(BitmapDescriptorFactory.fromResource(R.drawable.marker)));
marker.showInfoWindow();
Marker marker2= mMap.addMarker(new
MarkerOptions().position(LOCATION_DUSS).title("Düsseldorf").snippet("Beautiful
big
town.").icon(BitmapDescriptorFactory.fromResource(R.drawable.marker)));
marker2.showInfoWindow();
Marker marker3= mMap.addMarker(new
MarkerOptions().position(LOCATION_COL).title("Cologne").snippet("Another
Beautiful big
town.").icon(BitmapDescriptorFactory.fromResource(R.drawable.marker)));
marker3.showInfoWindow();
}
public void onClick_Neersen(View v){
//CameraUpdate update = CameraUpdateFactory.newLatLng(LOCATION_NEERSEN);
CameraUpdate update =
CameraUpdateFactory.newLatLngZoom(LOCATION_NEERSEN,16);
mMap.animateCamera(update);
}
public void onClick_col(View v){
CameraUpdate update = CameraUpdateFactory.newLatLngZoom(LOCATION_COL,11);
mMap.animateCamera(update);
}
public void onClick_Duss(View v){
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
CameraUpdate update =
CameraUpdateFactory.newLatLngZoom(LOCATION_DUSS,10);
mMap.animateCamera(update);
}
}
`

Class variables behave differently for list and int?

Class variables behave differently for list and int?

The class shared variables are shared with all the instances of the
classes as far as I know. But I am having trouble getting my head around
this.
class c():
a=[1]
b=1
def __init__(self):
pass
x=c()
x.a.append(1)
x.b+=1 #or x.b=2
print x.a #[1,1]
print x.b #2
y=c()
print y.a #[1,1] :As Expected
print y.b #1 :why not 2?
y.a resonates with the x.a but y.b doesn't.
hope someone can clarify.
EDIT: And how can the same functionality be created for ints.

Android: Save Mediarecorder-Stream as playable file

Android: Save Mediarecorder-Stream as playable file

I want to record videos with my android device (Nexus 10) and upload it
later to youtube.
So far I'am recording with the android MediaRecoder and stream it via
LocalSocket to save the data to multiple files. But the files are not
playable.
I read some articles that sine API-Level 18 it is possible to convert
files with MediaCodec and/or MediaMuxer. And i found this this code, but i
do not really understand how to handle it.
Has anybody an easy example which shows how to convert the raw data from
the LocalSocket to a playable file (i.e. mp4 files)?
My MediaRecoder looks like this:
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
CamcorderProfile camcorderProfile_HQ =
CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
camcorderProfile_HQ.fileFormat = MediaRecorder.OutputFormat.MPEG_4;
camcorderProfile_HQ.videoCodec = MediaRecorder.VideoEncoder.MPEG_4_SP;
recorder.setProfile(camcorderProfile_HQ);
recorder.setPreviewDisplay(surfaceHolder.getSurface());
clientSocket = new LocalSocket();
clientSocket.connect(new LocalSocketAddress(SOCKET_ADDRESS));
recorder.setOutputFile(clientSocket.getFileDescriptor());
recorder.prepare();
recorder.start();
Thanks in advance.

Cant remotely access my VNC Server ..

Cant remotely access my VNC Server ..

Ive installed a TightVNC server .. and it accepts connections on port
12589 instead of 5900 with authentication .. On my Local LAN of class A
private address .. I can access my VNC server running machine with the
java viewer .. and remote desktop works fine locally!
But I cant connect on the same port number on my public IP address
assigned to my WiFi router .. I have a DSL connection .. and ive even
forwarded the port 12589 to my 10.x.x.x static IP in Netgear WGR614v10
(tried all 3 protocols: UDP/TCP/both(any))
Online open port checker programs too report the port is closed!
Even with Disabling antivirus and firewall , I couldn't remote desktop ..
Is there anything more can be done ..

wrong parameter count in mysql_query

wrong parameter count in mysql_query

I have a error on my php code. I will insert a new row And i get the
error: wrong parameter count in mysql_query
<?php
include('../sec/inc_mysql_connect.php');
include 'googledistance.class.php';
$sql = "SELECT VVBnummer, Adres, Postcode FROM tblscheidsrechters";//
echo($sql);
$result = mysql_query($sql);
$sql_sh = "SELECT ID, SporthalAdres, Postcode FROM tblsporthal";
//echo('<br>' . $sql_sh);
$result_sh = mysql_query($sql_sh);
while($record = mysql_fetch_array($result))
{
while($record_sh = mysql_fetch_array($result_sh))
{
$fromAddress = $record['Adres'] . ',' . $record['Postcode'];
//echo($fromAddress . '<br>');
$toaddress = $record_sh['SporthalAdres'] . ',' .
$record_sh['Postcode']; //echo($toaddress . '<br>');
$gd = new GoogleDistance($fromAddress, $toaddress);
$vvb = $record['VVBnummer'];
$shid = $record_sh['ID'];
$afstand = $gd->getDistance();
$tijd = $gd->getDuration();
?>
<body>
<p>Scheidsrechter: <?php echo($record['VVBnummer']); ?></p>
<p>Sporthal: <?php echo($record_sh['ID']); ?></p>
<p>Afstand in km (h/t): <?php echo $gd->getDistance()/1000 ; ?></p>
<p>Tijd in minuten: <?php echo $gd->getDuration()/60; ?></p>
<p>Gevonden oorsprong: <?php echo $gd->getOrigin(); ?></p>
<p>Gevonden bestemming: <?php echo $gd->getDestination(); ?></p>
<hr />
</body>
<?php
$sql = "INSERT INTO klvv_sr_afstand_sh ( vvb_nr_sr, shid, afstand, tijd)
VALUES('$vvb', '$shid', '$afstand', '$tijd')"; echo($sql);
$record = mysql_query();
}
}
?>
The error happens when i will insert the row Thx for the help

Friday, 23 August 2013

Array out of bounds - Basic Java

Array out of bounds - Basic Java

I'm learning how to program in Java but I can't seem to get past an array
problem. See, I get an array out of bounds error when I run this program:
I know this is probably really easy to solve but I have no idea what's
going on.
Thanks!
public class AlturaPromedio {
float alturas[];
int cont;
float promedio;
InputStreamReader inputStream = new InputStreamReader(System.in);
BufferedReader buffRead = new BufferedReader(inputStream);
float cargarAlturas() throws IOException {
alturas = new float[4];
for (cont = 0; cont < alturas.length; cont++) {
System.out.println("Escriba el nombre de la primer altura:");
alturas[cont] = Float.parseFloat(buffRead.readLine());
}
return alturas[cont];
}
float calcularPromedio() {
promedio = (alturas[1] + alturas[2] + alturas[3] + alturas[4] +
alturas[0]) / 5;
return promedio;
}
/*float calcularMaximo(){
maximo = Alturas.min(alturas);
*/
public static void main(String[] ar) throws IOException {
AlturaPromedio personas = new AlturaPromedio();
personas.cargarAlturas();
personas.calcularPromedio();
}
}

JRockit JVM crashes with OOM on Lucene IndexWriter merge

JRockit JVM crashes with OOM on Lucene IndexWriter merge

We recently upgraded to Lucene 3.6 and JRockit JVM is crashing with OOM
exception for large dataset. Following is the JRockit dump:
2013-08-22 18:37:43,524 INFO [STDOUT] (indexer:46030) ===== BEGIN DUMP
============================================================= 2013-08-22
18:37:43,524 INFO [STDOUT] (indexer:46030) JRockit dump produced after 0
days, 05:03:42 on Thu Aug 22 18:37:36 2013



2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) Error Message:
Illegal memory access. [54]
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) Exception Rec:
EXCEPTION_ACCESS_VIOLATION (00000000c0000005) at 0x0000000180137D32 -
memory at 0x0000000000000080 could not be read.
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) Version : Oracle
JRockit(R) R28.2.3-13-149708-1.6.0_31-20120327-1523-windows-x86_64
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) CPU : Intel
Nehalem-EX (HT) SSE SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 Core Intel64
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) Number CPUs : 48
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) Tot Phys Mem :
137425145856 (131058 MB)
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) OS version :
Microsoft Windows 2008 R2 version 6.1 (Build 7600) (64-bit)
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) Thread System:
Windows Threads
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) Java locking : Lazy
unlocking enabled (class banning) (transfer banning)
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) State : JVM is
running (Main thread has finished)
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) Command Line :
-Xms11059m -Xmx11059m -XgcPrio:pausetime -XXgcTrigger:25
-XpauseTarget:200ms -XXcompressedRefs:enable=false
-XXtlasize:min=16k,preferred=512k -Xverbose:gcreport -Xns:3072m -server
-Xrs -Dsun.rmi.transport.tcp.handshakeTimeout=0
-Desa.common.rootlogger.client=esa.common.rootlogger.indexer
-Druntime.tmpdir=D:\CW\V714\scratch\temp\component\225pst round
2-indexer@46030-20130822133352-0
-Desa.common.rootlogger.roodir=D:/CW/V714/data/esadb/case-logs/225pst
round 2/225pst round 2-indexer@46030-20130822133352-0.log
-Dsun.java.command=com.teneo.esa.admin.service.shell.Shell 46030 normal
-Dsun.java.launcher=SUN_STANDARD com.teneo.esa.admin.service.shell.Shell
46030 normal
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) java.home :
c:\jrockit-jdk1.6.0_31-R28.2.3-4.1.0-x64\jre
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) StackOverFlow: 0
StackOverFlowErrors have occured
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) OutOfMemory : 0
OutOfMemoryErrors have occured
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) C Heap : Good; no
memory allocations have failed
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) GC Strategy : Mode:
pausetime, with strategy: genconcon (basic strategy: genconcon)
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) GC Status : OC is
not running. Last finished OC was OC#471.
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) : YC is currently
running. This is YC#6512.
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) YC Promotion : This
YC has been able to promote all found objects so far
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) YC History : Ran 0
YCs before OC#467.
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) : Ran 6 YCs before
OC#468.
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) : Ran 20 YCs before
OC#469.
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) : Ran 15 YCs before
OC#470.
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) : Ran 1 YCs before
OC#471.
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) : Started 25 YCs
since last OC.
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) Heap :
0x0000000180410000 - 0x0000000433710000 (Size: 11059 MB)
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) Compaction : (no
compaction area)
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) Allocation :
TLA-min: 16384, TLA-preferred: 524288 TLA-waste limit: 16384
2013-08-22 18:37:43,539 INFO [STDOUT] (indexer:46030) CompRefs :
References are uncompressed 64-bit.
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) Thread:
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) "Lucene Merge Thread
#0" id=445057 idx=0x690 tid=23496 lastJavaFrame=0x0000000073E9DF50
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) Stack 0:
start=0x0000000073E60000, end=0x0000000073EA0000,
guards=0x0000000073E64000 (ok), forbidden=0x0000000073E61000
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) Thread Stack Trace:
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) at
findNext+306(refiter.c:280+28)@0x0000000180137D32
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) at
findNextToReturn+40(refiter.c:303+0)@0x0000000180137DD8
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) at
trProcessLocksForThread+99(roots.c:620+19)@0x0000000180138D74
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) at
javaLockConvertLazyToThin+197(javalock.c:1760+99)@0x0000000180130746
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) at
javalock_lazy_possibleToUnlock+162(javalock.c:2032+15)@0x0000000180130D33
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) at
RJNI_jrockit_vm_Locks_checkAndTransferLazyLocked+297(javalock.c:2175+16)@0x0000000180130EBA
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) -- Java stack --
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) at
jrockit/vm/Locks.checkAndTransferLazyLocked(Ljava/lang/Object;)I(Native
Method)
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) at
jrockit/vm/Locks.monitorEnterSecondStage(Locks.java:971)[optimized]
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) at
jrockit/vm/Locks.monitorEnter(Locks.java:2179)[optimized]
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) at
org/apache/lucene/index/MergePolicy$OneMerge.checkAborted(MergePolicy.java:144)
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) at
org/apache/lucene/index/IndexWriter.mergeMiddle(IndexWriter.java:4251)[optimized]
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) at
org/apache/lucene/index/IndexWriter.merge(IndexWriter.java:3952)[optimized]
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) at
org/apache/lucene/index/ConcurrentMergeScheduler.doMerge(ConcurrentMergeScheduler.java:388)[inlined]
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) at
org/apache/lucene/index/ConcurrentMergeScheduler$MergeThread.run(ConcurrentMergeScheduler.java:456)[optimized]
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) at
jrockit/vm/RNI.c2java(JJJJJ)V(Native Method)
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) -- end of trace
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) Memory usage report:
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) Could not mark
thread stacks regions properly.
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) Total mapped
14738456KB (reserved=1774596KB)
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) - Java heap
11324416KB (reserved=0KB)
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) - GC tables 378784KB
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) - Thread stacks 0KB
(#threads=0)
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) - Compiled code
1048576KB (used=19557KB)
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) - Internal 904KB
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) - OS 78384KB
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) - Other 1817472KB
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) - Classblocks 4608KB
(malloced=4486KB #13282)
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) - Java class data
83200KB (malloced=82754KB #62498 in 13282 classes)
Not tracing sites.
2013-08-22 18:37:43,586 INFO [STDOUT] (indexer:46030) - Native memory
tracking 4224KB (malloced=2077KB #10)

Selecting enabled rows with ClientSelectColumn

Selecting enabled rows with ClientSelectColumn

I have a telerik GridClientSelectColumn along with AllowMultiRowSection
set to true for selecting all rows. So on the server side, some of the
rows are disabled, but when I go ahead click the button, it will select
all the rows regardless the button is being enabled/disabled.
So I figured I can loop through all the rows on client side using jquery
and see if they are disabled previously and if so I will mark them as
unchecked during OnRowSelected.
But I am not sure how to go about it, I have a RadGrid, a MasterTableView
and several GridBoundColumn.
Any tips would be helpful!

Application freeze after manual rotation in iOS 5

Application freeze after manual rotation in iOS 5

So i have a bug. It appears when i try to rotate my application after user
clicked unlock rotation button. For this feature i use next code

RotateHelperViewController *viewController =
[[RotateHelperViewController alloc] init];
viewController.neededOrientation = currentDeviceOrientation;
self.orientationFromLockedState = currentDeviceOrientation;
[UIView animateWithDuration:0.4 animations:^{
[self presentModalViewController:viewController animated:NO];
}
completion:^(BOOL finished) {
[viewController dismissModalViewControllerAnimated:NO];
[viewController release];
self.orientationFromLockedState = -1;
}];
this bug appears only on ios 5.x on iOS 6.x all works good. Also rotation
works fine if we rotate automaticaly.

Communicate with multiple clients & server with certificates

Communicate with multiple clients & server with certificates

I have a software that communicates with different clients and servers.
For each server/client you need a certificate to communicate with it. For
the communication with the server there is mainly .cer/.crt needed, for
the clients .jks & .p12.
Im looking for the best way to deal with this different certificates &
keystores (in java):
.cer /.crt
.jks
.p12
If possible I dont want to programm every communication different and
every time new when the certificate-type changes. Is there a way??
As I never worked before with certificates or keystores any help is
appreciated. Thanks!

Thursday, 22 August 2013

Basic Object Structure and Calling for JavaScript

Basic Object Structure and Calling for JavaScript

I'm trying to do something very simple. That is, create an object with a
function I can call from somewhere else. I must be missing something. The
code I'm trying right now is:
function Object1() {
function Function1() {
alert("hello");
}
}
Object1.Function1();

Git hook for any action that updates the working directory

Git hook for any action that updates the working directory

Following an answer to a previous question, I implemented a Git hook
script which needs to fire whenever the working directory is updated. I
linked this script to the following in .git/hooks:
post-checkout
post-commit
post-merge
This mostly works, but not always. One case I found is git stash. This is
a problem because my hook generates a text file wihch I also mark with git
update-index --assume-unchanged to tell Git that I don't want to check in
changes (an empty version is checked in). However, git stash will revert
the assume-unchanged file (to the empty file), which means the hook needs
to run again, yet the hook is not invoked after git stash.
I suspect a similar problem may exist with git rebase too, but that's not
as easy to explain.
I want a hook which Git will always run after updating the working
directory. Is this possible?

Threads java que

Threads java que

import java.util.ArrayList; import java.util.List;
public class NameList{
private List names = new ArrayList();
public synchronized void addName(String name){
names.add(name);
}
public synchronized void print(){
for (int i = 0; i < names.size(); i++) {
System.out.print(names.get(i)+" ");
System.out.println(Thread.currentThread().getName());
}
}
public static void main(String args[]){
final NameList nl = new NameList();
for (int i = 0; i <2; i++) {
new Thread(){
public void run(){
nl.addName("A");
nl.addName("B");
nl.addName("C");
nl.print();
}
}.start();
}
}
}
Output:
A Thread-1
B Thread-1
C Thread-1
A Thread-0
B Thread-0
C Thread-0
A Thread-0
B Thread-0
C Thread-0
why does Thread-0 output 6 times and thread-1 3?????

Mencoder failing to initialize video driver

Mencoder failing to initialize video driver

I am using the following Mencoder command as part of a perl script that
burns subtitles for different MP4 videos.
mencoder -profile h264mp4 source_file.mp4 -subcp utf8 -sub
subtitle_file.srt -o destination_file.mp4 >> /dev/null
This has been working for over a year without problems and it is now
giving the following fatal error when run:
** MUXER_LAVF
*****************************************************************
REMEMBER: MEncoder's libavformat muxing is presently broken and can generate
INCORRECT files in the presence of B-frames. Moreover, due to bugs MPlayer
will play these INCORRECT files as if nothing were wrong!
*******************************************************************************
FATAL: Cannot initialize video driver.
ffmpeg version 0.7.15, Copyright (c) 2000-2013 the FFmpeg developers
built on Feb 22 2013 07:18:58 with gcc 4.4.5
configuration: --enable-libdc1394 --prefix=/usr --extra-cflags='-Wall -g
' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl
--enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid
--enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264
--enable-libspeex --enable-nonfree --disable-stripping --enable-avfilter
--enable-libdirac --disable-decoder=libdirac --enable-libfreetype
--enable-libschroedinger --disable-encoder=libschroedinger
--enable-version3 --enable-libopenjpeg --enable-libvpx --enable-librtmp
--extra-libs=-lgcrypt --disable-altivec --disable-armv5te
--disable-armv6 --disable-vis
libavutil 50. 43. 0 / 50. 43. 0
libavcodec 52.123. 0 / 52.123. 0
libavformat 52.111. 0 / 52.111. 0
libavdevice 52. 5. 0 / 52. 5. 0
libavfilter 1. 80. 0 / 1. 80. 0
libswscale 0. 14. 1 / 0. 14. 1
libpostproc 51. 2. 0 / 51. 2. 0
This are the contents of the h264mp4 profile:
[h264mp4]
profile-desc="H.264 MP4"
vf=pullup,softskip,pp=fd,hqdn3d,harddup
lavdopts=threads=2
ovc=x264=yes
x264encopts=crf=22:subq=6:frameref=6:qcomp=0.8:8x8dct=yes:weight_b=yes:me=umh:partitions=p8

x8,i4x4:nodct_decimate=yes:trellis=1:direct_pred=auto:level_idc=30:nocabac=yes:threads=auto
oac=faac=yes
faacopts=br=128:raw=yes:mpeg=4:tns=yes:object=2
of=lavf=yes
lavfopts=format=mp4
sws=9
ofps=24000/1001
srate=48000
I get the same error on my Debian Squeeze and on Amazon's Bitnami servers.
Both were updated recently so my guess is that the new packages don't like
either the command line or the profile parameters.

Java Tapestry: Clearing a count value after a t:loop

Java Tapestry: Clearing a count value after a t:loop

I am printing the first 12 elements of a Comments array. After 12 have
been printed, a "More" link is printed. I am doing using a COMMENT_COUNT
int, and iterating it on each comment printed. I want to return the value
of COMMENT_COUNT to 0 after the "More" link is printed. How can I do this?
I have left my current hack in place, in which I just call ${clearCount()}
after printing the "More" link (right now it spits "true" out into the
template). I am guessing there is a much, much better way to do this. I am
looking for a better way to call ${clearCount()}, or a better way to set
COMMENT_COUNT to 0 after printing the "More" link.
.tml:
<t:loop source="currentCategoryTextmedium.commentArraySorted"
value="currentComment">
<t:if test="isCommentLessThan12()">
<span>
<a blah blah>${currentComment.blahblah}</a>
</span>
</t:if>
</t:loop>
<t:if test="isCommentMoreThan12()">
<span>
<a "blah blah">MORE</a>
</span>
</t:if>
${clearCount()}
java:
public int COMMENT_COUNT;
public boolean isCommentLessThan12() {
if (COMMENT_COUNT < 12) {
COMMENT_COUNT++;
return true;
}
else {
return false;
}
}
public boolean isCommentMoreThan12() {
COMMENT_COUNT++;
if (COMMENT_COUNT > 12) {
return true;
}
else {
return false;
}
}
public boolean clearCount() {
COMMENT_COUNT= 0;
return true;
}

Android FTP file Upload

Android FTP file Upload

I want to upload a existing file from my Android to a FTP-Server.
The following code works, but only in its own project.
public class FtpConnectDemo {
public static void main(String[] args) {
uploadDatei(SERVER, "SERVER/htdocs/wa/data/ArtikelDatenbank.csv",
"ArtikelDatenbank.csv", USER, PASSWORD);
}
public static void uploadDatei(String ftpServer, String
pfadUndDateiName, String dateiName, String benutzer, String passwort)
{
StringBuffer sb = new StringBuffer("ftp://");
sb.append(benutzer);
sb.append(':');
sb.append(passwort);
sb.append('@');
sb.append(ftpServer);
sb.append('/');
sb.append(pfadUndDateiName);
sb.append(";type=a");
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
URL url = new URL(sb.toString());
URLConnection urlc = url.openConnection();
bos = new BufferedOutputStream(urlc.getOutputStream());
bis = new BufferedInputStream(new FileInputStream(dateiName));
int i;
// read byte by byte until end of stream
while ((i = bis.read()) != -1) {
bos.write(i);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (bis != null) {
try {
bis.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
if (bos != null) {
try {
bos.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
}
}
If I include this code into my other project it doesn't work anymore. The
method is called by a click on a button. The onClickListener should call
the second method uploadCsvAufServer()
Here is my other project.
Calling method:
private void initObjekte() {
dbHelper = new DBController(this);
this.buttonSync = (Button) this.findViewById(R.id.button_sync);
this.buttonSync.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// 1. Erstellen einer csv-Datei, die die Werte aus 1.
enthält: OK
Synchronisierung.this.saveUpdateDateiAufSdCard();
// 2. Kopieren der Datei auf den Webserver
Synchronisierung.this.uploadCsvAufServer(
Synchronisierung.this.SERVER,
Synchronisierung.this.SERVER_DATEINAME,
Synchronisierung.this.DATEINAME,
Synchronisierung.this.BENUTZER,
Synchronisierung.this.PASSWORT
);
// Bisher als "nein" gekennzeichnete Werte werden als
sychronisiert markiert und auf "ja" gesetzt
Synchronisierung.this.dbHelper.updateSyncStatus();
Synchronisierung.this.getNichtSyncedDaten();
}
});
}
Called method:
public void uploadCsvAufServer() {
StringBuffer sb = new StringBuffer("ftp://");
sb.append(this.BENUTZER);
sb.append(':');
sb.append(this.PASSWORT);
sb.append('@');
sb.append(this.SERVER);
sb.append('/');
sb.append(this.SERVER_DATEINAME);
sb.append(";type=a");
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
URL url = new URL(sb.toString());
URLConnection urlc = url.openConnection();
bos = new BufferedOutputStream(urlc.getOutputStream());
bis = new BufferedInputStream(new FileInputStream(this.DATEINAME));
int i;
// read byte by byte until end of stream
while ((i = bis.read()) != -1)
{
bos.write(i);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (bis != null) {
try
{
bis.close();
} catch (IOException ioe)
{
ioe.printStackTrace();
}
}
if (bos != null) {
try
{
bos.close();
} catch (IOException ioe)
{
ioe.printStackTrace();
}
}
}
}
Errors from LogCatsee below:
08-22 14:03:15.793: E/AndroidRuntime(773): FATAL EXCEPTION: main
08-22 14:03:15.793: E/AndroidRuntime(773):
android.os.NetworkOnMainThreadException
08-22 14:03:15.793: E/AndroidRuntime(773): at
android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
08-22 14:03:15.793: E/AndroidRuntime(773): at
java.net.InetAddress.lookupHostByName(InetAddress.java:385)
08-22 14:03:15.793: E/AndroidRuntime(773): at
java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
08-22 14:03:15.793: E/AndroidRuntime(773): at
java.net.InetAddress.getByName(InetAddress.java:289)
08-22 14:03:15.793: E/AndroidRuntime(773): at
java.net.InetSocketAddress.<init>(InetSocketAddress.java:105)
08-22 14:03:15.793: E/AndroidRuntime(773): at
java.net.InetSocketAddress.<init>(InetSocketAddress.java:90)
08-22 14:03:15.793: E/AndroidRuntime(773): at
libcore.net.url.FtpURLConnection.connectInternal(FtpURLConnection.java:219)
08-22 14:03:15.793: E/AndroidRuntime(773): at
libcore.net.url.FtpURLConnection.connect(FtpURLConnection.java:191)
08-22 14:03:15.793: E/AndroidRuntime(773): at
libcore.net.url.FtpURLConnection.getOutputStream(FtpURLConnection.java:339)
08-22 14:03:15.793: E/AndroidRuntime(773): at
de.noretec.nfcsync.view.Synchronisierung.uploadCsvAufServer(Synchronisierung.java:244)
08-22 14:03:15.793: E/AndroidRuntime(773): at
de.noretec.nfcsync.view.Synchronisierung$1.onClick(Synchronisierung.java:95)
08-22 14:03:15.793: E/AndroidRuntime(773): at
android.view.View.performClick(View.java:4204)
08-22 14:03:15.793: E/AndroidRuntime(773): at
android.view.View$PerformClick.run(View.java:17355)
08-22 14:03:15.793: E/AndroidRuntime(773): at
android.os.Handler.handleCallback(Handler.java:725)
08-22 14:03:15.793: E/AndroidRuntime(773): at
android.os.Handler.dispatchMessage(Handler.java:92)
08-22 14:03:15.793: E/AndroidRuntime(773): at
android.os.Looper.loop(Looper.java:137)
08-22 14:03:15.793: E/AndroidRuntime(773): at
android.app.ActivityThread.main(ActivityThread.java:5041)
08-22 14:03:15.793: E/AndroidRuntime(773): at
java.lang.reflect.Method.invokeNative(Native Method)
08-22 14:03:15.793: E/AndroidRuntime(773): at
java.lang.reflect.Method.invoke(Method.java:511)
08-22 14:03:15.793: E/AndroidRuntime(773): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
08-22 14:03:15.793: E/AndroidRuntime(773): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
08-22 14:03:15.793: E/AndroidRuntime(773): at
dalvik.system.NativeStart.main(Native Method)
08-22 14:03:19.773: E/Trace(787): error opening trace file: No such file
or directory (2)
Does anybody see why I got these errors?

How to save a CSV file to a variable with a foreach loop?

How to save a CSV file to a variable with a foreach loop?

Basically, I am loading a CSV file via a HTML upload form, then saving it
into PHP. I need to create a foreach loop to somehow print out the file
line by line.
I am not to sure how to do this since I have honestly never designed a PHP
foreach loop before.
This is the code that is capturing and saving the multidimensional array
from the CSV file
$csv_array = array(array());
$file = fopen($_FILES['upload_csv']['tmp_name'], 'r');
if($file)
{
while (($line = fgetcsv($file)) !== FALSE)
{
$csv_array[] = array_combine(range(1, count($line)),
array_values($line));
}
fclose($file);
}
This is my current foreach loop which is not working well at all which I
grabbed and slightly changed from one of my other functions.
$all_questions;
if(!empty($csv_array))
{
foreach($csv_array as $question)
{
$all_questions = $all_questions . implode(',',$question) . "\n";
}
}
So in conclusion, I need my foreach loop to go through my multidimensional
array to save it as one big string. If my CSV file is like this:
question1,answer1,answer2,answer3,answer4
question2,answer1,answer2,answer3,answer4
question3,answer1,answer2,answer3,answer4
I need it saved into a variable in the exact same format. I need to also
keep my multidimensional array since I need it for other reasons.
Thanks in advance!

Wednesday, 21 August 2013

How to change DataGridView column value based on condition in C#

How to change DataGridView column value based on condition in C#

Is it possible to change the column value or cell value based on the
Condition.

Consider i am having 3 columns in a data-grid view (i.e) to find the
greatest of two number

The input from Data gird view is got from SQL Server
1.First Data grid view column is A and second one is B and 3rd column is
to find whether A is bigger than B or not. if the condition satisfies it
should display the text "TRUE" or else "FALSE" in 3rd Column

How to fix memory leak in SurfaceView

How to fix memory leak in SurfaceView

I met a memory leak issue in surfaceview.
I define a custom view MyView which extends from surfaceview.
int Layout file
<com.andoird.example.MyView
....
....
/>
and setContentView in onCreate(); after finish the Activity. I get the log
below; It show the there are memory leak in Surface view.
I hope someone can help me to resolve this. Thank you!
use Android 4.2.
Log 1:
08-16 16:29:23.751 E/StrictMode(23220): A resource was acquired at
attached stack trace but never released. See java.io.Closeable for
information on avoiding resource leaks.
08-16 16:29:23.751 E/StrictMode(23220): java.lang.Throwable: Explicit
termination method 'release' not called
08-16 16:29:23.751 E/StrictMode(23220): at
dalvik.system.CloseGuard.open(CloseGuard.java:184)
08-16 16:29:23.751 E/StrictMode(23220): at
android.view.Surface.<init>(Surface.java:293)
08-16 16:29:23.751 E/StrictMode(23220): at
android.view.SurfaceView.<init>(SurfaceView.java:101)
Log 2
08-16 16:29:23.751 E/StrictMode(23220): A resource was acquired at
attached stack trace but never released. See java.io.Closeable for
information on avoiding resource leaks.
08-16 16:29:23.751 E/StrictMode(23220): java.lang.Throwable: Explicit
termination method 'release' not called
08-16 16:29:23.751 E/StrictMode(23220): at
dalvik.system.CloseGuard.open(CloseGuard.java:184)
08-16 16:29:23.751 E/StrictMode(23220): at
android.view.Surface.<init>(Surface.java:293)
08-16 16:29:23.751 E/StrictMode(23220): at
android.view.SurfaceView.<init>(SurfaceView.java:102)

Comma gem export failing on Heroku - working on local environment

Comma gem export failing on Heroku - working on local environment

Using the the comma gem and exporting CSV files perfectly fine on my local
environment. Also working on our staging environment which is running on
an AWS instance.
ONLY failing on Heroku.
Heroku says:
2013-08-21T21:55:34.875724+00:00 app[web.1]: NoMethodError (undefined
method `klass' for nil:NilClass):
2013-08-21T21:55:34.875724+00:00 app[web.1]: app/models/job.rb:220:in
`block in <class:Job>'
2013-08-21T21:55:34.875724+00:00 app[web.1]:
app/controllers/jobs_controller.rb:25:in `block (2 levels) in index'
2013-08-21T21:55:34.875724+00:00 app[web.1]:
app/controllers/jobs_controller.rb:18:in `index'
And line 220 in my Job model is:
Comma do
...
customer :first_name
...
end
job.rb includes the line:
belongs_to :customer
And customer.rb has:
has_many :jobs
And as I mentioned this entire thing works great on my local box - I click
the export button and out pops all the jobs, with each customer in the
appropriate column.
For whatever reason it's only failing on Heroku.
I'm using Ruby 2.0.0-p0 on Heroku, Comma gem only verified up to 1.9.2
according to the documentation - BUT - I'm using Ruby 2.0.0-p0 on the
staging server AND on my local environment and, again, it's working.
It's the 'klass" that's really throwing me off, because I don't have that
anywhere in my code. I've read other threads about the same error and
their solutions, but I don't have things like nested model forms and the
like.
It is some issue with Heroku & Ruby 2.0 and associations? I've got the
has_many and belongs_to on both sides, but still seems to be
misunderstanding the association...

AJax/PHP Login Form - Mysql Database [Jquery Mobile]

AJax/PHP Login Form - Mysql Database [Jquery Mobile]

I'm having an issue with AJAX/PHP form submission.
My ajax is as follows:
<script type="text/javascript">
$('#loginForm').submit(function() {
$.ajax({
type: "POST",
url: "php/server/login.php",
data: {
username: $("#username").val(),
password: $("#password").val()
},
success: function(html)
{
if(html == 'true')
{
window.location.replace('main.html');
}
else
{
$("#errorMessage").html(html);
}
},
beforeSend:function()
{
$("$errorMessage").html("Attempting to login...");
}
});
return false;
});
</script>
My form:
<form id="loginForm">
<div id="errorMessage"></div>
<div data-role="fieldcontain">
<label for="username">Username:</label>
<input class="required" id="username" type="text"
placeholder="Username" />
</div><!-- End Contained Fields -->
<div data-role="fieldcontain">
<label for="password">Password:</label>
<input class="required" id="password" type="password"
placeholder="Password" />
</div><!-- End Contained Fields -->
<div data-role="fieldcontain">
<input type="submit" id="login" value="Login" />
</div><!-- End Contained Fields -->
</form><!-- End Form -->
And then my login.php script:
<?php
session_start();
$username = $_POST['username'];
$password = md5($_POST['password']);
$db = new PDO('mysql:host=localhost;dbname=mobile;charset=utf8', 'root',
'password');
try {
$stmt = $db->query("SELECT * FROM users WHERE username='$username' and
password='$password'");
$row_count = $stmt->rowCount();
if($row_count == 1)
{
echo 'true';
$_SESSION['username'] = $username;
}
else
{
echo 'false';
}
} catch(PDOException $ex) {
echo "An error has occured!";
}
?>
I originally had programmed my whole JQuery Mobile application using just
raw php, but recently found out that I must use AJAX and Html to be able
to port it to IOS and Android using PhoneGap.
I'm rather new to using ajax and have read as many articles that I
could/topics here to try to get it to work. Unsure if I'm having a syntax
issue or just not handling it correctly.
My local machine is loading a mysql server (database name is mobile, table
I'm trying to load is users). I know that part is all correct because it
works fine with php.
Could someone explain my issue? Thank you.

Add the Empty space on view source using javascript or jquery

Add the Empty space on view source using javascript or jquery

Is there is a way to add the extra empty spaces while viewing source. I am
not asking for hiding the source. I want to add the extra white space in
the source code when you view.
http://www.immihelp.com/visitor-visa/sponsor-documents.html. If you visit
the site click view source then it appear with empty white space. Is there
is a way to do this in jquery or javascript.
Any suggestion would be great.
Thanks.

Can't parse a JSON Response using C#

Can't parse a JSON Response using C#

I have a very simple response from a Json request, however I can't seem to
find a easy way to parse it. I only find tutorials that use classes of
third party's. I want to use the native functionality of .NET 3.5 writing
in C# to interpret the response. Can anybody help, please?
{
"id": "10000",
"key": "TST-24",
"self": "http://www.example.com/jira/rest/api/2/issue/10000"
}

Tuesday, 20 August 2013

Delphi COM objects multithreading

Delphi COM objects multithreading

I've been programming for a while and regarding COM/ActiveX object, I'm
facing very strange issues, that are abviously above my knowledge. Here it
is. My software talks to COM objects using late binding. Since those COM
object talk to hardware (such as scientific camera for instance), I have
choosen to seralise all calls into a dedicated thread. this allows the
main thread to interact with the user. So I'm sending messages from the
main user thread (or any other thread) to the thread that is design to
dealing solely with activeX.
Here how it looks



procedure MythreadActiveX.execute;
begin
CoInitialize(nil);
Try
ComObject :=CreateOLEObject(COMID);
While not Terminated do
Begin
If PeekMessage(Msg,0,0,0,PM_REMOVE) then
Begin
TranslateMessage(Msg);
DispatchMessage (Msg);
end;
If (FEvent.WaitFor(TimOutMs)=wrSignaled) then // Wait for command
Begin
FEvent.ResetEvent;
Try
Case COM_Order of
Oder1:Begin
.........
end
Oder2:Begin
.........
end
end;
FEventComplete.SetEvent;
end;
end;
CoUnInitialize;
end;
This works like a charm with most COM server, but fails with other COM
DLL/Server, especially written in visual basic, where the I have noticed
with process explorer that the ActiveX code is executed into the main
thread despite what I did above ! The consequence result in - main thread
holding up - main thread memory corruption (with large array for
instance)... == my app crash
What is the cause ? is this related to ActiveX threading model ? I would
like to understand and to correct my code to cope with that (In that case,
the COM shall run in the main thread....)
Thanks (Since I spent time on this, i'm ready to provide more information
in order to understand)

Share Desktop via Web Browser

Share Desktop via Web Browser

I need to share my Desktop with users that don't use Linux. I'm looking
for a tool where users can hit a URL in their browser and view my desktop,
like join.me for Windows.
I tried running join.me via Wine, but I get nothing but a black screen.

Can I use .htaccess to convert a url slug to a POST request?

Can I use .htaccess to convert a url slug to a POST request?

I would like to use .htaccess to take a URL like this:
mydomain.com/some-url-slug
and instead redirects the user to mydomain.com, but with a POST request
that includes "some-url-slug".
Is this possible? Thanks!!

Routing errors while processing URL(s) without a http prefix

Routing errors while processing URL(s) without a http prefix

We render HTML within a certain page and certain links don't have a http
prefix (e.g. foo.com/bar) when you click on it throws a routing error. Is
there a easier way to navigate to the right URL in such cases

Horizontal scroll on UIScrollView without pan gesture

Horizontal scroll on UIScrollView without pan gesture

How can I make it so that when I use my UIScrollView the pan gesture
recognizer selector is not called.
I want to be able to scroll in the scroll view without the pan gesture
selector being called.
Here is my pan detected function:
- (void)panDetected:(UIPanGestureRecognizer *)panRecognizer
{
CGPoint translation = [panRecognizer translationInView:self.view];
CGPoint imageViewPosition = self.draggableImage.center;
imageViewPosition.x += translation.x;
imageViewPosition.y += translation.y;
self.draggableImage.center = imageViewPosition;
[panRecognizer setTranslation:CGPointZero inView:self.view];
}
I do not want it to be called when I am using my UIScrollView at the
bottom of the page.

Calculating limits. Am I correct? (with working)

Calculating limits. Am I correct? (with working)

This is my working for the first two questions (i and ii). Does anyone
know how to work out iii? Also, is my working correct? Any feedback is
appreciated. I also did a rough calculation of iii and I think the answer
is supposed to be 5 but I'm not too sure of the working.
(i) We are finding the limit as x approaches -2. According to the system
of equations, we should look at where it says -2 ¡Ü x ¡Ü 3 because x is
approaching -2 and -2 fits into this system. So Ix^2 - 4I if -2 ¡Ü x ¡Ü 3
is what we're looking at. What we're finding is the limit if x approaches
-2. So let's replace x with -2. Ix^2 - 4I I(-2)^2 - 4I I(4) - 4I I0I 0 lim
f(x) as x app. -2 = 0.
(ii) lim f(x) as x app. 2. This fits into Ix^2 - 4I if -2 ¡Ü x ¡Ü 3. Same
reasoning as above. After it says if, it says if -2 ¡Ü x ¡Ü 3 and if we
replace 2 for x here it makes sense. So now we replace 2 for x where it
says Ix^2 - 4I. Ix^2 - 4I I(2)^2 - 4I I(4) - 4I I0I 0 lim f(x) as x app. 2
= 0.

pyinstaller exe with pubsub

pyinstaller exe with pubsub

I have written a wxpython application that uses several different threads
all of which need to write to the log window (textctrl box). Because of
this I followed this tutorial
http://www.blog.pythonlibrary.org/2010/05/22/wxpython-and-threads/
And used wx.CallAfter and PubSub.
This was my original code
from wx.lib.pubsub import Publisher
Publisher().subscribe(self.messenger, "update")
wx.CallAfter(Publisher().sendMessage, "update", "Thread finished!")
def messenger(self, msg):
self.logtxtctrl.WriteText(msg.data)
this code worked brilliantly and thought it would be easy to use
pyinstaller to create an exe for my code.
How wrong was I!!
So after reading some comments it seems there are two versions of the
pubSub API, so using this
http://wiki.wxpython.org/WxLibPubSub
I tweaked my code to the following
from wx.lib.pubsub import setuparg1
from wx.lib.pubsub import pub
pub.subscribe(self.messenger, "update")
wx.CallAfter(pub.sendMessage, "update", data="Program success")
def messenger(self, data):
self.logtxtctrl.WriteText(data)
This code now works and again I tried to use pyinstaller and still no luck.
So i then read the following articles
How to get pubsub to work with pyinstaller?
http://www.pyinstaller.org/ticket/312
Both of which were very useful and I tried all the different variations of
changing the hook files and different spec files, I still cannot get it to
work.
These posts are almost 2 years ago and I would have thought adding pubsub
would be solved.
Can anyone please explain the process of what hooks I need, what to have
in a spec file and other elements I need to do to get it to work?
if there is no solution how else can I do thread safe communications to
widgets?

Monday, 19 August 2013

Protobuf-net return type List is null

Protobuf-net return type List is null

I'm trying to config my service to use protobuf-net. The methods that
return T[] and T works but List is returning null. Is it supported?
Also, how can i tell that it is really using protobuf for during
serialization. I tried to use fiddler but i can't really tell the
difference.
public interface IOrdersService
{
[OperationContract(IsOneWay = false)]
OrderDTO[] GetAllOrders();
[OperationContract(IsOneWay = false)]
List<OrderDTO> GetAllOrders2();
[OperationContract(IsOneWay = false)]
OrderDTO GetOrder();
}
public class OrdersClient : IOrdersServiceCallback
{
private OrdersServiceClient client;
public OrdersClient()
{
}
public void Init()
{
InstanceContext site = new InstanceContext(null, new OrdersClient());
client = new OrdersServiceClient(site);
}
public void Start()
{
OrderDTO[] orders = client.GetAllOrders();
OrderDTO[] orders2 = client.GetAllOrders2();
OrderDTO dto = client.GetOrder();
Console.WriteLine(dto);
}
}
web config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service name="OrdersServer.OrdersService">
<endpoint address=""
binding="wsDualHttpBinding"
bindingConfiguration="Binding1"
contract="OrdersServer.IOrdersService"
behaviorConfiguration="ProtoBufBehavior" />
</service>
</services>
<bindings>
<wsDualHttpBinding>
<binding name="Binding1">
<!-- Binding property values can be modified here. -->
<security mode="None"/>
</binding>
</wsDualHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values
below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging
purposes, set the value below to true. Set to false before
deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="ProtoBufBehavior">
<protobuf />
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<!--add binding="basicHttpsBinding" scheme="https" />-->
<add scheme="http" binding="wsDualHttpBinding"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<extensions>
<behaviorExtensions>
<add name="protobuf"
type="ProtoBuf.ServiceModel.ProtoBehaviorExtension, protobuf-net,
Version=2.0.0.640, Culture=neutral,
PublicKeyToken=257b51d87d2e4d67"/>
</behaviorExtensions>
</extensions>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value
below to true.
Set to false before deployment to avoid disclosing web app folder
information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
client config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IOrdersService"
clientBaseAddress="http://localhost:8000/whatisthis/">
<security mode="None" />
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint
address="http://localhost.fiddler:49522/OrdersService.svc"
binding="wsDualHttpBinding"
bindingConfiguration="WSDualHttpBinding_IOrdersService"
contract="OrdersServiceReference.IOrdersService"
name="WSDualHttpBinding_IOrdersService"
behaviorConfiguration="proto"/>
</client>
<behaviors>
<endpointBehaviors>
<behavior name="proto">
<protobuf />
</behavior>
</endpointBehaviors>
</behaviors>
<extensions>
<behaviorExtensions>
<add name="protobuf"
type="ProtoBuf.ServiceModel.ProtoBehaviorExtension,
protobuf-net, Version=2.0.0.640, Culture=neutral,
PublicKeyToken=257b51d87d2e4d67"/>
</behaviorExtensions>
</extensions>
</system.serviceModel>
</configuration>