Search This Blog

Showing posts with label wcf. Show all posts
Showing posts with label wcf. Show all posts

Saturday, February 19, 2011

Limit MongoDB database size?

Programmer Question

We're interested in deploying MongoDB, but we need to know if we can limit database/table sizes?



For example:



db.user1.find()
db.user2.find()



As you can see from the above, each user will have their own database. We want to limit each user's database so we don't have any one user eating up all our hard drive space.



Is this possible with MongoDB?



Thanks.



Find the answer here

PHP: include() bug, or user error? (Passed filename in IF statement)

Programmer Question

Alright so I've already created a PHP bug about this but it was marked as bogus, but I can't help but to believe they didn't read it carefully...



Link to Bug #54042



The error is caused by using an include() statement in an IF statement, making the statement believe it's been passed an empty string.



Reviewing the bug will explain everything, including a test script.



Is it a bug, or am I missing something "feature"-wise? This is weird seeing as how assigning the output of include to a variable and then testing that value works just fine (which would be the workaround).



Any insight?



Find the answer here

Thursday, February 17, 2011

Sparse array support in HDF5

Programmer Question

Hi,



I need to store a 512^3 array on disk in some way and I'm currently using HDF5. Since the array is sparse a lot of disk space gets wasted.



Does HDF5 provide any support for sparse array ?



Find the answer here

Tuesday, February 15, 2011

Custom Post Types on Category Pages

Programmer Question

Hi!



I am using this bit of code to make custom post typess show on my category pages:





Is there a way I can modify this code to include it into functions.php instead of category.php and achieve the same effect?



Thanks!



Find the answer here

Sunday, February 13, 2011

Does PowerShell have something similar to the Perl abbrev() function

Programmer Question

So in Perl, there is a function call abbrev() that given a list of keywords, returns a hash mapping all the minimally abbreviations to their keyword:



@keywords = {"this", "and", "that"}
%AbbevList = abbrev(@keywords);


This would return a Hash like this:



thi => "this"
this => "this"
tha => "that"
that => "that"
a => "and"
an => "and"
and => "and"


In Perl, this allowed me to take user abbreviations for my keywords and easily map them correctly to the "real" keyword as long as the user's input was minimally unique.



Does PowerShell have anything similar?



Find the answer here

How to do this with routing in Rails?

Programmer Question

Say we have a simple resource called news:



resources :news


The generated paths are in this form /news/:id. I would like to provide a shortcut for this by dropping the /news/, so that /1/ goes to news#show with id 1 and the same for all the other resourceful actions of news.



I figured it's probably something along the lines of



match '/:id(/:action)', :controller => 'news'


but this isn't working.



Find the answer here

Saturday, February 12, 2011

Konntent.com codeigniter htaccess

Programmer Question

Please i need help with my application hosted at kontent.com that runs on Codeigniter. I get a No input file specified message and cant get it working



Find the answer here

Enclosure Memory Copies

Programmer Question

function myClass()
{
//lots and lots of vars and code here.

this.bar = function()
{
//do something with the numerous enclosed myClass vars
}

this.foo = function()
{
alert('Hello'); //don't do anything with the enclosed variables.
}
}


Each instance of myClass gets its own copy of bar and foo, which is why prototyped methods use less memory. However, I would like to know more about the memory use of inner methods.



It seems obvious to me that (1) below must be true. Do you agree?




  1. Not only do distinct myClass instances have their own distinct copies of bar, but they also must have their own distinct copies of the myClass enclosure. (or else how does the bar method keep the myClass variables straight on a per instance basis?)



Now (2) is the question I'm really after.




  1. Since the inner foo method doesn't use anything in the myClass enclosure a natural qustion is: Is javascript smart enough to not keep a myClass enclosure in memory for the use of foo?



Find the answer here

Friday, February 11, 2011

Horizontal Centering of Multi-Line List Items in Unordered List

Programmer Question

I have an unordered list that wraps onto a second line, and needs to be centered horizontally within the containing UL. Each LI is a set width and height. I've seen many approaches that work for a single line, but nothing I've tried is working when the list wraps to a second line. Would be ideal if this worked in IE7+ -- Thanks for the help.



See here for an illustration: http://grab.by/8UIl



Find the answer here

Are there javadoc-like tools to generate RESTful web service apidoc from JAX-RS annotations?

Programmer Question

I'm developing a web service with CXF by using JAX-RS annotations on resources. These annotations specify arguments names, default values, and the valid input and output mime types.



It'd be nice to be able to run a javadoc-esque tool on my code to generate a concise set of documentation of this interface, but I cannot seem to find anything.



The docs produced by javadoc itself would require too much trimming down, I really want something that understands the semantics of the JAX-RS annotations and generates something friendly to the devs who want to use my service.



Find the answer here

Thursday, February 10, 2011

Tween animation on a Canvas in a custom View

Programmer Question

I have a class that extends View and I draw everything I need inside it's canvas in the onDraw method. Something like this:



