Search Results

Search found 1513 results on 61 pages for 'adam heath'.

Page 41/61 | < Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >

  • Can a Generic Method handle both Reference and Nullable Value types?

    - by Adam Lassek
    I have a series of Extension methods to help with null-checking on IDataRecord objects, which I'm currently implementing like this: public static int? GetNullableInt32(this IDataRecord dr, int ordinal) { int? nullInt = null; return dr.IsDBNull(ordinal) ? nullInt : dr.GetInt32(ordinal); } public static int? GetNullableInt32(this IDataRecord dr, string fieldname) { int ordinal = dr.GetOrdinal(fieldname); return dr.GetNullableInt32(ordinal); } and so on, for each type I need to deal with. I'd like to reimplement these as a generic method, partly to reduce redundancy and partly to learn how to write generic methods in general. I've written this: public static Nullable<T> GetNullable<T>(this IDataRecord dr, int ordinal) { Nullable<T> nullValue = null; return dr.IsDBNull(ordinal) ? nullValue : (Nullable<T>) dr.GetValue(ordinal); } which works as long as T is a value type, but if T is a reference type it won't. This method would need to return either a Nullable type if T is a value type, and default(T) otherwise. How would I implement this behavior?

    Read the article

  • Rails - how do you create a user index page like stack overflows with multiple tabs whilst keeping t

    - by adam
    On stackoverflow in the users profile area there are many tabs which all display differing information such as questions asked and graphs. Its the same view though and im wondering hows its best to achieve this in rails whilst keeping the controller skinny and logic in the view to a minimum. def index @user = current_user case params[:tab_selected] when "questions" @data = @user.questions when "answers" @sentences = @user.answers else @sentences = @user.questions end respond_to do |format| format.html # index.html.erb nd end but how do i process this in the index view without a load of if and else statments. And if questions and answers are presented differently whats the best way to go about this.

    Read the article

  • Safest LAMP encrypt method

    - by Adam Kiss
    Hello, what is PHP's safest encrypt/decrypt method, in use with MySQL - to store let's say passwords? Of course, not for portal purposes. I want to do little password (domain/mysql/ftp...) storage for whole team online, but I don't want really to endanger our clients' bussinesses. Hash can't be used for obvious reasons (Doesn't really make sense to run rainbow tables every time :D). Any idea?

    Read the article

  • Android Multiple objects in SimpleAdapter

    - by Adam Sherratt
    I have a need (unless you can think of a better way) of passing multiple objects to a custom list adapter. I know that I'm barking up the wrong tree here, and would appreciate someone setting me on the right course! Thanks playlistadapter = new MyPlaylistAdapter(MyApplication.getAppContext(), songsList, retained_songsList, folderMode, R.layout.file_view, new String[] { "songTitle","songAlbum", "songPath" }, new int[] { R.id.checkTextView, R.id.text2, R.id.text3 }); And my adapter class: public class MyPlaylistAdapter extends SimpleAdapter{ private ArrayList <Song> songsList = new ArrayList<Song>(); private ArrayList <Song> retained_songsList = new ArrayList<Song>(); private ArrayList<Song> playlistcheck = new ArrayList<Song>(); private String folderMode; private String TAG = "AndroidMediaCenter"; public MyPlaylistAdapter(Context context,List<Song> SongsList, List<Song> Retained_songsList, String FolderMode,int resource, String[] from, int[] to) { super(context, null, resource, from, to); songsList.clear(); songsList.addAll(SongsList); Log.i(TAG, "MyPlayListAdapter Songslist = " + songsList.size()); retained_songsList.clear(); retained_songsList.addAll(Retained_songsList); folderMode = FolderMode; } public View getView(int position, View convertView, ViewGroup parent) { //PlayListViewHolder holder; CheckedTextView checkTextView; TextView text2; TextView text3; if (convertView == null) { LayoutInflater inflater = (LayoutInflater) MyApplication.getAppContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); //LayoutInflater inflater=getLayoutInflater(); convertView=inflater.inflate(R.layout.file_view, parent, false); //convertView.setBackgroundColor(0xFF00FF00 ); //holder = new PlayListViewHolder(); checkTextView = (CheckedTextView) convertView.findViewById(R.id.checkTextView); text2 = (TextView) convertView.findViewById(R.id.text2); text3 = (TextView) convertView.findViewById(R.id.text3); //convertView.setTag(holder); } else { //holder = (PlayListViewHolder) convertView.getTag(); } //put something into textviews String tracks = null; String tracks_Details = null; String trackspath = null; tracks = songsList.get(position).getSongTitle(); tracks_Details = songsList.get(position).getAlbum() + " (" + songsList.get(position).getArtist() + ")"; trackspath = songsList.get(position).getSongPath(); checkTextView = (CheckedTextView) convertView.findViewById(R.id.checkTextView); text2 = (TextView) convertView.findViewById(R.id.text2); text3 = (TextView) convertView.findViewById(R.id.text3); checkTextView.setText(tracks); if(folderMode.equals("Playlists")){ checkTextView.setBackgroundColor(Color.GREEN); checkTextView.setChecked(false); try { int listsize_rs = retained_songsList.size(); for (int j = 0; j<listsize_rs;j++){ if((retained_songsList.get(j).getSongPath()).equals(songsList.get(position).getSongPath())){ checkTextView.setBackgroundColor(Color.TRANSPARENT); //Need to check here whether the checkedtextview is ticked or not checkTextView.setChecked(true); playlistcheck.add(songsList.get(position)); break; } } } catch (Exception e) { e.printStackTrace(); } }else { //Need to check here whether the checkedtextview is ticked or not try { if (songsList.get(position).getSongCheckedStatus()==true){ checkTextView.setChecked(true); }else{ checkTextView.setChecked(false); } } catch (Exception e) { e.printStackTrace(); } } text2.setText(tracks_Details); text3.setText(trackspath); Log.i(TAG, "MyPlayListAdapter Songslist = " + songsList.size()); return convertView; } } However, this doesn't inflate, throwing the following errors: 10-26 23:11:09.464: E/AndroidRuntime(2826): FATAL EXCEPTION: main 10-26 23:11:09.464: E/AndroidRuntime(2826): java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.GetMusicComplete flg=0x10 } in com.Nmidia.AMC.MusicActivity$18@414c5770 10-26 23:11:09.464: E/AndroidRuntime(2826): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:765) 10-26 23:11:09.464: E/AndroidRuntime(2826): at android.os.Handler.handleCallback(Handler.java:615) 10-26 23:11:09.464: E/AndroidRuntime(2826): at android.os.Handler.dispatchMessage(Handler.java:92) 10-26 23:11:09.464: E/AndroidRuntime(2826): at android.os.Looper.loop(Looper.java:137) 10-26 23:11:09.464: E/AndroidRuntime(2826): at android.app.ActivityThread.main(ActivityThread.java:4745) 10-26 23:11:09.464: E/AndroidRuntime(2826): at java.lang.reflect.Method.invokeNative(Native Method) 10-26 23:11:09.464: E/AndroidRuntime(2826): at java.lang.reflect.Method.invoke(Method.java:511) 10-26 23:11:09.464: E/AndroidRuntime(2826): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 10-26 23:11:09.464: E/AndroidRuntime(2826): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 10-26 23:11:09.464: E/AndroidRuntime(2826): at dalvik.system.NativeStart.main(Native Method) 10-26 23:11:09.464: E/AndroidRuntime(2826): Caused by: java.lang.NullPointerException 10-26 23:11:09.464: E/AndroidRuntime(2826): at android.widget.SimpleAdapter.getCount(SimpleAdapter.java:93) 10-26 23:11:09.464: E/AndroidRuntime(2826): at android.widget.ListView.setAdapter(ListView.java:460) 10-26 23:11:09.464: E/AndroidRuntime(2826): at com.Nmidia.AMC.MusicActivity.setFilterMusic(MusicActivity.java:1230) 10-26 23:11:09.464: E/AndroidRuntime(2826): at com.Nmidia.AMC.MusicActivity$18.onReceive(MusicActivity.java:996) 10-26 23:11:09.464: E/AndroidRuntime(2826): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:755) 10-26 23:11:09.464: E/AndroidRuntime(2826): ... 9 more

    Read the article

  • jQuery or CSS - How do you make a link in a table row appear underlined even when the cursor is in a

    - by adam
    I have a table of 3-4 columns, the central one being task names that are also links(yet another todo app..groan). Im trying to make it so that whenever the mouse hovers over any part of the table row - not just the link itself - the link will appear underlined. Its a small detail but its been annoying me like hell and i refuse to let it get the better of me now. At first i tried jQuery with a (forgive the obvious syntax errors but this is the jist) $('#row_in_question').hover( function(){ $(this).find(...the link..).toggleClass("highlighted") }, function(){ $(this).find(...the link..).toggleClass("highlighted") } ); with this as a styling for the a element in general .highlighted { text-decoration: underlined; } and it did indeed toggle the highlighted class on that link - however css inheritance got in the way and no visual changes made. Since i previously styled that link to have no underline when not hovered it wouldnt change the style. So how do i go about this? I dont want the whole row to become clickable, I just want the text to become underlined.

    Read the article

  • Using drawAtPoint with my CIImage not doing anything on screen

    - by Adam
    Stuck again. :( I have the following code crammed into a procedure invoked when I click on a button on my application main window. I'm just trying to tweak a CIIMage and then display the results. At this point I'm not even worried about exactly where / how to display it. I'm just trying to slam it up on the window to make sure my Transform worked. This code seems to work down through the drawAtPoint message. But I never see anything on the screen. What's wrong? Thanks. Also, as far as displaying it in a particular location on the window ... is the best technique to put a frame of some sort on the window, then get the coordinates of that frame and "draw into" that rectangle? Or use a specific control from IB? Or what? Thanks again. // earlier I initialize a NSImage from JPG file on disk. // then create NSBitmapImageRep from the NSImage. This all works fine. // then ... CIImage * inputCIimage = [[CIImage alloc] initWithBitmapImageRep:inputBitmap]; if (inputCIimage == Nil) NSLog(@"could not create CI Image"); else { NSLog (@"CI Image created. working on transform"); CIFilter *transform = [CIFilter filterWithName:@"CIAffineTransform"]; [transform setDefaults]; [transform setValue:inputCIimage forKey:@"inputImage"]; NSAffineTransform *affineTransform = [NSAffineTransform transform]; [affineTransform rotateByDegrees:3]; [transform setValue:affineTransform forKey:@"inputTransform"]; CIImage * myResult = [transform valueForKey:@"outputImage"]; if (myResult == Nil) NSLog(@"Transformation failed"); else { NSLog(@"Created transformation successfully ... now render it"); [myResult drawAtPoint: NSMakePoint ( 0,0 ) fromRect: NSMakeRect ( 0,0,128,128 ) operation: NSCompositeSourceOver fraction: 1.0]; //100% opaque [inputCIimage release]; } }

    Read the article

  • Re-ordering collection C#

    - by Adam
    Hi - I have a problem which I cant seem to find answer to through searches (either that or I am searching for the completely wrong thing!). I have a list of items called "Top 10" in a sortedlist item that is populated from my DB (SortedList where int is position and string is item). I want to be able to move items up & down the list order at the click of a button and then save the new order back to the DB. I am OK with the DB part it is just the re-ordering I am really struggling with - is a sortedlist the correct collection for this? Many thanks for any advice offered.

    Read the article

  • Where should document-related actions for a Cocoa app be implemented?

    - by Adam Preble
    I'm writing a document-based Cocoa app that's basically a graphical editing program. I want the user to be able to show/hide non-modal windows (such as an inspector window). Since these windows would be shown/hidden from menu items, where is the "best" place to implement the actions, such as - (IBAction)toggleInspector:(id)sender? I've seen that in the Sketch example code these are implemented in the app delegate, and the window controller instances are kept there as well, but that feels like more of a convenient place to put it than the most "graceful" place. Additionally, since this inspector would only be relevant when a document is open it feels like it should be associated more with the document's main NSWindowController than the app.

    Read the article

  • GetAccessControl error with NTAccount

    - by Adam Witko
    private bool HasRights(FileSystemRights fileSystemRights_, string fileName_, bool isFile_) { bool hasRights = false; WindowsIdentity WinIdentity = System.Security.Principal.WindowsIdentity.GetCurrent(); WindowsPrincipal WinPrincipal = new WindowsPrincipal(WinIdentity); AuthorizationRuleCollection arc = null; if (isFile_) { FileInfo fi = new FileInfo(@fileName_); arc = fi.GetAccessControl().GetAccessRules(true, true, typeof(NTAccount)); } else { DirectoryInfo di = new DirectoryInfo(@fileName_); arc = di.GetAccessControl().GetAccessRules(true, true, typeof(NTAccount)); } foreach (FileSystemAccessRule rule in arc) { if (WinPrincipal.IsInRole(rule.IdentityReference.Value)) { if (((int)rule.FileSystemRights & (int)fileSystemRights_) > 0) { if (rule.AccessControlType == AccessControlType.Allow) hasRights = true; else if (rule.AccessControlType == AccessControlType.Deny) { hasRights = false; break; } } } } return hasRights; } The above code block is causing me problems. When the WinPrincipal.IsInRole(rule.IdentityReference.Value) is executed the following exception occurs: "The trust relationship between the primary domain and the trusted domain failed.". I'm very new to using identities, principles and such so I don't know what's the problem. I'm assuming it's with the use of NTAccount? Thanks

    Read the article

  • How to determine where a Mailitem is being opened from in Outlook 2007 using VSTO 2005 SE

    - by Adam
    I have an Outlook 2007 Add-in in VSTO 2005 SE that allows users to save e-mails into our document management system. From within our system users are able to open e-mails they have previously saved. However, when doing so I need to try and prevent them from saving them again. I am trying to figure out how to determine if the Mailitem being opened is coming from the Outlook e-mail client or from an external source. I know that normally the EntryId Property of the Mailitem is null or empty string when a Mailitem has not been previously saved in Outlook, however, it seems like when a Mailitem is being opened from within our system the EntryID is not null.

    Read the article

  • Using cProfile results with KCacheGrind

    - by Adam Luchjenbroers
    I'm using cProfile to profile my Python program. Based upon this talk I was under the impression that KCacheGrind could parse and display the output from cProfile. However, when I go to import the file, KCacheGrind just displays an 'Unknown File Format' error in the status bar and sits there displaying nothing. Is there something special I need to do before my profiling stats are compatible with KCacheGrind? ... if profile: import cProfile profileFileName = 'Profiles/pythonray_' + time.strftime('%Y%m%d_%H%M%S') + '.profile' profile = cProfile.Profile() profile.run('pilImage = camera.render(scene, samplePattern)') profile.dump_stats(profileFileName) profile.print_stats() else: pilImage = camera.render(scene, samplePattern) ... Package Versions KCacheGrind 4.3.1 Python 2.6.2

    Read the article

  • .NET Multipage Tiff with Lossy Compression

    - by Adam Berent
    I need a way to take several jpgs and convert them into a single multi page Tiff. I have that working using GDI+ however it only works with the compression LZW which is lossless. This means that my 3 50KB Jpgs turn into 3MB multipage Tiff file. This is not something I can accept for the software that I am working on. I know that Tiff Image format can use a JPG compression scheme but GDI+ does not seem to support this. If anyone knows how to do this in .NET (C#) or of any component that does this conversion.

    Read the article

  • What is the point of a constant in C#

    - by Adam
    Can anyone tell what is the point of a constant in C#? For example, what is the advantage of doing cosnt int months = 12; as opposed to int months = 12; I get that constants can't be changed, but then why not just... not change it's value after you initialize it?

    Read the article

  • iphone sdk - why is the video returned not full res?

    - by ADAM
    im developing an app for the iphone and im able to get a video using a UIImagePickerController the problem is that the video thats returned by the UIImagePickerControllerMediaURL is not full resoultion -- its only 480 x 360 as opposed to 640 x 480 like the videos that sync to my itunes. -please someone tell me this is not a limitation of the current sdk? - how can i work around it and is there a way to set the uiimage picker so its taking full res video?

    Read the article

  • How to get rid of g++ hash_map deprecation warning?

    - by Adam
    When I compile a c++ application I'm writing that makes use of hash_map, I get this warning on g++ 4.3.2: You are using the deprecated header . To eliminate this warning, use an ANSI-standard header file or use hte -Wno-deprecated compiler flag. 9> #include <ext/hash_map> What include replaces this? I've searched for a while on google, and can't find anything except for people having similar problems, but no solution.

    Read the article

  • C# / IronPython Interop with shared C# Class Library

    - by Adam Haile
    I'm trying to use IronPython as an intermediary between a C# GUI and some C# libraries, so that it can be scripted post compile time. I have a Class library DLL that is used by both the GUI and the python and is something along the lines of this: namespace MyLib { public class MyClass { public string Name { get; set; } public MyClass(string name) { this.Name = name; } } } The IronPython code is as follows: import clr clr.AddReferenceToFile(r"MyLib.dll") from MyLib import MyClass ReturnObject = MyClass("Test") Then, in C# I would call it as follows: ScriptEngine engine = Python.CreateEngine(); ScriptScope scope = null; scope = engine.CreateScope(); ScriptSource source = engine.CreateScriptSourceFromFile("Script.py"); source.Execute(scope); MyClass mc = scope.GetVariable<MyClass>("ReturnObject ") When I call this last bit of code, source.Execute(scope) runs returns successfully, but when I try the GetVariable call, it throw the following exception Microsoft.Scripting.ArgumentTypeException: expected MyClass , got MyClass So, you can see that the class names are exactly the same, but for some reason it thinks they are different. The DLL is in a different directory than the .py file (I just didn't bother to write out all the path setup stuff), could it be that there is an issue with the interpreter for IronPython seeing these objects as difference because it's somehow seeing them as being in a different context or scope?

    Read the article

  • OOP C# Question: Making a Fruit a Pear

    - by Adam Kane
    Given that I have an instance of Fruit with some properties set, and I want to get those properties into a new Pear instance (because this particular Fruit happens to have the qualities of a pear), what's the best way to achieve this effect? For example, what we can't do is simple cast a Fruit to a Pear, because not all Fruits are Pears: public static class PearGenerator { public static Pear CreatePear () { // Make a new generic fruit. Fruit genericFruit = new Fruit(); // Upcast it to a pear. (Throws exception: Can't cast a Fruit to a Pear.) Pear pear = (Pear)genericFruit; // Return freshly grown pear. return ( pear ); } } public class Fruit { // some code } public class Pear : Fruit { public void PutInPie () { // some code } } Thanks! Update: I don't control the "new Fruit()" code. My starting point is that I've got a Fruit to work with. I need to get that Fruit into a new Pear somehow. Maybe copy all the properties one by one?

    Read the article

  • What is the best way to organize object oriented code?

    - by Adam
    I haven't coded in java for a long time, and after coding in C, I'm having issued organizing my code for OOP. More specifically I'm not sure when to create a new method, and when to create a new class, and when to just lump everything together. Are there some general rules or guidelines on how it should be done?

    Read the article

  • Using Wordpress as more than just a blog?

    - by Adam
    I have been making plans to create a site that would contain several different sections, such as several blog feeds for reviews and articals, a forum, and also a stock site where people can sell/buy photos. I was planning on doing this in PHP, but have recently started using wordpress and found it to be very powerful. is a site like this too "advanced" to be done in wordpress?

    Read the article

  • iPad Camera Connection kit?

    - by Adam
    Does anyone know if it is possible to access the iPad's camera connection kit? I would like to read the files off the connected mass storage device. Would this be possible or is this something that only Apple can do in there apps. Thanks

    Read the article

< Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >