Porting code to Pharo 2.0 - stream

Pharo 2.0 changed some basic API bits, and I cannot found the new way of doing the following:
FileDirectory default directoryNamed: aFolderString.
FileDirectory on: aFilename.
FileDirectory default assureExistenceOfPath: aString.
ReferenceStream on: stream.
What would be the new equivalent code?
Is there an update guide available describing how to translate or port code?

The following statements correspond do the ones you put in your question.
FileSystem workingDirectory / aFolderString
aFilename asFileReference
aString asFileReference ensureDirectory
ReferenceStream does no longer exist in 2.0.
aPathString asFileReference resolves aPathString, so if there are slashes in your name you will end up in a subdirectory.
/ on the other hand takes a single directory or file name as an argument, and does not resolve further subdirectories. Depending on your platform you can easily refer to a file named foo/bar with a slash in the name with FileSystem workingDirectory / 'foo/bar'.

I have collected some translations you may find useful:
+------------------------------------------------------+---------------------------------------------------------------------------+
| FileDirectory | FileSystem |
+------------------------------------------------------+---------------------------------------------------------------------------+
| FileDirectory assureExistence. | aString asFileReference ensureDirectory. |
| FileDirectory baseNameFor: aString. | aString asFileReference base. |
| FileDirectory containingDirectory. | Path parent asFileReference pathString. |
| FileDirectory default deleteFileNamed: aString. | aString asFileReference ensureDeleted. |
| FileDirectory default directoryExists: aString. | aString asFileReference exists. |
| FileDirectory default directoryNamed: aFolderString. | FileSystem disk / aFolderString. |
| FileDirectory directoryEntryFor: aString. | aString asFilereference. |
| (FileDirectory entryFor: aString) / 'filename'. | aString asFileReference / 'filename'. |
| FileDirectory extensionFor: aString. | aString asFileReference extension. |
| FileDirectory default fileExists: aString. | aString asFileReference exists. " or " DiskStore current isFile: aString. |
| FileDirectory default fullNameFor: aString. | aString asFileReference fullName. |
| FileDirectory default pathName. | FileSystem disk workingDirectory fullName. |
| FileDirectory on: aFilename. | aFilename asFileReference. |
| (FileDirectory on: aString) entries collect: #name. | aString asFileReference children collect: #basename. |
| (FileDirectory on: aString) entryAt: 'filename'. | aString asFileReference / 'filename'. |
| FileDirectory oldFileNamed: aString. | aString asFileReference readStream. |
| FileDirectory slash. | FileSystem disk separator. " or " DiskStore delimiter asString. |
+------------------------------------------------------+---------------------------------------------------------------------------+

ReferenceStream is not supported anymore and has been deleted in Pharo 2.0. You should use Fuel which is well written, well documented, well tested and very fast. http://rmod.lille.inria.fr/web/pier/software/Fuel

Related

Include path has been specified but still failed to include the header in the path in a Bazel C++ project

