I'm creating an IOS app with swift and I'm having a lot of trouble and cannot seem to find the answer.
I have a giant (local) folder that contains a lot of JSONs in my app directory. The path tree looks like:
APP
├── _LocationJSONs
| └── (All 300+ JSONs here)
├── AppDelegate.swift
├── ViewController.swift
├── Main.storyboard
├── LaunchScreen.storyboard
└── Info.plist
I need to read in and parse all the JSONs from that local directory, however I don't always know the name.
I've seen Bundle.main.path(forResource: "file name", ofType: "json") but I can't use that becuase it requires a hard coded name. I've also seen doing something like
let fm = FileManager.default
let path = Bundle.main.resourcePath!
But that just leads to a documents path and I can't seem to get anything from there
Is there any way to 1. Get the path of that directory, and 2. Get the name of all the JSONs that way I can parse them later?
You should use the Bundle method urls(forResourcesWithExtension:subdirectory:localization:) and pass in subdirectory: "_LocationJSONs".
That will let you get a list of all the files inside your "_LocationJSONs" subdirectory that have a given extension (probably "json" in your case)
Bundle.main.urls(forResourcesWithExtension: "json", subdirectory: "LocationJSONs")!
(Might want to do better unwrapping but this works for now)
Related
I have Nuxt.js project whose contents are
alok#alok-HP-Laptop-14s-cr1xxx:~/tmp/portfolio$ tree -L 1
.
├── assets
├── components
├── layouts
├── middleware
├── node_modules
├── nuxt.config.js
├── package.json
├── package-lock.json
├── pages
├── plugins
├── README.md
├── static
└── store
9 directories, 4 files
This is very nice structure which is described on https://nuxtjs.org/guide/directory-structure .
I have some CSV data which I want to display in table in page/template. So how and where should I keep my this CSV data file so which can be easily accessed and rendered in template/page?
It really depends on your data, your setup and experience...
If your data is not changing too often and you are willing to build and deploy your app every time it changes, the simplest thing you can do is to convert csv to json and include myData from myData.json directly from JavaScript (and keep it in the same folder as your component)
data will by part of your app bundle (ok if its just few lines)
works great with static site (nuxt generate) or SPA mode of Nuxt (don't need Node on server side so it can be hosted on Netlify and such)
simple
Other option is to put in inside static folder but then you will need to download it into your running app at run-time using Ajax (Axios for example). You can find examples here
more complicated
ability to update data without building whole app (just upload single file)
Even in this second case I would argue its better to parse it once and convert into something JavaScript can read easily (like JSON) and keep it that way instead of parsing at run-time every time someone uses your site...
Summary
When I upload a zip file containing multiple SolidWorks assemblies and parts, an assembly contains the same name as my rootFile, and my rootFile is sorted later in a alphabetic order. The translator is using the wrong rootFile for the translation.
Could this be a bug in the translation service?
Example
example.zip
├── part1.sldprt
├── part2.sldprt
├── an assy.sldasm <-- This file will be selected by translator
└── assy.sldasm <-- This file is selected as rootFile
Let's say I upload the zip file above, "example.zip", and then request a translation with "assy.sldasm" as rootFile.
After completion, when I request the manifest of the translated file, the "rootFile"is now "an assy.sldasm".
Conclusion
My conclusion is that the translator matches filenames without requiring a match on the full filename.
This means, that because assy.sldasm is sorted after an assy.sldasm it will match to an assy.sldasm first.
Files to replicate the issue can be sent upon request.
posting the comment as an answer for more searchable by others:
Although I have not dataset of Solidworks, I can reproduce this problem with linked files of Inventor, AutoCAD or Revit. it looks translation job finds the file which contains the string rootFileName, and returns the first one (in sorted) ,instead of matching exact the string of rootFileName. Sorry for the problem. I logged it with our engineer team: DERI-5444
polymer build command output the result to the build directory.
Is there any way to change the output path?
/* Output directory example */
./build/
├── es5-bundled
├── es6-bundled
├── es6-unbundled
└── polymer.json
You can change the names of the subfolders within build folder to any name you like. Just change the name property in builds array of your polymer.json file.
See the documentation for this.
Currently, no method exists to change the build output path (see this issue). You can, however, use polymer-build (the same package used by polymer-cli) with gulp, which gives you a lot more control over those kind of things.
I have a YAML file that holds some data and needs to be processed client side.
---
some: content
...
Jekyll handles everything with Front Matter, which results in the whole YAML content to be treated as Front Matter and the page then has no content.
Is there a way to tell Jekyll to treat the file as static, even though it has a YAML header?
I tried different combinations of exclude and keep_files, also setting Front Matter defaults in my _config.yml, but nothing is really working.
My workaround now is to add an additional Front Matter block in front of the content:
---
layout: null
---
---
some: content
...
The YAML file though is a swagger definition and adding this extra block would both:
make it complicated to test/generate the definition locally or in Swagger Editor
Generate confusion, if the file is downloaded via github.
So ideally I would like to store the file without any modification and somehow teach Jekyll to leave it alone.
There is no way to tell Jekyll to avoid to process a file with front matter without a plugin.
A simple solution would be to use Jekyll hook's to copy the original unprocessed file with front matter to the generated site just after the whole site has been generated.
For example, adding _plugins/copyfile.rb:
Jekyll::Hooks.register :site, :post_write do |site|
src = "_unprocessed/about.md"
dest = "_site/assets"
puts "Copying #{src} to #{dest}"
FileUtils.cp(src, dest)
end
That would copy _unprocessed/about.md with front matter to the final site assets dir.
As _unprocessed starts with an underscore it won't be present in the resulting site.
Building the site:
/tmp/s⟫jekyll b
Configuration file: /tmp/s/_config.yml
Source: /tmp/s
Destination: /tmp/s/_site
Incremental build: disabled. Enable with --incremental
Generating...
Copying _unprocessed/about.md to _site/assets
done in 0.884 seconds.
Auto-regeneration: disabled. Use --watch to enable.
/tmp/s⟫ tree _site/
_site/
├── 404.html
├── assets
│ ├── about.md
│ └── main.css
├── feed.xml
├── index.html
└── jekyll
└── update
└── 2017
└── 11
└── 09
└── welcome-to-jekyll.html
6 directories, 6 files
Cross-posting my answer here as it may be relevant (not sure; I'm not a Jekyll user but github pages uses it.) https://stackoverflow.com/a/48954668/1461007
I am looking for a way to have multiple markdown files (.md) in a directory and have them available as files (not sub-directories).
Example:
├── about/
| └── index.md
| └── history.md
| └── vision.md
I want these to become urls like this (treated as files (no trailing slash))
base.url/about/
base.url/about/history
base.url/about/vision
instead of (directories (trailing slash)):
base.url/about/
base.url/about/history/
base.url/about/vision/
How can I achieve that?
You can do this with Jekyll 3.x using permalinks in your files front matter. But, if you want to use this with Jekyll 2.4+ and Github pages, it seems that there is a problem.
Permalinks with trailing slash are the way to go for now.