Daily Archives

Articles indexed Saturday October 13 2012

Page 4/15 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • @PersistenceContext cannot be resolved to a type

    - by Saken Kungozhin
    i was running a code in which there's a dependency @PersistenceContext and field private EntityManager em; both of which cannot be resolved to a type, what is the meaning of this error and how can i fix it? the code is here: package org.jboss.tools.examples.util; import java.util.logging.Logger;` import javax.enterprise.context.RequestScoped; import javax.enterprise.inject.Produces; import javax.enterprise.inject.spi.InjectionPoint; import javax.faces.context.FacesContext; /** * This class uses CDI to alias Java EE resources, such as the persistence context, to CDI beans * * <p> * Example injection on a managed bean field: * </p> * * <pre> * &#064;Inject * private EntityManager em; * </pre> */ public class Resources { // use @SuppressWarnings to tell IDE to ignore warnings about field not being referenced directly @SuppressWarnings("unused") @Produces @PersistenceContext private EntityManager em; @Produces public Logger produceLog(InjectionPoint injectionPoint) { return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); } @Produces @RequestScoped public FacesContext produceFacesContext() { return FacesContext.getCurrentInstance(); } }

    Read the article

  • Core Animation bad access on device

    - by user1595102
    I'm trying to do a frame by frame animation with CAlayers. I'm doing this with this tutorial http://mysterycoconut.com/blog/2011/01/cag1/ but everything works with disable ARC, when I'm try to rewrite code with ARC, it's works on simulator perfectly but on device I got a bad access memory. Layer Class interface #import <Foundation/Foundation.h> #import <QuartzCore/QuartzCore.h> @interface MCSpriteLayer : CALayer { unsigned int sampleIndex; } // SampleIndex needs to be > 0 @property (readwrite, nonatomic) unsigned int sampleIndex; // For use with sample rects set by the delegate + (id)layerWithImage:(CGImageRef)img; - (id)initWithImage:(CGImageRef)img; // If all samples are the same size + (id)layerWithImage:(CGImageRef)img sampleSize:(CGSize)size; - (id)initWithImage:(CGImageRef)img sampleSize:(CGSize)size; // Use this method instead of sprite.sampleIndex to obtain the index currently displayed on screen - (unsigned int)currentSampleIndex; @end Layer Class implementation @implementation MCSpriteLayer @synthesize sampleIndex; - (id)initWithImage:(CGImageRef)img; { self = [super init]; if (self != nil) { self.contents = (__bridge id)img; sampleIndex = 1; } return self; } + (id)layerWithImage:(CGImageRef)img; { MCSpriteLayer *layer = [(MCSpriteLayer*)[self alloc] initWithImage:img]; return layer ; } - (id)initWithImage:(CGImageRef)img sampleSize:(CGSize)size; { self = [self initWithImage:img]; if (self != nil) { CGSize sampleSizeNormalized = CGSizeMake(size.width/CGImageGetWidth(img), size.height/CGImageGetHeight(img)); self.bounds = CGRectMake( 0, 0, size.width, size.height ); self.contentsRect = CGRectMake( 0, 0, sampleSizeNormalized.width, sampleSizeNormalized.height ); } return self; } + (id)layerWithImage:(CGImageRef)img sampleSize:(CGSize)size; { MCSpriteLayer *layer = [[self alloc] initWithImage:img sampleSize:size]; return layer; } + (BOOL)needsDisplayForKey:(NSString *)key; { return [key isEqualToString:@"sampleIndex"]; } // contentsRect or bounds changes are not animated + (id < CAAction >)defaultActionForKey:(NSString *)aKey; { if ([aKey isEqualToString:@"contentsRect"] || [aKey isEqualToString:@"bounds"]) return (id < CAAction >)[NSNull null]; return [super defaultActionForKey:aKey]; } - (unsigned int)currentSampleIndex; { return ((MCSpriteLayer*)[self presentationLayer]).sampleIndex; } // Implement displayLayer: on the delegate to override how sample rectangles are calculated; remember to use currentSampleIndex, ignore sampleIndex == 0, and set the layer's bounds - (void)display; { if ([self.delegate respondsToSelector:@selector(displayLayer:)]) { [self.delegate displayLayer:self]; return; } unsigned int currentSampleIndex = [self currentSampleIndex]; if (!currentSampleIndex) return; CGSize sampleSize = self.contentsRect.size; self.contentsRect = CGRectMake( ((currentSampleIndex - 1) % (int)(1/sampleSize.width)) * sampleSize.width, ((currentSampleIndex - 1) / (int)(1/sampleSize.width)) * sampleSize.height, sampleSize.width, sampleSize.height ); } @end I create the layer on viewDidAppear and start animate by clicking on button, but after init I got a bad access error -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; NSString *path = [[NSBundle mainBundle] pathForResource:@"mama_default.png" ofType:nil]; CGImageRef richterImg = [UIImage imageWithContentsOfFile:path].CGImage; CGSize fixedSize = animacja.frame.size; NSLog(@"wid: %f, heigh: %f", animacja.frame.size.width, animacja.frame.size.height); NSLog(@"%f", animacja.frame.size.width); richter = [MCSpriteLayer layerWithImage:richterImg sampleSize:fixedSize]; animacja.hidden = 1; richter.position = animacja.center; [self.view.layer addSublayer:richter]; } -(IBAction)animacja:(id)sender { if ([richter animationForKey:@"sampleIndex"]) {NSLog(@"jest"); } if (! [richter animationForKey:@"sampleIndex"]) { CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"sampleIndex"]; anim.fromValue = [NSNumber numberWithInt:0]; anim.toValue = [NSNumber numberWithInt:22]; anim.duration = 4; anim.repeatCount = 1; [richter addAnimation:anim forKey:@"sampleIndex"]; } } Have you got any idea how to fix it? Thanks a lot.

    Read the article

  • Redirect to hash URL

    - by r1987
    I'm building a site with a hashchange on wordpress, all working good. It just loads a single.php template file into a div. The problem is that i can still access my single url (http://www.mydomain.com/my-single-post). Since its not having any head and style tags with it, i don't want people to go over there. Also google has picked up the direct links, because I use the href attribute to load content into the div. So my question is: If someone clicks a link lets say in a forum, http://www.mydomain.com/my-single-post , is it possible to redirect him instantly to http://www.mydomain.com/#my-single-post ? I have researched that it has something to do with .htaccess, but I also have Pages, where i don't want the hash infront of the page-name.

    Read the article

  • Cakephp 2.2 Blog Tutorial undefined constant errors

    - by user1741925
    Have copy pasted the code from Blog tutorial in cakephp 2.2 but its not working. Getting the following errors. Notice (8): Use of undefined constant Html Notice (8): Use of undefined constant Form Notice (8): Use of undefined constant posts Notice (8): Use of undefined constant all Notice (8): Undefined index: all Below is the code for PostsController and index.ctp. <?php class PostsController extends AppController { public $helpers = array(’Html’, ’Form’); public function index() { $this->set(’posts’, $this->Post->find(’all’)); } public function view($id = null) { $this->Post->id = $id; $this->set(’post’, $this->Post->read()); } } ?> index.ctp <h1>Blog posts</h1> <table> <tr> <th>Id</th> <th>Title</th> <th>Created</th> </tr> <?php foreach ($posts as $post): ?> <tr> <td><?php echo $post[’Post’][’id’]; ?></td> <td> <?php echo $post[’Post’][’title’]; ?> </td> <td><?php echo $post[’Post’][’created’]; ?></td> </tr> <?php endforeach; ?> <?php unset($post); ?> </table>

    Read the article

  • dig works but dig +trace <domain_name> not working

    - by anoopmathew
    In my local system i can't get the proper result of dig +trace , but dig works fine. I'm using Ubuntu 10.04 LTS version. I'll attach the result of dig and dig +trace along with this updates. dig +trace gmail.com ; << DiG 9.7.0-P1 << +trace gmail.com ;; global options: +cmd ;; Received 12 bytes from 4.2.2.4#53(4.2.2.4) in 291 ms dig gmail.com ; << DiG 9.7.0-P1 << gmail.com ;; global options: +cmd ;; Got answer: ;; -HEADER<<- opcode: QUERY, status: NOERROR, id: 59528 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;gmail.com. IN A ;; ANSWER SECTION: gmail.com. 49 IN A 74.125.236.118 gmail.com. 49 IN A 74.125.236.117 ;; Query time: 302 msec ;; SERVER: 4.2.2.4#53(4.2.2.4) ;; WHEN: Sat Oct 13 14:57:56 2012 ;; MSG SIZE rcvd: 59 Please anyone update a solution for this issue. I'm just worried about my issue.

    Read the article

  • error in fill datagrid whit query

    - by Amir Tavakoli
    i have a data-gride-view and i add my query to this when write my query i catch this error: The schema returned by the new query differs from the base query and this my query: SELECT B.SettingKey, 'SysSettingsDep' AS TableName, B.SettingValue, B.SettingDesc FROM SysCustomer AS A INNER JOIN SysSettingsDep AS B ON A.SettingKey = B.SettingKey UNION SELECT C.SettingKey, 'SysSettingsMachine' AS TableName, C.SettingValue, C.SettingDesc FROM SysCustomer AS A INNER JOIN SysSettingsMachine AS C ON A.SettingKey = C.SettingKey UNION SELECT D.SettingKey, 'SysSettings' AS TableName, D.SettingValue, D.SettingDesc FROM SysCustomer AS A INNER JOIN SysSettings AS D ON A.SettingKey = D.SettingKey help me to solve this, tnx

    Read the article

  • while loop / string input not working java

    - by Mikeecb
    I have looked online and all of the tutorials / questions have pointed me to this. I can't see why this isn't working. Any help would be much appreciated. Thanks import java.util.*; public class test { static Scanner userInput = new Scanner(System.in); public static void main(String[] args) { String textEntered = userInput.next(); if (textEntered == "hello") { System.out.println("Hello to you too!"); } } } I enter "hello" but nothing is printed. Also I have tried next() and nextLine();

    Read the article

  • jquery: .attr() fails for child element

    - by user984003
    I'm going crazy staring at this. I need to change the attribute of an element, something which I have done many times before. But it fails. Now I can't even get jquery to show me the attribute that it has. Does it have to do with what is returned by find()? var c = new_photo_div.find('[class = photo]')[0]; alert(c); alert(new_photo_div.attr('class')); alert(c.attr('class')); The first alert correctly identifies the element: Object HTMLImageElement The second alert correctly gives me the class of new_photo_div. The third alert fails. No alert. I think it should say: photo

    Read the article

  • Python - Compress Ascii String

    - by n0idea
    I'm looking for a way to compress an ascii-based string, any help? I need also need to decompress it. I tried zlib but with no help. What can I do to compress the string into lesser length? code: def compress(request): if request.POST: data = request.POST.get('input') if is_ascii(data): result = zlib.compress(data) return render_to_response('index.html', {'result': result, 'input':data}, context_instance = RequestContext(request)) else: result = "Error, the string is not ascii-based" return render_to_response('index.html', {'result':result}, context_instance = RequestContext(request)) else: return render_to_response('index.html', {}, context_instance = RequestContext(request))

    Read the article

  • How to pass multiple params to function in python?

    - by user1322731
    I am implementing 8bit adder in python. Here is the adder function definition: def add8(a0,a1,a2,a3,a4,a5,a6,a7,b0,b1,b2,b3,b4,b5,b6,b7,c0): All function parameters are boolean. I have implemented function that converts int into binary: def intTObin8(num): bits = [False]*8 i = 7 while num >= 1: if num % 2 == 1: bits[i] = True else: bits[i] = False i = i - 1 num /= 2 print bits return [bits[x] for x in range(0,8)] I want this function to return 8 bits. And to use this two functions as follows: add8(intTObin8(1),intTObin8(1),0) So the question is: How to pass 8 parameters using one function?

    Read the article

  • HTML5 placing image where i want it on screen

    - by corrigan_sam
    I have a little start screen running and i want the image, which is acting as a button, to placed at a certain point, but when i try to it stays in the same place, and i don't know how i can get it to stay in the place i want it. Here is my code, its is HTML with some css: <style> #SplashScreen{ position:relative; overflow:hidden; } #StartButton { cursor:pointer; position:absoloute; left:100px; top:100px; } </style> <div id="SplashScreen" width="400" height="400"> <h1>Game Title</h1> <img id="StartButton" src="play.png"/> </div> The image just draws underneath the title and not where i want it. Any help?

    Read the article

  • IE8 Using Google Font on ENTIRE Page Instead of Just Selected Text

    - by Jim
    All my web searches for Google Fonts with IE8 show people talking about google fonts just not loading or not showing up. I don't have that problem. Instead IE8 is loading my Google Font just fine, but its applying the font to ALL the type on the page! Things seem to be fine in other browsers. Is there some kind of glitch in my CSS that IE is choking on? http://nbkclientsite.fuzzpopstudio.com/ Ok here's some of the relevant css: body { font-size: 16px; font-size: 1rem; font-family: Helvetica-Neue,Helvetica, Arial, sans-serif; text-rendering: optimizeLegibility; color: #444; } .contact-us-text { font-family: 'Arvo', serif; font-size: 150%; color: #2770b4; } .contact-us-phone { font-family: 'Arvo', serif; font-size: 175%; } Everything pertinent should be in just one style sheet. You can easily view it with Firebug or Chrome's Inspector or whatever you want. In FF and Chrome, everything is inheriting Helvetica or Arial as it should be. But not in IE8. You'd have to use Firebug and view the entire stylesheet if you want to see more.

    Read the article

  • fill combobox value in datagridview based on other combobox in datagridview

    - by Purohit Raghu
    I m creating Web Application..in C# I have One Data grid view In that i Have 2 Combo box i m trying 2 bind second combo box based on first combo-box. in First Combo-box I have value Shirt,T shirt so i want if shirt is selected than second combo-box should have value Slim,Regular..and if T shirt Is selected than second Combo-box should have V neck and rounded color. i have different table for thirst and shirt type... I work fine for first time but when i goes on second row and change the combo box value than it will also change value of second combo box value of previous row as well .. Where i need to change to prevent change in upper row i have following code private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (dataGridView1.CurrentCell.ColumnIndex == 0) { ComboBox cbx = e.Control as ComboBox; cbx.SelectionChangeCommitted -= new EventHandler(cbx_SelectionChangeCommitted); cbx.SelectionChangeCommitted += new EventHandler(cbx_SelectionChangeCommitted); } } private void cbx_SelectionChangeCommitted(object sender, EventArgs e) { int selectedIndex = ((ComboBox)sender).SelectedIndex; if (selectedIndex == 1) //this condition is true if i have selected shirt from combobox1 { ShirtType(); } if (selectedIndex == 2) { Tshirtype(); } } void ShirtType() { try { string str; str = "select ShirtType_name,ShirtType_Id from ShirtType_master"; ds = new DataSet(); ds = cn.readdata(str); Type.DataSource = ds.Tables[0];//Type is Combobox name of Second Combobox Type.DisplayMember = ds.Tables[0].Columns[0].ToString(); ; Type.ValueMember = ds.Tables[0].Columns[1].ToString(); ; } catch (Exception ee) { } } void Tshirtype() { try { string str; str = "select TShirtType_name,TshirtType_Id from TshirtType_Master"; ds = new DataSet(); ds = cn.readdata(str); Type.DataSource = ds.Tables[0]; Type.DisplayMember = ds.Tables[0].Columns[0].ToString(); ; Type.ValueMember = ds.Tables[0].Columns[1].ToString(); ; }

    Read the article

  • slide navigation

    - by robosot
    I'm trying to make slide navigation. Here is my code html <li> <a href="#">Services</a> <div class="subcategories"> <a href="#">Cleaning</a> </div> </li> The subcategories div is hidden. js $('li a').hover(function() { $(this).next().slideToggle('fast', function() { }); }); This code works. The problem is that when the mouse goes out of the li a the subcategories div disappears. What i want is that when the user point the li a the subcategories div to be shown so the user be able to click on some link of the sub navigation.

    Read the article

  • assign keys for combo box in java

    - by adesh kumar
    I want to add a JComboBox in Swing that is simple but I want to assign the values for each items in combo. I have the following code JComboBox jc1= new JComboBox(); jc1.addItem("a"); jc1.addItem("b"); jc1.addItem("c"); Now what I want is that when click on combo box it should return 1, 2 and 3 correspondingly instead of a ,b, c. Is there any way to assign the key values for each items in combo box?

    Read the article

  • Override `drop` for a custom sequence

    - by Bruno Reis
    In short: in Clojure, is there a way to redefine a function from the standard sequence API (which is not defined on any interface like ISeq, IndexedSeq, etc) on a custom sequence type I wrote? 1. Huge data files I have big files in the following format: A long (8 bytes) containing the number n of entries n entries, each one being composed of 3 longs (ie, 24 bytes) 2. Custom sequence I want to have a sequence on these entries. Since I cannot usually hold all the data in memory at once, and I want fast sequential access on it, I wrote a class similar to the following: (deftype DataSeq [id ^long cnt ^long i cached-seq] clojure.lang.IndexedSeq (index [_] i) (count [_] (- cnt i)) (seq [this] this) (first [_] (first cached-seq)) (more [this] (if-let [s (next this)] s '())) (next [_] (if (not= (inc i) cnt) (if (next cached-seq) (DataSeq. id cnt (inc i) (next cached-seq)) (DataSeq. id cnt (inc i) (with-open [f (open-data-file id)] ; open a memory mapped byte array on the file ; seek to the exact position to begin reading ; decide on an optimal amount of data to read ; eagerly read and return that amount of data )))))) The main idea is to read ahead a bunch of entries in a list and then consume from that list. Whenever the cache is completely consumed, if there are remaining entries, they are read from the file in a new cache list. Simple as that. To create an instance of such a sequence, I use a very simple function like: (defn ^DataSeq load-data [id] (next (DataSeq. id (count-entries id) -1 []))) ; count-entries is a trivial "open file and read a long" memoized As you can see, the format of the data allowed me to implement count in very simply and efficiently. 3. drop could be O(1) In the same spirit, I'd like to reimplement drop. The format of these data files allows me to reimplement drop in O(1) (instead of the standard O(n)), as follows: if dropping less then the remaining cached items, just drop the same amount from the cache and done; if dropping more than cnt, then just return the empty list. otherwise, just figure out the position in the data file, jump right into that position, and read data from there. My difficulty is that drop is not implemented in the same way as count, first, seq, etc. The latter functions call a similarly named static method in RT which, in turn, calls my implementation above, while the former, drop, does not check if the instance of the sequence it is being called on provides a custom implementation. Obviously, I could provide a function named anything but drop that does exactly what I want, but that would force other people (including my future self) to remember to use it instead of drop every single time, which sucks. So, the question is: is it possible to override the default behaviour of drop? 4. A workaround (I dislike) While writing this question, I've just figured out a possible workaround: make the reading even lazier. The custom sequence would just keep an index and postpone the reading operation, that would happen only when first was called. The problem is that I'd need some mutable state: the first call to first would cause some data to be read into a cache, all the subsequent calls would return data from this cache. There would be a similar logic on next: if there's a cache, just next it; otherwise, don't bother populating it -- it will be done when first is called again. This would avoid unnecessary disk reads. However, this is still less than optimal -- it is still O(n), and it could easily be O(1). Anyways, I don't like this workaround, and my question is still open. Any thoughts? Thanks.

    Read the article

  • Java template classes using generator or similar?

    - by Hugh Perkins
    Is there some library or generator that I can use to generate multiple templated java classes from a single template? Obviously Java does have a generics implementation itself, but since it uses type-erasure, there are lots of situations where it is less than adequate. For example, if I want to make a self-growing array like this: class EasyArray { T[] backingarray; } (where T is a primitive type), then this isn't possible. This is true for anything which needs an array, for example high-performance templated matrix and vector classes. It should probably be possible to write a code generator which takes a templated class and generates multiple instantiations, for different types, eg for 'double' and 'float' and 'int' and 'String'. Is there something that already exists that does this? Edit: note that using an array of Object is not what I'm looking for, since it's no longer an array of primitives. An array of primitives is very fast, and uses only as much space a sizeof(primitive) * length-of-array. An array of object is an array of pointers/references, that points to Double objects, or similar, which could be scattered all over the place in memory, require garbage collection, allocation, and imply a double-indirection for access. Edit2: good god, voted down for asking for something that probably doesn't currently exist, but is technically possible and feasible? Does that mean that people looking for ways to improve things have already left the java community? Edit3: Here is code to show the difference in performance between primitive and boxed arrays: int N = 10*1000*1000; double[]primArray = new double[N]; for( int i = 0; i < N; i++ ) { primArray[i] = 123.0; } Object[] objArray = new Double[N]; for( int i = 0; i < N; i++ ) { objArray[i] = 123.0; } tic(); primArray = new double[N]; for( int i = 0; i < N; i++ ) { primArray[i] = 123.0; } toc(); tic(); objArray = new Double[N]; for( int i = 0; i < N; i++ ) { objArray[i] = 123.0; } toc(); Results: double[] array: 148 ms Double[] array: 4614 ms Not even close!

    Read the article

  • A Surface view and a canvas to move Bitmap

    - by John Apple Sim
    I have a SurfaceView and I want the Bitmap Logo inside it in the canvas to be movable What I'm doing wrong ? static float x, y; Bitmap logo; SurfaceView ss = (SurfaceView) findViewById(R.id.svSS); logo = BitmapFactory.decodeResource(getResources(), R.drawable.logo); x = 40; y = 415; ss.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent me) { try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } switch(me.getAction()) { case MotionEvent.ACTION_DOWN: x = me.getX(); y = me.getY(); break; case MotionEvent.ACTION_UP: x = me.getX(); y = me.getY(); break; case MotionEvent.ACTION_MOVE: x = me.getX(); y = me.getY(); break; } return true; } }); public class OurView extends SurfaceView implements Runnable{ Thread t = null; SurfaceHolder holder; boolean isItOK = false; public OurView(Context context) { super(context); holder = getHolder(); } public void run (){ while (isItOK == true){ //canvas DRAWING if (!holder.getSurface().isValid()){ continue; } Canvas c = holder.lockCanvas(); c.drawARGB(255, 200, 100, 100); c.drawBitmap(logo, x,y,null); holder.unlockCanvasAndPost(c); } } public void pause(){ isItOK = false; while(true){ try { t.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } t = null; } public void resume(){ isItOK = true; t = new Thread(this); t.start(); } } Now the surface view is just black .. nothing happens also its not colored 200, 100, 100

    Read the article

  • Transferring data from 2d Dynamic array in C to CUDA and back

    - by Soumya
    I have a dynamically declared 2D array in my C program, the contents of which I want to transfer to a CUDA kernel for further processing. Once processed, I want to populate the dynamically declared 2D array in my C code with the CUDA processed data. I am able to do this with static 2D C arrays but not with dynamically declared C arrays. Any inputs would be welcome! I mean the dynamic array of dynamic arrays. The test code that I have written is as below. #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <conio.h> #include <math.h> #include <stdlib.h> const int nItt = 10; const int nP = 5; __device__ int d_nItt = 10; __device__ int d_nP = 5; __global__ void arr_chk(float *d_x_k, float *d_w_k, int row_num) { int index = (blockIdx.x * blockDim.x) + threadIdx.x; int index1 = (row_num * d_nP) + index; if ( (index1 >= row_num * d_nP) && (index1 < ((row_num +1)*d_nP))) //Modifying only one row data pertaining to one particular iteration { d_x_k[index1] = row_num * d_nP; d_w_k[index1] = index; } } float **mat_create2(int r, int c) { float **dynamicArray; dynamicArray = (float **) malloc (sizeof (float)*r); for(int i=0; i<r; i++) { dynamicArray[i] = (float *) malloc (sizeof (float)*c); for(int j= 0; j<c;j++) { dynamicArray[i][j] = 0; } } return dynamicArray; } /* Freeing memory - here only number of rows are passed*/ void cleanup2d(float **mat_arr, int x) { int i; for(i=0; i<x; i++) { free(mat_arr[i]); } free(mat_arr); } int main() { //float w_k[nItt][nP]; //Static array declaration - works! //float x_k[nItt][nP]; // if I uncomment this dynamic declaration and comment the static one, it does not work..... float **w_k = mat_create2(nItt,nP); float **x_k = mat_create2(nItt,nP); float *d_w_k, *d_x_k; // Device variables for w_k and x_k int nblocks, blocksize, nthreads; for(int i=0;i<nItt;i++) { for(int j=0;j<nP;j++) { x_k[i][j] = (nP*i); w_k[i][j] = j; } } for(int i=0;i<nItt;i++) { for(int j=0;j<nP;j++) { printf("x_k[%d][%d] = %f\t",i,j,x_k[i][j]); printf("w_k[%d][%d] = %f\n",i,j,w_k[i][j]); } } int size1 = nItt * nP * sizeof(float); printf("\nThe array size in memory bytes is: %d\n",size1); cudaMalloc( (void**)&d_x_k, size1 ); cudaMalloc( (void**)&d_w_k, size1 ); if((nP*nItt)<32) { blocksize = nP*nItt; nblocks = 1; } else { blocksize = 32; // Defines the number of threads running per block. Taken equal to warp size nthreads = blocksize; nblocks = ceil(float(nP*nItt) / nthreads); // Calculated total number of blocks thus required } for(int i = 0; i< nItt; i++) { cudaMemcpy( d_x_k, x_k, size1,cudaMemcpyHostToDevice ); //copy of x_k to device cudaMemcpy( d_w_k, w_k, size1,cudaMemcpyHostToDevice ); //copy of w_k to device arr_chk<<<nblocks, blocksize>>>(d_x_k,d_w_k,i); cudaMemcpy( x_k, d_x_k, size1, cudaMemcpyDeviceToHost ); cudaMemcpy( w_k, d_w_k, size1, cudaMemcpyDeviceToHost ); } printf("\nVerification after return from gpu\n"); for(int i = 0; i<nItt; i++) { for(int j=0;j<nP;j++) { printf("x_k[%d][%d] = %f\t",i,j,x_k[i][j]); printf("w_k[%d][%d] = %f\n",i,j,w_k[i][j]); } } cudaFree( d_x_k ); cudaFree( d_w_k ); cleanup2d(x_k,nItt); cleanup2d(w_k,nItt); getch(); return 0;

    Read the article

  • Java: IDE working well with Maven War overlays

    - by Thorbjørn Ravn Andersen
    We have a Java EE 6 web application which is fully mavenized, and we use the Maven "war overlay" facility to add customer specific files, and which currently runs in Glassfish 3.1. We have traditionally used Eclipse for development, but I have found that the combination of Maven processing and War deployments may not be optimal in terms of deployment times, and that the mavenization allows us to use any IDE with good Maven support. Therefore is Eclipse the best bet for our particular scenario (maven war overlays - glassfish, and debugging it) or is e.g. Netbeans or IntelliJ better? Please, back opinions with actual experiences, thanks.

    Read the article

  • Spinner activity not working

    - by user1696863
    I'm trying to create an activity, RateCardActivity, which has a spinner in it. My layout file for RateCardActivity is rate_card. My RateCardActivity looks like the following. public class RateCardActivity { public void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.rate_card); Spinner spinner = (Spinner) findViewById(R.id.select_city); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.select_city, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); } } The layout file rate_card is: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:custom="http://schemas.android.com/apk/res/com.olacabs.customer" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/textView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@android:color/darker_gray" android:gravity="center" android:paddingBottom="4dp" android:paddingTop="4dp" android:text="@string/rate_card" android:textColor="@color/white" android:textSize="20dp" custom:customFont="litera_bold.ttf" /> <Spinner android:id="@+id/select_city" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout> The RateCardActivity is called from another activity using an intent (I'm sure there is nothing wrong with that part of the code as when I substitute RateCardActivity with another activity, the application works fine). When I try to open the RateCardActivity in the application in emulator, the application crashes and I got the message "The application has stopped unexpectedly. Please try again later." I can't seem to understand what I'm doing wrong, and want to know how to correct this?

    Read the article

  • "Simple" sort a nested array using array_multisort or native PHP functions instead of my own foreach loop

    - by Ana Ban
    I have the following array of days of the week, with each day having hours of the day (the whole array represents the schedule of a part-time employee): Array ( [7] => Array ( [0] => 15 [1] => 14 [2] => 13 [3] => 11 [4] => 12 [5] => 10 ) [1] => Array ( [0] => 10 [1] => 13 [2] => 12 ) [6] => Array ( [0] => 14 ) [3] => Array ( [0] => 4 [1] => 5 [2] => 6 ) ) and I simply need to: sort asc each sub-array (2nd dimension) - no need to maintain the numeric keys, values are integers sort asc the 1st dimension and maintain the numeric, integer keys ie: Array ( [1] => Array ( [0] => 10 [1] => 12 [2] => 13 ) [3] => Array ( [0] => 4 [1] => 5 [2] => 6 ) [6] => Array ( [0] => 14 ) [7] => Array ( [0] => 10 [1] => 11 [2] => 12 [3] => 13 [4] => 14 [5] => 15 ) ) Additional info: only the keys of the 1st dimension and the values of the 2nd dimension (and of course their association) are meaningful to my use-case the 1st dimension can have at most 7 values, ranging from 1-7 (days of the week), and will have at least 1 value (1 day) the 2nd dimension can have at most 24 values, ranging from 0-23 (hours of each day), and will have at least 1 value (1 hour per day) I know I can do this with a foreach on the whole ksorted array and sort each 2nd dimension array: ksort($sched); foreach ($sched as &$array) sort($array); unset($array); but I was hoping I could achieve this with native php array function(s) instead. My search led me to try array_multisort(array_values($array), array_keys($array), $array) but I just can't make it work.

    Read the article

  • Adding new column in Sales Order View Items in Magento Admin

    - by fdierre
    In the admin interface of Magento I need to modify the tables in the Sales / Order / View order so that it shows, besides the products name, their manufacturer as well. I'm trying to look for the file to modify to make that happen. I thought I would find a section with all the columns that are displayed in app/code/core/Mage/Sales/Block/Order/Item/Renderer/Default.php but by inspecting it there seem to be no reference to the columns/product attributes. I also tried to modify app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml by changing <?php echo $this->getColumnHtml($_item, 'name') ?> into <?php echo $this->getColumnHtml($_item, 'manufacturer') ?> but it changed nothing, so I suppose that file is not involved... Can anybody please point me to the right file to modify? Thank you!

    Read the article

  • What VMWare should I choose?

    - by wbad
    I'm new to VMWare stuff. What I need to do is pretty basic: Just to install two different Windows 2008 versions on a server with 2x 4core CPU and 2x 3TB hard disks. I asked my datacenter to install the free version (VMware ESXi 4.1) but apparently it did not recognize 3TB disks. Now I'm wondering whether VMWare 5 can handle 3TB disks, and if so, what variant? There is a huge array of options there and some prices are astonishingly high: http://www.vmware.com/products/datacenter-virtualization/vsphere/pricing.html So I'm really confused and I appreciate your hints.

    Read the article

  • let CRON send emails through SMTP ( debian squeeze )

    - by supernova
    i would like to send emails whenever a cronjob has completed, i read that this is possible with exim4. in /etc/alias i added the line myuser: [email protected] in /etc/exim4/update-exim4.conf.conf i set dc_smarthost='smtp.myserver.ip::25 and in /etc/exim4/passwd.client i set smtp.myserver.ip:[email protected]:mypassword my problem is that i can't see any login at my mailserver, and in the exim logs i saw a few lines with 2012-10-13 09:17:01 1TMvy1-0001fp-F2 ** [email protected] R=nonlocal: Mailing to remote domains not supported 2012-10-13 09:17:01 1TMvy1-0001fr-JE <= <> R=1TMvy1-0001fp-F2 U=Debian-exim P=local S=17426 are there any additional config settings i have to set? edit : i solved the prev. error by running dpkg-reconfigure, but now i'm facing the following error <root@debian> R=dnslookup T=remote_smtp defer (-53): retry time not reached for any host

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >