Other 小数到基数36 /基数36到十进制

DIGITS = ('0'..'9').to_a + ('A'..'Z').to_a

def to_base36_from_l(num)
	result = ""
	while num != 0
		tmp = num / DIGITS.length
		remainder = num - tmp * DIGITS.length
		char = DIGITS[remainder]
		num = tmp
		result = char + result
	end
	result
end

def to_l_from_base36(str)
	answer = 0
	str.reverse.split("").each_with_index { |c, i|
		answer += (DIGITS.index(c) * (DIGITS.length ** i))
	}
	answer
end

# sample usage

num = 1451252361345125

base36 = to_base36_from_l(num)
puts "#{base36} from #{to_l_from_base36(base36)}"

# output: EAFC4PPW85 from 1451252361345125

Other 使用AMR / 3GP进行ffmpeg编译(用于flash视频编码)

./configure --enable-mp3lame --enable-amr_nb --enable-amr_nb-fixed --enable-amr_wb --enable-a52 --enable-gpl --extra-cflags=-I/usr/local/include/ --extra-ldflags=-L/usr/local/lib/

Other 在Ubuntu中从命令行设置静态IP

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# This is a list of hotpluggable network interfaces.
# They will be activated automatically by the hotplug subsystem.
mapping hotplug
        script grep
        map eth0

# The primary network interface
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1

Other 跨平台安全密码存储

A quicker method that also works cross-platform is to use OpenSSL (which macos includes).

To encypt a list of secrets with the 256-bit AES, open the terminal and do:

openssl enc -aes256 -salt -a -e -out secrets.aes

You'll then be prompted twice for a password, after which you can begin typing whatever you want. When you've typed enough, hit control-d twice and the data will be encrypted and placed in a filed named "secrets.aes".

To decrypt the file created above, do:

openssl enc -aes256 -a -d -in secrets.aes 

Enter the password when asked and openssl will decrypt the file and print it in the terminal. Because openssl works the same under macos, bsd, linux, and (cygwin) Windows, files created like this can be used on any platform.

A slight variation can be used to encrypt/decrypt files (rather than typed input):

openssl enc -aes256 -salt -a -e -in myfile -out myfile.aes
openssl enc -aes256 -salt -a -d -in myfile.aes -out myfile

There are also other cyphers available, type "openssl enc help" for a list.

Other 下载

<?php
	if(isset($_GET["file"]) && $_GET["file"] != "") {
		if(file_exists($_GET["file"])) {
			header("Content-type: application/x-download");
			header("Content-Length: ".filesize($file)); 
			header('Content-Disposition: attachment; filename="'.basename($_GET["file"]).'"');
			readfile($_GET["file"]); 
			exit();
		} else {
			exit("File not found");
		}
		
	} else { exit(); }
?>

Other Cygwin rxvt快捷命令

C:\cygwin\bin\rxvt.exe -g 120x40 -sl 1000  -fn Consolas -fg White -bg Black -e bash --login -i

Other 了minHeight

.foo {
min-height: 500px;
height: auto !important;
height: 500px;
}

Other 覆盖

#overlay {
     visibility: hidden;
     position: absolute;
     left: 0px;
     top: 0px;
     text-align:center;
     z-index: 1000;
     background-image:url(/images/overlay.gif);
}

#overlay div {
     width:300px;
     margin: 100px auto;
     background-color: #fff;
     border:1px solid #000;
     padding:15px;
     text-align:center;
}

function toggleDisplay(DomObject) {

    if (DomObject.style.visibility) {
    	DomObject.style.visibility = (DomObject.style.visibility == 'visible') ? 'hidden' : 'visible';
    }
    else {
    	DomObject.style.display = (DomObject.style.display == 'block') ? 'none' : 'block';
    }
}

function overlay() {
	var DomObject = document.getElementById('overlay');
        setOverlayDim(DomObject);
	toggleDisplay(DomObject);
	
	setTimeout('toggleDisplay(\'overlay\')',5000);
}

//set the height and width dimensions for the fullscreen overlay layer
function setOverlayDim(DomObject) {
    var x;
    var y;

    // all except Explorer
    if (self.innerHeight) {
    	x = self.innerWidth;
    	y = self.innerHeight;
    }
    // Explorer 6 Strict Mode
    else if (document.documentElement && document.documentElement.clientHeight) {
    	x = document.documentElement.clientWidth;
    	y = document.documentElement.clientHeight;
    }
    // other Explorers
    else if (document.body) {
    	x = document.body.clientWidth;
    	y = document.body.clientHeight;
    }
    
    DomObject.style.width = x.toString() + 'px';
    DomObject.style.height = y.toString() + 'px';
}

   
    <div id="overlay" style="visibility:hidden;">
         <div id="overlayContent">

              <a href="#" onclick="overlay();" style="color:#000;">Close</a>

         </div>
    </div>

<input type="button" value="" onclick="overlay();" />

Other 粘性页脚

/* 
STICKER - A valid, easy to use CSS sticky footer by Ryan Fait
This is the basic CSS you need along with the one extra empty
div and the wrapper required to achieve the effect. I suggest
that you leave the * { margin: 0; } code in while testing and
building your site because margins do have a tendency to mess
things up a bit. Have fun!
Copyright (c) 2006-2007 Ryan Fait
*/

* {
margin: 0;
}
html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -4em; /* the bottom margin is the negative value of the footer's height */
}
.footer, .push {
height: 4em; /* .push must be the same height as .footer */
}

Other XHTML1.0 Stric模板

<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
		<meta name="keywords" content="" />
		<meta name="description" content="" />
		<title>Title Here</title>
		
		<!-- CSS Links -->
		<link rel="stylesheet" href="basic.css" type="text/css" media="screen" />
		<link rel="alternate stylesheet" type="text/css" href="alternative.css" title="alternative" />
		
		<!-- Scripts Here -->
		<script src="../js/script1.js" type="text/javascript"></script>
		<script src="../js/script2.js" type="text/javascript"></script>

	</head>

<body>

</body>
</html>