Can't use neko classes in a simple haxe program - haxe

The haxe code is very simple:
Main.hx
package nekotest;
class Main {
public static function main() {
var name = neko.System.args()[0];
trace("Hello " + name);
trace("Your name is " + Std.string(name.length) + " characters longs.");
}
}
In console:
E:\WORKSPACE\HaxeTest\src>haxe -main nekotest.Main -neko test.n
nekotest/Main.hx:6: characters 19-35 : Unknown identifier : neko
The haxe and neko are all installed:
E:\WORKSPACE\HaxeTest\src>haxe
Haxe Compiler 2.10 - (c)2005-2012 Motion-Twin
Usage : haxe.exe -main <class> [-swf|-js|-neko|-php|-cpp|-cs|-java|-as3] <output> [options]
Options :
-cp <path> : add a directory to find source files
-js <file> : compile code to JavaScript file
-swf <file> : compile code to Flash SWF file
E:\WORKSPACE\HaxeTest\src>neko
NekoVM 1.8.2 (c)2005-2011 Motion-Twin
Usage : neko <file>
Do I miss something?

The document I used is outdated, the "neko.System" has been removed. I use the new code, which can be compiled:
static function main() {
Sys.println("What's your name?");
var input = Sys.stdin().readLine();
Sys.println("Hello " + input);
}

It works after changing
var name = neko.System.args()[0];
to
var name = System.args()[0];

Related

Kotlin unresolved reference when using mutlithreading

So I'm trying to use kotlin together with selenium and threading, but one parameter doesnt work. Here's my code:
class myClass(parameter1 : String, parameter2 : String, parameter3 : Int) : Thread(){
init{
var driver : ChromeDriver = ChromeDriver()
}
override fun run() {
driver.get("somewebsite")
var id_field = driver.findElementByName("iD")
id_field.sendKeys(parameter1)
id_field.submit()
name = parameter2 + parameter3.toString()
//At this Point, Intellij Idea tells me: Unresolved reference: parameter3
name_field = driver.findElementByName("name")
name_field.sendKeys(name)
name_field.submit()
}
}
fun main() {
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver")
val threads: Array<myClass> = Array(2) { myClass("some_id", "name", it)}
}
What should happen is that the script goes to my website, enters the name and iD. But I want to be able to run mutiple threads of my script where the threads "iteration" (which is parameter 3) is being added to my name.
So for example:
- thread 1 logs in with: name1
- thread 2 logs in with: name2
(...)
- thread 20 logs in with: name20
But my question is:
Why doesnt kotlin say: Unsolved reference: parameter 3?

How to make Flexmark-Java process "#"-mentions?

