Search Results

Search found 5 results on 1 pages for 'vyacheslav loginov'.

Page 1/1 | 1 

  • Access to nested methods when DSL

    - by Vyacheslav Loginov
    class Warcraft def initialize &block instance_eval &block end def method_missing name, *args, &block instance_variable_set("@#{name}".to_sym, args[0]) self.class.send(:define_method, name, proc { instance_variable_get("@#{name}")}) end def game &block @game = Game.new &block end class Game def initialize &block instance_eval &block end def method_missing name, *args, &block instance_variable_set("@#{name}".to_sym, args[0]) self.class.send(:define_method, name, proc { instance_variable_get("@#{name}")}) end end end warcraft = Warcraft.new do name "Warcraft III" battle_net :iccup game do side :sentinels hero "Furion" rune_appear_every 2 end end puts warcraft.inspect # => #<Warcraft:0x00000000be3e80 @name="Warcraft III", @battle_net=:iccup, @game=#<Warcraft::Game:0x000000009c6c38 @side=:sentinels, @hero="Furion", @rune_appear_every=2>> How to access nested methods? puts warcraft.battle_net # => iccup puts warcraft.side #=> #<Proc:[email protected]:9 (lambda)> puts warcraft.game #=> dsl.rb:18:in `instance_eval': block not supplied (ArgumentError) puts warcraft.game.side #=> dsl.rb:18:in `instance_eval': block not supplied (ArgumentError)

    Read the article

  • Context migration in CUDA.NET

    - by Vyacheslav
    I'm currently using CUDA.NET library by GASS. I need to initialize cuda arrays (actually cublas vectors, but it doesn't matters) in one CPU thread and use them in other CPU thread. But CUDA context which holding all initialized arrays and loaded functions, can be attached to only one CPU thread. There is mechanism called context migration API to detach context from one thread and attach it to another. But i don't how to properly use it in CUDA.NET. I tried something like this: class Program { private static float[] vector1, vector2; private static CUDA cuda; private static CUBLAS cublas; private static CUdeviceptr ptr; static void Main(string[] args) { cuda = new CUDA(false); cublas = new CUBLAS(cuda); cuda.Init(); cuda.CreateContext(0); AllocateVectors(); cuda.DetachContext(); CUcontext context = cuda.PopCurrentContext(); GetVectorFromDeviceAsync(context); } private static void AllocateVectors() { vector1 = new float[]{1f, 2f, 3f, 4f, 5f}; ptr = cublas.Allocate(vector1.Length, sizeof (float)); cublas.SetVector(vector1, ptr); vector2 = new float[5]; } private static void GetVectorFromDevice(object objContext) { CUcontext localContext = (CUcontext) objContext; cuda.PushCurrentContext(localContext); cuda.AttachContext(localContext); //change vector somehow vector1[0] = -1; //copy changed vector to device cublas.SetVector(vector1, ptr); cublas.GetVector(ptr, vector2); CUDADriver.cuCtxPopCurrent(ref localContext); } private static void GetVectorFromDeviceAsync(CUcontext cUcontext) { Thread thread = new Thread(GetVectorFromDevice); thread.IsBackground = false; thread.Start(cUcontext); } } But execution fails on attempt to copy changed vector to device because context is not attached? Any ideas how i can get it work?

    Read the article

  • Fluent NHibernate and PostgreSQL, SchemaMetadataUpdater.QuoteTableAndColumns - System.NotSupportedEx

    - by Vyacheslav
    Hello! I'm using fluentnhibernate with PostgreSQL. Fluentnhibernate is last version. PosrgreSQL version is 8.4. My code for create ISessionFactory: public static ISessionFactory CreateSessionFactory() { string connectionString = ConfigurationManager.ConnectionStrings["PostgreConnectionString"].ConnectionString; IPersistenceConfigurer config = PostgreSQLConfiguration.PostgreSQL82.ConnectionString(connectionString); FluentConfiguration configuration = Fluently .Configure() .Database(config) .Mappings(m => m.FluentMappings.Add(typeof(ResourceMap)) .Add(typeof(TaskMap)) .Add(typeof(PluginMap))); var nhibConfig = configuration.BuildConfiguration(); SchemaMetadataUpdater.QuoteTableAndColumns(nhibConfig); return configuration.BuildSessionFactory(); } When I'm execute code at line SchemaMetadataUpdater.QuoteTableAndColumns(nhibConfig); throw error: System.NotSupportedException: Specified method is not supported. Help me, please! I'm very need for solution. Best regards

    Read the article

  • Fluentnhibernate and PostgerSQL, SchemaMetadataUpdater.QuoteTableAndColumns - System.NotSupportedExc

    - by Vyacheslav
    Hello! I'm using fluentnhibernate with PostgreSQL. Fluentnhibernate is last version. PosrgreSQL version is 8.4. My code for create ISessionFactory: public static ISessionFactory CreateSessionFactory() { string connectionString = ConfigurationManager.ConnectionStrings["PostgreConnectionString"].ConnectionString; IPersistenceConfigurer config = PostgreSQLConfiguration.PostgreSQL82.ConnectionString(connectionString); FluentConfiguration configuration = Fluently .Configure() .Database(config) .Mappings(m => m.FluentMappings.Add(typeof(ResourceMap)) .Add(typeof(TaskMap)) .Add(typeof(PluginMap))); var nhibConfig = configuration.BuildConfiguration(); SchemaMetadataUpdater.QuoteTableAndColumns(nhibConfig); return configuration.BuildSessionFactory(); } When I'm execute code at line SchemaMetadataUpdater.QuoteTableAndColumns(nhibConfig); throw error: System.NotSupportedException: Specified method is not supported. Help me, please! I'm very need for solution. Best regards

    Read the article

  • NSTableView with columns bound to different NSArrayControllers

    - by Vyacheslav Karpukhin
    i have NSTableView and two columns in it: NSTableColumn *column = [[[NSTableColumn alloc] initWithIdentifier:@"custId"] autorelease]; [column bind:@"value" toObject:arrC2 withKeyPath:@"arrangedObjects.custId" options:nil]; [table addTableColumn:column]; column = [[[NSTableColumn alloc] initWithIdentifier:@"totalGrams"] autorelease]; [column bind:@"value" toObject:valuationArrC withKeyPath:@"arrangedObjects.totalGrams_double" options:nil]; [table addTableColumn:column]; as you can see, columns bound to different NSArrayControllers. first column shows correct values, but second just shows "(" symbol. but if i swap columns like this: NSTableColumn *column = [[[NSTableColumn alloc] initWithIdentifier:@"totalGrams"] autorelease]; [column bind:@"value" toObject:valuationArrC withKeyPath:@"arrangedObjects.totalGrams_double" options:nil]; [table addTableColumn:column]; column = [[[NSTableColumn alloc] initWithIdentifier:@"custId"] autorelease]; [column bind:@"value" toObject:arrC2 withKeyPath:@"arrangedObjects.custId" options:nil]; [table addTableColumn:column]; then i see values of first column (which was second in the first example) and again "(" in the second column. i don't understand that behaviour. how can i bound two array controllers to one table?

    Read the article

1