Where can I find com.ibm.wala.dalvik.test.* code base? - wala

I am looking for source code base of com.ibm.wala.dalvik.test.* package. It seems to be not there in the main WALA github page.
Also are these classes deprecated?
com.ibm.wala.util.functions.VoidFunction
com.ibm.wala.util.Predicate
org.apache.tools.ant.Project

Related

How to properly implement repository in flutter/dart

Being new to flutter and dart, I am looking for ways to structure my projects. I have found that the Repository pattern made its way to dart (I have a strong Java background), but I have found that there's not the necessary tools yet to properly implement a repository.
How I would normally approach this is to first create the simple straightforward methods. I ended up with the following dart code:
abstract class CategoryRepository {
Future<List<Category>> getCategories();
Future<Category?> getCategoryById(String id);
}
All is good. But now imagine I have a PostRepository, and I only want to return posts of a specific category? I am missing a standardized way in flutter how to add conditions to my repository select methods. I cannot believe nobody has written something for this purpose before so I am doubting whether I am on the right track here. Maybe my Java background is throwing me off.
In Java (specifically Spring JPA) I am used to specifications, predicates and criteria as documented here.
In .NET you can implement select methods of a repository pattern with the Expression class which allows you to use LINQ to add select criteria as documented here.
For Flutter or Dart, what would be the equivalent? Or am I on the wrong track?
I have found the flutter_repository package, but it is deprecated (without a reason). Looking at the documentation it indeed had Specifications which are used to add conditions. This would be exactly what I expect/need, but again it's deprecated.
This is where I cannot find the information publicly anymore and am questioning "how to properly implement repository in flutter/dart", hence the reason for posting this.

Couldn't find a related Android.mk template on android source tree

I am reading the android platform-build docs with gnu makefile(Android.mk) from https://android.googlesource.com/platform/build/+/master/core/build-system.html.
Now I met an issue I didn't find a related template example?
<h3><a name="templates"/>How to add another component to the build - Android.mk templates</h3>
<p>You have a new library, a new app, or a new executable. For each of the
common types of modules, there is a corresponding file in the templates
directory. It will usually be enough to copy one of these, and fill in your
own values. Some of the more esoteric values are not included in the
templates, but are instead just documented here, as is the documentation
on using custom tools to generate files.</p>
<p>Mostly, you can just look for the TODO comments in the templates and do
what it says. Please remember to delete the TODO comments when you're done
to keep the files clean. The templates have minimal documentation in them,
because they're going to be copied, and when that gets stale, the copies just
won't get updated. So read on...</p>
<h4>Apps</h4>
<p>Use the <code>templates/apps</code> file.</p>
<p>This template is pretty self-explanitory. See the variables below for more
details.</p>
As sections mentioned above I assume there are somethings named 'templates' directory for
a library, apps ... But I couldn't find that in android source tree.
Could anyone enlighten me?
The examples are not located in a templates subfolder, but in the same directory as build-system.html:
binary.mk, shared_library.mk, java_library.mk, and many more.
Note: Android is switching from the Makefile-based build system to Soong. You might want to consider switching, too.

Get Visual Studio Code snippets scope programmatically using API

Can I get the list of the available scopes for snippets?
Is there any native functionality that would control what files to create and where?
Snippets are scoped to languages and introduced to VS Code as global or local to a workspace. Languages can be contributed to VS Code by exceptions. Typically by declaring a language in the package.json, adding a syntax and snippet files. Update:
Here is the guide how to add a snippet to any language via your extension. If you follow the guide and add a snippet to the current workspace, you will notice that the file with extension .code-snippets gets created under the .vscode folder in the workspace. Therefore you can enumerate all such files using the vscode.workspace.workspaceFolders and fs.readDir APIs.
vscode.workspace.workspaceFolders!.forEach(workspaceFolder => {
const snippetFiles = fs.readdirSync(path.join(workspaceFolder.uri.fsPath, '.vscode'))
.filter(el => /\.code-snippets$/.test(el));
});
Similarly, the global snippets get added as .code-snippets files into the user profile folder - on Windows it looks like this: C:\Users\currentUser\AppData\Roaming\Code\User\snippets\*.code-snippets. Both locations you can scan for *.code-snippets files as well as programmatically add such files to those folders.
Here is the documentation how to add snippets to a scope via a file. There does not seem to be any public API to enumerate all such snippet files in a programmatic way.
But if you want to retrieve list of the languages in the screenshot you posted, use this API:
vscode.languages.getLanguages()
It could help if you explained what are you trying to achieve. Do you want to find where a particular snippet is coming from to change it? Do you want to add a snippet to a language in this list? Or to a language that is not on this list?

Reference GitHub file in jsFiddle

