Search Results

Search found 31491 results on 1260 pages for 'simple talk'.

Page 38/1260 | < Previous Page | 34 35 36 37 38 39 40 41 42 43 44 45  | Next Page >

  • Converting string to a simple type

    - by zespri
    .Net framework contains a great class named Convert that allows conversion between simple types, DateTime type and String type. Also the class support conversion of the types implementing IConvertible interface. The class has been implemented in the very first version of .Net framework. There were a few things in the first .Net framework that were not done quite right. For example .Parse methods on simple types would throw an exception if the string couldn't be parsed and there would be no way to check if exception is going to be thrown in advance. A future version of .Net Framework removed this deficiency by introducing the TryParse method that resolved this problem. The Convert class dates back to time of the old Parse method, so the ChangeType method on this class in implemented old style - if conversion can't be performed an exception is thrown. Take a look at the following code: public static T ConvertString<T>(string s, T @default) { try { return (T)Convert.ChangeType(s, typeof(T), CultureInfo.InvariantCulture); } catch (Exception) { return @default; } } This code basically does what I want. However I would pretty much like to avoid the ugly try/catch here. I'm sure, that similar to TryParse, there is a modern method of rewriting this code without the catch-all. Could you suggest one?

    Read the article

  • simple image animation with the keyboard

    - by conorhiggins
    Hi the app I am currently working on requires a simple animation to be performed, which I am able to do but timing is an issue. The app uses the slightly opaque keyboard and I have set up a black background to make it more visually pleasing . The app is a utility app and as the user clicks on a settings button the app will flip which looks great. However there is a problem at the moment in that while the app is flipping the keyboard also closes which itself looks great also, however the background remains. I was wondering if there was a way of animating the background image to follow the keyboard's animation pattern and speed? If I set up a discrete animation time the chances are there will be some sort of overlap and either the image will show too long or the keyboard will show too long. Any suggestions? Another option is to make the keyboard show constantly if anyone knows how to do that? i would rather animate it though as it is quite a simple app and so I would like to make it as aesthetically pleasing as possible. /Conor

    Read the article

  • Simple HTML interface to XSD?

    - by Visage
    I'm writing an app that, at its heart, uses a hierarchical tree of nodes in XML, it looks like this: <node> <name>Node1</name> <Attribute1>Something</Attribute1> <Attribute2>SomethingElse</Attribute2> <child>Node2</child> <child>Node4</child> <child>Node7</child> </node> And so on (all child elements must refer to an existing node, though the node inquestion doesnt have to precede the first reference to it) For a simple structure like this is there a simple tool to generate a html page that will allow a user to enter Nodes and dynamically update a server-side xml file? Im basically writing a tool that will use such a file, but the people who's job it is to create the file arent especially techno-literate, so creating the XML by hand is a no-no. I could hand-crank one fairly quickly, but if I can get a tool to do it, even better (especially as the format may change in future)....

    Read the article

  • Building simple jQuery plugin, need assistance

    - by kirisu_kun
    Hi there, I'm building my first ever jQuery plugin (it's just a simple experiment). Here's what I have so far: (function($){ $.fn.extend({ auchieFader: function(options) { var defaults = { mask: '', topImg : '', } var options = $.extend(defaults, options); return this.each(function() { var o = options; var obj = $(this); var masker = $(o.mask, obj); masker.hover(function () { $(o.topImg).stop().animate({ "opacity": "0" }, "slow"); }, function () { $(o.topImg).stop().animate({ "opacity": "1" }, "slow"); }); }); } }); })(jQuery); I'm then calling the plugin using: $('.fader').auchieFader({mask: ".mask", topImg: ".top"}); If I then add another request say: $('.fader2').auchieFader({mask: ".mask", topImg: ".top"}); Then no matter what instance of my 2 faders I hover both of them will trigger. I know this is because my mask mask and topImg options have the same class - but how can I modify the plugin to allow for these items to have the same class? I know it's probably something really simple, but I'm still finding my way with jQuery and Javascript in general. Any other tips on improving my code would also be greatly appreciated! Cheers, Chris

    Read the article

  • problem with a very simple tile based game

    - by newbieguy
    Hello, I am trying to create a pacman-like game. I have an array that looks like this: array: 1111111111111 1000000000001 1111110111111 1000000000001 1111111111111 1 = Wall, 0 = Empty space I use this array to draw tiles that are 16x16 in size. The Game character is 32x32. Initially I represented the character's position in array indexes, [1,1] etc. I would update his position if array[character.new_y][charater.new_x] == 0 Then I translated these array coordinates to pixels, [y*16, x*16] to draw him. He was lining up nicely, wouldn't go into walls, but I noticed that since I was updating him by 16 pixels each, he was moving very fast. I decided to do it in reverse, to store the game character's position in pixels instead, so that he could use less than 16 pixels per move. I thought that a simple if statement such as this: if array[(character.new_pixel_y)/16][(character.new_pixel_x)/16] == 0 would prevent him from going into walls, but unfortunately he eats a bit of the bottom and right side walls. Any ideas how would I properly translate pixel position to the array indexes? I guess this is something simple, but I really can't figure it out :(

    Read the article

  • How to make simple dicitonary J2ME

    - by batosai_fk
    Hi, I am beginner in JavaME. I'd like to make simple dicitionary. The source data is placed on "data.txt" file in "res" directory. The structure is like this: #apple=kind of fruit; #spinach=kind of vegetable; The flow is so simple. User enters word that he want to search in a text field, e.g "apple", system take the user input, read the "data.txt", search the matched word in it, take corresponding word, and display it to another textfield/textbox. I've managed to read whole "data.txt" using this code.. private String readDataText() { InputStream is = getClass().getResourceAsStream("data.txt"); try { StringBuffer sb = new StringBuffer(); int chr, i=0; while ((chr = is.read()) != -1) sb.append((char) chr); return sb.toString(); } catch (Exception e) { } return null; } but I still dont know how to split it, find the matched word with the user input and take corresponding word. Hope somebody willing to share his/her knowledge to help me.. Add to batosai_fk's Reputation

    Read the article

  • Creating simple calculator with bison & flex in C++ (not C)

    - by ak91
    Hey, I would like to create simple C++ calculator using bison and flex. Please note I'm new to the creating parsers. I already found few examples in bison/flex but they were all written in C. My goal is to create C++ code, where classes would contain nodes of values, operations, funcs - to create AST (evaluation would be done just after creating whole AST - starting from the root and going forward). For example: my_var = sqrt(9 ** 2 - 32) + 4 - 20 / 5 my_var * 3 Would be parsed as: = / \ my_var + / \ sqrt - | / \ - 4 / / \ / \ ** 32 20 5 / \ 9 2 and the second AST would look like: * / \ my_var 3 Then following pseudocode reflects AST: ast_root = create_node('=', new_variable("my_var"), exp) where exp is: exp = create_node(OPERATOR, val1, val2) but NOT like this: $$ = $1 OPERATOR $3 because this way I directly get value of operation instead of creation the Node. I believe the Node should contain type (of operation), val1 (Node), val2 (Node). In some cases val2 would be NULL, like above mentioned sqrt which takes in the end one argument. Right? It will be nice if you can propose me C++ skeleton (without evaluation) for above described problem (including *.y file creating AST) to help me understand the way of creating/holding Nodes in AST. Code can be snipped, just to let me get the idea. I'll also be grateful if you point me to an existing (possibly simple) example if you know any. Thank you all for your time and assistance!

    Read the article

  • Cannot press QPushButton in a simple program

    - by shadyabhi
    Basically, I want a simple pushButton with a colorful text which when pressed exits the application. Why cant I press PushButton in this simple program. I am using QT 4.6 on Arch x86_64. #include <QtGui/QApplication> #include <QLabel> #include <QPushButton> #include<QtGui> int main(int argc, char *argv[]) { QApplication a(argc, argv); QMainWindow *Main=new QMainWindow; QPushButton *button = new QPushButton(Main); QLabel *label = new QLabel(Main); label->setText("<h2><i>Hello</i> ""<font color=red>Qt!</font></h2>"); label->setVisible(true); QObject::connect(button, SIGNAL(clicked()),label, SLOT(clear())); label->setAlignment(Qt::AlignCenter|Qt::AlignVCenter); label->setWindowTitle("HelloWorld Test Program"); Main->show(); return a.exec(); }

    Read the article

  • c++ simple conditional logging

    - by Sunny
    Disclaimer: I'm not a c++ developer, I can only do basic things. (I understand pointers, just my knowledge is so rusty, I haven't touch c/c++ for about 20 years :) ) The setup: I have an Outlook addin, written in C#/.Net 1.1. It uses a c++ shim to load. Usually, this works pretty well, and I use in my c# code nlog for logging purposes. But sometimes, the addin fails to load, i.t. it does not hit the managed code at all for me to be able to investigate the problem from the log files. So, I need to hook some basic logging into the c++ shim - just writing in a file. I need to make it as simple as possible for our users to enable. Actually I would prefer not to ship it by default. I was thinking about something, which will check if a specific dll is present (the logging dll), and if so, to use it. Otherwise, it will just not log anything. That way, when I have a user with such a problems, I can send him only the logging dll, the user will save it in the runtime directory, and I'll have the file. I guess this have to be done with some form a factory solution, which returns either a dummy logger, or if the dll is found, a real one. Another option would be to make some simple logger, and rebuild the shim with or w/o using it, based on directives. This is not the desirable approach, because the shim needs to be signed, and I have to instruct the user to make a backup copy of the "real" one, then restore when done, etc., instead of just saving and deleting a dll. I'd appreciate any good suggestion how to approach it, together with links or sample code how to go after this. Cheers

    Read the article

  • Creating a Simple C# Wrapper to clean up code

    - by Tangopop
    I have this code: public void Contacts(string domainToBeTested, string[] browserList, string timeOut, int numberOfBrowsers) { verificationErrors = new StringBuilder(); for (int i = 0; i < numberOfBrowsers; i++) { ISelenium selenium = new DefaultSelenium("LMTS10", 4444, browserList[i], domainToBeTested); try { selenium.Start(); selenium.Open(domainToBeTested); selenium.Click("link=Email"); Assert.IsTrue(selenium.IsElementPresent("//div[@id='tabs-2']/p/a/strong")); selenium.Click("link=Address"); Assert.IsTrue(selenium.IsElementPresent("//div[@id='tabs-3']/p/strong")); selenium.Click("link=Telephone"); Assert.IsTrue(selenium.IsElementPresent("//div[@id='tabs-1']/ul/li/strong")); } catch (AssertionException e) { verificationErrors.AppendLine(browserList[i] + " :: " + e.Message); } finally { selenium.Stop(); } } Assert.AreEqual("", verificationErrors.ToString(), verificationErrors.ToString()); } My problem is i would like to make it so that i can use the code surrounding the 'try' many many times in the rest of the code. I think it has something to do with wrappers, but i can't get a simple answer for this from the web. So in simple terms the only piece of this code which changes is the bit between the try {} the rest is standard code that i have currently used over 100 times and is turning out to be a pain to maintain. Hope this is clear, many thanks.

    Read the article

  • Aligning left and right in a simple footer

    - by Wolfram
    I'm currently working on a simple footer, and I would like to align one line of text left and the other to the right. This is what I have so far: <div id="footer"> Last Updated: October 15, 2012 <!--left align--> Contact Us Login <!--right align (these will be links)--> </div> #footer { font-family: Arial; font-size: .9em; color: #24ACAE; border-top: 1px solid #24ACAE; margin-left: 90px; margin-right: 90px; padding-top: 5px; } The above code results in the two lines of text being next to each other and I've tried various ways of fixing this such as putting the the 2nd line in a span and aligning right and even putting the lines into a table. None of what I have tried has resulted in both lines being properly aligned. Using a margin-left alone does not work because when the first line is updated and becomes longer, it will push the second line downwards. Relative positioning seems to have the same issue. Hopefully there's something simple that I'm overlooking.

    Read the article

  • Simple search engine issues

    - by user1184100
    Simple search engine issues.. I'm creating a simple search engine but i'm not able to figure out how to go about it. So here's what I have tried. I need to get the results based on first/last name.. JSFiddle : http://jsfiddle.net/WSPbP/ JS $(document).ready(function() { $('#sbutn').click(function() { $v = $('#searchbox').val(); console.log($('#myConnections >div').find("div:contains("+$v+")")); }); }); HTML <div id="searchelement"> <div class="search"><input type="text" name="search" id="searchbox" value="" /></div> <div class="searchbutton" id="sbutn"><button type="button">Search</button></div> </div> </br> <div id="myConnections"> <div class="left" style="width:100px; height:100px;"> <img style="width:70px; height:70px;" src="picture1.jpg" alt=""><br> person1_xyz </div> <div class="left" style="width:100px; height:100px;"> <img style="width:70px; height:70px;" src="picture2.jpg" alt=""><br> person2 abc </div> </div>

    Read the article

  • json-simple API

    - by cp
    Hello Is there a javadoc for json-simple? I am trying to make a JSONObject from an existing map among other calls and this trial by casting is getting too much, grin. thx.

    Read the article

  • simple onmouseover to call javascript not working

    - by tic
    In a simple html page I have: <SCRIPT> function Clicker(number){ if (number == 1) document.write ('<style type="text/css">body {background-color: #cccccc;}</style>'); } </SCRIPT> and in the html body: <a onmouseclick="Clicker(1)" href="#">clic</a> But when I click on the link nothing happens. Where am I wrong?

    Read the article

  • Simple forloop - Python

    - by RadiantHex
    Hi folks, this is probably too simple of a question, but here I go. I have paginated items, each page contains 100 items. The program fetches items till it reaches the item index specified within item_num This is what I have: item_num = 56 range(0, item_num/100 + (item_num%100 > 0)): get_next_100() I'm not really sure about the (item_num%100 0) boolean I used. Is there anything wrong with what I did?

    Read the article

  • Very Simple Regex Question

    - by Sunil
    Hello sir I have a very simple regex question suppose I have 2 condition 1 url =http://www.abc.com/cde/def 2 url =https://www.abc.com/sadfl/dsaf and how can I extract the baseUrl using regex. sample output 1 http://www.abc.com 2 https://www.abc.com Thanks

    Read the article

  • Simple Prime Generator in Python

    - by marc lincoln
    Hi, could someone please tell me what I'm doing wrong with this code. It is just printing 'count' anyway. I just want a very simple prime generator (nothing fancy). Thanks a lot. lincoln. import math def main(): count = 3 one = 1 while one == 1: for x in range(2, int(math.sqrt(count) + 1)): if count % x == 0: continue if count % x != 0: print count count += 1

    Read the article

  • Simple thread-safe non-blocking file logger class in c#

    - by Jason Renlan
    I have a web application, that will log some information to a file. I am looking for a simple thread-safe non-blocking file logger class in c#. I have little experience with threading. I known there are great logging components out there like log4Net, Enterprise Library Logging Block, ELMAH, but I do not want an external dependence for my application. I was thinking about using this queue implementation http://www.codeproject.com/KB/cpp/lockfreeq.aspx

    Read the article

  • Simple Inversion of Control framework for Java/Scala

    - by Alexey Romanov
    I am looking for a simple to use IoC container for GUI applications written in Java/Scala. It should support Convention over Configuration, lifecycle management, configuration in code (preferably without any XML needed at all), and checking dependencies at compile-time as much as possible. Something similar to Autofac would be perfect.

    Read the article

  • How to make SIMPLE C++ Makefile?

    - by befall
    Hi everyone, For a project, we are required to use a makefile to pull everything together, but our abhorrent professor never showed us how to. I only have ONE file, a3driver.cpp. The driver imports a class from a location "/user/cse232/Examples/example32.sequence.cpp". That's it, everything else is contained with the .cpp. How would I go about making a simple Makefile that creates an executable called "a3a.exe"?

    Read the article

  • Any simple shape recognition libraries for Java?

    - by Phil
    I am working on a on-screen keyboard for Android, and I need to recognize starting points, turning points and end points of lines drawn by the user on the keyboard. A simple straightening function would be nice, as it is difficult to draw a perfectly straight line even with a stylus, not to mention finger-only touchscreens today. What I am trying to write is something like Swype. Any good libraries that I can use or make reference to?

    Read the article

  • RESTEasy - simple string array/collection marshalling

    - by peperg
    Is there a simple way for marshalling and unmarshalling String[] or List in RESTEasy? My code sample : @GET @Path("/getSomething") @Produces(MediaType.APPLICATION_JSON) public List<String> getSomeData() { return Arrays.asList("a","b","c","d"); } Above gives me an Exception : Could not find MessageBodyWriter for response object of type: java.util.Arrays$ArrayList of media type: application/json

    Read the article

  • A simple way to implement pathfinding using bullet physics - iPhone SDK

    - by Dave
    Hi, I have bullet physics set up and working on the iPhone but now I want to implement some sort of path finding with it. The problem is I have no idea where to start, the level is pretty simple just a lot of pillars that I want the 'bad guys' to navigate around to get to the player character. Do you have any suggestions or are there any tutorials you recommend for pathfinding using this on the iPhone?

    Read the article

< Previous Page | 34 35 36 37 38 39 40 41 42 43 44 45  | Next Page >