I have projects with a directory structure like that
---root
| |--src
| |--project1
| |--model
| | |--incude
| | | |--model
| | | |--modelA.hpp
| | | |--modelB.hpp
| | |--modelA.cpp
| | |--modelB.cpp
| | |--BUILD #1
| |...
| |--view
| |...
| |--common
| | |--include
| | |--common
| | |--data_type.hpp
| |--BUILD #2
|--WORKSPACE
As I have other package in this project and some of them use the same self-defined data type, I defined them in a package named common.
Now I include the data_type.hpp in file modelA.hpp
...
#include "common/data_type.hpp
...
Refering to the stage3 example in the tutorial, the BUID(#1) is like that
cc_library(
name = "modelA",
hdrs = "include/model/modelA.hpp",
deps = ["//src/project/common:data_type"],
copts = ["-Isrc/project/common/include"],
)
and the BUILD(#2) which defines the depedency module data_typeis like that
cc_library(
name = "data_type",
hdrs = ["include/common/data_type.hpp"],
visibility = ["//visibility:public"],
)
However, when I built the code, I got
src/project/model/include/model/modelA.hpp: fatal error: common/data_type.hpp: No such file or directory
Why I have defined copts = ["-Isrc/heimdallr/common/include"] but still got this error?
Please check the Header inclusion checking section of C/C++ Rules from the Bazel document. Relative to the workspace directory, all include paths should be created. Kindly refer to this issue for more information. Thank you!

DRBD StandAlone with new resource

I have two nodes "A" (primary) & "B". Each node have 3 resources. On node "B" i replace disks and after that i add each resource as secondary. Two resources successfully connect and sync, but with one resource i have issue. When on node "B" i stop this resource, node "A" shows
lv1 role:Primary
disk:UpToDate
b.host connection:Connecting
When i starts this resource on node "B", node "A" shows:
lv1 role:Primary
disk:UpToDate
b.host connection:StandAlone
and node "B" shows:
lv1 role:Secondary
disk:Inconsistent
a.host connection:Connecting
I try everything, remove/add resource, metadata on node "B", remove data, rebuild raid drbdadm connect lv1 --discard-my-data etc.
One difference between worked an broken resources is This node was a crashed primary, and has not seen its peer since
+--< Current data generation UUID >-
| +--< Bitmap's base data generation UUID >-
| | +--< younger history UUID >-
| | | +-< older history >-
V V V V
E43824C7BC375B4A:626476078D91E933:CC1DC3FAD143EDCC:E4E71860FBA887C2:1:1:1:1:0:0:0:0:0:0:0:1
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
-< Data consistency flag >--+ | | | | | | | | | | |
-< Data was/is currently up-to-date >--+ | | | | | | | | | |
-< Node was/is currently primary >--+ | | | | | | | | |
-< This node was a crashed primary, and has not seen its peer since >--+ | | | | | | | |
-< The activity-log was applied, the disk can be attached >--+ | | | | | | |
-< The activity-log was disabled, peer is completely out of sync >--+ | | | | | |
-< This node was primary when it lost quorum >--+ | | | | |
-< Node was/is currently connected >--+ | | | |
-< The peer's disk was out-dated or inconsistent >--+ | | |
-< A fence policy other the dont-care was used >--+ | |
-< Node was in the progress of marking all blocks as out of sync >--+ |
-< At least once we saw this node with a backing device attached >--+
Any ideas how i can fix it?
UPD: Find new differences a kernel: drbd lv1/0 drbd1 b.host: The peer's disk size is too small! (999671944 < 1000196216 sectors)
In my case on node "A" (primary) i have LVM, on node "B" i have MDRAID. This differences give me difference in resource size in 524 272 sectors. What i do to save my data. I run both resources in primary mode, mount and copy data from "A" to "B", then i rebuild node "A" to MDRAID and sync resources.

Absolute vs relative vs "slash" URL?

If this full URL:
http://domain.com/dir/file.css
Is an "absolute URL", where the link will work from any website.
And this:
../dir/file.css
Is a "relative URL", where the link will only work from that directory path.
What is the combination of those two called…
/dir/file.css
Where the link will work from any location on that site?
Your first example is a URL. Your second and third examples are not URLs, they're paths. If the path begins with / then it's an absolute path, otherwise it's a relative path.
Web browsers generally understand how to interpret a path in relation to the "current" host and path.
You’re basically talking about a URI scheme. In your example:
/dir/file.css
This is considered the path:
/dir/
And this is the filename:
file.css
So saying “hostname plist path & filename” is a safe bet. Or perhaps /dir/file.css can be considered the root path since the / at the beginning anchors it to the hostname part of the URL.
This diagram from Wikipedia explains it well:
foo://username:password#example.com:8042/over/there/index.dtb?type=animal&name=narwhal#nose
\_/ \_______________/ \_________/ \__/ \___/ \_/ \______________________/ \__/
| | | | | | | |
| userinfo hostname port | | query fragment
| \________________________________/\_____________|____|/ \__/ \__/
| | | | | | |
| | | | | | |
scheme authority path | | interpretable as keys
name \_______________________________________________|____|/ \____/ \_____/
| | | | | |
| hierarchical part | | interpretable as values
| | |
| path interpretable as filename |
| ___________|____________ |
/ \ / \ |
urn:example:animal:ferret:nose interpretable as extension
path
_________|________
scheme / \
name userinfo hostname query
_|__ ___|__ ____|____ _____|_____
/ \ / \ / \ / \
mailto:username#example.com?subject=Topic

How to get MultiMarkDown to view tables in Sublime Text 2 OSX

I am trying to avoid using inline HTML to get tables working in my MD file. I have Markdown Preview and Table Editor installed via the package installer, and multimarkdown installed via homebrew, but I can't get the following text to display as a table:
| Left align adsf | Right align | Center align |
| :--------------- | ----------: | :----------: |
| This | This | This |
| column | column | column |
| will | will | will |
| be | be | be |
| left | right | center |
| aligned | aligned | aligned |
When I "Markdown Preview" it just displays like this:
| | | Left align adsf | Right align | Center align | | --- | --- | ---------------- | ----------- | ------------ | | | | ---------------s | ----------- | ------------ | | --- | --- | :--------------- | ----------: | :----------: | | | | This | This | This | | | | column | column | column | | | | will | will | will | | | | be | be | be | | | | left | right | center | | | | aligned | aligned | aligned |
I have switched the file type to MultiMarkdown (lower right portion of ST2 screen)
I have searched, and it appears some people have a build system, or other approaches I have been unable to get going. What am I missing? If a build system is needed, how do I set up one? I am mainly interested in viewing this in HTML, but wouldn't be opposed to other ways....
If you switch the parser to github, it'll work just fine.
Go to Prefrences > Package Settings > Markdown Preview > Settings - User and paste this code:
{
"parser": "github"
}
"If a build system is needed, how do I set up one?"
In OS X I would strong suggest getting the excellent Marked.app and then setting up a new build system in ST containing this trivial code
{
"osx": {"cmd": ["open", "-a", "Marked", "$file"]},
"selector": "text.html.markdown"
}
Then when you 'build' a markdown file (Cmd+B) you will get a preview generated in Marked.
Easy and elegant and well worth the cup-of-coffee price of Marked to avoid all the hassle of the plugin approach.

rails object to memcached and then out again

I want to store a simple active record object using memcached. I know I need to first convert the object to JSON before saving it to memcached my question is how I can pull it out again, deserialize it and use it as an activerecord relation. Do I have to make a custom parser the JSON or am I overlooking some drop dead easy solution?
The active record object looks like this:
+------+-----+-----------+---------------------------------+---------------------+-------+
| id | ppl | exclusive | name | price | spots |
+------+-----+-----------+---------------------------------+---------------------+-------+
| 8948 | 12 | false | 12 Bed Mixed Dorm | 9.0000000000000000 | 12 |
| 8947 | 10 | false | 10 Bed Mixed Dorm | 9.5000000000000000 | 10 |
| 8946 | 6 | false | 6 Bed Mixed Dorm | 10.0000000000000000 | 6 |
| 8945 | 4 | false | Basic 4 Bed Mixed Dorm | 10.0000000000000000 | 4 |
| 8944 | 2 | true | Twin Private Shared Bathroom | 12.0000000000000000 | 1 |
| 8943 | 1 | true | Standard Single Private Ensuite | 15.0000000000000000 | 1 |
+------+-----+-----------+---------------------------------+---------------------+-------+
You shouldn't don't need to worry about the serialization -- in almost all cases, this can be handled for you:
#Gemfile
gem install dalli
#config/environments/production.rb
config.cache_store = :dalli_store, '127.0.0.1' #use memcached
#Get id 1245 from model_names
Rails.cache.fetch("ModelName#1245") do
ModelName.find(1245)
end

Resources