Daily Archives

Articles indexed Monday August 25 2014

Page 8/14 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • How can I support objects larger than a single tile in a 2D tile engine?

    - by Yheeky
    I´m currently working on a 2D Engine containing an isometric tile map. It´s running quite well but I'm not sure if I´ve chosen the best approach for that kind of engine. To give you an idea what I´m thinking about right now, let's have a look at a basic object for a tile map and its objects: public class TileMap { public List<MapRow> Rows = new List<MapRow>(); public int MapWidth = 50; public int MapHeight = 50; } public class MapRow { public List<MapCell> Columns = new List<MapCell>(); } public class MapCell { public int TileID { get; set; } } Having those objects it's just possible to assign a tile to a single MapCell. What I want my engine to support is like having groups of MapCells since I would like to add objects to my tile map (e.g. a house with a size of 2x2 tiles). How should I do that? Should I edit my MapCell object that it may has a reference to other related tiles and how can I find an object while clicking on single MapCells? Or should I do another approach using a global container with all objects in it?

    Read the article

  • Django admin.py missing field error

    - by user782400
    When I include 'caption', I get an error saying EntryAdmin.fieldsets[1][1]['fields']' refers to field 'caption' that is missing from the form In the admin.py; I have imported the classes from joe.models import Entry,Image Is that because my class from models.py is not getting imported properly ? Need help in resolving this issue. Thanks. models.py class Image(models.Model): image = models.ImageField(upload_to='joe') caption = models.CharField(max_length=200) imageSrc = models.URLField(max_length=200) user = models.CharField(max_length=20) class Entry(models.Model): image = models.ForeignKey(Image) mimeType = models.CharField(max_length=20) name = models.CharField(max_length=200) password = models.URLField(max_length=50) admin.py class EntryAdmin(admin.ModelAdmin): fieldsets = [ ('File info', {'fields': ['name','password']}), ('Upload image', {'fields': ['image','caption']})] list_display = ('name', 'mimeType', 'password') admin.site.register(Entry, EntryAdmin) admin.site.register(Image)

    Read the article

  • Android app not releasing mic/speaker

    - by SeaRoth
    I have a VOIP application that blocks the microphone and speaker after using it! Steps to reproduce: Place a call on 4G (both mic and speaker work) Place a call on app (both mic and speaker work) Place a call on 4G (Neither mic nor speaker work) Steps to fix mic and speaker: Open applications / Voice Recorder Record something quickly Place call (both mic and speaker work) I have 2 classes with about 300 lines of code each: RtpStreamReceiver RtpStreamSender Am I not releasing something?

    Read the article

  • Implement date picker and time picker in button click and store in edit text boxes

    - by user3597791
    Hi I am trying to implement a date picker and time picker in button click and store in edit text boxes. I have tried numerous things but since i suck at coding I cant get any of them to work. Please find my class and xml below and i would be grateful for any help import android.app.Activity; import android.content.Intent; import android.database.Cursor; import android.graphics.BitmapFactory; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.Toast; public class NewEvent extends Activity { private static int RESULT_LOAD_IMAGE = 1; private EventHandler handler; private String picturePath = ""; private String name; private String place; private String date; private String time; private String photograph; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.new_event); handler = new EventHandler(getApplicationContext()); ImageView iv_user_photo = (ImageView) findViewById(R.id.iv_user_photo); iv_user_photo.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, RESULT_LOAD_IMAGE); } }); Button btn_add = (Button) findViewById(R.id.btn_add); btn_add.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { EditText et_name = (EditText) findViewById(R.id.et_name); name = et_name.getText().toString(); EditText et_place = (EditText) findViewById(R.id.et_place); place = et_place.getText().toString(); EditText et_date = (EditText) findViewById(R.id.et_date); date = et_date.getText().toString(); EditText et_time = (EditText) findViewById(R.id.et_time); time = et_time.getText().toString(); ImageView iv_photograph = (ImageView) findViewById(R.id.iv_user_photo); photograph = picturePath; Event event = new Event(); event.setName(name); event.setPlace(place); event.setDate(date); event.setTime(time); event.setPhotograph(photograph); Boolean added = handler.addEventDetails(event); if(added){ Intent intent = new Intent(NewEvent.this, MainEvent.class); startActivity(intent); }else{ Toast.makeText(getApplicationContext(), "Event data not added. Please try again", Toast.LENGTH_LONG).show(); } } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) { Uri imageUri = data.getData(); String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(imageUri, filePathColumn, null, null, null); cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); picturePath = cursor.getString(columnIndex); cursor.close(); Here is my xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="10dp"> <TextView android:id="@+id/tv_new_event_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Add New Event" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_alignParentTop="true" /> <Button android:id="@+id/btn_add" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Add Event" android:layout_alignParentBottom="true" /> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@id/tv_new_event_title" android:layout_above="@id/btn_add"> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <ImageView android:id="@+id/iv_user_photo" android:src="@drawable/add_user_icon" android:layout_width="100dp" android:layout_height="100dp"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Event:" /> <EditText android:id="@+id/et_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputType="text" > <requestFocus /> </EditText> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Place:" /> <EditText android:id="@+id/et_place" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputType="text" > <requestFocus /> </EditText> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Date:" /> <EditText android:id="@+id/et_date" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputType="date" /> <Button android:id="@+id/button" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <requestFocus /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Time:" /> <EditText android:id="@+id/et_time" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputType="time" /> <Button android:id="@+id/button1" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button1" /> <requestFocus /> </LinearLayout> </ScrollView> </RelativeLayout>

    Read the article

  • Python: Is there a way to get HTML that was dynamically created by Javascript?

    - by Joschua
    As far as I can tell, this is the case for LyricWikia. The lyrics (example) can be accessed from the browser, but can't be found in the source code (can be opened with CTRL + U in most browsers) or reading the contents of the site with Python: from urllib.request import urlopen URL = 'http://lyrics.wikia.com/Billy_Joel:Piano_Man' r = urlopen(URL).read().decode('utf-8') And the test: >>> 'Now John at the bar is a friend of mine' in r False >>> 'John' in r False But when you select and look at the source code of the box in which the lyrics are displayed, you can see that there is: <div class="lyricbox">[...]</div> Is there a way to get the contents of that div-element with Python?

    Read the article

  • Android ACTION_BOOT_COMPLETED called everytime?

    - by user3976029
    I am trying to write a code in Android , to create a condition during booting but my condition satisfies everytime ( during booting as well as during running of the device also). I am trying to do is , to execute the condition during the booting only. My Code : MainActivity.java package com.example.bootingtest; import android.os.Bundle; import android.widget.Toast; import android.app.Activity; import android.content.Intent; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (Intent.ACTION_BOOT_COMPLETED!=null) { Toast.makeText(getApplicationContext(), "Device is booting ...", Toast.LENGTH_LONG).show(); } } } I have given manifest permission . <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> I want to execute this condition only during booting or device start-up but this condition satisfies every time , whenever i open the app. Please suggest me , how can i run the condition only during the device booting or start-up. Please help me out.

    Read the article

  • Extracting specific words that end with .c and .h [on hold]

    - by Alberto Mederos
    I have a very big list of file names that end with a the following: .c .h .cpp and much more. I need to extract file names that end with .c and .h How do I do that? Also, how could I add quotation marks to the beginning and end of the word, followed with a comma? For example, if I have this in the list: mi_var.c How could I extract it from a very big list, and everything else that ends in .c and replace it to have quotation marks and a comma at the end? Like this: "mi_var.c", I'm new to this, any help is greatly appreciated. Here is part of the list: gsd5t_image.c, gsd5t_image_sqif.c, proc_arm.c, proc_cortex.c, proc_k32.c, proc_k32_entry.s, proc_k32_test.c, proc_k32_test_start.s, rom_sub_functions.s, rom_sub_functions_gcc.s, sqif_jump_table.s, sqif_jump_table_gcc.s, tracker_wrapper_functions.s, vector_M0.c, ptimer.c, ptimer_arm.c, ptimer_internal.h, ptimer_internal_arm.h, ptimer_internal_k32.h, ptimer_k32.c, RstMod_if.h, drvRstMod.h, tbus.dxy, tbus_common.c, tbus_common.h, act.c, act.h, act.msgs, act_if.c, act_if.h, sat_signal_processor.c, sat_signal_processor.h, ssp.dxy, ssp.msgs, ssp_acq_handlers.c, ssp_acq_handlers.h, ssp_atx_if.c, ssp_atx_if.h, ssp_bitsync_handlers.c, ssp_bitsync_handlers.h, ssp_cohver_handlers.c, ssp_cohver_handlers.h, ssp_cwscan_handlers.c, ssp_cwscan_handlers.h, ssp_track_handlers.c, ssp_track_handlers.h, ssp_atx_if_test_sort.c, ssp_hack.c, ssp_hack.h, ssp_suite.cpp, ssp_suite.h, ssptloop.c, ssptloop.h, sss.dxy, sss.msgs, sss_atx_if.c, sss_atx_if.h, strong_signal_scan.c, So how to extract certain names?

    Read the article

  • Expandable paragraphs with HTML and CSS

    - by user3704175
    I was wondering if anyone here would be as so kind as to help me out a bit. I am looking to make expandable paragraphs for my client's website. They would like to keep all of the content from their site, which is pretty massive, and they want a total overhaul of the design. They mainly wan tot keep it for SEO purposes. Anyhow, I thought it would be helpful for the both of use if there is some way to use expandable paragraphs, you know, with a "read more..." link after a certain line of text. I know that there are some JQuery and Java solutions for this, but we really would like to stay away from those options, if at all possible. When would like HTML and CSS, if we can. Here is kind of an example: HEADING HERE Paragraph with a bunch of text. I would like this to appear in a pre-determined line. For example, maybe the start of the paragraph goes on for, let's say, three lines and then we have the [read more...] When the visitor clicks "read more", we would like the rest of the content to just expand to reveal the article in its entirety. I would like for the content to already be on the page, so it just expands. I don't want it to be called in from another file or anything, if that makes sense. Thank you in advance for any and all help. It will be greatly appreciated! Testudo

    Read the article

  • traverse a string char by char javascript

    - by mikeandike
    function SimpleSymbols(str) { var letter =['a','b','c','d','e','f','g','h','i','j', 'k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']; var newstr = ""; for (var i = 0; i<str.length; i++){ if (str.charAt(i).toLowerCase() in letter){ newstr += "M"; } else{ newstr += "X"; } } return newstr; } If str is "Argument goes here" it returns XXXXXXXXX. WHy doesn't it return MMMMMMMMMM?

    Read the article

  • Parse and transform XML with missing elements into table structure

    - by dnlbrky
    I'm trying to parse an XML file. A simplified version of it looks like this: x <- '<grandparent><parent><child1>ABC123</child1><child2>1381956044</child2></parent><parent><child2>1397527137</child2></parent><parent><child3>4675</child3></parent><parent><child1>DEF456</child1><child3>3735</child3></parent><parent><child1/><child3>3735</child3></parent></grandparent>' library(XML) xmlRoot(xmlTreeParse(x)) ## <grandparent> ## <parent> ## <child1>ABC123</child1> ## <child2>1381956044</child2> ## </parent> ## <parent> ## <child2>1397527137</child2> ## </parent> ## <parent> ## <child3>4675</child3> ## </parent> ## <parent> ## <child1>DEF456</child1> ## <child3>3735</child3> ## </parent> ## <parent> ## <child1/> ## <child3>3735</child3> ## </parent> ## </grandparent> I'd like to transform the XML into a data.frame / data.table that looks like this: parent <- data.frame(child1=c("ABC123",NA,NA,"DEF456",NA), child2=c(1381956044, 1397527137, rep(NA, 3)), child3=c(rep(NA, 2), 4675, 3735, 3735)) parent ## child1 child2 child3 ## 1 ABC123 1381956044 NA ## 2 <NA> 1397527137 NA ## 3 <NA> NA 4675 ## 4 DEF456 NA 3735 ## 5 <NA> NA 3735 If each parent node always contained all of the possible elements ("child1", "child2", "child3", etc.), I could use xmlToList and unlist to flatten it, and then dcast to put it into a table. But the XML often has missing child elements. Here is an attempt with incorrect output: library(data.table) ## Flatten: dt <- as.data.table(unlist(xmlToList(x)), keep.rownames=T) setnames(dt, c("column", "value")) ## Add row numbers, but they're incorrect due to missing XML elements: dt[, row:=.SD[,.I], by=column][] column value row 1: parent.child1 ABC123 1 2: parent.child2 1381956044 1 3: parent.child2 1397527137 2 4: parent.child3 4675 1 5: parent.child1 DEF456 2 6: parent.child3 3735 2 7: parent.child3 3735 3 ## Reshape from long to wide, but some value are in the wrong row: dcast.data.table(dt, row~column, value.var="value", fill=NA) ## row parent.child1 parent.child2 parent.child3 ## 1: 1 ABC123 1381956044 4675 ## 2: 2 DEF456 1397527137 3735 ## 3: 3 NA NA 3735 I won't know ahead of time the names of the child elements, or the count of unique element names for children of the grandparent, so the answer should be flexible.

    Read the article

  • AngularJS: download pdf file from the server

    - by Bartosz Bialecki
    I want to download a pdf file from the web server using $http. I use this code which works great, my file only is save as a html file, but when I open it it is opened as pdf but in the browser. I tested it on Chrome 36, Firefox 31 and Opera 23. This is my angularjs code (based on this code): UserService.downloadInvoice(hash).success(function (data, status, headers) { var filename, octetStreamMime = "application/octet-stream", contentType; // Get the headers headers = headers(); if (!filename) { filename = headers["x-filename"] || 'invoice.pdf'; } // Determine the content type from the header or default to "application/octet-stream" contentType = headers["content-type"] || octetStreamMime; if (navigator.msSaveBlob) { var blob = new Blob([data], { type: contentType }); navigator.msSaveBlob(blob, filename); } else { var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL; if (urlCreator) { // Try to use a download link var link = document.createElement("a"); if ("download" in link) { // Prepare a blob URL var blob = new Blob([data], { type: contentType }); var url = urlCreator.createObjectURL(blob); $window.saveAs(blob, filename); return; link.setAttribute("href", url); link.setAttribute("download", filename); // Simulate clicking the download link var event = document.createEvent('MouseEvents'); event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null); link.dispatchEvent(event); } else { // Prepare a blob URL // Use application/octet-stream when using window.location to force download var blob = new Blob([data], { type: octetStreamMime }); var url = urlCreator.createObjectURL(blob); $window.location = url; } } } }).error(function (response) { $log.debug(response); }); On my server I use Laravel and this is my response: $headers = array( 'Content-Type' => $contentType, 'Content-Length' => strlen($data), 'Content-Disposition' => $contentDisposition ); return Response::make($data, 200, $headers); where $contentType is application/pdf and $contentDisposition is attachment; filename=" . basename($fileName) . '"' $filename - e.g. 59005-57123123.PDF My response headers: Cache-Control:no-cache Connection:Keep-Alive Content-Disposition:attachment; filename="159005-57123123.PDF" Content-Length:249403 Content-Type:application/pdf Date:Mon, 25 Aug 2014 15:56:43 GMT Keep-Alive:timeout=3, max=1 What am I doing wrong?

    Read the article

  • DELETE causing a redirect loop?

    - by robocode
    I have an express app with a postgres backend where a user can add/delete recipes, and each time they do so they get an updated list of recipes. Adding a recipe is fine, but when I delete one it seems to get stuck in a redirect loop. In app.js I have router.get('/delete/:d', delRec.deleteRecipe); which calls the following code exports.deleteRecipe = function(req, res){ pg.connect(conString, function(err, client) { client.query('DELETE FROM recipes WHERE recipe_name = ', [req.params.d], function(err, result) { if(err) { return console.error('error running query', err); } else if (result) { pg.end(); console.log('deleting'); } }); }); res.redirect('recipes'); }; If I try delete a recipe, console.log('deleting') produces deleting deleting deleting deleting deleting deleting deleting deleting deleting deleting deleting deleting deleting deleting deleting deleting deleting deleting deleting deleting deleting The recipes route is below (sorry that it's so convoluted) router.get('/recipes', function(req, res) { pg.connect(conString, function(err, client) { if(err) { return console.error('could not connect to postgres', err); } client.query('SELECT * FROM recipes', function(err, result) { if(err) { return console.error('error running query', err); } recipes = result.rows; for(var d in recipes) { if (recipes.hasOwnProperty(d)) { recipeList[d] = recipes[d].recipe_name; } } res.render('recipes', {recipes: recipes, recipeList: recipeList}); }); }); });

    Read the article

  • How to draw flowchart for code involving opening from text file and reading them

    - by problematic
    like this code fp1=fopen("Fruit.txt","r"); if(fp1==NULL) { printf("ERROR in opening file\n"); return 1; } else { for(i=0;i<lines;i++)//reads Fruits.txt database { fgets(product,sizeof(product),fp1); id[i]=atoi(strtok(product,",")); strcpy(name[i],strtok(NULL,",")); price[i]=atof(strtok(NULL,",")); stock[i]=atoi(strtok(NULL,"\n")); } } fclose(fp1); These symbols sound too similar to differentiate their function,can anyone helps me by any method, or use names of shape according to this site http://www.breezetree.com/article-excel-flowchart-shapes.htm

    Read the article

  • Entity Framework autoincrement key

    - by Tommy Ong
    I'm facing an issue of duplicated incremental field on a concurrency scenario. I'm using EF as the ORM tool, attempting to insert an entity with a field that acts as a incremental INT field. Basically this field is called "SequenceNumber", where each new record before insert, will read the database using MAX to get the last SequenceNumber, append +1 to it, and saves the changes. Between the getting of last SequenceNumber and Saving, that's where the concurrency is happening. I'm not using ID for SequenceNumber as it is not a unique constraint, and may reset on certain conditions such as monthly, yearly, etc. InvoiceNumber | SequenceNumber | DateCreated INV00001_08_14 | 1 | 25/08/2014 INV00001_08_14 | 1 | 25/08/2014 <= (concurrency is creating two SeqNo 1) INV00002_08_14 | 2 | 25/08/2014 INV00003_08_14 | 3 | 26/08/2014 INV00004_08_14 | 4 | 27/08/2014 INV00005_08_14 | 5 | 29/08/2014 INV00001_09_14 | 1 | 01/09/2014 <= (sequence number reset) Invoice number is formatted based on the SequenceNumber. After some research I've ended up with these possible solutions, but wanna know the best practice 1) Optimistic Concurrency, locking the table from any reads until the current transaction is completed (not fancy of this idea as I guess performance will be of a great impact?) 2) Create a Stored Procedure solely for this purpose, does select and insert on a single statement as such concurrency is at minimum (would prefer a EF based approach if possible)

    Read the article

  • Problems with with A* algorithm

    - by V_Programmer
    I'm trying to implement the A* algorithm in Java. I followed this tutorial,in particular, this pseudocode: http://theory.stanford.edu/~amitp/GameProgramming/ImplementationNotes.html The problem is my code doesn't work. It goes into an infinite loop. I really don't know why this happens... I suspect that the problem are in F = G + H function implemented in Graph constructors. I suspect I am not calculate the neighbor F correclty. Here's my code: List<Graph> open; List<Graph> close; private void createRouteAStar(Unit u) { open = new ArrayList<Graph>(); close = new ArrayList<Graph>(); u.ai_route_endX = 11; u.ai_route_endY = 5; List<Graph> neigh; int index; int i; boolean finish = false; Graph current; int cost; Graph start = new Graph(u.xMap, u.yMap, 0, ManhattanDistance(u.xMap, u.yMap, u.ai_route_endX, u.ai_route_endY)); open.add(start); current = start; while(!finish) { index = findLowerF(); current = new Graph(open, index); System.out.println(current.x); System.out.println(current.y); if (current.x == u.ai_route_endX && current.y == u.ai_route_endY) { finish = true; } else { close.add(current); neigh = current.getNeighbors(); for (i = 0; i < neigh.size(); i++) { cost = current.g + ManhattanDistance(current.x, current.y, neigh.get(i).x, neigh.get(i).y); if (open.contains(neigh.get(i)) && cost < neigh.get(i).g) { open.remove(open.indexOf(neigh)); } else if (close.contains(neigh.get(i)) && cost < neigh.get(i).g) { close.remove(close.indexOf(neigh)); } else if (!open.contains(neigh.get(i)) && !close.contains(neigh.get(i))) { neigh.get(i).g = cost; neigh.get(i).f = cost + ManhattanDistance(neigh.get(i).x, neigh.get(i).y, u.ai_route_endX, u.ai_route_endY); neigh.get(i).setParent(current); open.add(neigh.get(i)); } } } } System.out.println("step"); for (i=0; i < close.size(); i++) { if (close.get(i).parent != null) { System.out.println(i); System.out.println(close.get(i).parent.x); System.out.println(close.get(i).parent.y); } } } private int findLowerF() { int i; int min = 10000; int minIndex = -1; for (i=0; i < open.size(); i++) { if (open.get(i).f < min) { min = open.get(i).f; minIndex = i; System.out.println("min"); System.out.println(min); } } return minIndex; } private int ManhattanDistance(int ax, int ay, int bx, int by) { return Math.abs(ax-bx) + Math.abs(ay-by); } And, as I've said. I suspect that the Graph class has the main problem. However I've not been able to detect and fix it. public class Graph { int x, y; int f,g,h; Graph parent; public Graph(int x, int y, int g, int h) { this.x = x; this.y = y; this.g = g; this.h = h; this.f = g + h; } public Graph(List<Graph> list, int index) { this.x = list.get(index).x; this.y = list.get(index).y; this.g = list.get(index).g; this.h = list.get(index).h; this.f = list.get(index).f; this.parent = list.get(index).parent; } public Graph(Graph gp) { this.x = gp.x; this.y = gp.y; this.g = gp.g; this.h = gp.h; this.f = gp.f; } public Graph(Graph gp, Graph parent) { this.x = gp.x; this.y = gp.y; this.g = gp.g; this.h = gp.h; this.f = g + h; this.parent = parent; } public List<Graph> getNeighbors() { List<Graph> aux = new ArrayList<Graph>(); aux.add(new Graph(x+1, y, g,h)); aux.add(new Graph(x-1, y, g,h)); aux.add(new Graph(x, y+1, g,h)); aux.add(new Graph(x, y-1, g,h)); return aux; } public void setParent(Graph g) { parent = g; } } Little Edit: Using the System.out and the Debugger I discovered that the program ALWAYS is check the same "current" graph, (15,8) which is the (u.xMap, u.yMap) position. Looks like it keeps forever in the first step.

    Read the article

  • Virtualhost subdomain Internal Server Error

    - by Andrew
    I am trying to set up user generated sub domains for my PHP application. When I go to sub.domain.com and if I upload an index.html file it works fine, however if I use index.php it gives me a "Internal Server Error 500" message I have done the steps below to get subdomains working STEP 1: Edited my DNZ zone file and appended *.domain.com. IN A 91.111.111.111 STEP 2: Appended to httpd.conf the following: <VirtualHost 91.111.111.111:80> ServerName domain.com ServerAlias *.domain.com DocumentRoot /home/domain/public_html/sub <Directory "/home/domain/public_html/sub"> Options -Indexes Options FollowSymLinks AllowOverride All </Directory> </VirtualHost> Step 3: Tested by uploading an index.html file to the document directory in step 2, and works fine. Tried with an index.php gives a internal server error and then I looked into Apache error log and shows error for a redirect loop more than 10 times Update: getting this error: No user or group set - set suPHP_UserGroup Any ideas why I can not use any .php file in the directory?

    Read the article

  • Detaching all entities of T to get fresh data

    - by Goran
    Lets take an example where there are two type of entites loaded: Product and Category, Product.CategoryId - Category.Id. We have available CRUD operations on products (not Categories). If on another screen Categories are updated (or from another user in the network), we would like to be able to reload the Categories, while preserving the context we currently use, since we could be in the middle of editing data, and we do not want changes to be lost (and we cannot depend on saving, since we have incomplete data). Since there is no easy way to tell EF to get fresh data (added, removed and modified), we thought of twp possible ways: 1) Getting products attached to context, and categories detached from context. This would mean that we loose the ability to access Product.Category.Name, which we do sometimes require, so we would need to manually resolve it (example when printing data). 2) detaching / attaching all Categories from current context. Context.ChangeTracker.Entries().Where(x => x.Entity.GetType() == typeof(T)).ForEach(x => x.State = EntityState.Detached); And then reload the categories, which will get fresh data. Do you find any problem with this second approach? We understand that this will require all constraints to be put on foreign keys, and not navigation properties, since when detaching all Categories, Product.Category navigation properties would be reset to null also. Also, there could be a potential performance problem, which we did not test, since there could be couple of thousand products loaded, and all would need to resolve navigation property when reloading. Which of the two do you prefer, and is there a better way (EF6 + .NET 4.0)?

    Read the article

  • How to find which file is open in eclipse editor without using IEditorPart?

    - by Destructor
    I want to know which file (or even project is enough) is opened in eclipse editor? I know we can do this once we get IEditorPart from doSetInput method, IFile file = ((IFileEditorInput) iEditorPart).getFile(); But I want the name of file without using IEditorPart, how can I do the same? Checking which is the selected file in project explorer is not of much help because, user can select multiple files at once and open all simultaneously and I did not way to distinguish which file opened at what time. Adding more info: I have an editor specified for a particular type of file, now every time it opens, during intializing editor I have some operation to do based on project properties. While initializing editor, I need the file handle (of the one which user opened/double clicked) or the corresponding project handle. I have my editor something this way: public class MyEditor extends TextEditor{ @Override protected void initializeEditor() { setSourceViewerConfiguration(new MySourceViewerConfiguration( CDTUITools.getColorManager(), store, "MyPartitions", this)); } //other required methods @Override protected void doSetInput(IEditorInput input) throws CoreException { if(input instanceof IFileEditorInput) { IFile file = ((IFileEditorInput) input).getFile(); } } } as I have done in the doSetInput() method , I want the file handle(even project handle is sufficient). But the problem is in initializeEditor() function there is no reference to editorInput, hence I am unable to get the file handle. In the source viewer configuration file, I set the code scanners and this needs some project specific information that will set the corresponding rules.

    Read the article

  • R: Plotting a graph with different colors of points based on advanced criteria

    - by balconydoor
    What I would like to do is a plot (using ggplot), where the x axis represent years which have a different colour for the last three years in the plot than the rest. The last three years should also meet a certain criteria and based on this the last three years can either be red or green. The criteria is that the mean of the last three years should be less (making it green) or more (making it red) than the 66%-percentile of the remaining years. So far I have made two different functions calculating the last three year mean: LYM3 <- function (x) { LYM3 <- tail(x,3) mean(LYM3$Data,na.rm=T) } And the 66%-percentile for the remaining: perc66 <- function(x) { percentile <- head(x,-3) quantile(percentile$Data, .66, names=F,na.rm=T) } Here are two sets of data that can be used in the calculations (plots), the first which is an example from my real data where LYM3(df1) < perc66(df1) and the second is just made up data where LYM3 perc66. df1<- data.frame(Year=c(1979:2010), Data=c(347261.87, 145071.29, 110181.93, 183016.71, 210995.67, 205207.33, 103291.78, 247182.10, 152894.45, 170771.50, 206534.55, 287770.86, 223832.43, 297542.86, 267343.54, 475485.47, 224575.08, 147607.81, 171732.38, 126818.10, 165801.08, 136921.58, 136947.63, 83428.05, 144295.87, 68566.23, 59943.05, 49909.08, 52149.11, 117627.75, 132127.79, 130463.80)) df2 <- data.frame(Year=c(1979:2010), Data=c(sample(50,29,replace=T),75,75,75)) Here’s my code for my plot so far: plot <- ggplot(df1, aes(x=Year, y=Data)) + theme_bw() + geom_point(size=3, aes(colour=ifelse(df1$Year<2008, "black",ifelse(LYM3(df1) < perc66(df1),"green","red")))) + geom_line() + scale_x_continuous(breaks=c(1980,1985,1990,1995,2000,2005,2010), limits=c(1978,2011)) plot As you notice it doesn’t really do what I want it to do. The only thing it does seem to do is that it turns the years before 2008 into one level and those after into another one and base the point colour off these two levels. Since I don’t want this year to be stationary either, I made another tiny function: fun3 <- function(x) { df <- subset(x, Year==(max(Year)-2)) df$Year } So the previous code would have the same effect as: geom_point(size=3, aes(colour=ifelse(df1$Year<fun3(df1), "black","red"))) But it still does not care about my colours. Why does it make the years into levels? And how come an ifelse function doesn’t work within another one in this case? How would it be possible to the arguments to do what I like? I realise this might be a bit messy, asking for a lot at the same time, but I hope my description is pretty clear. It would be helpful if someone could at least point me in the right direction. I tried to put the code for the plot into a function as well so I wouldn’t have to change the data frame at all functions within the plot, but I can’t get it to work. Thank you!

    Read the article

  • Liferay Document Management System Workflow

    - by Rajkumar
    I am creating a DMS in Liferay. So far I could upload documents in Liferay in document library. And also i can see documents in document and media portlet. The problem is though status for the document is in pending state, the workflow is not started. Below is my code. Anyone please help. Very urgent. Folder folder = null; // getting folder try { folder = DLAppLocalServiceUtil.getFolder(10181, 0, folderName); System.out.println("getting folder"); } catch(NoSuchFolderException e) { // creating folder System.out.println("creating folder"); try { folder = DLAppLocalServiceUtil.addFolder(userId, 10181, 0, folderName, description, serviceContext); } catch (PortalException e3) { // TODO Auto-generated catch block e3.printStackTrace(); } catch (SystemException e3) { // TODO Auto-generated catch block e3.printStackTrace(); } } catch (PortalException e4) { // TODO Auto-generated catch block e4.printStackTrace(); } catch (SystemException e4) { // TODO Auto-generated catch block e4.printStackTrace(); } // adding file try { System.out.println("New File"); fileEntry = DLAppLocalServiceUtil.addFileEntry(userId, 10181, folder.getFolderId(), sourceFileName, mimeType, title, "testing description", "changeLog", sampleChapter, serviceContext); Map<String, Serializable> workflowContext = new HashMap<String, Serializable>(); workflowContext.put("event",DLSyncConstants.EVENT_CHECK_IN); DLFileEntryLocalServiceUtil.updateStatus(userId, fileEntry.getFileVersion().getFileVersionId(), WorkflowConstants.ACTION_PUBLISH, workflowContext, serviceContext); System.out.println("after entry"+ fileEntry.getFileEntryId()); } catch (DuplicateFileException e) { } catch (PortalException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SystemException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } catch (PortalException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return fileEntry.getFileEntryId(); } I have even used WorkflowHandlerRegistryUtil.startWorkflowInstance(companyId, userId, fileEntry.getClass().getName(), fileEntry.getClassPK, fileEntry, serviceContext); But still i have the same problem

    Read the article

  • Annotation retention policy: what real benefit is there in declaring `SOURCE` or `CLASS`?

    - by watery
    I know there are three retention policies for Java annotations: CLASS: Annotations are to be recorded in the class file by the compiler but need not be retained by the VM at run time. RUNTIME: Annotations are to be recorded in the class file by the compiler and retained by the VM at run time, so they may be read reflectively. SOURCE: Annotations are to be discarded by the compiler. And although I understand their usage scenarios, I don't get why it is such an important thing to specify the retention policy that retention policies exist at all. I mean, why aren't all the annotations just kept at runtime? Do they generate so much bytecode / occupy so much memory that stripping those undeclared as RUNTIME does make that much difference?

    Read the article

  • Devexpress Repository ComboBoxEdit loosing cursor position. Edit.SelectionStart Not being assigned

    - by user575219
    I am having an issue with my comboBoxEdit in a gridcontrol. I am using Winforms Devepress 11.2. I clicked in the text of an existing Repository comboBoxEdit, and typed in "appear backwards", however, it displayed as "sdrawkcab raeppa" like it would in a mirror. There are some posts about this topic but none of the solutions seem to work The reason for this is the following foreach (GridColumn column in this.gvNotes.Columns) { var columnEdit = column.ColumnEdit; if (columnEdit != null) { column.ColumnEdit.EditValueChanged += this.PostEditValueChanged; } } private void PostEditValueChanged(object sender, EventArgs e) { this.gvNotes.PostEditor(); } This PostEditor ensures the save button is enabled when the user is still in the current cell. The user does not need to leave the cell or change column for the changes to be posted to the grid. So this is what I did: private void PostEditValueChanged(object sender, EventArgs e) { ComboBoxEdit edit = this.gridNotes.FocusedView.ActiveEditor as ComboBoxEdit; if (edit != null) { int len = edit.SelectionLength; int start = edit.SelectionStart; gridNotes.FocusedView.PostEditor(); edit.SelectionLength = len; edit.SelectionStart = start; } This did not solve the problem of the cursor resetting to the start position. Edit.SelectionStart is not being assinged to the len value.Even though len changes to 1 edit.SelectionStart remains at 0 Does anyone know what event needs to be handled to not loose the cursor position?

    Read the article

  • Adding a variable href attribute to a hyperlink using XSLT

    - by Pete
    I need to create links using dynamic values for both the URL and the anchor text. I have column called URL, which contains URL's, i.e., http://stackoverflow.com, and I have a column called Title, which contains the text for the anchor, i.e., This Great Site. I figure maybe all I need to do is nest this tags, along with a little HTML to get my desired result: <a href="> <xsl:value-of select="@URL">"> <xsl:value-of select="@Title"/> </xsl:value-of> </a> In my head, this would render: <a href=" http://stackoverflow.com"> This Great Site </a> I know there's more to it, but I haven't been able to clearly understand what more I need. I think this issue has been addressed before, but not in a way I could understand it. I'd be more than happy to improve the question's title to help noobs like myself find this item, and hopefully an answer. Any help is greatly appreciated.

    Read the article

  • Phonegap - iOS keyboard is not hiding on outside tap of input field

    - by Prasoon
    On input text focus, keyboard appears as expected. But when I click outside of the input text, keyboard does not hide. I am using java script and jQuery. With jQueryMobile JS and CSS - page behaves correctly. But for this project we are not using jQueryMobile. This problem is only with iOS simulator/device. With Android, it's working perfectly fine. I even tried using document.activeElement.blur(); on outer element click/tap. But then I am unable to focus to input text, because that input text is inside that outer element.

    Read the article

  • Hadoop streaming with Python and python subprocess

    - by Ganesh
    I have established a basic hadoop master slave cluster setup and able to run mapreduce programs (including python) on the cluster. Now I am trying to run a python code which accesses a C binary and so I am using the subprocess module. I am able to use the hadoop streaming for a normal python code but when I include the subprocess module to access a binary, the job is getting failed. As you can see in the below logs, the hello executable is recognised to be used for the packaging, but still not able to run the code. . . packageJobJar: [/tmp/hello/hello, /app/hadoop/tmp/hadoop-unjar5030080067721998885/] [] /tmp/streamjob7446402517274720868.jar tmpDir=null JarBuilder.addNamedStream hello . . 12/03/07 22:31:32 INFO mapred.FileInputFormat: Total input paths to process : 1 12/03/07 22:31:32 INFO streaming.StreamJob: getLocalDirs(): [/app/hadoop/tmp/mapred/local] 12/03/07 22:31:32 INFO streaming.StreamJob: Running job: job_201203062329_0057 12/03/07 22:31:32 INFO streaming.StreamJob: To kill this job, run: 12/03/07 22:31:32 INFO streaming.StreamJob: /usr/local/hadoop/bin/../bin/hadoop job -Dmapred.job.tracker=master:54311 -kill job_201203062329_0057 12/03/07 22:31:32 INFO streaming.StreamJob: Tracking URL: http://master:50030/jobdetails.jsp?jobid=job_201203062329_0057 12/03/07 22:31:33 INFO streaming.StreamJob: map 0% reduce 0% 12/03/07 22:32:05 INFO streaming.StreamJob: map 100% reduce 100% 12/03/07 22:32:05 INFO streaming.StreamJob: To kill this job, run: 12/03/07 22:32:05 INFO streaming.StreamJob: /usr/local/hadoop/bin/../bin/hadoop job -Dmapred.job.tracker=master:54311 -kill job_201203062329_0057 12/03/07 22:32:05 INFO streaming.StreamJob: Tracking URL: http://master:50030/jobdetails.jsp?jobid=job_201203062329_0057 12/03/07 22:32:05 ERROR streaming.StreamJob: Job not Successful! 12/03/07 22:32:05 INFO streaming.StreamJob: killJob... Streaming Job Failed! Command I am trying is : hadoop jar contrib/streaming/hadoop-*streaming*.jar -mapper /home/hduser/MARS.py -reducer /home/hduser/MARS_red.py -input /user/hduser/mars_inputt -output /user/hduser/mars-output -file /tmp/hello/hello -verbose where hello is the C executable. It is a simple helloworld program which I am using to check the basic functioning. My Python code is : #!/usr/bin/env python import subprocess subprocess.call(["./hello"]) Any help with how to get the executable run with Python in hadoop streaming or help with debugging this will get me forward in this. Thanks, Ganesh

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14  | Next Page >