nested

Nested django templates

有些话、适合烂在心里 提交于 2019-12-03 03:05:52
This seems like a pretty basic thing to do but although I've been using Django for around a year, I've never run into this scenario yet. In a lot of templating/web frameworks, template inheritance works a bit differently, in that usually it behaves more like wrappers, so if you have childtemplate.html, parenttemplate.html, and grandparenttemplate.html, then the finally rendering usually looks something like: grandparent header parent header child header child content parent content parent footer grandparent content grandparent footer That's not exactly how it works in Django but I'm wondering

Why does field declaration with duplicated nested type in generic class results in huge source code increase?

孤街浪徒 提交于 2019-12-03 02:37:02
问题 Scenario is very rare, but quite simple: you define a generic class, then create a nested class which inherits from outer class and define a associative field (of self type) within nested. Code snippet is simpler, than description: class Outer<T> { class Inner : Outer<Inner> { Inner field; } } after decompilation of IL, C# code look like this: internal class Outer<T> { private class Inner : Outer<Outer<T>.Inner> { private Outer<Outer<T>.Inner>.Inner field; } } This seems to be fair enough,

Building ViewModels based on nested Model Entities in WPF and MVVM Pattern

我与影子孤独终老i 提交于 2019-12-03 02:35:26
I have a problem understanding how to build view models based on the following models (I simplified the models to be clearer) public class Hit { public bool On { get; set;} public Track Track { get; set; } } public class Track { public ObservableCollection<Hit> Hits { get; set; } public LinearGradientBrush Color { get; set; } public Pattern Pattern { get; set; } } public class Pattern { public string Name { get; set; } public ObservableCollection<Tracks> Tracks { get; set; } } Now, my problem is, how to build the ViewModels.. I need to keep the original relationships through the models,

How to use enum with grouping and subgrouping hierarchy/nesting

被刻印的时光 ゝ 提交于 2019-12-03 01:31:16
I have one enum 'class' called Example as follows: enum Example { //enums belonging to group A: enumA1, enumA2, enumA3, //enums belonging to group B: enumB1, enumB2, enumB3, //enums belonging to group C: enumC1, enumC2, enumC3; } It's important for my project they all enums I work with belong to Example (since this is an argument in a constructor of a class). How do I use enum hierarchy/nesting in order to achieve the following: A method that tests whether an enum is of group A, B or C. For example, something like Example.enumA1.isGroupBelonging(Group.A) or isGroupBelonging(Example.enumA1

Hadoop MapReduce provide nested directories as job input

为君一笑 提交于 2019-12-03 01:23:33
I'm working on a job that processes a nested directory structure, containing files on multiple levels: one/ ├── three/ │ └── four/ │ ├── baz.txt │ ├── bleh.txt │ └── foo.txt └── two/ ├── bar.txt └── gaa.txt When I add one/ as an input path, no files are processed, since none are immediately available at the root level. I read about job.addInputPathRecursively(..) , but this seems to have been deprecated in the more recent releases (I'm using hadoop 1.0.2). I've written some code to walk the folders and add each dir with job.addInputPath(dir) , which worked until the job crashed when trying to

create a spark dataframe from a nested json file in scala [duplicate]

冷暖自知 提交于 2019-12-03 00:47:40
This question already has an answer here : How to access sub-entities in JSON file? (1 answer) I have a json file that looks like this { "group" : {}, "lang" : [ [ 1, "scala", "functional" ], [ 2, "java","object" ], [ 3, "py","interpreted" ] ] } I tried to create a dataframe using val path = "some/path/to/jsonFile.json" val df = sqlContext.read.json(path) df.show() when I run this I get df: org.apache.spark.sql.DataFrame = [_corrupt_record: string] How do we create a df based on contents of "lang" key? I do not care about group{} all I need is, pull data out of "lang" and apply case class like

How to modify a nested struct on a vector?

你。 提交于 2019-12-03 00:27:23
问题 I am working on a program that keeps inventory of vehicles, so I created a struct for it. It also needs to keep a list of the drivers, so I created a nested struct for that. Here's the code: struct Vehicle { string License; string Place; int Capacity; struct Driver { string Name; int Code; int Id; } dude; }; I ask for user input and then put the structs in a vector using this function: void AddVehicle(vector<Vehicle> &vtnewV) { Vehicle newV; Vehicle::Driver dude; cout << "Enter license plate

Rails 3 - Update div content with Ajax and jquery (nested resources)

亡梦爱人 提交于 2019-12-03 00:21:41
I've two simple models, Pin and Comment, Comments belongs to Pin: class Pin < ActiveRecord::Base has_many :comments, dependent: :destroy and class Comment < ActiveRecord::Base belongs_to :pin In the index action of Pin I've basically a list of all the pins + a div . This div must show all the comments when user select a pin. Concept is quite simple, but I can't figure out how to achieved it. I've found many subjects related, but I always lost myself in the differences with my problem. Some precise questions: How to do this ajax load? (with jquery) Do I need to use partials or use index view of

How to make a triangle with a nested for

北战南征 提交于 2019-12-02 23:54:57
问题 I need to use a nested for loop in Java to make a triangle like this ******** ******* ****** ***** **** *** ** * Heres my code: for (int i=8; i>0; i--) { for (int j=0; j<i; j++) { System.out.print('#'); } System.out.println(""); } I get a triangle but not the one i want. Instead, my triangle looks like this: ******** ******* ****** ***** **** *** ** * 回答1: You'll need the outer loop to count the 8 rows. The inner loop would output the *'s for each row. The row count of the outer loop will

How to turn a list into nested dict in Python

江枫思渺然 提交于 2019-12-02 23:38:35
Need to turn x: X = [['A', 'B', 'C'], ['A', 'B', 'D']] Into Y: Y = {'A': {'B': {'C','D'}}} More specifically, I need to create a tree of folders and files from a list of absolute paths, which looks like this: paths = ['xyz/123/file.txt', 'abc/456/otherfile.txt'] where, each path is split("/") , as per ['A', 'B', 'C'] in the pseudo example. As this represents files and folders, obviously, on the same level (index of the array) same name strings can't repeat. X = [['A', 'B', 'C'], ['A', 'B', 'D'],['W','X'],['W','Y','Z']] d = {} for path in X: current_level = d for part in path: if part not in