markhuyong's garden


  • Home

  • Categories

  • Archives

  • Tags

Understanding sun.misc.Unsafe

Posted on 2017-08-24

Understanding guide

  • Oracle’s proposed removal of sun.misc.Unsafe in Java 9
  • Java Magic. Part 4: sun.misc.Unsafe
  • Understanding sun.misc.Unsafe - DZone Java

JDK code

  • openjdk/unsafe.cpp at jdk9/jdk9 · dmlloyd/openjdk
  • openjdk/unsafe.hpp at jdk9/jdk9 · dmlloyd/openjdk
  • openjdk/hotspot/test/runtime/Unsafe at jdk9/jdk9 · dmlloyd/openjdk
  • GC: Unsafe - sun.misc.Unsafe (.java) - GrepCode Class Source

hexo cheatsheet

Posted on 2017-08-10 | In Hexo

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Cheatsheet

Installation

1
2
3
npm install hexo -g #install
npm update hexo -g #update
hexo init #initialize

Shorthands

1
2
3
4
5
6
7
8
hexo n #hexo new
hexo p #hexo publish
hexo g #hexo generate
hexo s #hexo server
hexo d #hexo deploy

hexo s -g #hexo server with generator
hexo s -g --draft #hexo server with generator and show drafts

Server

1
2
3
4
5
6
7
hexo server #Hexo will watch files, don't need to restart server 
hexo server -s #Static mode, serve public folder and disable file watching.
hexo server -p 5000 #change port
hexo server -i 192.168.1.1 #custom ip
hexo clean #Cleans the cache file (db.json) and generated files (public).
hexo g #Generates static files.
hexo d #Deploys your website.

Watching

1
2
hexo generate
hexo generate --watch #Watch file changes

Deploy

1
2
3
4
5
hexo generate --deploy
hexo deploy --generate

hexo deploy -g
hexo server -g

Posts

1
2
3
4
5
6
7
8
9
10
11
hexo new "postName" # new post _posts/postName.md
hexo new page "pageName"
hexo generate
hexo server
hexo deploy #.deploy deploy to GitHub repo
hexo new [layout] <title>
hexo new photo "My Gallery"
hexo new "Hello World" --lang tw

hexo new draft "New Draft" # New-Draft.md
hexo publish "New Draft" # copy New-Draft.md from _drafts to _posts

Quick Start

Command line reference: Commands | Hexo

Installation with github: How to use Hexo and deploy to GitHub Pages

Next theme: Hexo搭建GitHub博客(三)- NexT主题配置使用 | Zhiho’s Blog

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

Converting HTML to Text or Markdown

Posted on 2017-08-10

original link

I’m working on a documentation project where I might need to convert
some existing HTML pages back into text or Markdown format for the new
system. Rather than manually editing the HTML source, I’m testing with a
couple different ways to script it automatically. In the examples below,
I’m using a documentation page for our GoToMeeting API method Get
Meetings
.

Lynx

Lynx is an open-source
text web browser that is usually present on Linux machines and can be
installed for Mac and Windows. I’ve used it in the past to see how web
pages will appear to search engines or for accessibility
testing
.
In both cases, you can quickly tell whether your text is sufficiently
communicating your content.

For the case of saving web pages in text format, Lynx also has a
command-line option “-dump”:

$ lynx -dump http://www.whatismyip.com/ > example.txt

In my test case I couldn’t convince Lynx to fetch an SSL page, so I
download it with Curl and pipe it into Lynx:

$ curl --silent https://developer.citrixonline.com/api/gotomeeting-rest-api/apimethod/get-meetings | lynx -dump -stdin > lynx.txt

Here’s a sample section of the output:

URL
https://api.citrixonline.com/G2M/rest/meetings
Method
GET
Response Type
JSON
Parameters
scheduled A string "true" to get all future meetings.
history A string "true" to get past meetings within date range.
startDate If history=true, required start of date range, in ISO8601 UTC
format.
endDate If history=true, required end of date range, in ISO8601 UTC
format.

Pandoc

Pandoc
is an open-source “universal document converter” which understands (and
can convert between) about two dozen different formats. It’s well suited
for writing a document in a primary source, then converting to other
formats for different publishing options.

The option we’ll use here is Pandoc’s ability to convert from HTML to
Markdown, for example:

$ pandoc -s -r html http://www.whatismyip.com/ -o pandoc.md

For my page, I use the same trick as above because Pandoc can’t connect
to SSL directly:

$ curl --silent https://developer.citrixonline.com/api/gotomeeting-rest-api/apimethod/get-meetings | pandoc -s -r html -o pandoc.md

And here’s the sample output of the same section as above:

### URL
https://api.citrixonline.com/G2M/rest/meetings
### Method
GET
### Response Type
JSON
### Parameters
**scheduled** A string "true" to get all future meetings.
**history** A string "true" to get past meetings within date range.
**startDate** If history=true, required start of date range, in ISO8601
UTC format.
**endDate** If history=true, required end of date range, in ISO8601 UTC
format.

Conclusion

Both of these options do a pretty decent job of converting HTML into
text or Markdown format. Pandoc seems slightly better in terms of
getting to Markdown format, but I would need to run some more samples to
see how much manual editing would be needed after.

I’m also going to play a bit more with Aaron Schwartz’s
Html2Text. In my quick test, it
appeared to have a problem with malformed HTML so I need to do some
further testing with it.

Hello World

Posted on 2017-08-10

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

Linux Commands Cheat Sheet

Posted on 2017-08-10 | In linux
A quick reference for Linux commands.
Read more »
12
markhuyong

markhuyong

15 posts
7 categories
21 tags
© 2018 markhuyong
Powered by Hexo
Theme - NexT.Muse