Is there a possibility to misuse grab files from a github repo as external resources in jsFiddle?
TLDR; Visit rawgit.com which will pop your files on a CDN straight from GitHub so you can use them.
Unfortunately none of the answers here worked for me. The rawgithub URL didn't seem to work as the connection gets refused. So here's a full solution that did work. Firstly in GitHub you need to click the Raw button to get the original JavaScript.
Then copy the URL from the page it takes you too. You'll notice if you try and use this directly you'll get a warning from JSFiddle.
More to the point is the browser will give you an error, e.g.:
Refused to execute script from https://raw.githubusercontent.com/nnnick/Chart.js/master/Chart.min.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
Take that URL and visit rawgit.com. This will give you a URL of the format https://rawgit.com/nnnick/Chart.js/master/Chart.min.js which you can then use.
I've tried and tested this and it seems to work fine without issue
This is an updated answer, since the url's have changed slightly for Github... I ran into this issue and figured it out for present day. Hopefully this helps people out finding this post recently. Example for Bootstrap Slate theme from Bootswatch:
Raw file url: https://raw2.github.com/thomaspark/bootswatch/gh-pages/slate/bootstrap.css
Remove the 2. after raw: https://rawgithub.com/thomaspark/bootswatch/gh-pages/slate/bootstrap.css
That's it! :D
Nowadays JSDelivr seems to be the best option.
UPDATE
How to use or misuse github as kind of a CDN is not a thought that only benign "fiddlers" have; criminals have that thought also. Unfortunately, github, being as free and as anonymous as it is, is prone to be misused. As far as I can tell, the fact that some of the above solutions are things which are now broken, has to do with that.
Here is how I do it. It works now (Nov 2019), but it's admittedly not very convenient.
Get a github account yourself, if you don't already have one. Create a repository the name of which is identical to your github user name. That repo (and only that repo), - I'll call it the "home repo" - you can use as your web hosting service. https : // yourGithubUserName .github.io will show your home repo "raw/as it is" to the public. (Folder contents is not shown, and you HAVE TO have an index.html)
Now, if you want to use someone else's github repo in a fiddle, just copy over the complete repo to your home repo, and then just reference your copy of that repo with the src attribute of a script tag in the HTML part of the fiddle. Like this:
<head>
<script src="https://mathheadinclouds.github.io/thirdparty/esprima.js"></script>
<script src="https://mathheadinclouds.github.io/thirdparty/estraverse.browser.js"></script>
<script src="https://mathheadinclouds.github.io/thirdparty/escope.browser.js"></script>
</head>
<body></body>
Above snippet shows the HTML part of a working fiddle which is using the node modules esprima, estraverse, and escope, which is to say, the github repos of the same name. thirdparty is there because that's the name of the subfolder (in my home repo) where I put the copies.
As I said, not very convenient (lot's of copy and paste to set it all up), but that's what works for me.
And I should mention, just copy/paste might not be enough, you might have to do browserify or webpack on the referenced repo (if it was made for node, that is.)
here is the fiddle I was talking about.
OLD ANSWER
(works, but is kind of slow)
You can use requirify. It's made to enable you to require (as it is in node) on the browser command line; but it works in fiddles too, I tested it. I have no clue if it's "the best", compared to the other methods above (since I didn't go through them all and tested them), but it works.
Here is an example fiddle loading esprima (javascript parser), then escodegen (reverse javascript parser depending on esprima), then parsing and regenerating some simple javascript code.
what
require('lorem', 'ipsum')
does is, it loads the ipsum node module from npm, and puts the result into global variable named lorem. So this is only for npm modules not general github files which aren't also node modules. Shouldn't be much restriction since you can always turn it into a node module if it's your own project.
here it is
second example using same technique.
(((it's actually even simpler as shown in the fiddle. You can just put the 2 require statements right one after the other, you don't need a callback function in between (just one callback function to wait until both are loaded))))
Another possibility is to add the Git library to the cdnJS Script Repository (they write that any library that is resonably popular on GitHub will be accepted) and then use it as external resource.
Just found out: there are lots of Javascript libraries at http://jsdb.io/ and it's very easy to add new ones there--i's just a matter of entering the URL of a Github repository.
If there is a git repo in following folder structure
fiddletest/test1 (fiddletest is the repo name and test1 is a folder)
then the corresponding jsfiddle link will be
http://jsfiddle.net/gh/get/<library name>/<version>/<github user name>/fiddletest/tree/master/test1/
The folder and file structure must be like this
fiddletest(the repo name)
|____ test1
|____ demo.html
|____ demo.js
|____ demo.css
|____ demo.details
except these three files others will be ignored.
the details file should hold the fiddle details and link of external resources(if any) as follows
---
name: test fiddle repo
description: this is a test repo
resources:
- http://abc.xyz.com/abc.js
- http://abc.xyz.com/abc2.js
...
May be you have noticed the and in the fiddle link. If a fiddle is with pure js the the library name should be "library" and the version should be "pure"
In a nutshell the fiddle link to reffer to github should be in following format
http://jsfiddle.net/gh/get/<library name>/<version>/<github user name>/<repo name>/tree/<branchname>/<folder name>/
2021
Just go to github file and click "Download" button and copy URL - it will works with fetch - working example here (it not works in SO snippet - I don't know why) - example url from this file:
https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/VC/glTF-Embedded/VC.gltf

RichTextToolbar in GWT 2.3

I'm trying to create a RichTextArea (following the GWT Showcase : link )
When I do a code completion of RichTextToolbar, I'm not able to find it. Is this an external library?
And then I googled and found this : google code link. Is this the same library in the Google Showcase? Or is the RichTextToolbar is an old implementation that not being brought to version 2.3?
Update:I tested this and what I feel is although the implementation the same, the UI looks different though.
It seems that they created their own version of RichTextToolbar.
This class is part of the GWT Showcase.
Here is a decent explanation to get the RichTextToolbar working. You take the source code from showcase basicaly.
http://www.jeanhsu.com/2010/06/10/how-to-use-richtexttoolbar-in-gwt/