Daily Archives

Articles indexed Monday January 17 2011

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

  • Asp .Net MVC Viewmodel should be class or struct?

    - by Jonas Everest
    Hey guys, I have just been thinking about the concept of view model object we create in asp.net MVC. Our purpose is to instantiate it and pass it from controller to view and view read it and display the data. Those view model are usually instantiated through constructor. We won't need to initialize the members, we may not need to redefine/override parameterless constructor and we don't need inheritance feature there. So, why don't we use struct type for our view model instead of class. It will enhance the performance.

    Read the article

  • Javascript: gradually adding to string in each iteration ?

    - by Kim Jong Woo
    I have a string like this that is split up: var tokens = "first>second>third>last".split(">"); What I would like in each iteration is for it to return Iteration 0: "last" Iteration 1: "third>last" Iteration 2: "second>third>last" Iteration 3: "first>second>third>last" I am thinking of using decrementing index for loop.... but is there a more efficient approach ? for (int w = tokens.length-1; w == 0; w--) { }

    Read the article

  • mysql: storing arbitrary data

    - by Hailwood
    Background: I was asking a question on stack overflow regarding creating tables on the fly where this conversation ensued: This smells like a terrible idea! In fact, it smells just like this one. What in the world do you want to use this for? – deceze @deceze: very true, However, How else would you store the contents of these CSV files. They must be stored in mysql for indexing. The only solid fact about them is that they all have a mobile column with a standard format. The CSV can have an arbitrary amount of columns with an arbitrary amount of rows. They can (with no exaggeration) range from a single row, 35 column csv to an 80k row single column CSV. I am open to other ideas. – Hailwood There are many solutions for this, from attribute-value schemas to JSON storage and NoSQL storage. Open a new question about it. Whatever you do though, don't dynamically create tables! – deceze Question: So my question is, What would you say is the best way to store this data? Are you in agreement with deceze about not creating dynamic tables?

    Read the article

  • How to access a TextView element in a BroadcastReceiver

    - by ric03uec
    Hello, I am testing a simple widget in android and using Alarms to update a TextView at regular intervals. The problem is that in the BroadcastReceiver class I cannot access the TextView element, which I want to get updated when the alarm expires. The class is being called properly because the Toast i have put there is giving the appropriate message. The following code is from the class where I configure the widget and set the timers. public void onCreate(Bundle bundle) { super.onCreate(bundle); Intent intent = getIntent(); Bundle extras = intent.getExtras(); if(extras != null){ mWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(WidgetConfigure.this); RemoteViews views = new RemoteViews(WidgetConfigure.this.getPackageName(), R.layout.widget_layout); views.setTextViewText(R.id.quote, "Widget Loaded From Activity"); appWidgetManager.updateAppWidget(mWidgetId, views); setTimer(); //set the timers... setResult();// set the result... } } Now i want to update the same TextView when the BroadCastReceiver is called after the timer expires. I have tried the code provided in the ExampleAppWidget example provided in android api demos and that isnt working out. How can i set the required text? Thankx in advance

    Read the article

  • Import Contacts from .vcf file in Android 2.1

    - by Prateek Jain
    Hi All, I am able to retrieve all contacts from android in .vcf file using following code. ContentResolver cr = getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,null, null, null, null); String lookupKey = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY)); Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey); System.out.println("The value is " + cr.getType(uri)); AssetFileDescriptor fd = this.getContentResolver().openAssetFileDescriptor(uri, "r"); FileInputStream fis = fd.createInputStream(); I don't know how to use this .vcf file to import all these contacts using code. The .vcf file contains all the details of all contacts including photos etc. Cheers, Prateek

    Read the article

  • Imagemagick command line in PHP

    - by charly
    Hello everyone, I've got the following two commands for imagemagick in the command line: convert in.png container-mask.png +matte -compose CopyOpacity -composite out.png composite container.png out.png -compose multiply final.png Those two commands include 3 files: in.png: the file that should be masked container-mask.png: the back/white mask of the areas of container.png where in.png should be visible container.png image that includes the container for in.png, the one that has been masked in black/white with container-mask.png Now the question is how to transpose this commands into PHP calls. I've played around quite a bit, but I can't make sense of the API at http://php.net/manual/en/book.imagick.php Thanks and Bests, Charly

    Read the article

  • Android and fairly large SQLite datafiles

    - by SK9
    I'm starting an Android project, a port from an existing iPhone project I've completed. I have a fairly large read-only SQLite database, about 100Mb in all. It's called "mydata.sqlite". Where do I place this in my Eclipse workspace? It's too big for "assets". Next, how do I best get at the file? I would think to try (handling exceptions later) something like: SQLiteDatabase myDatabase = null; myDatabase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); But I would then need the path string myPath and since I don't know where to put the resource I don't know what this needs to be. Can I put "mydata.sqlite" into "res/raw" (once I create "raw" in Eclipse?) and then referene it as a resource with "R.raw.mydata"? I would very much appreciate some direct help here, rather than a reference to a tutorial. I have checked tons of these, including those that are already cited here on stackoverflow. I've also gone through the "Notepad" project in the Android developer documents. However these and the documentation typically consider only new, empty or small databases. This should be a simple thing and given the time I've spent already it is perhaps easier to ask. Thanking you kindly in advance for your assistance.

    Read the article

  • How to customize preferences screen theme to look like that ?

    - by Alex
    Ok, I have a Preferences activity set with an XML layout. Here I have a couple of Preferences that open some dialogs. On these preferences I want to have an arrow on the right of them like in the screenshot. How I do this, is something related to the theme ? First screenshot is how I want to look, second is what I have now. http://img545.imageshack.us/i/screenshot1zlk.png/ http://img405.imageshack.us/i/tsc3.png/

    Read the article

  • Why and what for: java enum

    - by Mat Banik
    Today I was browsing through some question on this site and I found mention of enum being used in singleton pattern and that there are some thread safety benefits to such solution. I never used enums and I have been programing in java for more than couple a years now. And apparently they changed a lot and now they even do full blown support of OOP within them selfs. Now why and what for should I used enum in day to day programing?

    Read the article

  • How should I get the value contained in a particular field of a Drupal 7 custom node?

    - by Matt V.
    What is the "proper" way to get the value stored in a particular field within a custom Drupal node? I've created a custom module, with a custom node, with a custom URL field. The following works: $result = db_query("SELECT nid FROM {node} WHERE title = :title AND type = :type", array( ':title' => $title, ':type' => 'custom', ))->fetchField(); $node = node_load($result); $url = $node->url['und']['0']['value']; ...but is there a better way, maybe using the new Field API functions?

    Read the article

  • Doctrine: String keys with Array hydration

    - by BenV
    According to their documentation, you should use Array hydration rather than record hydration when retrieving data for read-only purposes. However, this means I have to access the attributes of the retrieved object using arrays and string keys: $user['Phonenumbers'][0]['number'] instead of the OO style: $user->PhoneNumbers[0]->number Now I'm kinda new to PHP, but in other languages I've worked with the 2nd notation would be preferable because typos would be caught at compile time while typos in string literals would not be noticed until runtime. Does this apply to PHP/Doctrine?

    Read the article

  • Trying to grab several random videos from database, but it just shows the same one all the time.

    - by Birk
    Hi guys, I'm trying to grab several random videos from my database, and have them show on a page. However, it just keeps on grabbing the same video rather than several different ones. So I end up with 5 of the same video rather than 5 different ones. Here's the grab random PHP code file... and after it is the template output file. //===================================================== // Random | Previous | Next //===================================================== $show['random'] = $db->quick_fetch( "SELECT file_id, title, title_seo, category_id, thumb FROM files WHERE files.category_id = '".$show['main']['category_id']."' AND files.verified=1 ORDER BY RAND() LIMIT 0,1; "); Here's the template CSS html thingy code I have this pasted 5 times to show 5 random videos <td valign="top" width="53%"><? $sql="select * from files ORDER BY rand() limit 0,5"; $res=@mysql_query($sql); $data=@mysql_result($res,0,'filename'); $id=@mysql_result($res,0,'file_id'); $title=@mysql_result($res,0,'title'); $title2=str_replace(" ", "-",$title); $path="{$siteurl}/media/{$file.random.file_id}/{$file.random.title_seo}/"; $img="{$siteurl}/thumbs/{$file.random.thumb}"; echo " {$file.random.title}"

    Read the article

  • How to remove caracters like (), ' * [] form a grep results with grep, awk or sed?

    - by easyyu
    For example if I made a file with grep that give me a next result: 16 Jan 07:18:42 (name1), xx.210.49.xx), 16 Jan 07:19:14 (name2), xx.210.xx.24), 16 Jan 07:19:17 (name3), xx.140.xxx.79), 16 Jan 07:19:44 (name4), xx.210.49.xx), 16 Jan 07:19:56 (name5), xx.140.xxx.79), ,then how to sed awk or grep to remove all except date name and IP to look like this: 16 Jan 07:18:42 name1 xx.210.49.xx 16 Jan 07:19:14 name2 xx.210.xx.24 16 Jan 07:19:17 name3 xx.140.xxx.79 16 Jan 07:19:44 name4 xx.210.49.xx 16 Jan 07:19:56 name5 xx.140.xxx.79 My grep command look like this: grep 'double' $DAEMON | awk -F" " '{print $2" "$1" "$3" "$8" "$10}' > $DBLOG Thx.

    Read the article

  • Adding a div layer on top of a jquery carousel. Tough one.

    - by wilwaldon
    Hey everyone, I have a tough one, well it's tough for me because I'm kinda new to the whole jQuery carousel thing, never built one before this project. Here's my problem. If you go to the TEST SITE you will see a scroller with a blue background about half way down the page. If you mouse onto the "data analytics" slide you should see a black box fade in. Here is my dilemma. I want that black box to be a menu that's connected to the data analytics slide. I've done a mock up for you so you can see what I'm talking about. Here is my scroller code. I'm using jCarousel. <div class="carousel"> <ul> <li> <div id="homeslide1"> testers sdfasdfasdfas asdftjhs iasndkad kasdnf <a href="#" id="#homeslide1-toggle">Close this</a> </div> <a href="#" id="homeslide1-show"><img src="<?php bloginfo('template_url'); ?>/images/home_data_analytics.jpg" width="200" height="94" /></a> </li> <li><img src="<?php bloginfo('template_url'); ?>/images/home_oem_partnerships.jpg" width="200" height="94" /></li> <li><img src="<?php bloginfo('template_url'); ?>/images/home_reporting.jpg" width="200" height="92" /></li> <li><img src="<?php bloginfo('template_url'); ?>/images/home_returning_lost_customers.jpg" width="200" height="92" /></li> <li><img src="<?php bloginfo('template_url'); ?>/images/home_sales.jpg" width="200" height="92" /></li> <li><img src="<?php bloginfo('template_url'); ?>/images/home_service_retention.jpg" width="200" height="92" /></li> </ul> Here is my scroller css /*HOMEPAGE SCROLLER*/ .carousel {!important padding:10px; width: 890px; margin: 0px 0px 0px 26px;} .carousel ul li element.style{height: 94px;} .carousel ul{width: 200px; padding: 5px;} .carouselitem{height: 94px;} .prev{background: url(images/home_left_scroll.png); height: 94px; width: 16px; text-indent: -999px; outline: none; cursor:pointer; float: left;} .next{background: url(images/home_right_scroll.png); height: 94px; width: 16px; text-indent: -999px; outline: none; cursor:pointer; float: right;} .carousel ul li{ padding: 0px 3px 0px 3px; margin: 0px; height:!important 94px; } .home_right_arrow{ width: 16px; float: right;} .home_left_arrow{ width: 16px; float: left;} .homeslide1{ width: 200px; height: 94px;} I've tried all sorts of z-index tricks but can't seem to figure it out on my own. If you solve this riddle I'll buy you a beer if we ever meet up. I'll also give you a high five through the internet. Is there a simple way to do this via jQuery? If so could you point me in the right direction? Thanks so much.

    Read the article

  • iPhone: Cannot get simulator to generate .gcda profiling data files.

    - by Derek Clarkson
    I'm attempting to profile my code using the iPhone simulator. I've enabled Generate Test Coverage File and Instrument Program Flow and added -lgcov to the linker flags. According to everything I've read that should be all I need to do in terms of setup. Executing the program I can see the .gcno files appearing along side the .o compiled code in the build/.build/Debug-iphonesimulator/.build/Objects-normal/i386 directory. But when I run the app in the simulator I do not get any *.gcda files appearing. My understanding is that these files contain the data from the instrumentation. But I cannot find them anywhere on the computer. I know they can be produced and appear along side the *.gcno files because I have an old trashed buil directory which does have them. I just cannot figure out what I have to do to get them to appear and record the run. Any help appreciated.

    Read the article

  • What is the best way to get an audio file duration in Android?

    - by Gilead
    Hi! I'm using a SoundPool [ 1 ] to play audio clips in my app. All is fine but I need to know when the clip playback has finished. At the moment I track it in my app by obtaining the duration of each clip using a MediaPlayer [ 2 ] instance. That works fine but it looks wasteful to load each file twice, just to get the duration. I could roughly calculate the duration myself knowing the length of the file (available from the AssetFileDescriptor [ 3 ]) but I'd still need to know the sample rate and the number of channels. I see two potential solutions to that problem: Figuring out when a clip has finished playing (doesn't seem to be possible with SoundClip). Having a class which could load just the header of an audio file and give me the sample rate/number of channels (and, ideally, the sample count to get the exact duration). Any suggestions? Thanks, Max The code I'm using at the moment (works fine but is rather heavy for the purpose): String[] fileNames = ... MediaPlayer mp = new MediaPlayer(); for (String fileName : fileNames) { AssetFileDescriptor d = context.getAssets().openFd(fileName); mp.reset(); mp.setDataSource(d.getFileDescriptor(), d.getStartOffset(), d.getLength()); mp.prepare(); int duration = mp.getDuration(); // ... } On a side note, this question has already been asked [ 4 ] but got no answers.

    Read the article

  • Rebuilding a Mac Mini (early 2009)

    - by Kelly Jones
    This weekend I decided to rebuild the family’s Mac Mini.  It’s the early 2009 model and I hadn’t done it since we got it in March of 2009.  Even worse, I had done the import data step (or whatever Apple calls it) which brought over all of the data files and apps from our previous Mac.  AND that install goes back to before 2005, as far as I can remember.  SO, to say that “cruft” had built up in the operating system, is probably a bit of an understatement. The rebuild went pretty smoothly, especially since I had a couple of spare hard drives.  I hooked up a spare USB drive and formatted it for use with the Mac.  I then used Carbon Copy to clone the internal hard drive onto the USB drive.  (Carbon Copy is a great little app that I used several years ago and I was happy to see it was not only still around, but updated as well.) Once I had my backup, I shut down the Mac and replaced the internal hard drive.  I had purchased the hard drive last fall to use with my work laptop, but I got a new work laptop (with awesome dual SSDs) so I wasn’t using it anymore.  The replacement drive (Seagate Momentus 7200.4 ST9500420AS 500GB 7200 RPM 2.5" SATA 3.0Gb/s Internal Notebook Hard Drive) has more than double the original’s capacity and is also faster.  I’ll have to keep an eye on the temperature, since that 7200 drive will run hotter. Opening the Mac Mini is not for the easily intimidated!  That cool little case is quite the pain to open.  Luckily, OWC put a video together here.  After replacing the drive, I then installed a clean copy of OS 10.5 using the DVDs that came with the Mac.  After the OS, it was time to reinstall the apps.  I downloaded some of the freeware, just to make sure I had the latest versions.  For the rest, I just copied from the backup cloned drive to the new drive.  (I love the way most Mac apps are written – with almost everything contained within a “package” that I can just copy from one drive to another.  MUCH better than the Windows way of using shared DLLs and the registry to store critical pieces that the app needs in order to run!) The whole process took longer than I would have preferred, but it was long overdue.  It definitely “feels” faster, especially boot time and application launches.

    Read the article

  • Looking for a good Web Server that is cheap

    - by SoLoGHoST
    I am a Project Manager, and former Lead Developer for a software portal system that requires a forum software to run. I am in need of a server that is cheap, reliable, and supports the latest PHP (5.2+), MySQL, unlimited e-mails (preferably), a cPanel, multiple sub-domains (atleast 3+). Currently I am paying $34.95 USD/month (approx. $420 USD/year). This is too high for me to pay to keep the site running. I just recently became Project Manager and in charge of Finances and I'm extremely concerned for the future of Dream Portal. With those prices I'm not sure I'll be able to keep it running for too long. Can someone please tell me of a good server that meets all of the requirements that I listed above that is cheaper on a yearly basis? Note: Currently on a Dedicated Server with limited disk space at 15000 MB (15 GB), monthly bandwidth = 500000 MB, 50 emails limit, 20 sub-domains limit, 30 FTP accts., and 25 SQL Databases.

    Read the article

  • Aircrack-ng, is it illegal?

    - by Jasen
    I just found out about this linux-based network toolset called aircrack-ng, and its pretty interesting, and I'm learning how to use it. But it just occured to me, that like a lot of linux programs, they're developed in foreign countries, with different laws. I did do a google search, and the only thing in regards to what i am asking that pops up is a question on another site. So, my question is, is it illegal in America, specifically Ohio, to use this program? I mean i know it has a legitimate purpose, but so does hemp. Also, sorry if this is the wrong place for this question, but I'm not exactly sure where it should go.

    Read the article

  • Is there a performance pentalty using in-place models/families in a large Revit project

    - by Jaips
    (I'm quite new at Revit so apologies if my concepts are a bit inaccurate) I have heard using, in-place models in Revit projects is poor practice since it can slow down a large project. However i noticed Revit also organising inplace models lumping them with the rest of the families. So my question is: Is there really any performance penalty/benefit to be had by inserting families from an external file as opposed to creating inplace models in a Revit project?

    Read the article

  • portable usb harddisk regardless in windows and ubuntu / linux environment

    - by user8184
    I am doing web development mostly in ubuntu. Sometimes i need to go into windows to do other administrative work. Now i am ignorant about file systems. I cannot tell the difference between NTFS and FAT32. My eyes just glaze over the wikipedia articles. All I know is i have been using this 320 Gb portable USB harddisk to save files when I am in ubuntu and when I am in windows. Now i got a situation where sometimes the windows 7 cannot detect the harddisk. I believe it has to do with the file system issue. Or my harddisk is coming apart. To make it easy to backup my files in a portable USB harddisk regardless in ubuntu or windows, please advise me. That means i can go from from linux/ubuntu to portable harddisk read/write files from windows 7 to portable harddisk read/write files the same files. Thank you.

    Read the article

  • How can I make NetworkManager ignore my wireless card?

    - by ændrük
    I do not want NetworkManager to list or manipulate my wireless card. Can I hide its interface from NetworkManager somehow? I have tried adding this in /etc/network/interfaces, iface wlan0 inet static address 192.168.1.101 netmask 255.255.255.0 gateway 192.168.1.1 wireless-essid Synaptotagmin pre-up wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf post-down killall -q wpa_supplicant and this in /etc/NetworkManager/nm-system-settings.conf, [keyfile] unmanaged-devices=/org/freedesktop/Hal/devices/net_00_19_e0_57_86_af but NetworkManager Applet still lists and allows me to connect to wireless networks.

    Read the article

  • Nonresponsive UI starting a few days ago; no obvious resource shortage

    - by user3679
    The mouse stops and moves jerkily, and sometimes won't register clicks. Gnome stopped responding a few hours ago--everything looks fine, but no clicks on menu items do anything. I've been running Ubuntu 10.10 since it was released; 8GB RAM and a 60GB SSD. I haven't added any hardware or software recently except the Ubuntu recommended updates; the last thing was the bitcoin client a week ago. top shows 3 CPU cores free and over a gig of ram left. I don't know what else to look at.

    Read the article

  • How to fix hibernate / suspend with proprietary nVidia driver?

    - by Chris
    Hi, I've just got an Dell Precision M6500 that comes with an nVidia card. Together with Kubunutu 10.10 and the proprietary nvidia driver suspend to disk or RAM does not work. It's allways ending with a running system and a locked screen (i.e. I can just enter my password and everything is as before - it's never sleeping) Can someone please help me to debug this issue? Where should I look for information? None of the log files seem to show an obvious error... Thanks, Chris

    Read the article

  • C++ associative array with arbitrary types for values

    - by Gerald Kaszuba
    What is the best way to have an associative array with arbitrary value types for each key in C++? Currently my plan is to create a "value" class with member variables of the types I will be expecting. For example: class Value { int iValue; Value(int v) { iValue = v; } std::string sValue; Value(std::string v) { sValue = v; } SomeClass *cValue; Value(SomeClass *v) { cValue = c; } }; std::map<std::string, Value> table; A downside with this is you have to know the type when accessing the "Value". i.e.: table["something"] = Value(5); SomeClass *s = table["something"].cValue; // broken pointer Also the more types that are put in Value, the more bloated the array will be. Any better suggestions?

    Read the article

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