Daily Archives

Articles indexed Wednesday June 2 2010

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

  • gtk+ checkbutton settings

    - by jldupont
    Is there a way to use set_active on a gtkCheckButton but without the user being able to press/toggle the said button? In other words, I want to programmatically control the active state of the CheckButton but I don't want the user to be able to change it.

    Read the article

  • Parsing line with delimiter in Python

    - by neversaint
    I have lines of data which I want to parse. The data looks like this: a score=216 expect=1.05e-06 a score=180 expect=0.0394 What I want to do is to have a subroutine that parse them and return 2 values (score and expect) for each line. However this function of mine doesn't seem to work: def scoreEvalFromMaf(mafLines): for word in mafLines[0]: if word.startswith("score="): theScore = word.split('=')[1] theEval = word.split('=')[2] return [theScore, theEval] raise Exception("encountered an alignment without a score") Please advice what's the right way to do it?

    Read the article

  • Rearranging parts of the URL result from link_to in Rails

    - by mathee
    This is how I'm doing it now: link_to "Profile", :controller => "profiles", :action => "asked", :id => @profile # => <a href="/profiles/asked/1">Profile</a> Does it make more sense for the URL to be <a href="/profiles/1/asked">Profile</a>? Profile 1 asked some number of questions, so it makes more sense to me for the URL to look like: /:controller/:id/:action. If you agree, how do I accomplish this? If you don't agree, please let me know why. (I'm new to Ruby on Rails, so I'm still getting used to MVC conventions.) Any advice would be great!

    Read the article

  • Compiler Errors...it ran yesterday!?

    - by howdytest
    This is a pre-existing Java project being run in Eclipse 3.5.2 32 bit.. Day 1: Install Java SE 6 Update 20 JDK. Experience Crash in Eclipse. Install Java 5. Same problem-(uninstall java 5). Re-install Java 6. Install Eclipse 3.3.1. Install Eclipse 3.5.2. 32-bit. No problems. Run Eclipse 3.5.2. 64-bit. No problems. Set up the project, configure, and run. No problems. Day 2: Load Eclipse to start a new project. Previous project now has 940 errors. Error Type is "Java Problem". The project ran 100% without a problem on Day 1. The only thing that happened between Day 1 and Day 2 was restarting my computer. I just tried to recreate the project, step by step, and am still getting the same errors. I know it's not the code -- it was working. Not to mention that it's an opensource project, such a problem would be documented. I'm thinking something is wrong with my Java install. Or, perhaps, it's a 32-bit/64-bit problem. I'm running win7 64bit. So before formatting my window's partition, I thought I'd throw the problem your way to see if anyone knows what's going on. Thanks.

    Read the article

  • How to display a subview loaded from a separate NIB file

    - by Marcus Netter
    I'm developing a Cocoa desktop application that uses a source list in the style of iTunes: different elements in the source list cause the main content area to display different views. The content area is entirely filled with a (vertical) NSSplitView; on the left is an NSOutlineView source list. When the user selects an item on the left, the relevant view appears on the right side of the splitter. I can make it work well enough by putting everything in one NIB file and putting a borderless NSTabView to the right of the splitter; to switch views, I just have to change the selected tab. But putting all the views in one NIB is bad practice, so I'm trying to move each of the subviews into their own NIB files. I have a pretty good idea of most of this process — I've created an NSViewController subclass for each of these views (EntityDetailViewController, GroupDetailViewController, and so on), set the File's Owner of each new NIB to the relevant controller class, set the view connection in each NIB, and reworked the bindings. What I don't know is how to actually change which subview is being shown on screen. I've tried using the default generic NSView on the right side and sending it addSubview: messages; I've tried connecting to it as the first subview and calling NSView *newSubview = /* get subview from the new subview controller */ [[subview superview] replaceSubview:subview with:newSubview]; [self setSubview:newSubview]; But everything just leaves the space blank. How do I display a subview loaded from a separate NIB?

    Read the article

  • How to write applications that modifies the Windows UI?

    - by StevenGilligan
    Hi, I have this programming question that's been bothering me for some time now. I'm wondering how is it possible to write applications that change the Windows UI? More precisely how could you write an application that modifies the Windows Taskbar or the Windows Desktop? I'm really interested in this topic but cannot find a lot of information. I've read about extending the Windows Shell but I can't seem to find anything related to modifying the Taskbar and the Desktop. I'm looking for something along the lines of Rainmeter. How did those guys create an application that lives inside the Windows Desktop? I'd like to point out that my prefered language for this would be C# but if you want to give me hints in other languages I'm fine with it and I am running on Windows 7. Thank you

    Read the article

  • How to use AVAudioPlayer to play M4P

    - by SimpleCode
    I want to use AVAudioPlayer to play M4p files from iTunes generator. I could use uiWebView to play it and it worked, but I want to put an image of my choice on the background of the player instead of the "quick time" logo. Can you help me as how to do this? Here is an example of the m4p file I want to play with AVAudioPlayer. http://a801.phobos.apple.com/us/r1000/059/Music/b9/0d/be/mzi.zqnndbil.aac.p.m4p Seriously, big thanks in advance!!

    Read the article

  • Design Question - how do you break the dependency between classes using an interface?

    - by Seth Spearman
    Hello, I apologize in advance but this will be a long question. I'm stuck. I am trying to learn unit testing, C#, and design patterns - all at once. (Maybe that's my problem.) As such I am reading the Art of Unit Testing (Osherove), and Clean Code (Martin), and Head First Design Patterns (O'Reilly). I am just now beginning to understand delegates and events (which you would see if you were to troll my SO questions of recent). I still don't quite get lambdas. To contextualize all of this I have given myself a learning project I am calling goAlarms. I have an Alarm class with members you'd expect (NextAlarmTime, Name, AlarmGroup, Event Trigger etc.) I wanted the "Timer" of the alarm to be extensible so I created an IAlarmScheduler interface as follows... public interface AlarmScheduler { Dictionary<string,Alarm> AlarmList { get; } void Startup(); void Shutdown(); void AddTrigger(string triggerName, string groupName, Alarm alarm); void RemoveTrigger(string triggerName); void PauseTrigger(string triggerName); void ResumeTrigger(string triggerName); void PauseTriggerGroup(string groupName); void ResumeTriggerGroup(string groupName); void SetSnoozeTrigger(string triggerName, int duration); void SetNextOccurrence (string triggerName, DateTime nextOccurrence); } This IAlarmScheduler interface define a component that will RAISE an alarm (Trigger) which will bubble up to my Alarm class and raise the Trigger Event of the alarm itself. It is essentially the "Timer" component. I have found that the Quartz.net component is perfectly suited for this so I have created a QuartzAlarmScheduler class which implements IAlarmScheduler. All that is fine. My problem is that the Alarm class is abstract and I want to create a lot of different KINDS of alarm. For example, I already have a Heartbeat alarm (triggered every (int) interval of minutes), AppointmentAlarm (triggered on set date and time), Daily Alarm (triggered every day at X) and perhaps others. And Quartz.NET is perfectly suited to handle this. My problem is a design problem. I want to be able to instantiate an alarm of any kind without my Alarm class (or any derived classes) knowing anything about Quartz. The problem is that Quartz has awesome factories that return just the right setup for the Triggers that will be needed by my Alarm classes. So, for example, I can get a Quartz trigger by using TriggerUtils.MakeMinutelyTrigger to create a trigger for the heartbeat alarm described above. Or TriggerUtils.MakeDailyTrigger for the daily alarm. I guess I could sum it up this way. Indirectly or directly I want my alarm classes to be able to consume the TriggerUtils.Make* classes without knowing anything about them. I know that is a contradiction, but that is why I am asking the question. I thought about putting a delegate field into the alarm which would be assigned one of these Make method but by doing that I am creating a hard dependency between alarm and Quartz which I want to avoid for both unit testing purposes and design purposes. I thought of using a switch for the type in QuartzAlarmScheduler per here but I know it is bad design and I am trying to learn good design. If I may editorialize a bit. I've decided that coding (predefined) classes is easy. Design is HARD...in fact, really hard and I am really fighting feeling stupid right now. I guess I want to know if you really smart people took a while to really understand and master this stuff or should I feel stupid (as I do) because I haven't grasped it better in the couple of weeks/months I have been studying. You guys are awesome and thanks in advance for your answers. Seth

    Read the article

  • Problem with onRetainNonConfigurationInstance

    - by David
    I am writing a small app using the Android SDK, 1.6 target, and the Eclipse plug-in. I have layouts for both portrait and landscape mode, and most everything is working well. I say most because I am having issues with the orientation change. One part of the app has a ListView "on top of" another section. That section consists of 4 checkboxes, a button, and some TextViews. That is the portrait version. The landscape version replaces the ListView with a Spinner and rearranges some of the other components (but leaves the ALL resource ids the same). While in either orientation things work like they should. It's when the app switches orientation that things go off. Only 1 of the checkboxes maintains it's state throughout both layout changes. The other three CBs only maintain their state when going from landscape-portrait. I am also having problem getting the ListView/Spinner to correctly set themselves on changing. I am using onRetainNonConfigurationInstance() and creating a custom object that is returned. When I step through the code during a orientation change, the custom object is successfully pulled back out the the ether, and the widgets are being set to the correct values (inspecting them). But for some reason, once the onCreate is done, the checkboxes are not set to true. public class SkillSelectionActivity extends Activity { private Button rollDiceButton; private ListView skillListView; private CheckBox makeCommonCB; private CheckBox useEdgeCB; private CheckBox useSpecializationCB; private CheckBox isExtendedCB; private TextView skillNameView; private TextView skillRanksView; private TextView rollResultView; private TextView rollSuccessesView; private TextView rollFailuresView; private TextView extendedTestTotalView; private TextView extendedTestTimeView; private TextView skillSpecNameView; private int extendedTestTotal = 0; private int extendedTestTime = 0; private Skill currentSkill; private int currentPosition = 0; private SRCharacter character; private int skillSelectionType; private Spinner skillSpinnerView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.skill_selection2); Intent intent = getIntent(); Bundle extras = intent.getExtras(); skillSelectionType = extras.getInt("SKILL_SELECTION"); skillListView = (ListView) findViewById(R.id.skillList); skillSpinnerView = (Spinner) findViewById(R.id.skillSpinner); rollDiceButton = (Button) findViewById(R.id.rollDiceButton); makeCommonCB = (CheckBox) findViewById(R.id.makeCommonCB); useEdgeCB = (CheckBox) findViewById(R.id.useEdgeCB); useSpecializationCB = (CheckBox) findViewById(R.id.useSpecializationCB); isExtendedCB = (CheckBox) findViewById(R.id.extendedTestCB); skillNameView = (TextView) findViewById(R.id.skillName); skillRanksView = (TextView) findViewById(R.id.skillRanks); rollResultView = (TextView) findViewById(R.id.rollResult); rollSuccessesView = (TextView) findViewById(R.id.rollSuccesses); rollFailuresView = (TextView) findViewById(R.id.rollFailures); extendedTestTotalView = (TextView) findViewById(R.id.extendedTestTotal); extendedTestTimeView = (TextView) findViewById(R.id.extendedTestTime); skillSpecNameView = (TextView) findViewById(R.id.skillSpecName); character = ((SR4DR) getApplication()).getCharacter(); ConfigSaver data = (ConfigSaver) getLastNonConfigurationInstance(); if (data == null) { makeCommonCB.setChecked(false); useEdgeCB.setChecked(false); useSpecializationCB.setChecked(false); isExtendedCB.setChecked(false); currentSkill = null; } else { currentSkill = data.getSkill(); currentPosition = data.getPosition(); useEdgeCB.setChecked(data.isEdge()); useSpecializationCB.setChecked(data.isSpec()); isExtendedCB.setChecked(data.isExtended()); makeCommonCB.setChecked(data.isCommon()); if (skillSpinnerView != null) { skillSpinnerView.setSelection(currentPosition); } if (skillListView != null) { skillListView.setSelection(currentPosition); } } // Register handler for UI elements rollDiceButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // guts removed for clarity } }); makeCommonCB.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // guts removed for clarity } }); isExtendedCB.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // guts removed for clarity } }); useEdgeCB.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // guts removed for clarity } }); useSpecializationCB.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // guts removed for clarity } }); if (skillListView != null) { skillListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { // guts removed for clarity } }); } if (skillSpinnerView != null) { skillSpinnerView.setOnItemSelectedListener(new MyOnItemSelectedListener()); } populateSkillList(); } private void populateSkillList() { String[] list = character.getSkillNames(skillSelectionType); if (list == null) { list = new String[0]; } if (skillListView != null) { ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, list); skillListView.setAdapter(adapter); } if (skillSpinnerView != null) { ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); skillSpinnerView.setAdapter(adapter); } } public class MyOnItemSelectedListener implements OnItemSelectedListener { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // guts removed for clarity } public void onNothingSelected(AdapterView<?> parent) { // Do nothing. } } @Override public Object onRetainNonConfigurationInstance() { ConfigSaver cs = new ConfigSaver(currentSkill, currentPosition, useEdgeCB.isChecked(), useSpecializationCB.isChecked(), makeCommonCB.isChecked(), isExtendedCB.isChecked()); return cs; } class ConfigSaver { private Skill skill = null; private int position = 0; private boolean edge; private boolean spec; private boolean common; private boolean extended; public ConfigSaver(Skill skill, int position, boolean useEdge, boolean useSpec, boolean isCommon, boolean isExt) { this.setSkill(skill); this.position = position; this.edge = useEdge; this.spec = useSpec; this.common = isCommon; this.extended = isExt; } // public getters and setters removed for clarity } }

    Read the article

  • Stable random color algorithm

    - by Olmo
    Here we have an interesting real-world algorithm requirement involving colors. 1) Nice random colors: In ordeeing to draw a beautifull chart (i.e: pie chart) we need to pick a random set of Colors that: a) are different enought b) Play nicely Doesnt Look hard. For example u fix bright and saturation and divide hue in steps of 360/Num_sectors 2) Stable: given Pie1 with sectors with labes ('A','B','C') and Pie2 with sector with labels ('B','C','D'), will be nice if color('B',pie1)= color('B',pie2) and the same for 'C' and so on, so people don't get crazy when seeing similar updated charts, even if some sectors appear some dissapeared or the number of sectors changed. The label is the only stable thing. 3) hard-coded colors: the algorithm allows hardcoded label-color relationships as an input but stills doing a good work (1 & 2) for the rest of free labels. I think this algorithm, even if it looks quite ad-hoc, will be usefull in more then one situation. Any ideas?

    Read the article

  • Need feedback on two member functions of a Table class in C++

    - by George
    int Table::addPlayer(Player player, int position) { deque<Player>::iterator it = playerList.begin()+position; deque<Player>::iterator itStart = playerList.begin()+postion; while(*it != "(empty seat)") { it++; if (it == playerList.end()) { it = playerList.begin(); } if (it == itStart) { cout << "Table full" << endl; return -1; } } //TODO overload Player assignment, << operator *it = player; cout << "Player " << player << " sits at position " << it - playerList.begin() << endl; return it - playerList.begin(); } } int Table::removePlayer(Player player) { deque<Player>::iterator it = playerList.begin(); //TODO Do I need to overload != in Player? while(*it != player) { it++; if (it == playerList.end()) { cout << "Player " << player << " not found" << endl; return -1; } } *it = "(empty seat)"; cout << "Player " << player << " stands up from position " << it - playerList.begin() << endl; return it - playerList.begin(); } Would like some feedback on these two member functions of a Table class for Texas Hold Em Poker simulation. Any information syntax, efficiency or even common practices would be much appreciated.

    Read the article

  • How to insert bulk data into mysql table from asp.net at once.

    - by kranthi
    Hi, I have a requirement that I need to read an excel sheet using asp.net/C# and insert all the records into mysql table.The excel sheet consists of around 2000 rows and 50 columns. Currently,upon reading the excel records ,I am inserting the records one by one using a prepare statement into mysql table.But its taking around 70 secs to do so because of the huge data. I've also thought of creating a new datarow, assigning values to each cell,adding the resulting datarow to datatable and finally calling dataadapter.update(...).But it seems to be complex because I got around 50 columns and hence I'll have to assign 50 values to the datarow. Could someone please suggest if there is an alternate to improve the performance of the insertion? Thanks

    Read the article

  • Is it possible to include JButton in a JTable?

    - by Benjamin Confino
    I have a JTable that stores the results of a database query, so far so good. What I want is for the last column in each table to have a clickible JButton that will open the edit screen for the object represented in that row, and that means the button will need to know the details of the first column in the table from its own row (the ID from the database). Any advice? I already tried just adding JButtons but they turned into Text when I tried to run it.

    Read the article

  • SQL Injection When Using MySQLi Prepared Statements

    - by Sev
    If all that is used to do any and all database queries is MySQLi prepared statements with bound parameters in a web-app, is sql injection still possible? Notes I know that there are other forms of attack other than sql-injection, but my question is specific to sql-injection attacks on that particular web application only.

    Read the article

  • Is it possible to get the client process ID of an application that runs on SQL server?

    - by Andrea.Ko
    Hi all, For my VFP application, i have a program to check currently who is accessing the server (by using sp_who2), also another progam to check who is currently locking which table. But i wish to know which options my users is accessing at the moment. Am thinking if i can write a SP to get the current connected process ID for a specific client, and insert to a table(ActLog) in SQL with the program name pass into this table during users load the program. And delete that particular record when user unload the program. Then from the ActLog, i can know who is currently accessing to which program. At the moment, i wish to know if i able to get the client process ID? rgds/Andrea

    Read the article

  • Need to read a file, search for some data and output the data using PHP

    - by Kyle
    Hello...I am new to PHP (never really used it before tonight) and I need to use a PHP script to read the contents of a file on my website (http://kylemills.net/Geocaching/BadgeGen/MacroFiles/BadgeGenBeta.gsk) and then take some specific varying data and output it. For example: If my file contains the text: random text Here is some text #There is some text here too $Version = "V2.2.23 Beta" random text #some more text $Text="some text" If the above was the contents of my file, I need the script to return "V2.2.23 Beta" (without quotes). The idea is that as I update the file, the version changes and I want this to be reflected across my site. I am sorry if I don't make any sense...any help would be appreciated :) -Thanks so much, Kyle

    Read the article

  • Mono WCF NetTcp service takes only one client at a time

    - by vene
    While trying to build a client-server WCF application in Mono we ran into some issues. Reducing it to just a bare example we found that the service only accepts one client at a time. If another client attempts to connect, it hangs until the first one disconnects. Simply changing to BasicHttpBinding fixes it but we need NetTcpBinding for duplex communication. Also the problem does not appear if compiled under MS .NET. EDIT: I doubt (and hope not) that Mono doesn't support what I'm trying to do. Mono code usually throws NotImplementedExceptions in such cases as far as I noticed. I am using Mono v2.6.4 This is how the service is opened in our basic scenario: public static void Main (string[] args) { var binding = new NetTcpBinding (); binding.Security.Mode = SecurityMode.None; var address = new Uri ("net.tcp://localhost:8080"); var host = new ServiceHost (typeof(Hello)); host.AddServiceEndpoint (typeof(IHello), binding, address); ServiceThrottlingBehavior behavior = new ServiceThrottlingBehavior () { MaxConcurrentCalls = 100, MaxConcurrentSessions = 100, MaxConcurrentInstances = 100 }; host.Description.Behaviors.Add (behavior); host.Open (); Console.ReadLine (); host.Close (); } The client channel is obtained like this: var binding = new NetTcpBinding (); binding.Security.Mode = SecurityMode.None; var address = new EndpointAddress ("net.tcp://localhost:8080/"); var client = new ChannelFactory<IHello> (binding, address).CreateChannel (); As far as I know this is a Simplex connection, isn't it? The contract is simply: [ServiceContract] public interface IHello { [OperationContract] string Greet (string name); } Service implementation has no ServiceModel tags or attributes. I'll update with details as required.

    Read the article

  • Using DAO's or static methods in Domain Object with nHibernate

    - by mickyjtwin
    I am using nHibernate for the first time, and after alot of reading/researching, plus looking at other projects done with nHibernate, have seen a couple of implementation practices. I am looking for opinions about which would be best to use and why. Essentially the two methods are as follows: Using Data Access Objects and a DAO Factory. Example usage: INotificationListDAO nListDAO = NHDaoFactory.GetNotificationListDAO(); NotificationList list = nListDAO.GetByListID(""); Use Static methods in the Domain Object. Example usage: NotificationList list = NotificationList.GetByListID(""); NHHelper.Session.Get(id); NHHelper.Session basically calls the NHibernateSessionManager.Instace.GetSessionFrom(""). While both look similar, it is more to do with best practice. From what I understand, the first option is more so if you are developing enterprise level applications, where my requirements are more for mid-range websites.

    Read the article

  • DB time always showing as zero in Rails development log timings

    - by Olly
    I've noticed that the Rails log correctly displays the time taken to execute an action in the logs, and that the View: part of that is also rendered correctly. However, the DB: value is always zero: Aug 11 13:00:22 [2326] INFO: Completed in 2072ms (View: 94, DB: 0) | 200 OK In fact, all my DB timings are being logged as zero. I'm logging at DEBUG level, in development mode, running Rails 2.3.2. Apologies in advance if the answer is blatantly obvious.

    Read the article

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