View gists in a more grace page.
visit http://g.zhiye.li/:gistid
to view the gist, eg
// for below gitst
https://gist.github.com/zhiyelee/9403314
var animal = { eats: true } | |
var rabbit = { jumps: true } | |
rabbit.__proto__ = animal // inherit | |
console.log(rabbit.eats) // true | |
var animal = { eats: true } | |
rabbit = Object.create(animal); |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="instanceof cross iframe" /> | |
<meta charset="utf-8"> | |
<title>instanceof cross iframe</title> | |
</head> | |
<body> | |
<iframe id="fr" ></iframe> | |
// http://codeforces.com/contest/236/problem/A | |
function judge(str) { | |
var arr = str.split(''); | |
var obj = {}; | |
var len = 0; | |
for (var i = 0; i < arr.length; i++) { | |
if (!obj[arr[i]]) { | |
obj[arr[i]] = 1; | |
len ++; |
Introduction to the YUI Test
When is it appropriate to use CRC for error detection versus more modern hashing functions such as MD5 or SHA1? Is the former easier to implement on embedded hardware?
http://stackoverflow.com/questions/996843/when-is-crc-more-appropriate-to-use-than-md5-sha1
by @defines http://stackoverflow.com/a/996873/775783
CRC works fine for detecting random errors in data that might occur, for example, from network interference, line noise, distortion, etc.
CRC is computationally much less complex than MD5 or SHA1. Using a hash function like MD5 is probably overkill for random error detection. However, using CRC for any kind of security check would be much less secure than a more complex hashing function such as MD5.
Original link in stackoverflow: http://unix.stackexchange.com/q/73989/87921
I've noticed that man pages and other documents formatted by Unix utilities often use double backticks ``
followed by double single quotes ''
to wrap quoted phrases instead of the double quote character "
. Single quotes are similarly replaced. Why is this?
Here are a couple examples, from the man page for grep
:
To find all occurrences of the pattern `.Pp' at the beginning of a line:
$ grep '^\.Pp' myfile
Cycles are handled using the property of node's module system that it walks up the directories looking for node_modules
folders. So, at every stage, if a package is already installed in an ancestor node_modules
folder, then it is not installed at the current location.
Consider the case above, where foo -> bar -> baz
. Imagine if, in addition to that, baz depended on bar, so you'd have: foo -> bar -> baz -> bar -> baz ...
. However, since the folder structure is: foo/node_modules/bar/node_modules/baz
, there's no need to put another copy of bar into .../baz/node_modules
, since when it calls require("bar"), it will get the copy that is installed in foo/node_modules/bar
.
This shortcut is only used if the exact same version would be installed in multiple nested node_modules
folders. It is still possible to have a/node_modules/b/node_modules/a
if the two "a" packages are different versions. However, without repeating the exact same package multiple times, an infinite regress will always be pr
# Hello, and welcome to makefile basics. | |
# | |
# You will learn why `make` is so great, and why, despite its "weird" syntax, | |
# it is actually a highly expressive, efficient, and powerful way to build | |
# programs. | |
# | |
# Once you're done here, go to | |
# http://www.gnu.org/software/make/manual/make.html | |
# to learn SOOOO much more. |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a she ll session *as a function* | |
GEM_PATH=$GEM_PATH:/usr/local/rvm/gems/ruby-1.9.2-p290 | |
PATH=$PATH:/usr/local/rvm/gems/ruby-1.9.2-p290/bin | |
GIT_WORK_TREE=$HOME/octopress/ git checkout -f | |
cd $HOME/octopress/ | |
bundle install | |
bundle exec rake generate |