Search Results

Search found 1594 results on 64 pages for 'initialization'.

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

  • a better way to initialize database ONCE when rail server starts

    - by Hadi
    i would like to initialize database the first time the server is started, that involve calling a class method. Given the class name is: Product At first i put an .rb file config\initializers\init.rb as it gets automatically called. Everything works ok, until the database is deleted, and i am trying to do rake db:migrate. rake db:migrate fails saying that cannot find 'product' table. inside init.rb = Product.populate_db The solution i came up is: I took out init.rb do rake db:migrate put back init.rb run the server. My rails application is mainly for reporting and the data is seeded from other application, so i have to do the above step everyday Is there a better way to do the initialization?

    Read the article

  • How to initialize a static const map in c++?

    - by Meloun
    Hi, I need just dictionary or asociative array string = int. There is type map C++ for this case. But I need make one map in my class make for all instances(- static) and this map cannot be changed(- const); I have found this way with boost library std::map<int, char> example = boost::assign::map_list_of(1, 'a') (2, 'b') (3, 'c'); Is there other solution without this lib? I have tried something like this, but there are always some issues with map initialization. class myClass{ private: static map<int,int> create_map() { map<int,int> m; m[1] = 2; m[3] = 4; m[5] = 6; return m; } static map<int,int> myMap = create_map(); } thanks

    Read the article

  • Java: design problem with private-final-int-value and empty constructor

    - by HH
    $ javac InitInt.java InitInt.java:7: variable right might not have been initialized InitInt(){} ^ 1 error $ cat InitInt.java import java.util.*; import java.io.*; public class InitInt { private final int right; //DUE to new Klowledge: Design Problem //I think having an empty constructor like this // is an design problem, shall I remove it? What do you think? // When to use an empty constructor? InitInt(){} public static void main(String[] args) { InitInt test = new InitInt(); System.out.println(test.getRight()); } public int getRight(){return right;} } Initialization problem with Constructor InitInt{ // Still the error, "may not be initialized" // How to initialise it? if(snippetBuilder.length()>(charwisePos+25)){ right=charwisePos+25; }else{ right=snippetBuilder.length()-1; } }

    Read the article

  • Pattern for iPhone background loading during init?

    - by Rob S.
    Hi everyone, I'm currently kicking off a background thread to do some REST queries in my app delegate's didFinishLaunchingWithOptions. This thread creates some objects and populates the model as the rest of the app continues to load (because I don't block, and didFinishLaunchingWithOptions returns YES). I also put up a loading UIViewController 'on top' of the main view that I tear down after the background initialization is complete. My problem is that I need to notify the first view (call it the Home view) that the model is ready, and that it should populate itself. The trick is that the background download could have finished before Home.viewDidAppear is called, or any of the other Home.initX methods. I'm having difficulty synchronizing all of this and I've thought about it long enough that it feels like I'm barking up the wrong tree. Are there any patterns here for this sort of thing? I'm sure other apps start by performing lengthy operations with loading screens :) Thanks!

    Read the article

  • Which of these Array Initializations is better in Ruby?

    - by Bragaadeesh
    Hi, Which of these two forms of Array Initialization is better in Ruby? Method 1: DAYS_IN_A_WEEK = (0..6).to_a HOURS_IN_A_DAY = (0..23).to_a @data = Array.new(DAYS_IN_A_WEEK.size).map!{ Array.new(HOURS_IN_A_DAY.size) } DAYS_IN_A_WEEK.each do |day| HOURS_IN_A_DAY.each do |hour| @data[day][hour] = 'something' end end Method 2: DAYS_IN_A_WEEK = (0..6).to_a HOURS_IN_A_DAY = (0..23).to_a @data = {} DAYS_IN_A_WEEK.each do |day| HOURS_IN_A_DAY.each do |hour| @data[day] ||= {} @data[day][hour] = 'something' end end The difference between the first method and the second method is that the second one does not allocate memory initially. I feel the second one is a bit inferior when it comes to performance due to the numerous amount of Array copies that has to happen. However, it is not straight forward in Ruby to find what is happening. So, if someone can explain me which is better, it would be really great! Thanks

    Read the article

  • Spring factory beans not always initialised before being used.

    - by aos
    Hi, I am using spring to initialise my beans. I have configured a bean which I intend to use as a factory bean. <bean id="jsServicesFactory" class="x.y.z.JSServicesFactory" /> It is a very basic class - which has 4 getter methods. One example is public final PortletRegistry getPortletRegistry() { PortletRegistry registry = (PortletRegistry) JetspeedPortletServices .getSingleton().getService("PortletRegistryComponent"); return registry; } I have a 2nd bean which uses this factory beans to set one of its properties <bean id="batchManagerService" class="x.y.z.BatchManagerService"> ... <property name="portletRegistry"> <bean factory-bean="jsServicesFactory" factory-method="getPortletRegistry" /> </property> ... When I start my server in RAD, this all works perfectly. However when I deploy to Linux I sometimes get the following error ERROR org.springframework.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'batchManagerService' defined in ServletContext resource [/WEB-INF/context/root/batchManagerContext.xml]: Cannot create inner bean 'jsServicesFactory$created#70be70be' while setting bean property 'portletRegistry'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jsServicesFactory$created#70be70be' defined in ServletContext resource [/WEB-INF/context/root/batchManagerContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public final org.apache.jetspeed.components.portletregistry.PortletRegistry x.y.z.JSServicesFactory.getPortletRegistry()] threw exception; nested exception is java.lang.NullPointerException I have tried adding depends-on="jsServicesFactory" to my bean batchManagerService but it didn't work. Any ideas? Thanks

    Read the article

  • C++: Static variable inside a constructor, are there any drawbacks or side effects?

    - by doc
    What I want to do: run some prerequisite code whenever instance of the class is going to be used inside a program. This code will check for requiremts etc. and should be run only once. I found that this can be achieved using another object as static variable inside a constructor. Here's an example for a better picture: class Prerequisites { public: Prerequisites() { std::cout << "checking requirements of C, "; std::cout << "registering C in dictionary, etc." << std::endl; } }; class C { public: C() { static Prerequisites prerequisites; std::cout << "normal initialization of C object" << std::endl; } }; What bothers me is that I haven't seen similar use of static variables so far. Are there any drawbacks or side-effects or am I missing something? Or maybe there is a better solution? Any suggestions are welcome.

    Read the article

  • Simple OpenCL Kernel

    - by Yuuta
    I'm trying to write a kernel which is a little long but the output is not correct. I took out a lot almost everything and finally narrowed down the an initialization problem and I found that the following works: __kernel void k_sIntegral(__global const float* eData,__global const unsigned long* elements,__global float* area){ const int i = get_global_id(0); if(i < elements[0]){ area[i] = i; } } But the following does not work: __kernel void k_sIntegral(__global const float* eData,__global const unsigned long* elements,__global float* area){ const int i = get_global_id(0); if(i < elements[0]){ __local float a,b,c,j,k,h,s; area[i] = i; } } Using the first kernel, I get: area[1] = 1 Using the second kernel, I get: area[1] = 0 (from calloc) Update: It seems like the code does work, but I need to change the function name otherwise it somehow calls the previous function even though it was not compiled (?). Any leads to why that happens? If anyone can let me know what might be the problem I'll be really grateful, thanks in advance!

    Read the article

  • initializing a vector of custom class in c++

    - by Flamewires
    Hey basically Im trying to store a "solution" and create a vector of these. The problem I'm having is with initialization. Heres my class for reference class Solution { private: // boost::thread m_Thread; int itt_found; int dim; pfn_fitness f; double value; std::vector<double> x; public: Solution(size_t size, int funcNo) : itt_found(0), x(size, 0.0), value(0.0), dim(30), f(Eval_Functions[funcNo]) { for (int i = 1; i < (int) size; i++) { x[i] = ((double)rand()/((double)RAND_MAX))*maxs[funcNo]; } } Solution() : itt_found(0), x(31, 0.0), value(0.0), dim(30), f(Eval_Functions[1]) { for (int i = 1; i < 31; i++) { x[i] = ((double)rand()/((double)RAND_MAX))*maxs[1]; } } Solution operator= (Solution S) { x = S.GetX(); itt_found = S.GetIttFound(); dim = S.GetDim(); f = S.GetFunc(); value = S.GetValue(); return *this; } void start() { value = f (dim, x); } /* plus additional getter/setter methods*/ } Solution S(30, 1) or Solution(2, 5) work and initalizes everything, but I need X of these solution objects. std::vector<Solution> Parents(X) will create X solutions with the default constructor and i want to construct using the (int, int) constructor. Is there any easy(one liner?) way to do this? Or would i have to do something like: size_t numparents = 10; vector<Solution> Parents; Parents.reserve(numparents); for (int i = 0; i<(int)numparents; i++) { Solution S(31, 0); Parents.push_back(S); }

    Read the article

  • C++ invalid reference problem

    - by Karol
    Hi all, I'm writing some callback implementation in C++. I have an abstract callback class, let's say: /** Abstract callback class. */ class callback { public: /** Executes the callback. */ void call() { do_call(); }; protected: /** Callback call implementation specific to derived callback. */ virtual void do_call() = 0; }; Each callback I create (accepting single-argument functions, double-argument functions...) is created as a mixin using one of the following: /** Makes the callback a single-argument callback. */ template <typename T> class singleArgumentCallback { protected: /** Callback argument. */ T arg; public: /** Constructor. */ singleArgumentCallback(T arg): arg(arg) { } }; /** Makes the callback a double-argument callback. */ template <typename T, typename V> class doubleArgumentCallback { protected: /** Callback argument 1. */ T arg1; /** Callback argument 2. */ V arg2; public: /** Constructor. */ doubleArgumentCallback(T arg1, V arg2): arg1(arg1), arg2(arg2) { } }; For example, a single-arg function callback would look like this: /** Single-arg callbacks. */ template <typename T> class singleArgFunctionCallback: public callback, protected singleArgumentCallback<T> { /** Callback. */ void (*callbackMethod)(T arg); public: /** Constructor. */ singleArgFunctionCallback(void (*callback)(T), T argument): singleArgumentCallback<T>(argument), callbackMethod(callback) { } protected: void do_call() { this->callbackMethod(this->arg); } }; For user convenience, I'd like to have a method that creates a callback without having the user think about details, so that one can call (this interface is not subject to change, unfortunately): void test3(float x) { std::cout << x << std::endl; } void test5(const std::string& s) { std::cout << s << std::endl; } make_callback(&test3, 12.0f)->call(); make_callback(&test5, "oh hai!")->call(); My current implementation of make_callback(...) is as follows: /** Creates a callback object. */ template <typename T, typename U> callback* make_callback( void (*callbackMethod)(T), U argument) { return new singleArgFunctionCallback<T>(callbackMethod, argument); } Unfortunately, when I call make_callback(&test5, "oh hai!")->call(); I get an empty string on the standard output. I believe the problem is that the reference gets out of scope after callback initialization. I tried using pointers and references, but it's impossible to have a pointer/reference to reference, so I failed. The only solution I had was to forbid substituting reference type as T (for example, T cannot be std::string&) but that's a sad solution since I have to create another singleArgCallbackAcceptingReference class accepting a function pointer with following signature: void (*callbackMethod)(T& arg); thus, my code gets duplicated 2^n times, where n is the number of arguments of a callback function. Does anybody know any workaround or has any idea how to fix it? Thanks in advance!

    Read the article

  • Anonymous function vs. separate named function for initialization in jquery

    - by Martin N.
    We just had some controversial discussion and I would like to see your opinions on the issue: Let's say we have some code that is used to initialize things when a page is loaded and it looks like this: function initStuff() { ...} ... $(document).ready(initStuff); The initStuff function is only called from the third line of the snippet. Never again. Now I would say: Usually people put this into an anonymous callback like that: $(document).ready(function() { //Body of initStuff }); because having the function in a dedicated location in the code is not really helping with readability, because with the call on ready() makes it obvious, that this code is initialization stuff. Would you agree or disagree with that decision? And why? Thank you very much for your opinion!

    Read the article

  • How handle nifty initialization in a Slick2D state based game?

    - by nathan
    I'm using Slick2D and Nifty GUI. I decided to use a state based approach for my game and since i want to use Nifty GUI, i use the classes NiftyStateBasedGame for the main and NiftyOverlayBasicGameState for the states. As the description say, i'm suppose to initialize the GUI in the method initGameAndGUI on my states, no problem: @Override protected void initGameAndGUI(GameContainer gc, StateBasedGame sbg) throws SlickException { initNifty(gc, sbg) } It works great when i have only one state but if i'm doing a call to initNifty several times from different states, it will raise the following exception: org.bushe.swing.event.EventServiceExistsException: An event service by the name NiftyEventBusalready exists. Perhaps multiple threads tried to create a service about the same time? at org.bushe.swing.event.EventServiceLocator.setEventService(EventServiceLocator.java:123) at de.lessvoid.nifty.Nifty.initalizeEventBus(Nifty.java:221) at de.lessvoid.nifty.Nifty.initialize(Nifty.java:201) at de.lessvoid.nifty.Nifty.<init>(Nifty.java:142) at de.lessvoid.nifty.slick2d.NiftyCarrier.initNifty(NiftyCarrier.java:94) at de.lessvoid.nifty.slick2d.NiftyOverlayBasicGameState.initNifty(NiftyOverlayBasicGameState.java:332) at de.lessvoid.nifty.slick2d.NiftyOverlayBasicGameState.initNifty(NiftyOverlayBasicGameState.java:299) at de.lessvoid.nifty.slick2d.NiftyOverlayBasicGameState.initNifty(NiftyOverlayBasicGameState.java:280) at de.lessvoid.nifty.slick2d.NiftyOverlayBasicGameState.initNifty(NiftyOverlayBasicGameState.java:264) The initializeEventBus that raise the exception is called from the Nifty constructor and a new Nifty object is created within the initNifty method: public void initNifty( final SlickRenderDevice renderDevice, final SlickSoundDevice soundDevice, final SlickInputSystem inputSystem, final TimeProvider timeProvider) { if (isInitialized()) { throw new IllegalStateException("The Nifty-GUI was already initialized. Its illegal to do so twice."); } final InputSystem activeInputSystem; if (relayInputSystem == null) { activeInputSystem = inputSystem; } else { activeInputSystem = relayInputSystem; relayInputSystem.setTargetInputSystem(inputSystem); } nifty = new Nifty(renderDevice, soundDevice, activeInputSystem, timeProvider); } Is this a bug in the nifty for slick2d implementation or am i missing something? How am i supposed to handle nifty initialization over multiple states?

    Read the article

  • Using json as database with EF, how can I link EF and the json file during DbContext initialization?

    - by blacai
    For a personal testing-project I am considering to create a SPA with the following technologies: ASP.NET MVC + EF + WebAPI + AngularJS. The project will make use of small amount of data, so I was thinking I could use just a .json file as storage. But I am not sure about how to proceed with the link between EF and the json file in the initialization of the DbContext. I found a stackoverflow related question: http://stackoverflow.com/questions/13899342/can-we-use-json-as-a-database I know the basics of edit files and store data inside. What I tried is to get the data from the json file in the initilizer method and create the objects one by one. This is more a doubt about how this works if I save/update an object in the dbcontext, do I need to go through all the elements and add/update it manually? Is it better to rewrite the complete file? According to this http://stackoverflow.com/questions/7895335/append-data-to-a-json-file-with-php it is not a good practice to use json/XML for data wich will be manipulated. Anyone has experience with anything similar? Is this a really bad idea and I should use another kind of data-storage?

    Read the article

  • iphone dev: UIImageview subclass interface builder - how to call custom initializer

    - by ninjasmith
    hi. I messing with iphone developement. I have a uiimageview subclass that I want to use to detect touches. I have sucessfully added to interfacebuilder and I can detect a touch in my UIImageview subclass within my application so all is good on that front. however my UIImageView subclass has a custom initializer which is not called when it is created in interface builder. if I manually initialize the UIImageview and add it programmatically I think it will work but then I lose the ability to 'see' my positioning in Interface builder. how can I either 1) 'see' a uiimageview in interface builder that is added in code? (not possible?) 2) call my custom initializer when the subclass is instantiated in interfacebuilder. thanks

    Read the article

  • nhibernate configure and buildsessionfactory time

    - by davidsleeps
    Hi, I'm using Nhibernate as the OR/M tool for an asp.net application and the startup performance is really frustrating. Part of the problem is definitely me in my lack of understanding but I've tried a fair bit (understanding is definitely improving) and am still getting nowhere. Currently ANTS profiler has that the Configure() takes 13-18 seconds and the BuildSessionFActory() as taking about 5 seconds. From what i've read, these times might actually be pretty good, but they were generally talking about hundreds upon hundreds of mapped entities...this project only has 10. I've combined all the mapping files into a single hbm mapping file and this did improve things but only down to the times mentioned above... I guess, are there any "Traps for young players" that are regularly missed...obvious "I did this/have you enabled that/exclude file x/mark file y as z" etc... I'll try the serialize the configuration thing to avoid the Configure() stage, but I feel that part shouldn't be that long for that amount of entities and so would essentially be hiding a current problem... I will post source code or configuration if necessary, but I'm not sure what to put in really... thanks heaps! edit (more info) I'll also add that once this is completed, each page is extremely quick... configuration code- hibernate.cfg.xml <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" /> </configSections> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> <property name="connection.connection_string_name">MyAppDEV</property> <property name="cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache</property> <property name="cache.use_second_level_cache">true</property> <property name="show_sql">false</property> <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property> <property name="current_session_context_class">managed_web</property> <mapping assembly="MyApp.Domain"/> </session-factory> </hibernate-configuration> </configuration> My SessionManager class which is bound and unbound in a HttpModule for each request Imports NHibernate Imports NHibernate.Cfg Public Class SessionManager Private ReadOnly _sessionFactory As ISessionFactory Public Shared ReadOnly Property SessionFactory() As ISessionFactory Get Return Instance._sessionFactory End Get End Property Private Function GetSessionFactory() As ISessionFactory Return _sessionFactory End Function Public Shared ReadOnly Property Instance() As SessionManager Get Return NestedSessionManager.theSessionManager End Get End Property Public Shared Function OpenSession() As ISession Return Instance.GetSessionFactory().OpenSession() End Function Public Shared ReadOnly Property CurrentSession() As ISession Get Return Instance.GetSessionFactory().GetCurrentSession() End Get End Property Private Sub New() Dim configuration As Configuration = New Configuration().Configure() _sessionFactory = configuration.BuildSessionFactory() End Sub Private Class NestedSessionManager Friend Shared ReadOnly theSessionManager As New SessionManager() End Class End Class edit 2 (log4net results) will post bits that have a portion of time between them and will cut out the rest... 2010-03-30 23:29:40,898 [4] INFO NHibernate.Cfg.Environment [(null)] - Using reflection optimizer 2010-03-30 23:29:42,481 [4] DEBUG NHibernate.Cfg.Configuration [(null)] - dialect=NHibernate.Dialect.MsSql2005Dialect ... 2010-03-30 23:29:42,501 [4] INFO NHibernate.Cfg.Configuration [(null)] - Mapping resource: MyApp.Domain.Mappings.hbm.xml 2010-03-30 23:29:43,342 [4] INFO NHibernate.Dialect.Dialect [(null)] - Using dialect: NHibernate.Dialect.MsSql2005Dialect 2010-03-30 23:29:50,462 [4] INFO NHibernate.Cfg.XmlHbmBinding.Binder [(null)] - Mapping class: ... 2010-03-30 23:29:51,353 [4] DEBUG NHibernate.Connection.DriverConnectionProvider [(null)] - Obtaining IDbConnection from Driver 2010-03-30 23:29:53,136 [4] DEBUG NHibernate.Connection.ConnectionProvider [(null)] - Closing connection

    Read the article

  • class __init__ (not instance __init__)

    - by wallacoloo
    Here's a very simple example of what I'm trying to get around: class Test(object): some_dict = {Test: True} The problem is that I cannot refer to Test while it's still being defined Normally, I'd just do this: class Test(object): def __init__(self): self.__class__.some_dict = {Test: True} But I never create an instance of this class. It's really just a container to hold a group of related functions and data (I have several of these classes, and I pass around references to them, so it is necessary for Test to be it's own class) So my question is, how could I refer to Test while it's being defined, or is there something similar to __init__ that get's called as soon as the class is defined? If possible, I want self.some_dict = {Test: True} to remain inside the class definition. This is the only way I know how to do this so far: class Test(object): @classmethod def class_init(cls): cls.some_dict = {Test: True} Test.class_init()

    Read the article

  • Set attributes from dictionary in python

    - by Oscar Reyes
    Is it possible to create an object from a dictionary in python in such a way that each key is an attribute of that object? Something like this: dict = { 'name': 'Oscar', 'lastName': 'Reyes', 'age':32 } e = Employee( dict ) print e.name # Oscar print e.age + 10 # 42 I think it would be pretty much the inverse of this question: Python dictionary from an object's fields

    Read the article

  • C# - closures over class fields inside an initializer?

    - by Richard Berg
    Consider the following code: using System; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { var square = new Square(4); Console.WriteLine(square.Calculate()); } } class MathOp { protected MathOp(Func<int> calc) { _calc = calc; } public int Calculate() { return _calc(); } private Func<int> _calc; } class Square : MathOp { public Square(int operand) : base(() => _operand * _operand) // runtime exception { _operand = operand; } private int _operand; } } (ignore the class design; I'm not actually writing a calculator! this code merely represents a minimal repro for a much bigger problem that took awhile to narrow down) I would expect it to either: print "16", OR throw a compile time error if closing over a member field is not allowed in this scenario Instead I get a nonsensical exception thrown at the indicated line. On the 3.0 CLR it's a NullReferenceException; on the Silverlight CLR it's the infamous Operation could destabilize the runtime.

    Read the article

  • When -exactly- does the Rails3 application get initialized?

    - by bergyman
    I've been fighting left and right with rails 3 and bundler. There are a few gems out there that don't work properly if the rails application hasn't been loaded yet. factory_girl and shoulda are both examples, even on the rails3 branch. Taking shoulda as an example, when trying to run rake test:units I get the following error: DEPRECATION WARNING: RAILS_ROOT is deprecated! Use Rails.root instead. (called from autoload_macros at c:/code/test_harness/vendor/windows_gems/gems/shoulda-2.10.3/lib/shoulda/autoload_macros.rb:40) c:/code/test_harness/vendor/windows_gems/gems/shoulda-2.10.3/lib/shoulda/autoload_macros.rb:44:in 'join': can't convert #<Class:0x232b7c0> into String (TypeError) from c:/code/test_harness/vendor/windows_gems/gems/shoulda-2.10.3/lib/shoulda/autoload_macros.rb:44:in 'block in autoload_macros' from c:/code/test_harness/vendor/windows_gems/gems/shoulda-2.10.3/lib/shoulda/autoload_macros.rb:44:in 'map' from c:/code/test_harness/vendor/windows_gems/gems/shoulda-2.10.3/lib/shoulda/autoload_macros.rb:44:in 'autoload_macros' from c:/code/test_harness/vendor/windows_gems/gems/shoulda-2.10.3/lib/shoulda/rails.rb:17:in '<top (required)>' Digging a bit deeper into lib/shoulda/rails, I see this: root = if defined?(Rails.root) && Rails.root Rails.root else RAILS_ROOT end # load in the 3rd party macros from vendorized plugins and gems Shoulda.autoload_macros root, File.join("vendor", "{plugins,gems}", "*") So...what's happening here is while Rails.root is defined, Rails.root == nil, so RAILS_ROOT is used, and RAILS_ROOT==nil, which is then being passed on to Shoulda.autoload_macros. Obviously the rails app has yet to be initialized. With Rails3 using Bundler now, there's been some hubub over on the Bundler side about being able to specify an order in which the gems are required, but I'm not sure whether or not this would solve the problem at hand. Ultimately my questions is this: When exactly does the environment.rb file (which actually initializes the application) get pulled in? Is there any harm to bumping up when the app is initialized and have it happen before the Bundler.require line in config/application.rb? I've tried to hack bundler to specify the order myself, and have the rails gem pulled in first, but it doesn't appear to me that requiring the rails gem actually initializes the application. As this line (in config/application.rb) is being called before the app is initialized, any gem in the bundler Gemfile that requires rails to be initialized is going to tank. # Auto-require default libraries and those for the current Rails environment. Bundler.require :default, Rails.env

    Read the article

  • Java Singleton Pattern

    - by Spencer
    I'm used the Singleton Design Pattern public class Singleton { private static final Singleton INSTANCE = new Singleton(); // Private constructor prevents instantiation from other classes private Singleton() {} public static Singleton getInstance() { return INSTANCE; } } My question is how do I create an object of class Singleton in another class? I've tried: Singleton singleton = new Singleton(); // error - constructor is private Singleton singleton = Singleton.getInstance(); // error - non-static method cannot be referenced from a static context What is the correct code? Thanks, Spencer

    Read the article

  • inno setup - registry key vs. .ini files

    - by PPTim
    Hi, Dabbling with creating an installer with inno setup- but wondering: What are the pros and cons of using registry keys (windows program) vs. .ini files that sit within the program folder? If I store all my user settings in .ini files, the entire program can be removed by deleting the folder. With registry keys i'd have to create an uninstaller / remove the key manually. Why is it that most commercial applications use registry values? I know from brief use of Macs that most programs are drag and drop. Are one of the major reasons because of the lack of a registry key in mac OS?

    Read the article

  • Using STL/Boost to initialize a hard-coded set<vector<int> >

    - by Hooked
    Like this question already asked, I'd like to initialize a container using STL where the elements are hard-coded in the cleanest manner possible. In this case, the elements are a doubly nested container: set<vector<int> > A; And I'd like (for example) to put the following values in: A = [[0,0,1],[0,1,0],[1,0,0],[0,0,0]]; C++0x fine, using g++ 4.4.1. STL is preferable as I don't use Boost for any other parts of the code (though I wouldn't mind an example with it!).

    Read the article

  • an emacs command to open a new instance of emacs

    - by RamyenHead
    How can I make a cross-platform emacs command that opens another instance of emacs with -q option? The reason why I need such a command is that it would be easy to modify the command to make it open another instance of emacs with -q and -l option so that the new instance loads an el file that I am editing with the old instance.

    Read the article

  • What should I use for the filepath if I'm developing from my desktop?

    - by codeninja
    I'm having an extremely difficulty time getting the flowplayer to show up and the worst part is I have no idea what is wrong because I'm not getting any error messages! I have an external javascript file: C:/desktop/mysite/js/jq/plugins.js calling $f() from: C:/desktop/mysite/thirdparty/flowplayer/flowplayer.js the swf files also live there... I'm working on file/desktop (no localhost or webserver) $(video.id).flowplayer("thirdparty/flowplayer/flowplayer-3.1.15.swf", { clip:{ .... }, // min Flash version version:[9,115], // older versions will see a custom message onFail:function(){ alert("Failed!"); }, onError:function(errCode,errMsg){ alert(errCode+errMsg); } }); I don't know what path to use for the SWFs to get them to load, is the path relative to the javascript (plugins.js) that calls $f() or is it relative to the path of the flowplayer.js ?? bangs head on wall

    Read the article

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