Undefined index: URL [APP/View/Clients/index.ctp, line 90]
I have been asked to work on aplication someone else has created with
cakePHP. I am new to cakePHP.The application shows the following errors
Notice(8):
if(isset($client[0]) && $client[0]['contacts']['type_of']==3 &&
$var=='clients_with_contacts' && $this->Paginator->current()==1){
echo '<td
style="background:lightblue">'.$client[0]['Client'][$field].'</td>';
include - APP/View/Clients/index.ctp, line 90
View::_evaluate() - CORE/Cake/View/View.php, line 947
View::_render() - CORE/Cake/View/View.php, line 909
View::render() - CORE/Cake/View/View.php, line 471
Controller::render() - CORE/Cake/Controller/Controller.php, line 948
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 194
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 162
[main] - APP/webroot/index.php, line 112
There is a ton of code.If you can think of anything let me know.
Friday, 6 September 2013
Thursday, 5 September 2013
How to add a WHERE clause in UPDATE query in Datamapper
How to add a WHERE clause in UPDATE query in Datamapper
I have a Datamapper model, say XYZ. Now, There are multiple threads which,
at times, read a row using this model and attempt to update the same row -
only one should should succeed, depending on a property of XYZ, say abc
class XYZ
include DataMapper::Resource
property :id # primary key
property :abc
end
Now:
obj = XYZ.get(some_id)
obj.update(abc: 10) # Assume abc column value was 5 earlier
This may happen in several threads, and may happen simultaneously. Also,
the new value for column abc is different in each thread. Once, when a
thread updates abc, others should not. Essentially what I am trying to do
is to run this query via datamapper:
UPDATE `xyz` SET `abc` = 20 WHERE `id` = <some id> AND `abc` = 5
the model.update function does not allows to update an attribute and put a
condition of that attribute simultaneously. I know I can run an SQL query
directly; but is there any other way?
I have a Datamapper model, say XYZ. Now, There are multiple threads which,
at times, read a row using this model and attempt to update the same row -
only one should should succeed, depending on a property of XYZ, say abc
class XYZ
include DataMapper::Resource
property :id # primary key
property :abc
end
Now:
obj = XYZ.get(some_id)
obj.update(abc: 10) # Assume abc column value was 5 earlier
This may happen in several threads, and may happen simultaneously. Also,
the new value for column abc is different in each thread. Once, when a
thread updates abc, others should not. Essentially what I am trying to do
is to run this query via datamapper:
UPDATE `xyz` SET `abc` = 20 WHERE `id` = <some id> AND `abc` = 5
the model.update function does not allows to update an attribute and put a
condition of that attribute simultaneously. I know I can run an SQL query
directly; but is there any other way?
Word Cloud from Mysql field
Word Cloud from Mysql field
I would like to create a word cloud from one of the fields in a Mysql
table. I will display that word cloud on a webpage, then users be able to
click on the words which run an additional query for searches.
The field is a description, so contains a sentence or two.
Are there any Mysql functions which can work out a word frequency of
tables or fields?
I am looking to do this in php or ruby.
I would like to create a word cloud from one of the fields in a Mysql
table. I will display that word cloud on a webpage, then users be able to
click on the words which run an additional query for searches.
The field is a description, so contains a sentence or two.
Are there any Mysql functions which can work out a word frequency of
tables or fields?
I am looking to do this in php or ruby.
#EANF#
#EANF#
I have a database which returns the rows as lists in following format:
data = ['(1000,"test value",0,0.00,0,0)', '(1001,"Another test
value",0,0.00,0,0)']
After that, I use json_str = json.dumps(data) to get a JSON string. After
applying json.dumps(), I get the following output:
json_str = ["(1000,\"test value\",0,0.00,0,0)", "(1001,\"Another test
value\",0,0.00,0,0)"]
However, I need the JSON string in the following format:
json_str = [(1000,\"test value\",0,0.00,0,0), (1001,\"Another test
value\",0,0.00,0,0)]
So basically, I want to remove the surrounding double quotes. I tried to
accomplish this with json_str = json_str.strip('"') but this doesn't work.
Then, I tried json_str = json_str.replace('"', '') but this also removes
the escaped quotes.
Does anybody know a way to accomplish this or is there a function in
Python similiar to json.dumps() which produces the same result, but
without the surrounding double quotes?
Any help is appreciated!
I have a database which returns the rows as lists in following format:
data = ['(1000,"test value",0,0.00,0,0)', '(1001,"Another test
value",0,0.00,0,0)']
After that, I use json_str = json.dumps(data) to get a JSON string. After
applying json.dumps(), I get the following output:
json_str = ["(1000,\"test value\",0,0.00,0,0)", "(1001,\"Another test
value\",0,0.00,0,0)"]
However, I need the JSON string in the following format:
json_str = [(1000,\"test value\",0,0.00,0,0), (1001,\"Another test
value\",0,0.00,0,0)]
So basically, I want to remove the surrounding double quotes. I tried to
accomplish this with json_str = json_str.strip('"') but this doesn't work.
Then, I tried json_str = json_str.replace('"', '') but this also removes
the escaped quotes.
Does anybody know a way to accomplish this or is there a function in
Python similiar to json.dumps() which produces the same result, but
without the surrounding double quotes?
Any help is appreciated!
Meteor: Meteor.call() from within observe callback does not execute
Meteor: Meteor.call() from within observe callback does not execute
Is there any possibility of calling a server method from within a observe
callback in Meteor?
I put together an example that reproduces the issue, that a Meteor.call()
called from within a callback of myCursor.observe() does not execute. When
called from within the observe callback, the Meteor.method itself also
does not callback with an error, it just returns Undefined.
Stop ignoring me, Meteor.call() :) Any help is very appreciated!
observe.js
items=new Meteor.Collection("Items");
if (Meteor.isClient) {
Meteor.subscribe("Items");
Meteor.startup(function(){
itemsCursor=items.find();
itemsHandle=itemsCursor.observe({
added : function(doc){
console.log("added "+doc.text);
Meteor.call('aMethod',doc.text,function(e,r){
if(e){
console.log("error from server: "+e);
}else{
console.log("response from server: "+r);
}
});
},
removed : function(doc){
console.log("removed "+doc.text);
Meteor.call('aMethod',doc.text,function(e,r){
if(e){
console.log("error from server: "+e);
}else{
console.log("response from server: "+r);
}
});
}
});
});
Template.test.items=function(){
return items.find();
}
Template.test.events({
'click #add':function(){
items.insert({"text":"Timestamp: "+(new Date().getTime())});
},
'click #remove':function(){
items.remove(items.findOne()._id);
}
});
}
if (Meteor.isServer) {
Meteor.publish("Items",function(){
return items.find();
});
items.allow({
insert : function(userId,doc){
return true;
},
update : function(userId,doc){
return true;
},
remove : function(userId,doc){
return true;
}
});
Meteor.methods({
aMethod:function(text){
console.log("Got it! "+text);
return "Got it! "+text;
}
});
}
observe.html
<head>
<title>observe</title>
</head>
<body>
</body>
<template name="test">
<button id="add">add item</button>
<button id="remove">remove item</button>
<ol>
<li>
</ol>
</template>
Is there any possibility of calling a server method from within a observe
callback in Meteor?
I put together an example that reproduces the issue, that a Meteor.call()
called from within a callback of myCursor.observe() does not execute. When
called from within the observe callback, the Meteor.method itself also
does not callback with an error, it just returns Undefined.
Stop ignoring me, Meteor.call() :) Any help is very appreciated!
observe.js
items=new Meteor.Collection("Items");
if (Meteor.isClient) {
Meteor.subscribe("Items");
Meteor.startup(function(){
itemsCursor=items.find();
itemsHandle=itemsCursor.observe({
added : function(doc){
console.log("added "+doc.text);
Meteor.call('aMethod',doc.text,function(e,r){
if(e){
console.log("error from server: "+e);
}else{
console.log("response from server: "+r);
}
});
},
removed : function(doc){
console.log("removed "+doc.text);
Meteor.call('aMethod',doc.text,function(e,r){
if(e){
console.log("error from server: "+e);
}else{
console.log("response from server: "+r);
}
});
}
});
});
Template.test.items=function(){
return items.find();
}
Template.test.events({
'click #add':function(){
items.insert({"text":"Timestamp: "+(new Date().getTime())});
},
'click #remove':function(){
items.remove(items.findOne()._id);
}
});
}
if (Meteor.isServer) {
Meteor.publish("Items",function(){
return items.find();
});
items.allow({
insert : function(userId,doc){
return true;
},
update : function(userId,doc){
return true;
},
remove : function(userId,doc){
return true;
}
});
Meteor.methods({
aMethod:function(text){
console.log("Got it! "+text);
return "Got it! "+text;
}
});
}
observe.html
<head>
<title>observe</title>
</head>
<body>
</body>
<template name="test">
<button id="add">add item</button>
<button id="remove">remove item</button>
<ol>
<li>
</ol>
</template>
Ubuntu Server- RSA Authentication over public wifi
Ubuntu Server- RSA Authentication over public wifi
I'm relatively new with Ubuntu Servers, and in a recent attempt to limit
brute force attacks on my server, I tried to set up SSH to use RSA key
authentication. I created the key on my laptop correctly and transferred
it over my server, where it's stored in the .ssh/authorized_keys on my
server (I transferred it using scp via SSH). Now, whenever I am home or at
my apartments Wifi, I have no problem connecting and having my key
authenticate through the server. However, when I go to a public wifi (like
a hotel), it tells me: Permission Denied (publickey).
Anyone know why this happens?
I'm relatively new with Ubuntu Servers, and in a recent attempt to limit
brute force attacks on my server, I tried to set up SSH to use RSA key
authentication. I created the key on my laptop correctly and transferred
it over my server, where it's stored in the .ssh/authorized_keys on my
server (I transferred it using scp via SSH). Now, whenever I am home or at
my apartments Wifi, I have no problem connecting and having my key
authenticate through the server. However, when I go to a public wifi (like
a hotel), it tells me: Permission Denied (publickey).
Anyone know why this happens?
Java Deadlock in ClassLoaders
Java Deadlock in ClassLoaders
I have written two custom class loaders to load code dynamically.
The first one does load code from a Jar:
package com.customweb.build.bean.include;
import java.net.URL;
import java.net.URLClassLoader;
import com.customweb.build.process.ILeafClassLoader;
public class JarClassLoader extends URLClassLoader implements
ILeafClassLoader {
public JarClassLoader(URL[] urls, ClassLoader parent) {
super(urls, parent);
}
@Override
public Class<?> findClassWithoutCycles(String name) throws
ClassNotFoundException {
Class<?> c = findLoadedClass(name);
if (c != null) {
return c;
}
return findClass(name);
}
@Override
protected Class<?> findClass(String qualifiedClassName) throws
ClassNotFoundException {
synchronized (this.getParent()) {
synchronized (this) {
return super.findClass(qualifiedClassName);
}
}
}
@Override
public URL findResourceWithoutCycles(String name) {
return super.findResource(name);
}
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
synchronized (this.getParent()) {
synchronized (this) {
return super.loadClass(name);
}
}
}
}
The other class loader takes multiple class loaders to allow to access the
classes of the other class loaders. During the initialization of the first
one, I set an instance of this class loader as the parent. To break the
cycle I use the method 'findClassWithoutCycles'.
package com.customweb.build.process;
import java.net.URL;
import java.security.SecureClassLoader;
import java.util.ArrayList;
import java.util.List;
public class MultiClassLoader extends SecureClassLoader {
private final List<ClassLoader> classLoaders = new
ArrayList<ClassLoader>();
public MultiClassLoader(ClassLoader parent) {
super(parent);
}
public void addClassLoader(ClassLoader loader) {
this.classLoaders.add(loader);
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
for (ClassLoader loader : classLoaders) {
try {
if (loader instanceof ILeafClassLoader) {
return ((ILeafClassLoader)
loader).findClassWithoutCycles(name);
} else {
return loader.loadClass(name);
}
} catch (ClassNotFoundException e) {
// Ignore it, we try the next class loader.
}
}
throw new ClassNotFoundException(name);
}
@Override
protected URL findResource(String name) {
for (ClassLoader loader : classLoaders) {
URL url = null;
if (loader instanceof ILeafClassLoader) {
url = ((ILeafClassLoader)
loader).findResourceWithoutCycles(name);
} else {
url = loader.getResource(name);
}
if (url != null) {
return url;
}
}
return null;
}
}
But when I use this class loaders I get most of the time a deadlock. I
have past here the thread dump: http://pastebin.com/6wZKv4Y0
Since the Java ClassLoader blocks in some methods the thread by
synchronizing on $this, I try to synchronizing on the MultiClassLoader
first and then on the JarClassLoader. This should prevent any deadlocks,
when the order of acquiring a lock is the same. But it seems as somewhere
in the native class loading routine a lock on the class loader is
acquired. I came to this conclusion because the thread 'pool-2-thread-8'
is locked on the object '0x00000007b0f7f710'. But in the log I can't see
when this lock is acquired and by which thread.
How can I find out which thread does the synchronizing on the classloader?
I have written two custom class loaders to load code dynamically.
The first one does load code from a Jar:
package com.customweb.build.bean.include;
import java.net.URL;
import java.net.URLClassLoader;
import com.customweb.build.process.ILeafClassLoader;
public class JarClassLoader extends URLClassLoader implements
ILeafClassLoader {
public JarClassLoader(URL[] urls, ClassLoader parent) {
super(urls, parent);
}
@Override
public Class<?> findClassWithoutCycles(String name) throws
ClassNotFoundException {
Class<?> c = findLoadedClass(name);
if (c != null) {
return c;
}
return findClass(name);
}
@Override
protected Class<?> findClass(String qualifiedClassName) throws
ClassNotFoundException {
synchronized (this.getParent()) {
synchronized (this) {
return super.findClass(qualifiedClassName);
}
}
}
@Override
public URL findResourceWithoutCycles(String name) {
return super.findResource(name);
}
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
synchronized (this.getParent()) {
synchronized (this) {
return super.loadClass(name);
}
}
}
}
The other class loader takes multiple class loaders to allow to access the
classes of the other class loaders. During the initialization of the first
one, I set an instance of this class loader as the parent. To break the
cycle I use the method 'findClassWithoutCycles'.
package com.customweb.build.process;
import java.net.URL;
import java.security.SecureClassLoader;
import java.util.ArrayList;
import java.util.List;
public class MultiClassLoader extends SecureClassLoader {
private final List<ClassLoader> classLoaders = new
ArrayList<ClassLoader>();
public MultiClassLoader(ClassLoader parent) {
super(parent);
}
public void addClassLoader(ClassLoader loader) {
this.classLoaders.add(loader);
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
for (ClassLoader loader : classLoaders) {
try {
if (loader instanceof ILeafClassLoader) {
return ((ILeafClassLoader)
loader).findClassWithoutCycles(name);
} else {
return loader.loadClass(name);
}
} catch (ClassNotFoundException e) {
// Ignore it, we try the next class loader.
}
}
throw new ClassNotFoundException(name);
}
@Override
protected URL findResource(String name) {
for (ClassLoader loader : classLoaders) {
URL url = null;
if (loader instanceof ILeafClassLoader) {
url = ((ILeafClassLoader)
loader).findResourceWithoutCycles(name);
} else {
url = loader.getResource(name);
}
if (url != null) {
return url;
}
}
return null;
}
}
But when I use this class loaders I get most of the time a deadlock. I
have past here the thread dump: http://pastebin.com/6wZKv4Y0
Since the Java ClassLoader blocks in some methods the thread by
synchronizing on $this, I try to synchronizing on the MultiClassLoader
first and then on the JarClassLoader. This should prevent any deadlocks,
when the order of acquiring a lock is the same. But it seems as somewhere
in the native class loading routine a lock on the class loader is
acquired. I came to this conclusion because the thread 'pool-2-thread-8'
is locked on the object '0x00000007b0f7f710'. But in the log I can't see
when this lock is acquired and by which thread.
How can I find out which thread does the synchronizing on the classloader?
Subscribe to:
Posts (Atom)