{"id":8633,"date":"2019-07-02T16:31:00","date_gmt":"2019-07-02T07:31:00","guid":{"rendered":"https:\/\/thk.kanzae.net\/wp\/?p=8633"},"modified":"2020-02-05T19:41:00","modified_gmt":"2020-02-05T10:41:00","slug":"highlighter","status":"publish","type":"post","link":"https:\/\/thk.kanzae.net\/wp\/settings\/block-editor\/t8633\/","title":{"rendered":"\u30b7\u30f3\u30bf\u30c3\u30af\u30b9\u30cf\u30a4\u30e9\u30a4\u30bf\u30fc\u30d6\u30ed\u30c3\u30af"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u30b7\u30f3\u30bf\u30c3\u30af\u30b9\u30cf\u30a4\u30e9\u30a4\u30bf\u30fc\u306e\u30b5\u30f3\u30d7\u30eb<\/h2>\n\n\n\n<p class=\"m10-b\"><span style=\"font-weight:bold\">Javascript<\/span><\/p>\n\n\n\n<pre class=\"wp-block-luxe-blocks-syntaxhighlighter line-numbers language-javascript m0-t\"><code class=\"language-javascript\">function factorial(n) {\n    if (n == 0) {\n        return 1;\n    }\n    return n * factorial(n - 1);\n}<\/code><\/pre>\n\n\n\n<p class=\"m10-b\"><span style=\"font-weight:bold\">C\u8a00\u8a9e<\/span><\/p>\n\n\n\n<pre class=\"wp-block-luxe-blocks-syntaxhighlighter line-numbers language-c m0-t\"><code class=\"language-c\">#include &lt;stdio.h>\n\nint main(int argc, char* argv[])\n{\n    printf(\"Hello, world!\\n\");\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"m10-b\"><span style=\"font-weight:bold\">PHP<\/span><\/p>\n\n\n\n<pre class=\"wp-block-luxe-blocks-syntaxhighlighter line-numbers language-php m0-t\"><code class=\"language-php\">&lt;?php\nclass Car {\n    function Car() {\n        $this->model = \"Tesla\";\n    }\n}\n\n\/\/ create an object\n$Lightning = new Car();\n\n\/\/ show object properties\necho $Lightning->model;\n?><\/code><\/pre>\n\n\n\n<p class=\"m10-b\"><span style=\"font-weight:bold\">Bash<\/span><\/p>\n\n\n\n<pre class=\"wp-block-luxe-blocks-syntaxhighlighter line-numbers language-bash m0-t\"><code class=\"language-bash\">#!\/bin\/bash\n# Simple line count example, using bash\n#\n# Bash tutorial: http:\/\/linuxconfig.org\/Bash_scripting_Tutorial#8-2-read-file-into-bash-array\n# My scripting link: http:\/\/www.macs.hw.ac.uk\/~hwloidl\/docs\/index.html#scripting\n#\n# Usage: .\/line_count.sh file\n# -----------------------------------------------------------------------------\n\n# Link filedescriptor 10 with stdin\nexec 10&lt;&amp;0\n# stdin replaced with a file supplied as a first argument\nexec &lt; $1\n# remember the name of the input file\nin=$1\n\n# init\nfile=\"current_line.txt\"\nlet count=0\n\n# this while loop iterates over all lines of the file\nwhile read LINE\ndo\n    # increase line counter \n    ((count++))\n    # write current line to a tmp file with name $file (not needed for counting)\n    echo $LINE > $file\n    # this checks the return code of echo (not needed for writing; just for demo)\n    if [ $? -ne 0 ] \n     then echo \"Error in writing to file ${file}; check its permissions!\"\n    fi\ndone\n\necho \"Number of lines: $count\"\necho \"The last line of the file is: `cat ${file}`\"\n\n# Note: You can achieve the same by just using the tool wc like this\necho \"Expected number of lines: `wc -l $in`\"\n\n# restore stdin from filedescriptor 10\n# and close filedescriptor 10\nexec 0&lt;&amp;10 10&lt;&amp;-<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u30b7\u30f3\u30bf\u30c3\u30af\u30b9\u30cf\u30a4\u30e9\u30a4\u30bf\u30fc\u306e\u30b5\u30f3\u30d7\u30eb Javascript C\u8a00\u8a9e PHP Bash<\/p>\n","protected":false},"author":1,"featured_media":8726,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[60],"tags":[],"_links":{"self":[{"href":"https:\/\/thk.kanzae.net\/wp\/wp-json\/wp\/v2\/posts\/8633"}],"collection":[{"href":"https:\/\/thk.kanzae.net\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thk.kanzae.net\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thk.kanzae.net\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thk.kanzae.net\/wp\/wp-json\/wp\/v2\/comments?post=8633"}],"version-history":[{"count":0,"href":"https:\/\/thk.kanzae.net\/wp\/wp-json\/wp\/v2\/posts\/8633\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/thk.kanzae.net\/wp\/wp-json\/wp\/v2\/media\/8726"}],"wp:attachment":[{"href":"https:\/\/thk.kanzae.net\/wp\/wp-json\/wp\/v2\/media?parent=8633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thk.kanzae.net\/wp\/wp-json\/wp\/v2\/categories?post=8633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thk.kanzae.net\/wp\/wp-json\/wp\/v2\/tags?post=8633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}