Sort by several fields together in mongodb

Let's say there are two fields updatedAt and createdAt in the document. However, the document doesn't necessarily have to have the updatedAt field if the document hasn't been updated yet. I want to sort by both these fields, essentially merge the two

Undefined `save 'method for nil: NilClass on the controller

I am begging to learn ruby on rails and doing the following I am receiving the following errors: NoMethodError in ArticlesController#create undefined method `save' for nil:NilClass It has to do with the @article.save articles_controllers.rb class Art

At what stage of the execution process, IIS compress output?

I recently tried to integrate WebMarkupMin, a run-time html minification library, into my site (C#, IIS 8, MVC 4). We have IIS compression enabled. I discovered that IIS actually compresses the action filter output stream, which means when I try to m

Unleaded transition from video to video using html5

I am trying to create a feature where a user can change (back and forth) between multiple videos while maintaining a single consistent audio. Think of being able to watch a concert from multiple angles but listening to a single audio. The trouble I a

Name of the xml element with the colon

I'm working against a 3rd party xml api. They have defined a required xml structure similar to the following. <ns1:E xmlns:ns1="schema"> <ns1:B> <ns2:S> <ns2:V> <ns2:Bl /> </ns2:V> </ns2:S> </ns1:B>

Using TryParse to Set Object Property Values

I'm currently refactoring code to replace Convert.To's to TryParse. I've come across the following bit of code which is creating and assigning a property to an object. List<Person> list = new List<Person>(); foreach (DataRow row in dt.Rows) {

Hibernate HQL nested query

I've three classes that have nested relationships: public class Route { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @ManyToMany(cascade = {CascadeType.DETACH, CascadeType.REFRESH}, fetch = FetchType.EAGER) private List<Place>

Detection of regions described by lines on HTML5 Canvas

Start with a 2d grid on an HTML5 canvas. The user creates lines by plotting points - up to 5 lines. Next, the user can select another arbitrary point on the grid, and the region is highlighted. I need to take that point and define a polygon to fill t

How to render images in rails3 select

I want to render dropdown list in form with images as options. How to achieve this in rails3?Check out this plugin http://www.marghoobsuleman.com/jquery-image-dropdown there is no option to do it directly in Rails.

JTable method called when sorting by column

Is there any method in JTable (or in a related class) that is called when user click on the column header to sort the relative column? I would like to perform some operations when a user click happens on a column header, before that the sorting opera

Google map loads static image

I am using google map API in my project. My code is : var map; var op = { zoom: 8, center: new google.maps.LatLng(-34.397, 150.644), mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("container"), op);

Using a C # Params keyword in a generic type constructor

I have a generic class in C# with 2 constructors: public Houses(params T[] InitialiseElements) {} public Houses(int Num, T DefaultValue) {} Constructing an object using int as the generic type and passing in two ints as arguments causes the 'incorrec

Scaling the image to the height of the parent's canvas in WPF

I'm new to WPF and trying something simple. I'm making a custom control with a canvas where I have an image that is higher than the canvas. When it displays it overflows the canvas, so I want it to scale to the parent height. There's probably an easy

Arrays pushing characters

It might be a stupid question but it confused me. var text = "Hello Mr Andreas Andreas Kostakis o ala krem Andreas o pianistas o poutsopnikt\o skaraveos o Andreas"; var myName = "Andreas"; var hits = []; for ( var i = 0; i < text.le

How to select separate lines with a specified condition

Suppose there is a table _ _ a 1 a 2 b 2 c 3 c 4 c 1 d 2 e 5 e 6 How can I select distinct minimum value of all the rows of each group? So the expected result here is: _ _ a 1 b 2 c 1 d 2 e 5 EDIT My actual table contains more columns and I want to s

Mass Assignment Rails and Backbone.js

I have a Game model and I want to mass assign on create: def create game = Game.new(params[:game]) ... end But Backbone sends model attributes without wrapping them in 'game' param, and I have to do this: def create game = Game.new(:title=>params[:ti

by passing non-Zend_Form variables to a ViewScript

I'm using Zend_Form with a ViewScript decorator. This form will be for managing two fairly simple types of objects but is a big form so I'd like to have a single form / processing function. So I have this: class GameManagementForm extends Zend_Form{

WPF Navigation between Windows

I have designed 5 windows and all of them are having tab controls. Is there a better way or other ways to navigate between them ? I am now doing it like window1 w = new Window1(); w.Show(); this.Close(); also I am serializing an ApplicationContext cl

ScrollView Android scrolling

I'm working on a project where I have a ScrollView which contains a linearlayout. <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:background="#9e9e9e" android:layout_weight=&quo

hidden menu to include progress bar in Android

Hi i have created an activity which is used for downloading and uploading. I have used a menu(items:download, upload, delete, quit). But when i press the download button, download work begins, but the menu button does not disappear till this task com

Encoding Javascript

how could I convert a text escaped with StringEscpeUtils.escapeJavascript back to the original text in java? I have converted a russian text with escapeJavascript and the result is: \u041F\u043E\u0440\u043E\u0434\u044B, but backwards it is not workin

No Return Time Conversion

My script: $start = strtotime($color_date); $end = strtotime($accessory_date); $days_between = ceil(abs($end - $start) / 86400); The $days_between result should be an integer, but it's returning null. EDIT: $color_date="24/04/2013"; $accessory_d

python: __init__ template

I noticed I often write the following: class X: def __init__(self, var1, var2, var3): self.var1 = var1 self.var2 = var2 self.var3 = var3 # more code here Is it a good idea to make a template that I can reuse instead of doing this every time? If so, h

responsive design - links that come out of div

I am trying to make an existing website responsive. I have an issue when the browser window gets to a certain size the links within the containing div start flowing outside of the div. If I remove the ".main_navigation a {white-space:nowrap;}" i

Filter a list of Python dictionaries based on the key

I would need to filter a list of dictionaries to only retain dictionaries which have a key called "children". Here is an example of list: [{u'id': 5650, u'children': [{u'id': 4635}]}, {u'id': 5648, u'children': [{u'id': 67}, {u'id': 77}]}, {u'id