When processing markdown, GitHub supports the #-syntax to mention a username or team. How can such mentions be processed with Flexmark-Java? With following code snippet, Hello, #world ! is reported as a single Text node where I would expect to get world reported separately as some kind of MentionsNode:
final Parser parser = Parser.builder(new Parser.Builder()).build();
final Document document = parser.parse("Hello, #world !");
new NodeVisitor(Collections.emptyList()) {
public void visit(Node node) {
System.out.println("Node: " + node);
super.visit(node);
}
}.visit(document);
Output:
Node: Document{}
Node: Paragraph{}
Node: Text{text=Hello, #world !}
There is a corresponding extension for this:
final MutableDataHolder options = new MutableDataSet()
.set(Parser.EXTENSIONS, Collections.singletonList(GfmUsersExtension.create()));
final Parser parser = Parser.builder(options).build();
final Document document = parser.parse("Hello, #world, and #1!");
...

Grunt variable as filename and file path

I'm trying to use Grunt option to define a file path and file name. This used to work but now I'm getting an unexpected token error.
var myTarget = grunt.option('target');
'build/assets/css/' + myTarget + '.css': 'source/scss/' + myTarget + '/styles.scss'
You should use the special placeholders for variables in file names and strings. First, you should load the option (using grunt.option()) or configuration (using grunt.congif()), as an option for the Grunt initConfig method. Then you should use the special placeholders <%= varname %> to use the loaded options or configurations.
grunt.initConfig({
target : grunt.option('target'),
...
files : {
'build/assets/css/<%= target %>.css' : 'source/scss/<%= target %>/styles.scss'
}
...
});
Configuration can also load an object, so the special placeholder can match object properties too:
grunt.config('definitions', (function() {
return {
target : 'my-target'
};
})());
Later on your config:
grunt.initConfig({
config : grunt.config('definitions'),
...
files : {
'build/assets/css/<%= config.target %>.css' : 'source/scss/<%= config.target %>/styles.scss'
}
...
});
Read more about Grunt option, config and templates in the Grunt official website.
Hope it helps.

Gradle Native - Dynamically add libs in repository

I'm porting several Makefile projects in Gradle. I want every dependency to be versioned, so I created a common gradle file, namely general.gradle, that is included in each specific build.gradle file. For every project there is also a file dependencies.gradle, that contains a map {dependencyName, version}. Here an example:
ext.versions = [:]
versions.'libraryA'= "8a3f32"
versions.'libraryB'= "4af3e5"
I declare what libraryX refers to in general.gradle, inserting the libraries in the repositories, as follows:
repositories {
libs(PrebuiltLibraries) {
libraryA {
def libraryName = "${name}"
headers.srcDir "../${libraryName}"
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file("${baseDir}/lib/${targetPlatform.name}/${buildType.name}/lib${libraryName}_" + versions."${libraryName}" + ".so")
}
}
libraryB {
def libraryName = "${name}"
headers.srcDir "../${libraryName}"
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file("${baseDir}/lib/${targetPlatform.name}/${buildType.name}/lib${libraryName}_" + versions."${libraryName}" + ".so")
}
}
libraryC {....}
libraryD {....}
}
By this way, I can also set the right path depending on build type (debug or release) and platform (x86 or x86_64).
As you can see, inside every libraryX there is the very same code. I was wondering if I could avoid this unnecessary duplication, using a list
libraries = [ "libraryA", "libraryB", ...]
I tried doing:
repositories {
libs(PrebuiltLibraries) {
[ "libraryA", "libraryB", ...].each {
it {
def libraryName = "${name}"
headers.srcDir "../${libraryName}"
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file("${baseDir}/lib/${targetPlatform.name}/${buildType.name}/lib${libraryName}_" + versions."${libraryName}" + ".so")
}
}
}
}
but I got this error:
Exception thrown while executing model rule: model.repositories > No signature of method: java.lang.String.call() is applicable for argument types: (general_dt1njom2wz075lo490p9e44em$_run_closure3_closure24_closure25_closure26_closure29) values:
[general_dt1njom2wz075lo490p9e44em$_run_closure3_closure24_closure25_closure26_closure29#2b2954e1]
Possible solutions: wait(), any(), wait(long), take(int), each(groovy.lang.Closure), any(groovy.lang.Closure)
Any idea?
Thanks,
Mauro
At this context it is a String variable:
[ "libraryA", "libraryB", ...].each {
it {
You cannot call it, it's not a method.
A method you want to call is delegated to closure, defined in third party context, but you can refer to it by using delegate:
[ "libraryA", "libraryB", ...].each {
delegate."$it" {
See also: http://docs.groovy-lang.org/latest/html/documentation/#_delegation_strategy

How to open files in JAR file with filename length greater than 255?

I have a JAR file with following structure:
com
-- pack1
-- A.class
-- pack2
-- AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.class
When I try to read, extract or rename pack2/AA...AA.class (which has a 262 byte long filename) both Linux and Windows say filename is too long. Renaming inside the JAR file doesn't also work.
Any ideas how to solve this issue and make the long class file readable?
This pages lists the usual limits of file systems: http://en.wikipedia.org/wiki/Comparison_of_file_systems
As you can see in the "Limits" section, almost no file system allows more than 255 characters.
Your only chance is to write a program that extracts the files and shortens file names which are too long. Java at least should be able to open the archive (try jar -tvf to list the content; if that works, truncating should work as well).
java.util.jar can handle it:
try {
JarFile jarFile = new JarFile("/path/to/target.jar");
Enumeration<JarEntry> jarEntries = jarFile.entries();
int i = 0;
while (jarEntries.hasMoreElements()) {
JarEntry jarEntry = jarEntries.nextElement();
System.out.println("processing entry: " + jarEntry.getName());
InputStream jarFileInputStream = jarFile.getInputStream(jarEntry);
OutputStream jarOutputStream = new FileOutputStream(new File("/tmp/test/test" + (i++) + ".class")); // give temporary name to class
while (jarFileInputStream.available() > 0) {
jarOutputStream.write(jarFileInputStream.read());
}
jarOutputStream.close();
jarFileInputStream.close();
}
} catch (IOException ex) {
Logger.getLogger(JARExtractor.class.getName()).log(Level.SEVERE, null, ex);
}
The output willbe test<n>.class for each class.

Resources