help
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:I'll just leave this here in case it helps somebody some day
Help
====

I'll just leave this here in case it might help somebody else some day.  Some of these items
are copied from my old development blog I started on the **Radiant Mercury** programme at
Lockheed Martin.

Workaround for lack of SFTP support in Sea Monkey Composer:
-----------------------------------------------------------

If your web server host allows only SFTP (a good idea for security), you'll find that Composer
doesn't support SFTP.  For reasons of tool familiarity and process, I did not want to impose a
change of HTML editor on the maintainer of a certain web site, so I came up with the following
workaround for users who prefer to use the Composer HTML editor and didn't want to learn a new one:

1. Start a local FTP server on the user's machine.  In this case it was Mac OS X 10.5; setting up
an FTP server was as simple as turning on File Sharing in the Sharing section of System
Preferences, checking the firewall settings to make sure the FTP server was visible only to the
local machine, and editing `/etc/ftpchroot` to contain a single asterisk character for
security.

2. Create a directory in the user's home directory called `~/proxy_for_website/`

3. Inside that directory, mimic the directory structure that exists already at the web hosting
company, e.g., `~/public_html` and `~/secure_html` and all sub-directories that might exist
below them.

4. Inside Sea Monkey Composer, change the *Publish As...* settings as follows:

 - Publishing address: `ftp//name_of_user's_machine.local/proxy_for_website/public_html/`

 - User name: the user's username on the local machine.

 - Password: the user's password on the local machine.

5. Now set up an SSH public key pair on the user's local machine and on the web hosting company's
server in the usual way so that SSH can be done without a password (hint: use `ssh-agent` to do
it securely).  This will ensure that `rsync` can run automatically.

6. Set up a cron job on the user's machine to run the following script once every minute:

That's it.

	#!/bin/sh

	#
	# This script watches for any change in the $target directory, and if it
	# sees a change, copies whatever changed to the user's public_html directory
	# at Hurricane Electric.  Run this script once a minute from crontab.

	start_time=`date +%s`

	old_detectfile=/Users/username/detect_mozilla_upload_content.new

	new_detectfile=/Users/username/detect_mozilla_upload_content.old

	reportfile=/Users/username/detect_mozilla_upload_report

	target=/Users/username/proxy_for_website/public_html/

	rm -f $reportfile; touch $reportfile

	cd $target
	find . -type f -ls > $new_detectfile
	diff -q $new_detectfile $old_detectfile

	RC=$?
	if [ $RC -eq 0 ]; then
			echo "nothing to do at `date`" >> $reportfile
	else
			echo "\nchange in the proxy directory detected (diff rc was $RC) ; running rsync now\n" \
				>> $reportfile

			rsync -avz . username@he.net:public_html >> $reportfile
			RC=$?
			echo "\nRC from rsync was $RC" >> $reportfile

			mv $new_detectfile $old_detectfile

			end_time=`date +%s`
			elapsed_time=$(($end_time - $start_time))

			echo "\nElapsed time $elapsed_time seconds." >> $reportfile
	fi

As a bonus, your user will be pleased to discover that publishing in Composer is almost
instantaneous now.

Always specify the encoding!
----------------------------

Always specify the encoding!  When writing HTML (especially auto-generated HTML) you should
always include the Unicode encoding information in your header, like this:

	
	   
		  
		  
			 ...
		  <title>
	   </head>
	</html>

The `<meta>` tag containing `"Content-Type"` information must be the very first element
in the `<head>` block, because that's where HTML-aware applications go looking for it.

If you don't do this in your HTML, someday it will come back and bite you.

Piping and redirecting `stderr` in `csh`
----------------------------------------

To pipe `stderr` along with `stdout`, do:

	% cmd1 |& cmd2

To redirect `stderr` by itself to file `f1` and `stdout` to file `f2`, do:

	% (cmd > f1) >& f2,

Source: Daniel Gilley. *UNIX in a Nutshell* second edition.  Sebastopol, California:
O'Reilly & Associates, 1994.

Concatenating PDF files
-----------------------

If you have Ghostscript installed, do this:

	% set path=d:\work_in_progress\tools\gs\gs7.04\lib;d:\work_in_\
	progress\tools\gs\gs7.04\bin;%PATH%
	% gswin32.exe -sPAPERSIZE=letter -dNOPAUSE -dBATCH \
	-sDEVICE=pdfwrite -sOutputFile=result.pdf file1.pdf [file2.pdf...]

Useful UNIX commands
--------------------

`pfiles` *pid* will give a list of file descriptors currently open by process ID *pid*.

Choose the file descriptor you want and look for the `ino:` *nnnnn* field.  That is the
inode of the file.  To get the name of the file, do `% find . -inum` *nnnnn*, or
`% ls -i | grep` *nnnnn* `/usr/proc/bin/pfiles`

GitHub error `Commit failed: Failed to create a new commit.`
------------------------------------------------------------

This error from GitHub for Windows is caused by low disk space on the local volume containing the
repository.  Less than 4.9 gigabytes free: the error occurs.  Freeing up some space makes the
problem go away.

