embedding

Embedding Groovy in Java (Binding)

Deadly 提交于 2019-12-01 11:58:32
I try to Bind Variables to Groovy and from Groovy back zu Java: Java code: Binding binding = new Binding(); binding.setVariable("SRESULT", "foo"); GroovyShell gs = new GroovyShell(binding); gs.evaluate(script); String sResult = (String) gs.getContext().getVariable("SRESULT"); System.out.println("FROM GROOVY: " + sResult); Groovy Code: class Est { static SRESULT public static void main(String[] args) { println 'From Java: '+SRESULT SRESULT = 'bar' } } Output: From Java: foo FROM GROOVY: foo My Question: I want to change SRESULT in Groovy and have access to the Value in Java. Can anybody help me

Embed images for use in email message using PHP?

[亡魂溺海] 提交于 2019-12-01 10:53:38
问题 I know how to embed an image into an email as an attachment, but that's not really what I want to do. What I want to do is embed an image into the message and use that within the body of the email message itself. Is it possible to do this or possibly reference an attached file somehow to be used in the message? Should I even worry about this? Is it more beneficial to just load them via a link to the image on my network? I was thinking that this would take some load off my server so it didn't

IronPython - Load script from string in C# 4.0 application

▼魔方 西西 提交于 2019-12-01 08:50:20
问题 I have the following code (just a test): var engine = Python.CreateEngine(); var runtime = engine.Runtime; try { dynamic test = runtime.UseFile(@"d:\test.py"); test.SetVariable("y", 4); test.SetVariable("client", UISession.ControllerClient); test.Simple(); } catch (Exception ex) { var eo = engine.GetService<ExceptionOperations>(); Console.WriteLine(eo.FormatException(ex)); } But I would like to load the script from a string instead. 回答1: You can use engine.CreateScriptSourceFromString to load

Go: Embedding a primitive type?

馋奶兔 提交于 2019-12-01 07:05:45
问题 Suppose we have this piece of code: type User struct { int32 Name string } Can this type of embedding be useful? Does int32 have any methods which other can call on instances of User ? How can I access the value of the int32 that User is embedding? 回答1: The type int32 is a predeclared type, it has no methods. To verify: fmt.Println(reflect.TypeOf(int32(0)).NumMethod()) // Prints 0 You can refer to all embedded fields by using the unqualified type name as the field name (Spec: Struct types),

“Could not find transactional storage type” error with embedded RavenDB

白昼怎懂夜的黑 提交于 2019-12-01 02:26:58
I was able to successfully run a simple test for RavenDB based on the code found at: http://ravendb.net/tutorials/hello-world Next I tried to run it in an Embedded Manner, but I keep on getting the following error: Message: Could not find transactional storage type: Raven.Storage.Esent.TransactionalStorage, Raven.Storage.Esent StackTrace: at Raven.Database.Config.InMemoryRavenConfiguration.CreateTransactionalStorage(Action notifyAboutWork) in c:\Builds\raven\Raven.Database\Config\InMemoryRavenConfiguration.cs:line 272 at Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration

Type Composition: overriding interface types

时光怂恿深爱的人放手 提交于 2019-11-30 23:22:01
I want to compose a type of another type, but replace one of the fields (which is an interface value) with a fake. The problem I am getting is the underlying field is being used, so I can't seem to override the field. I've demoed the problem here: https://play.golang.org/p/lHGnyjzIS-Y package main import ( "fmt" ) type Printer interface { Print() } type PrinterService struct {} func (ps PrinterService) Print() { fmt.Println("PrinterService") } type Service struct { Client PrinterService } func (s Service) PrintViaMethod() { s.Client.Print() } type FakeService struct { Service Client Printer }

Embedding HTML in embedded SVG in HTML?

↘锁芯ラ 提交于 2019-11-30 19:23:29
It's allowed to embed SVG in HTML... <!DOCTYPE html> <html lang="en"> <head> <title>Hmmm....</title> </head> <body> <svg xmlns="http://www.w3.org/2000/svg" version="1.1" x="0" y="0" width="500px" height="100%"> <text>Hello cruel world!</text> </svg> </body> </html> ...and vice versa: <svg xmlns="http://www.w3.org/2000/svg" version="1.1" x="0" y="0" width="500px" height="100%"> <foreignObject x="0" y="0" width="100%" height="100%"> <body xmlns="http://www.w3.org/1999/xhtml"> <h1>Goodbye cruel world...</h1> </body> </foreignObject> </svg> The specs say (23.2, third paragraph) (and I quote:) "If

How to make Ghostscript's `ps2pdf14` stop subsetting fonts

做~自己de王妃 提交于 2019-11-30 09:58:19
I am using the ps2pdf14 utility that ships with Ghostscript, and I am having a problem with fonts. It does not seem to matter what instructions I pass to the command, it insists on subsetting any fonts it finds in the source document. e.g -dPDFSETTINGS#/prepress -dEmbedAllFonts#true -dSubsetFonts#false -dMaxSubsetPct#0 Note that the # is because the command is running on Windows, it is the same as =. If anyone has any idea how to tell ps2pdf not to subset fonts, I would be very grateful. --------------------------Notes ------------------------------------------ The source file is a PDF

MongoDB: automatically generated IDs are zeroes

孤者浪人 提交于 2019-11-30 08:15:25
I'm using MongoDB and official C# driver 0.9 I'm just checking how embedding simple documents works. There are 2 easy classes: public class User { public ObjectId _id { get; set; } public string Name { get; set; } public IEnumerable<Address> Addresses { get;set; } } public class Address { public ObjectId _id { get; set; } public string Street { get; set; } public string House { get; set; } } I create a new user: var user = new User { Name = "Sam", Addresses = (new Address[] { new Address { House = "BIGHOUSE", Street = "BIGSTREET" } }) }; collection.Insert(user.ToBsonDocument()); The user is

luaL_openlib replacement for Lua 5.2

让人想犯罪 __ 提交于 2019-11-30 06:39:07
I am adapting a library written for Lua < 5.2 and got to a call I don't know the equivalent of: luaL_openlib(L, "Polycore", polycoreLib, 0); Where polycoreLib is a static const struct luaL_Reg polycoreLib [] How can I replace the call to luaL_openlib ? The lua wiki only states : Calls such as luaL_openlib(L, name, lreg, x); should be carefully rewritten because a global table with the given name will be searched and possibly created. There's two answers to this: one for replicating the behaviour of earlier versions here (where a global table is created), and one for implementing the behaviour