Search Results

Search found 388 results on 16 pages for 'jp wann'.

Page 8/16 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Writing Ruby Libraries - hiding methods from outside the module

    - by JP
    Hi all, I'm writing a Ruby library which has a module with a bunch of classes inside it. Many of these classes need to be usable and modifiable by calling scripts, but I don't want (some of) the initializers to be visible/callable: module MyLib class Control def initialize # They can use this end def do_stuff Helper.new('things') end end class Helper # Shouldn't be visible def initialize(what) @what = what end def shout @what end end end c = MyLib::Control.new h = c.do_stuff p h.shout # => "things" # ^ All of this is desired # v This is undesirable p MyLib::Helper.new('!') # => <MyLib::Helper @what='!'> If it's a simple thing, then I'd also appreciate the generated RDoc not even include the .new method for the Helper class either. Any ideas? Thanks for reading!

    Read the article

  • Javascript Event for Select element Selection

    - by JP
    Hi everyone, I'm looking to find the Javascript Event I need to put into jQuery's .bind function in order to have the function triggered when a selection is made from a <select> element. At the moment I'm using .bind('change',function() { ...}) but I need the event to trigger when the selected option is chosen again. Any suggestions?

    Read the article

  • unicode convertion problem

    - by bhoomi-nature
    Hai frnds i am bhoomi new to php,i am having having below problem in my coding please can you help anyone 1.first i want to open one word document which is having content and i wann to edit it 2.for that i am opening word document from the server and at that time its opening with garbage value(i thing its not converting to utf8 format) 3.wen i delete that garbage value and insert something from textarea to that file it is going to insert and next time onwords its its getting open properly. 4.actually i wann that doc file should open with english words wats there in that doc instead of garbage value..first time opening only its giving problem. i am using below code for that please do the needful $filename = 'test.doc'; if(isset($_REQUEST['Submit'])){ $somecontent = stripslashes($_POST['somecontent']); // Let's make sure the file exists and is writable first. if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'w')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($somecontent) to file ($filename) - Continue - "; fclose($handle); } else { echo "The file $filename is not writable"; } } else{ // get contents of a file into a string $handle = fopen($filename, 'r'); $somecontent = fread($handle, filesize($filename)); ? Edit file

    Read the article

  • Using xval with fields containing periods

    - by JP
    Hello, I have been using xVal with success for a while but this evening ran into an issue where a field containing a period would not be validated (client or server-side). I am using ASP.NET MVC2 and need to use the period syntax in cases where I am model binding to a list. In the below example I am using a textbox for the sake of simplicity: xVal.AttachValidator(null, { "Fields": [{ "FieldName": "entry[622592].Value", "FieldRules": [{ "RuleName": "Required", "RuleParameters": {}}]}] }, {}) <input type="text" class="text" name="entry[622592].Value"/> If I replace both instances of "entry[622592].Value" to something trivial like "test" then the validation works successfully, but if i leave it this way the validation never appears to fire... Has anyone run into this issue? Thanks in advance!

    Read the article

  • Ruby & ActiveRecord: referring to integer fields by (uniquely mapped) strings

    - by JP
    While its not my application a simple way to explain my problem is to assume I'm running a URL shortener. Rather than attempt to try and figure out what the next string I should use as the unique section of the URL, I just index all my URLs by integer and map the numbers to strings behind the scenes, essentially just changing the base of the number to, let's say, 62: a-z + A-Z + 0-9. In ActiveRecord I can easily alter the reader for the url_id field so that it returns my base 62 string instead of the number being stored in the database: class Short < ActiveRecord::Base def url_id i = read_attribute(:convo) return '0' if i == 0 s = '' while i > 0 s << CHARS[i.modulo(62)] i /= 62 end s end end but is there a way to tell ActiveRecord to accept Short.find(:first,:conditions=>{:url_id=>'Ab7'}), ie. putting the 'decoding' logic into my Short ActiveRecord class? I guess I could define my own def self.find_by_unique_string(string), but that feels like cheating somehow! Thanks!

    Read the article

  • Twitter + Grackle, determining the logged in user

    - by JP
    This is crazy, but I'm stumped! Once my user has logged into twitter via OAuth how do I determine their username using grackle? @twitter = Grackle::Client.new(:auth => { :type => :oauth, :consumer_key => consumer_key, :consumer_secret => consumer_secret, :token => @access_token.token, :token_secret => @access_token.secret }) username = @twitte.something_here?

    Read the article

  • C++ enum casting and templates

    - by JP
    I get the following error with VS2008: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast) When casting a down casting a ClassA to ClassA_1 and ClassA_1 is a templated class that received an enum for parameter such as: ClassA { virtual ~ClassA(){}; } template <class Param1> ClassA_1 : public ClassA { public: //constructor ClassA_1(Param1 p1) { _p1 = p1; } Param1 _p1; } So I have a upcasted ClassA a = new ClassA_1<myenum>(); When I need to do this: ClassA_1<myenum> a1 = (ClassA_1<myenum> a); // This fails ... The only way it works is: ClassA_1<int> a1 = (ClassA_1<int> a); but this break my template as it must always deal with int... How to properly cast a enum that is now a int, back into the enum?

    Read the article

  • CSS: position:absolute inside position:relative, but not affecting parent?

    - by JP
    <style> #special p { display:none; } #special:hover p { display:block; } </style> <table> <tr> <td style="width:200px">Things</td> <td style="position:relative; width:220px"> <div style="position:absolute;right:0" id="special"> <img id="shows" /> <p>Variable width upto, say 600px (Will be hidden until this td is :hovered</p> </div> </td> </tr> </table> Can I make this work? Ie, can I make the #special p expand over the top of 'Things'? As I currently have it set up #special won't ever grow outside the 220px wide td. Any ideas?

    Read the article

  • iPhone SDK: How to get 4.0 on a device?

    - by jp chance
    This is a question about installing 4.0 on an 3rd gen iPod Touch. I already have a developer account. I have also downloaded the 4.0 SDK with XCode. I can test the new functionality in the simulator but I want to also try it on my device hence my question. I am looking for instructions on how to get it on my new third gen iPod Touch. Could someone suggest a link that has worked well for them? thanks.

    Read the article

  • Ruby: having callbacks on 'attr' objects

    - by JP
    Essentially I'm wondering how to place callbacks on objects in ruby, so that when an object is changed in anyway I can automatically trigger other changes: class MyClass attr_reader :proxy def proxy=(string_proxy = "") begin @proxy = URI.parse("http://"+((string_proxy.empty?) ? ENV['HTTP_PROXY'] : string_proxy)) @http = Net::HTTP::Proxy.new(@proxy.host,@proxy.port) rescue @http = Net::HTTP end end end m = MyClass.new m.proxy = "myproxy.com:8080" p m.proxy # => <URI: @host="myproxy.com" @port=8080> # However changing m.proxy will not change the @http variable, as proxy= is not being called. # Desired functionality: m.proxy = nil # Now @http.class is Net::HTTP, not Net::HTTP::Proxy

    Read the article

  • C++ Pass a hidden arg to a class constructor?

    - by JP
    I would like to define a class that accept the pointer to it's parent class as an Argument, but would it be possible to somehow pass it without needing to pass it directly such as: class Child { public: Child(Parent* hiddenArg); }; class Parent { public: Child myChild; }; I know this is weird, but I am making my own Signal/Slot implementation and Child would be a signal defined, but I would like to get the parent so I can use it's Event Dispatcher...

    Read the article

  • Adding a MouseOverHandler to an Element?

    - by JP
    I would like to listen for the mouse over event in GWT 1.6. Since GWT 1.6 has introduced handlers and deprecated listeners I'm unsure as to how I can accomplish this with what little information exists. Note: I have an Element object. That's what I need to add the mouse handler to. I apologize for my lack of clarity. Thanks!

    Read the article

  • Activerecord default accessors & unusual requirements

    - by JP
    I have an ActiveRecord::Base class which needs to have a field that is automatically generated when a new instance is made. How should I go about doing this? By defining an initialize function? class Thing < ActiveRecord::Base # 'special' (integer) needs to be set to lowest unused number (above 0) # considering that random rows will be removed via other processes end This is as far as I've got! Any ideas?

    Read the article

  • C++ Win/Linux thread syncronization Event

    - by JP
    Hello I have some code that is cross-platform by unsing #ifdef OS, I have a Queue protected by a CriticalSection on Windows, and by a pthread_mutex_t on Linux. I would like to implement a Wait(timeout) call that would block a thread until something has been enqueued. I though about using WaitForSingleObject on windows but it don't seem to support CriticalSection. Which Win32 and which Linux functions should I use to Wait and Signal for a condition to happen. Thank

    Read the article

  • Ruby: Allowing a module to have settings

    - by JP
    If I'm building a library in ruby, what's the best way to allow users of the library to set module-wide settings that will be available to all sub classes etc of the library? A good example would be if I'm writing a library for posting to a webservice: TheService::File.upload("myfile.txt") # Uploads anonymously TheService::Settings.login("myuser","mypass") # Or any other similar way of doing this TheService::File.upload("myfile.txt") # Uploads as 'myuser' The idea would be that unless TheService::Settings.logout is called then all TheService operations would be conducted under myuser's account. Any ideas?

    Read the article

  • Static page routing in Sinatra (Ruby)

    - by JP
    You can serve static files with Sinatra by placing them in public/ (by default) -- I have an index.html in there at the moment, but how can I make the root point to that file without having to parse it as a template? To be clear, I can access /index.html successfully, and I'd like to route / to be the same static file, but without redirecting. Any idea how to do this?

    Read the article

  • Windows Application Data Directory

    - by JP
    Not completely a programming question, but its close enough so here goes: In Mac OS I'll put user-specific files for my app in ~/Library/Application Data/{MyApp}/ and in *nix I'll put them in ~/.{MyApp}/ - where should I put them for Windows? I'll be using Ruby's File.expand_path to get to this directory, so if there's a windows equivalent of ~ then that's fine. (Answers for Windows XP, Vista and 7 would be appreciated if they're not the same)

    Read the article

  • ActiveRecord and transactionsin between `before_save` and `save`

    - by JP
    I have some logic in before_save whereby (only) when some conditions are met I let the new row be created with special_number equal to the maximum special_number in the database + 1. (If the conditions aren't met then I do something different, so I can't use auto-increments) My worry is that two threads acting on this database at once might pick the same special_number if the second is executed while the first is saving. Is there way to lock the database between before_save and finishing the save, but only in some cases? I know all saves are sent in transactions, will this do the job for me? def before_save if things_are_just_right # -- Issue some kind of lock? # -- self.lock? I have no idea # Pick new special_number new_special = self.class.maximum('special_number') + 1 write_attribute('special_number',new_special) else # No need to lock in this case write_attribute('special_number',some_other_number) end end

    Read the article

  • Ruby forwarding method calls

    - by JP
    I have an instance of a master class which generates instances of a subclass, these subclasses need to forward some method calls back to the master instance. At the moment I have code looking something like this, but it feels like I should be able to do the same thing more efficiently (maybe with method_missing?) class Master def initalize(mynum) @mynum = mynum end def one_thing(subinstance) "One thing with #{subinstance.var} from #{@mynum}" end def four_things(subinstance) "Four things with #{subinstance.var} from #{@mynum}" end def many_things(times,subinstance) "#{times} things with #{subinstance.var} from #{@mynum}" end def make_a_sub(uniqueness) Subthing.new(uniqueness,self) end class Subthing def initialize(uniqueness,master) @u = uniqueness @master = master end # Here I'm forwarding method calls def one_thing master.one_thing(self) end def four_things master.four_things(self) end def many_things(times) master.many_things(times,self) end end end m = Master.new(42) s = m.make_a_sub("very") s.one_thing === m.one_thing(s) s.many_things(8) === m.many_things(8,s) I hope you can see what's going on here. I would use method_missing, but I'm not sure how to cope with the possibility of some calls having arguments and some not (I can't really rearrange the order of the arguments to the Master methods either) Thanks for reading!

    Read the article

  • cattr_accessor outside of rails

    - by JP
    I'm trying to use the google_search ruby library (code follows) but it complains that 'cattr_accessor is an undefined method' - any ideas why this might be or how I could fix it? require 'rubygems' require 'google_search' GoogleSearch.web :q => "pink floyd"

    Read the article

  • C++ Macro problem, not replacing all values

    - by JP
    I have the following 2 macros: #define SCOPED_ENUM_HEADER(NAME) struct NAME{ enum _NAME{ #define SCOPED_ENUM_FOOTER(NAME) };}; typedef NAME::_NAME NAMEtype; Only the first instance of NAME get replaced by the passed NAME. What's wrong with it? Is is to be used in such a way: SCOPED_ENUM_HEADER(LOGLEVEL) UNSET, FILE, SCREEN SCOPED_ENUM_FOOTER(LOGLEVEL) Thanks you

    Read the article

  • C++ Macro problem, not remplacing all values

    - by JP
    I have the following 2 macros: #define SCOPED_ENUM_HEADER(NAME) struct NAME{ enum _NAME{ #define SCOPED_ENUM_FOOTER(NAME) };}; typedef NAME::_NAME NAMEtype; Only the first instance of NAME get remplaced by the passed NAME. What's wrong with it? Is is to be used in such a way: SCOPED_ENUM_HEADER(LOGLEVEL) UNSET, FILE, SCREEN SCOPED_ENUM_FOOTER(LOGLEVEL) Thanks you

    Read the article

  • Resgen al.exe generated resources do not work within .net library

    - by Raj G
    Hi, I am currently working on a library in .Net and I planned to make the strings that are used within the library into culture specific resource files. I made Resources.resx, Resources.en-US.resx and Resources.ja-JP.resx file. I also deleted the Resources.designer.cs file autogenerated by visual studio 2008. I am loading Resources through my custom ResourceManager object [using GetString method]. The problem that I am facing is that when I compile the library within visual studio and set the culture from the calling application, everything is working fine. But if I manually go to the directory and change a string for a culture and regenerate the satellite assembly with resgen and al.exe, the string displayed, falls back to the invariant culture. I have attached the ildasm view of both the dlls en-US generated from within visual studio //Metadata version: v2.0.50727 .assembly extern mscorlib { .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .hash = (71 05 4D 54 C4 8D C2 90 7D 8B CF 57 2E B5 98 22 // q.MT....}..W..." F5 5B 2E 06 ) // .[.. .ver 2:0:0:0 } .assembly EmailEngine.resources { .custom instance void [mscorlib]System.Reflection.AssemblyTitleAttribute::.ctor(string) = ( 01 00 0B 45 6D 61 69 6C 45 6E 67 69 6E 65 00 00 ) // ...EmailEngine.. .custom instance void [mscorlib]System.Reflection.AssemblyDescriptionAttribute::.ctor(string) = ( 01 00 FF 00 00 ) .custom instance void [mscorlib]System.Reflection.AssemblyCompanyAttribute::.ctor(string) = ( 01 00 FF 00 00 ) .custom instance void [mscorlib]System.Reflection.AssemblyProductAttribute::.ctor(string) = ( 01 00 0B 45 6D 61 69 6C 45 6E 67 69 6E 65 00 00 ) // ...EmailEngine.. .custom instance void [mscorlib]System.Reflection.AssemblyCopyrightAttribute::.ctor(string) = ( 01 00 12 43 6F 70 79 72 69 67 68 74 20 C2 A9 20 // ...Copyright .. 20 32 30 30 38 00 00 ) // 2008.. .custom instance void [mscorlib]System.Reflection.AssemblyTrademarkAttribute::.ctor(string) = ( 01 00 FF 00 00 ) .custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = ( 01 00 07 31 2E 30 2E 30 2E 30 00 00 ) // ...1.0.0.0.. .hash algorithm 0x00008004 .ver 1:0:0:0 .locale = (65 00 6E 00 2D 00 55 00 53 00 00 00 ) // e.n.-.U.S... } .mresource public 'EmailEngine.Properties.Resources.en-US.resources' { // Offset: 0x00000000 Length: 0x00000111 } .module EmailEngine.resources.dll // MVID: {D030D620-4E59-46F4-94F4-5EA0F9554E67} .imagebase 0x00400000 .file alignment 0x00000200 .stackreserve 0x00100000 .subsystem 0x0003 // WINDOWS_CUI .corflags 0x00000001 // ILONLY // Image base: 0x008B0000 ja-JP generated by me using resgen and al.exe // Metadata version: v2.0.50727 .assembly EmailEngine.resources { .hash algorithm 0x00008004 .ver 0:0:0:0 .locale = (6A 00 61 00 00 00 ) // j.a... } .mresource public 'EmailEngine.Properties.Resources.ja-JP.resources' { // Offset: 0x00000000 Length: 0x0000012F } .module EmailEngine.resources.dll // MVID: {0F470BCD-C36D-4B9F-A8ED-205A0E5A9F6F} .imagebase 0x00400000 .file alignment 0x00000200 .stackreserve 0x00100000 .subsystem 0x0003 // WINDOWS_CUI .corflags 0x00000001 // ILONLY // Image base: 0x007F0000 Can anyone help me as to why these two files are different and what is going on here? Why would the same Japanese resource file work when generated from within visual studio and not when generated using tools. TIA Raj

    Read the article

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