Search Results

Search found 36 results on 2 pages for 'omer gencay'.

Page 2/2 | < Previous Page | 1 2 

  • Configurable Values in Enum

    - by Omer Akhter
    I often use this design in my code to maintain configurable values. Consider this code: public enum Options { REGEX_STRING("Some Regex"), REGEX_PATTERN(Pattern.compile(REGEX_STRING.getString()), false), THREAD_COUNT(2), OPTIONS_PATH("options.config", false), DEBUG(true), ALWAYS_SAVE_OPTIONS(true), THREAD_WAIT_MILLIS(1000); Object value; boolean saveValue = true; private Options(Object value) { this.value = value; } private Options(Object value, boolean saveValue) { this.value = value; this.saveValue = saveValue; } public void setValue(Object value) { this.value = value; } public Object getValue() { return value; } public String getString() { return value.toString(); } public boolean getBoolean() { Boolean booleanValue = (value instanceof Boolean) ? (Boolean) value : null; if (value == null) { try { booleanValue = Boolean.valueOf(value.toString()); } catch (Throwable t) { } } // We want a NullPointerException here return booleanValue.booleanValue(); } public int getInteger() { Integer integerValue = (value instanceof Number) ? ((Number) value).intValue() : null; if (integerValue == null) { try { integerValue = Integer.valueOf(value.toString()); } catch (Throwable t) { } } return integerValue.intValue(); } public float getFloat() { Float floatValue = (value instanceof Number) ? ((Number) value).floatValue() : null; if (floatValue == null) { try { floatValue = Float.valueOf(value.toString()); } catch (Throwable t) { } } return floatValue.floatValue(); } public static void saveToFile(String path) throws IOException { FileWriter fw = new FileWriter(path); Properties properties = new Properties(); for (Options option : Options.values()) { if (option.saveValue) { properties.setProperty(option.name(), option.getString()); } } if (DEBUG.getBoolean()) { properties.list(System.out); } properties.store(fw, null); } public static void loadFromFile(String path) throws IOException { FileReader fr = new FileReader(path); Properties properties = new Properties(); properties.load(fr); if (DEBUG.getBoolean()) { properties.list(System.out); } Object value = null; for (Options option : Options.values()) { if (option.saveValue) { Class<?> clazz = option.value.getClass(); try { if (String.class.equals(clazz)) { value = properties.getProperty(option.name()); } else { value = clazz.getConstructor(String.class).newInstance(properties.getProperty(option.name())); } } catch (NoSuchMethodException ex) { Debug.log(ex); } catch (InstantiationException ex) { Debug.log(ex); } catch (IllegalAccessException ex) { Debug.log(ex); } catch (IllegalArgumentException ex) { Debug.log(ex); } catch (InvocationTargetException ex) { Debug.log(ex); } if (value != null) { option.setValue(value); } } } } } This way, I can save and retrieve values from files easily. The problem is that I don't want to repeat this code everywhere. Like as we know, enums can't be extended; so wherever I use this, I have to put all these methods there. I want only to declare the values and that if they should be persisted. No method definitions each time; any ideas?

    Read the article

  • Jquery dynamic button : how to bind to exisitng click event by class

    - by omer bach
    I have a click event triggered by the class selector inside the jquery ready scope: $(".testBtn").click(function() { alert("This Works"); }); This works fine for static buttons how ever this doesn't work for dynamic buttons which are added upon clicking the button with "addRowBtn" id. I'm guessing that it has something to do with that the button is created after the event is registered but still the new button has the 'testBtn' class so it makes sense it should work. Any idea what am i doing wrong and how to make the dynamic buttons registered to the class selector click event? Here is the whole code, you can copy and paste into an html, click the 'add button' and try to click the added buttons. you'll see nothing happens. <html> <head> <script src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'></script> <script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js'></script> <script> $(function() { $(".addRowBtn").click(function() { $("#mainTable tr:last").after("<tr><td><button class='testBtn'>NotWorking</button></td></tr>"); }); $(".testBtn").click(function() { alert("This Works"); }); }); </script> </head> <body> <table id="mainTable"> <button class="addRowBtn">Add button</button> <tr><th>Testing</th></tr> <tr><td><button class='testBtn'>Working</button></td></tr> </table> </body> </html>

    Read the article

  • How is "Make Object ID" implemented in the .NET debugger?

    - by Omer Raviv
    Hi, I would like know how this feature is implemented in VS - I understand it holds some sort of weak-reference to the object in the debugged-application's memory, but how exactly is it accomplished? I know simply tracking the address (as in native code) wouldn't work, because the GC might move the object about, invalidating the address. Thanks.

    Read the article

  • Which is the best Linux C/C++ debugger (or front-end to gdb) to help teaching programming?

    - by omer.gimenez
    I teach a sort of "lite" C++ programming course to novices ("lite" meaning no pointers, no classes, just plain old C, plus references and STL string and vectors). Students have no previous experience in programming, so I believe that using an interactive debugger would help them understand program flow, variables, and recursion. The course is taught in Linux. Teaching them to use gdb is just overkill (they will not use nor understand most features). I just need something simple but easy to use: to see at which line the program is now, what is in the stack (local variables, previous calls, etc.). I look something similar to old Turbo Pascal or Turbo C++ Borland's debugger, or Visual Studio debugger. Thank you,

    Read the article

  • JQuery Active Refresh Not Working After Server-Side Redirect

    - by Ömer Faruk AK
    I have a page which is refreshing actively every 5 second. But when i click a button from the page which is redirect to itself at server-side and then it's not refreshing. What can i do? JQuery Code; <script type="text/javascript" charset="${_response_encoding}"> // Reload the whole messages panel var refresh = function() { $('#thread').load('@{room()} #thread', function() { $('#thread').trigger('create'); }); } var create = function(){ $('#thread').trigger('create'); } // Call refresh every 5 seconds $(document).ready(setInterval(refresh, 5000)); </script> Server-Side Code; public static void served(Long servingID) { Serving serv = Serving.findById(servingID); serv.isServed = true; serv.save(); index(); }

    Read the article

  • Hyper reference links in Latex document starts from the beginning of the page

    - by okhalid
    Hi, I have a latex document. I am using hyperref, makeidx and glossary packages for my document. Every thing is created fine; table of content (all references works nicely), glossary and index except that page numbers printed in the glossary and index are correct but they point to page numbers starting from the beginning of the document where initial 10 pages are in arabic numbers and then roman numbers from 1 starts. e.g. I have 10 pages for initial front matter (abstract, declaration, table of contents etc etc). After that, mainmatter begins and so does the page numbers in roman from 1. So on this page 1, I have an index entry "hello" Now in the index, it prints "hello 1" which is correct except that when one clicks on 1, then it goes to the right at the beginning of the document rather then numbered page 1. Your help would be much appreciated. Thanks, Omer

    Read the article

  • How to execute a command from with in MSI?

    - by okhalid
    Hi, I have a installation setup with works like this: /exec.exe /some-command This whole setup is located on a shared disk to which my target machine have access to. All i want is to create a small MSI wrapper that basically executes the above command. I don't need to any other fancy things? I looked up on the web; there are tools that create MSI for you but they generate huge amount of other things with them as well. My need is very simple and straight forward. It would be great if some could help me with this issue. Thanks, Omer

    Read the article

  • Wrong chapter number on page headers except first page

    - by okhalid
    Hi, I am writing up my thesis in Latex and have a template. It works nicely for every thing else except one. Chapter numbers are correctly incremented on the first page of each chapter but for consecutive pages of each chapter, the header saying "Chapter x - This is a chapter title" have 1 always as chapter number. Following is the code sample from the CLS file which i think is relevant to the headers: \newcommand\btypeout[1]{\bhrule\typeout{\space #1}\bhrule} \def\today{\ifcase\month\or January\or February\or March\or April\or May\or June\or July\or August\or September\or October\or November\or December\fi \space \number\year} \usepackage{setspace} \onehalfspacing \setlength{\parindent}{0pt} \setlength{\parskip}{2.0ex plus0.5ex minus0.2ex} \usepackage{vmargin} \setmarginsrb { 1.5in} % left margin { 0.6in} % top margin { 1.0in} % right margin { 0.8in} % bottom margin { 20pt} % head height {0.25in} % head sep { 9pt} % foot height { 0.3in} % foot sep \raggedbottom \setlength{\topskip}{1\topskip \@plus 5\p@} \doublehyphendemerits=10000 % No consecutive line hyphens. \brokenpenalty=10000 % No broken words across columns/pages. \widowpenalty=9999 % Almost no widows at bottom of page. \clubpenalty=9999 % Almost no orphans at top of page. \interfootnotelinepenalty=9999 % Almost never break footnotes. \usepackage{fancyhdr} \lhead[\rm\thepage]{\fancyplain{}{\sl{\rightmark}}} \rhead[\fancyplain{}{\sl{\leftmark}}]{\rm\thepage} \chead{}\lfoot{}\rfoot{}\cfoot{} \pagestyle{fancy} %% Chapter Heading --------------- \renewcommand{\chaptermark}[1]{\btypeout{\thechapter\space #1}\markboth{\@chapapp\ \thechapter\ #1}{\@chapapp\ \thechapter\ #1}} %%-------------------------------------------------- \renewcommand{\sectionmark}[1]{} \renewcommand{\subsectionmark}[1]{} \def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else \hbox{} \thispagestyle{empty} \newpage \if@twocolumn\hbox{}\newpage\fi\fi\fi} Thanks, Omer

    Read the article

  • Go for Zend framework or Django for a modular web application?

    - by dr. squid
    I am using both Zend framework and Django, and they both have they strengths and weakness, but they are both good framworks in their own way. I do want to create a highly modular web application, like this example: modules: Admin cms articles sections ... ... ... I also want all modules to be self contained with all confid and template files. I have been looking into a way to solve this is zend the last days, but adding one omer level to the module setup doesn't feel right. I am sure this could be done, but should I? I have also included Doctrine to my zend application that could give me even more problems in my module setup! When we are talking about Django this is easy to implement (Easy as in concept, not in implementation time or whatever) and a great way to create web apps. But one of the downsides of Django is the web hosing part. There are some web hosts offering Django support, but not that many.. So then I guess the question is what have the most value; rapid modular development versus hosting options! Well, comments are welcome! Thanks

    Read the article

  • Menu floating to the right on IE and to the left in FF

    - by the_drow
    I am working on a website that has a menu which behaves correctly on FF but not on IE (as usuall). On IE it floats to the right while it should float to the left, however if float is set to none it behaves almost correctly, attaching the onto the top of the container. Here's the css: #navigation_wrap { background: url(../images/ltr/nav_bg.png); height: 34px; width: 954px; } .btn_login { float: right; margin: 4px 4px 0 0; } .navigation { float: left; } .navigation ul { list-style: none; margin: 8px 0 0 15px; } .navigation ul li { border-right: 1px solid white; float: left; padding: 0 12px 0 12px; } .navigation ul li.last { border: none; } .navigation ul li a { color: white; font-size: 14px; text-decoration: none; } .navigation ul li a:hover { text-decoration: underline; } .navigation ul li a.active { font-weight: bold; } And here's the html: <div id="navigation_wrap"> <div class="navigation"> <ul> <li><a class="active" href="default.asp">Home Page</a></li> <li><a class="" href="faq.asp">FAQ</a></li><li><a class="" href="articles.asp">Articles</a></li> <li><a class="" href="products.asp">Packages &amp; Pricing</a></li> <li><a class="" href="gp.asp?gpid=15">test1</a></li> <li><a class=" last" href="gp.asp?gpid=17">test asher</a></li> </ul> </div> <div class="btn_login"> ... </div> </div> I hope anyone would have an idea. Thanks, Omer.

    Read the article

< Previous Page | 1 2