pages tagged note http://meng6net.localhost/tag/note/ <p><small>Copyright © 2005-2020 by <code>Meng Lu &lt;lumeng3@gmail.com&gt;</code></small></p> Meng Lu's home page ikiwiki Mon, 14 Dec 2020 03:46:01 +0000 Warning about low disck space http://meng6net.localhost/computing/sysadmin/automatically_warning_about_low_disk_space/ http://meng6net.localhost/computing/sysadmin/automatically_warning_about_low_disk_space/ computing note software sysadmin Sun, 25 Oct 2020 00:50:16 +0000 2020-10-25T00:50:16Z <p>For whatever reason, even if my Macbook Pro computer booted with more than 10 GB disk space available, after working on it and having it powered on constantly for a day or two, its disk space very often will fall dramatically and sometimes even almost fill up with nominally something like 200 MB left. And it often causes issues:</p> <ul> <li> <p>Having to "manually" kill applications that are no longer responsive using Activity Monitor.</p> </li> <li> <p>Some applications not properly exiting and saving status and metadata. For example, Eclipse workspace data, backup files in Emacs, and currently opened tabs in Google Chrome.</p> </li> </ul> <p>I made a <a href= "https://github.com/lumeng/repogit-mengapps/blob/master/file_system/warn-about-low-disk-space.sh"> Bash script</a> to check and warn about low disk space and have it run periodically as a cron job.</p> Examples of using wget http://meng6net.localhost/computing/example/examples_of_using_wget/ http://meng6net.localhost/computing/example/examples_of_using_wget/ computing note tip wget Sun, 03 May 2020 05:47:34 +0000 2020-12-14T03:46:01Z <h2>Download web pages recursively under an URL<sup id= "fnref:1"><a href="http://meng6net.localhost/tag/note/#fn:1" rel="footnote">1</a></sup></h2> <pre><code> wget \ --recursive \ --no-clobber \ --page-requisites \ --html-extension \ --convert-links \ --restrict-file-names=windows \ --domains example.com \ -nH --cut-dirs=some_subdir \ -e robots=off \ --random-wait \ --wait 5 \ --no-parent \ www.example.com/subdirectory/ </code></pre> <ul> <li>Substitute <code>example.com</code> and <code>www.example.com/subdirectory/</code> with relevant expressions in your problem.</li> <li><code>--recursive</code>: download the entire Web site.</li> <li><code>--domains website.org</code>: don't follow links outside website.org.</li> <li><code>--no-parent</code>: don't follow links outside the directory <code>subdirectory</code>.</li> <li><code>--page-requisites</code>: get all the elements that compose the page (images, CSS and so on).</li> <li><code>--html-extension</code>: save files with the .html extension.</li> <li><code>--convert-links</code>: convert links so that they work locally, off-line.</li> <li><code>--restrict-file-names=windows</code>: modify filenames so that they will work in Windows as well.</li> <li><code>--no-clobber</code>: don't overwrite any existing files (used in case the download is interrupted and resumed).</li> <li><code>-e robots=off</code>: force crawling regardless of robots.txt setting.</li> <li><code>-nH --cut-dirs=some_subdir</code>: cuts out hostname and subdirectory name.</li> <li><code>--random-wait</code>: randomizes the time between requests to vary between 0.5 and 1.5 times of the waiting time specified by the <code>--wait</code> option.</li> <li><code>--wait 5</code>: number of seconds to wait between requests. (See <code>--random-wait</code>.)</li> </ul> <h2>References</h2> <div class="footnotes"> <hr /> <ol> <li id="fn:1">linuxjournal.com. <em>Downloading an Entire Web Site with wget</em>. 2008. <a href= "https://www.linuxjournal.com/content/downloading-entire-web-site-wget"> https://www.linuxjournal.com/content/downloading-entire-web-site-wget</a><a href="http://meng6net.localhost/tag/note/#fnref:1" rev="footnote">↩</a></li> </ol> </div> git pull from master http://meng6net.localhost/journal/git_pull_from_master/ http://meng6net.localhost/journal/git_pull_from_master/ computing git note Thu, 09 Apr 2020 05:00:48 +0000 2020-04-09T05:00:48Z <ol> <li>Check out your development branch</li> </ol> <pre><code>git checkout my_branch </code></pre> <ol> <li>Update your development branch my pulling commits from origin/master</li> </ol> <p>2a. method 1</p> <pre><code>git pull origin master </code></pre> <p>ab. method 2 ``` git fetch origin master git merge FETCH_HEAD</p> <ol> <li>Resolving conflcits.</li> </ol> <pre><code>git status </code></pre> <p>If it shows some files contain conflicts, manually edit the files and resolve the conflict blocks.</p> <p>git add the files edited. <code>git add my_file_1 ...</code></p> <p>git commit git push</p> <p>(END)</p> 一些劣质网络文章惯用的标题 http://meng6net.localhost/journal/%E4%B8%80%E4%BA%9B%E5%8A%A3%E8%B4%A8%E7%BD%91%E7%BB%9C%E6%96%87%E7%AB%A0%E6%83%AF%E7%94%A8%E7%9A%84%E6%A0%87%E9%A2%98/ http://meng6net.localhost/journal/%E4%B8%80%E4%BA%9B%E5%8A%A3%E8%B4%A8%E7%BD%91%E7%BB%9C%E6%96%87%E7%AB%A0%E6%83%AF%E7%94%A8%E7%9A%84%E6%A0%87%E9%A2%98/ journal note Fri, 03 Apr 2020 20:58:33 +0000 2020-04-03T20:58:33Z <p> 一些劣质网络文章,惯用模式化的哗众取宠的标题,内容往往格调低劣、似是而非、甚至错误百出,一遍一遍地收到这类「信息污染」的骚扰,不厌其烦。个人建议遇到此类,跟本就不必打开,直接跳过。</p> <ol> <li>就在刚刚…</li> <li>央视曝光…</li> <li>震惊国人…</li> <li>惊天秘密…</li> <li>疯狂转发…</li> <li>删前速看…</li> <li>千万别吃…</li> <li>还敢喝吗…</li> <li>癌症前兆…</li> <li>赶快扔了…</li> <li>太可怕了…</li> <li>大事不好…</li> <li>能害死你…</li> <li>多活十年…</li> <li>治病防癌…</li> <li>毒素最多…</li> <li>神奇功效…</li> <li>惊悚一幕…</li> <li>价值千万…</li> <li>绝密隐私…</li> <li>差点丧命…</li> <li>看后崩溃…</li> <li>身份曝光…</li> <li>北京震怒…</li> <li>xxxx震惊…</li> <li>高层揭秘…</li> <li>强硬反击…</li> <li>全民炸锅…</li> <li>摊大麻烦…</li> <li>国人哽咽…</li> <li>西方胆寒…</li> <li>美国慌了…</li> <li>安倍慌了…</li> <li>美国沉默…</li> <li>幕后黑手…</li> <li>北京发飙…</li> <li>世界哗然…</li> <li>果断出手…</li> <li>突然翻脸…</li> <li>西方崩溃…</li> <li>美国崩溃…</li> <li>最后警告…</li> <li>噩梦来临…</li> <li>世界沸腾…</li> <li>国人不忍了…</li> <li>中国出手了…</li> </ol> Examples of using Evernote http://meng6net.localhost/computing/example/examples_of_using_Evernote/ http://meng6net.localhost/computing/example/examples_of_using_Evernote/ Evernote computing documentation example note software tip Wed, 11 Mar 2020 18:41:54 +0000 2020-03-11T18:41:54Z <h2>Resync all data</h2> <ol> <li>Open Evernote.app on macOS.</li> <li>Press <kbd>Shift</kbd>-<kbd>Option/Alt</kbd> and click the synchronization wheel icon next to the search input field (as of Evernote macOS version 7.14 and 2020-3).</li> </ol> <h2>Refresh database indices</h2> <ul> <li>Press <kbd>Option/Alt</kbd> and click menu item 'Option &gt; Troubleshooting'</li> <li>Click 'Recreate Full Text Search Index' and 'Recreate Spotlight Search Index'.</li> </ul> Installing and configuring mutt http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_mutt/ http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_mutt/ computing configuration documentation homebrew installation macOS note pkgsrc software to-do Tue, 04 Feb 2020 19:44:45 +0000 2020-02-04T19:44:45Z <h2>Intro to Mutt</h2> <p><a href="http://www.mutt.org/"><code>mutt</code></a> is a text-based mail client for Unix operating systems.</p> <h2>Installing <code>mutt</code></h2> <pre><code>brew install mutt </code></pre> <h2>Installing <code>getmail</code></h2> <pre><code>brew install getmail </code></pre> Examples of using afinfo http://meng6net.localhost/computing/example/examples_of_using_afinfo/ http://meng6net.localhost/computing/example/examples_of_using_afinfo/ afinfo audio computing example metadata note software Thu, 27 Dec 2018 19:29:57 +0000 2018-12-27T19:38:14Z <p>Get metadata of an audio or video file:</p> <pre><code>$ afinfo 'some_multimedia_file.m4a'' </code></pre> <p>Get the duration in the unit of seconds:</p> <pre> <code>$ afinfo 'some_multimedia_file.m4a' | awk '/estimated duration/ { print $3 }' </code></pre> <h2>References</h2> <ul> <li> https://stackoverflow.com/questions/8933053/check-duration-of-audio-files-on-the-command-line</li> </ul> Haskell http://meng6net.localhost/journal/Haskell/ http://meng6net.localhost/journal/Haskell/ Haskell computing journal note programming Sat, 13 Oct 2018 03:56:52 +0000 2018-10-13T03:56:52Z <h2>Journal</h2> <h3>Entering multi-line code in GHCi</h3> <p>Use <code>:{</code> and <code>:}</code> to sandwich a block of code consisting of multiple lines:</p> <pre><code>Prelude&gt; :{ Prelude| incrementInteger :: Int -&gt; Int Prelude| incrementInteger x = x + 1 Prelude| :} Prelude&gt; incrementInteger 1 2 </code></pre> <h3>Using the latest released version of GHC with stack</h3> <p>Specify the version of LTS (i.e. Long Term Support) Haskell to use by default in `$HOME/.stack/global-project/stack.yaml:</p> <pre><code>resolver: lts-8.15 </code></pre> <p>As of May, 2017, the newest released version of LTS Haskell is 8.15. This version number can be found on https://www.haskell.org/downloads.</p> <h3><code>data</code>, <code>type</code>, and <code>newtype</code></h3> <ul> <li> <p>https://stackoverflow.com/a/33316715</p> </li> <li> <p>In GHCi, print the type of a symbol</p> <pre><code> Prelude&gt; :type Nothing Nothing :: Maybe a Prelude&gt; :type (+) (+) :: Num a =&gt; a -&gt; a -&gt; a Prelude&gt; :type print "Hello World" print "Hello World" :: IO () </code></pre></li> </ul> <h3><code>Nothing</code> and <a href= "https://wiki.haskell.org/Maybe"><code>Maybe</code></a></h3> <h3><a href="https://wiki.haskell.org/Partial_application">Partial application</a></h3> <p>Functions are not partial, but rather a function can be applied partially.</p> <h3>Function type decalaration</h3> <pre><code>myFunc :: type1 -&gt; type2 -&gt; type3 -&gt; type4 </code></pre> <h3><a href="https://wiki.haskell.org/Pure">Pure as in 'pure functional programming languages'</a></h3> <h3>Get information about a Haskell word in GHCi</h3> <pre><code>Prelude&gt; :info pure class Functor f =&gt; Applicative (f :: * -&gt; *) where pure :: a -&gt; f a ... -- Defined in ‘GHC.Base’ </code></pre> <h3><a href="https://stackoverflow.com/a/9221026">Concatenating multiple strings into one using <code>intercalate</code>, <code>intersperse</code> and <code>concat</code>, and <code>unword</code></a>.</h3> <h3>Function application takes precedence over any binary operator.</h3> <p>For example,</p> <pre> <code>ourPicture = colored green (solidCircle 1) &amp; solidCircle 2 </code></pre> <p>is equivalent to</p> <pre> <code>ourPicture = (colored green (solidCircle 1)) &amp; (solidCircle 2) </code></pre> <h3><a href= "http://learnyouahaskell.com/syntax-in-functions">guard</a></h3> <h3>Changing a prefixing function to an infix binary operator</h3> <pre><code>Prelude&gt; mod 3 2 1 Prelude&gt; 3 `mod` 2 1 </code></pre> <h3>Largest integer</h3> <pre><code>Prelude&gt; :{ Prelude| myInt :: Int Prelude| myInt = 2^63 - 1 Prelude| :} Prelude&gt; myInt 9223372036854775807 Prelude&gt; myInt + 1 -9223372036854775808 Prelude&gt; :{ Prelude| minInt :: Int Prelude| minInt = - 2^63 Prelude| :} Prelude&gt; minInt -9223372036854775808 Prelude&gt; minInt - 1 9223372036854775807 </code></pre> <h2>Arithmetic expression with different types of numbers</h2> <pre><code>Prelude&gt; :{ Prelude| d :: Double Prelude| i :: Int Prelude| d = 1.2 Prelude| i = 1 Prelude| :} Prelude&gt; d+i &lt;interactive&gt;:48:3: error: • Couldn't match expected type ‘Double’ with actual type ‘Int’ • In the second argument of ‘(+)’, namely ‘i’ In the expression: d + i In an equation for ‘it’: it = d + i Prelude&gt; d + fromIntegral i 2.2 Prelude&gt; </code></pre> <h2>References</h2> <ul> <li>https://www.stackage.org <ul> <li>Lookup basic information about a word, e.g. <code>pure</code>: https://www.stackage.org/lts-8.15/hoogle?q=pure</li> </ul> </li> </ul> Haskell http://meng6net.localhost/computing/programming/Haskell/ http://meng6net.localhost/computing/programming/Haskell/ Haskell computing note programming Sat, 13 Oct 2018 03:56:52 +0000 2018-10-13T03:56:52Z <h2>Misc</h2> <ul> <li>http://tryhaskell.org</li> </ul> <h2>Softwares</h2> <h3>IDE's</h3> <ul> <li>http://code.world/haskell, an online IDE to write and run Haskell code, e.g. https://code.world/haskell#Ptxn0dmOwm9z1xqIGrwPfzQ.</li> </ul> Installing and configuring Homebrew http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_Homebrew/ http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_Homebrew/ Homebrew computing configuration installation macOS note software to-do Sun, 02 Jul 2017 02:09:51 +0000 2017-07-02T02:09:51Z <h2>Topics</h2> <h2>How to upgrade if Homebrew stuck at an old version?</h2> <pre> <code>$ "$(brew --repo)" &amp;&amp; git fetch &amp;&amp; git reset --hard origin/master &amp;&amp; brew update </code></pre>