Searching and replacing hex characters in `vi` (not vim)
--------------------------------------------------------

    `:g/\%x94/s//"/g

How to set metadata in PDF files made by LaTeX
----------------------------------------------

    % Tell Adobe Acrobat Reader not to display the bookmarks pane.
    \hypersetup{pdfpagemode=UseNone}

    % Tell it to start in my preferred size and skip front matter.
    \hypersetup{pdfstartview=FitH}
    \hypersetup{pdfstartpage=12}

    % Fill in some other information in the PDF header.
    \hypersetup{pdftitle=Security Test and Evaluation of Cross Domain Systems}
    \hypersetup{pdfauthor=Joe Loughry}
    \hypersetup{pdfsubject=computer security}
    \hypersetup{pdfkeywords={doctoral thesis}}

How to use up space on a Mac OS X disk volume for testing
---------------------------------------------------------

Use `mkfile`

    % mkfile -nv 20g 20gig_file

It's not fast, though. The available disk space goes down immediately, but the command hangs for a
long time writing zeros to the file. Stackoverflow suggests a faster method using `dd` and `seek`:

    % dd if=/dev/zero of=filename bs=1 count=0 seek=200G

The `dd` method is no faster, though, and it's harder to interrupt with Ctrl-C.

Workaround for lost `.virtualmail` wildcard functionality
---------------------------------------------------------

[Hurricane Electric](http://www.he.net/), a *great* web hosting and co-location company, recently
started disabling `.virtualmail` wildcarding functionality, which I depended on for *ad hoc* email
addresses. The workaround is simple, because they allow me to create new mailboxes, and set
forwarding on them. Forwarding can even be done to accounts on other systems, although doing that
is discouraged because it attracts spammers.

I created a bunch of new mailboxes that forward to my real mailbox:

    - mailto:joe.loughry@applied-math.org forwards to mailto:joe@applied-math.org
    - mailto:rjl@applied-math.org forwards to mailto:joe@applied-math.org
    - mailto:joe@applied-math.org forwards to mailto:joe@applied-math.org
    - mailto:loughry@applied-math.org forwards to mailto:joe@applied-math.org

Messages sent to any of these addresses show up in one place, and their 'From:' address is
preserved so I can tell where it came from and notify the sender that they need to update their
address books.

How to display UNIX boot time messages in Mac OS X
--------------------------------------------------

To see more information in Mac OS X, `sudo nvram boot-args="-v"` in Terminal.

How to get `rsync(1)` to report only the files it changed
---------------------------------------------------------

    rsync -cir local_directory/ user@remote_host:remote_directory/

The `-c` option tells it to compare checksums instead of date/time; `-i` itemises
the changes it makes, and `-r` recurses into sub-directories.

How to throttle traffic selectively in Mac OS X
-----------------------------------------------

Use `ipfw` to throttle a particular protocol, *e.g.*, a Bitcoin Core client
operating on 8333/TCP, like this:

````
#/bin/sh

ipfw_cmd=/sbin/ipfw

#
# This function checks to see if the script is running with root privs.
#

function are_we_running_as_root_interrogative
{
    if [[ $EUID -ne 0 ]]; then
        echo "Run this script as:"
        echo "    $ sudo ./$0"
        exit 1
    else
        echo "The script is running as root."
    fi
}

are_we_running_as_root_interrogative
$ipfw_cmd -f flush

# Throttle only connections made outgoing by Bitcoin Core.

$ipfw_cmd pipe 1 config bw 200Kbit/s
$ipfw_cmd add 50 pipe 1 dst-port 8333

$ipfw_cmd pipe 1 show
````

How to get the PID of a running process *reliably*
--------------------------------------------------

To get the process ID of a running process in Bash, it is necessary to
pre-process the output from `ps` before parsing it with `cut`, like this:

````
/bin/echo -n "Starting Tor..."

tor --quiet -f $torrcLoc &

pid=`ps ax | grep "[t]or --quiet -f" | tr -s " " | cut -d ' ' -f 2`

if [[ $pid -ne 0 ]]; then
    echo "the process was started with PID $pid."
else
    echo "a problem occurred."
fi
````

</pre>  <br />
		
		
		</div>
		<!-- detail content end -->

		<div class="ad_footer">
			
				<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 728x90, 创建于 11-8-29 -->
<ins class="adsbygoogle"
     style="display:inline-block;width:728px;height:90px"
     data-ad-client="ca-pub-9609188192387119"
     data-ad-slot="4736870470"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
				
			
		</div>


		<!-- file list begin -->
		<div class="detail_file">
			<div class="menu1_left">
				<div class="menu1_right">
					<div class="menu1_txt">部分文件列表(点击文件名可查看文件内容)</div>
			  </div>
			</div>
			
			<div id="file_content">
					<!--div class="ad_footer">
					</div-->

									本源码包内暂不包含可直接显示的源代码文件,请下载源码包。
							</div>
		</div>
		<div class="clear"></div>
		<!-- file list end -->

			</div>
	<!-- content_right end -->
	<div class="clear"></div>
</div>
<!-- content end -->
	
<!-- footer begin -->
<div id="footer">
  <div id="footer_content">
    <div id="contact">联系我们:verysource_com<img src="/images/character/m_a_i_l.gif" width="51" height="12" align="absmiddle" /></div>
    <div id="copy_right">CopyRight © 2008-2022 verySource.Com All Rights reserved. <a target="_blank" rel="nofollow" href="https://beian.miit.gov.cn/" style="color:#66FFFF; font-size:14px;">京ICP备17048824号-1</a> 京公网安备:11010502034788</div>
  </div>
</div>
<div style="display:none;">
	
	<script>
	var _hmt = _hmt || [];
	(function() {
	  var hm = document.createElement("script");
	  hm.src = "https://hm.baidu.com/hm.js?9c89b037e07a1dbd53937515a5761041";
	  var s = document.getElementsByTagName("script")[0]; 
	  s.parentNode.insertBefore(hm, s);
	})();
	</script>
	
</div>
<!-- footer end -->
</body>
</html>