protected void onDraw(Canvas canvas) {
synchronized (this) {
float h = mHeight;
float w = mWidth;

canvas.drawColor(Color.WHITE);

float roadLine= (85.0f/100.0f)*h;

canvas.drawBitmap(mTop, 0, roadLine-mTop.getHeight(), null);

//this is what I'd like to animate
canvas.drawBitmap(mSmoke);

}
}


Now, how do I make an Animation (tween animation) draw in here?



Find the answer here

Tuesday, February 8, 2011

groovy: use brackets on method calls or not?

Programmer Question

hi all,



this is a fairly general question about whether people should be using brackets on method calls that take parameters or not.
i.e.



def someFunc(def p) {
...
}


then calling:



someFunc "abc"


vs...



someFunc("abc")


Is this just a question of consistency, or is there specific use cases for each?



Find the answer here

How do I do to map Value Object in Entity Framwork 4

Programmer Question

I want map a value object in Entity Framework 4 as in NHibernate where I use Component-Class(Nested in AR). How do I do this?



Find the answer here

Sunday, February 6, 2011

Other ways for zoom-in zoom-out in Android WebView?

Programmer Question

My actual task is to have zoom in zoom out for the WebView, but I don't want to scale images.



Are there ways to do that?



10x in advance,
Danail



Find the answer here

Saturday, February 5, 2011

Python - efficient representation of pixels and associated values

Programmer Question

I'm using python to work with large-ish (approx 2000 x 2000) vectors, where each I, J point in the vector represents a single pixel.



The matrices themselves are sparse (ie a substantial portion of them will have zero values), but when they are updated they tend to be increment operations, to a large number of adjacent pixels in a rectangular 'block', rather than random pixels here or there (a property i do not currently use to my advantage..).
Afraid a bit new to matrix arithmetic, but I've looked into a number of possible solutions, including the various flavours of scipy sparse matrices. So far co-ordinate (COO) matrices seem to be the most promising.
So for instance where I want to increment one block shape, I'd have to do something along the lines of:



>>> from scipy import sparse
>>> from numpy import array
>>> I = array([0,0,0,0])
>>> J = array([0,1,2,3])
>>> V = array([1,1,1,1])
>>> incr_matrix = sparse.coo_matrix((V,(I,J)),shape=(100,100))
>>> main_matrix += incr_matrix #where main_matrix was previously defined


In the future, i'd like to have a richer pixel value representation in anycase (tuples to represent RGB etc), something that numpy array doesnt support out of the box (or perhaps I need to use this).



Ultimately i'll have a number of these matrices that I would need to do simple arithmitic on, and i'd need the code to be as efficient as possible -- and distributable, so i'd need to be able to persist and exchange these objects in a small-ish representation without substantial penalties. I'm wondering if this is the right way to go, or should I be looking rolling my own structures using dicts etc?



Find the answer here

Classic ASP & XML

Programmer Question

I've got the following XML and the below ASP statement is working, but I need to get a specific tag rather than response.write everything. i.e. I want to get "Document_Name", or "Document_Size".



Does anyone know how I can do this?





tes1.png
123


Test.png
123




This is the code ..



Set objHdl = objLst.item(i)

Set PropertyImages = ObjHdl.getElementsByTagName("PropertyImages")

for x = 0 to (PropertyImages.Length-1)
Set Image = PropertyImages.item(x)

response.write "Image=" & Image.text & "
"
next


Find the answer here

Friday, February 4, 2011

Custom images with UISlider doesn't show on the device.

Programmer Question

Everything works on the simulator without a problem. However when I put it on my device it only show the ThumbImage. It is just really strange. I'm thinking this could be a iOS version issue or memory issue. My device is iPhone 3GS iOS 4.1.



@interface BlueChalkSlider : UISlider {}
@end

@implementation BlueChalkSlider
- (id)initWithCoder:(NSCoder *)decoder {
if ((self = [super initWithCoder: decoder])) {
self.backgroundColor = [UIColor clearColor];
[self setThumbImage:[UIImage imageNamed:@"Chalk.png"] forState:UIControlStateNormal];
[self setMinimumTrackImage:[UIImage imageNamed:@"ChalklineBlue.png"] forState:UIControlStateNormal];
[self setMaximumTrackImage:[UIImage imageNamed:@"ChalklineWhite.png"] forState:UIControlStateNormal];
}
return self;
}
@end


Find the answer here

Sunday, January 30, 2011

caching UIView objects as a way to improve performance

Programmer Question

Obviously Apple does this with UITableViewCells. I am curious if anyone has tried it with other UIView subclasses. And if so, what was your experience?



Find the answer here

Saturday, January 29, 2011

Empty but styled div in 960.gs

Programmer Question

I have the following column in my webpage draft, which is based on HTML5 Boilerplate and 960.gs:






However, when I open the page in Chrome, the column doesn't show up at all, unless I put some kind of content in it, like text or whitespace.



How can I make this work without resorting to desperate solutions like  ?



Find the answer here

[Do Not Validate ] ASP.NET - MVC3 property decoration?

Programmer Question

Is there an attribute I can decorate a single property on my model to tell the engine not to include the property in the validation routine?



[DoNotValidate] or [ValidateIgnore]



Find the answer here
Related Posts with Thumbnails