Skip to content

Commit

Permalink
Update files
Browse files Browse the repository at this point in the history
  • Loading branch information
lifesinger committed Feb 4, 2013
1 parent 3ac87b3 commit 6ef53a8
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 4 deletions.
8 changes: 5 additions & 3 deletions config/dev.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
// @author lifesinger@gmail.com
// @source http://lifesinger.github.com/config/dev.user.js
// @match file://localhost/Users/lifesinger/Sites/*
// @version 1.0.1
// @version 1.0.2
// ==/UserScript==

(function() {
var href = location.href

location.href = location.href.replace('file://localhost/Users/lifesinger/Sites/', 'http://localhost/~lifesinger/')

if (href.indexOf('?file') === -1) {
location.href = href.replace('file://localhost/Users/lifesinger/Sites/', 'http://localhost/~lifesinger/')
}
})()
3 changes: 2 additions & 1 deletion config/nogfw.pac
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ var rules = [
///(\w+\.){1,2}github\.com/,
//'seajs.org',

'mail.google.com',
'google.com',
// 'github.com',
'dropbox.com',

'youtube',
Expand Down
76 changes: 76 additions & 0 deletions lab/2013/unique/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>unique</title>
</head>
<body>
<script>

function unique1(arr) {
var ret = []

for (var i = 0; i < arr.length; i++) {
var item = arr[i]
if (ret.indexOf(item) === -1) {
ret.push(item)
}
}

return ret
}


var indexOf = [].indexOf ?
function(arr, item) {
return arr.indexOf(item)
} :
function indexOf(arr, item) {
for (var i = 0; i < arr.length; i++) {
if (arr[i] === item) {
return i
}
}
return -1
}

function unique2(arr) {
var ret = []

for (var i = 0; i < arr.length; i++) {
var item = arr[i]
if (indexOf(ret, item) === -1) {
ret.push(item)
}
}

return ret
}


function unique3(arr) {
var ret = []
var hash = {}

for (var i = 0; i < arr.length; i++) {
var item = arr[i]
var key = typeof(item) + item
if (hash[key] !== 1) {
ret.push(item)
hash[key] = 1
}
}

return ret
}


var arr = ['a', 'b', 'c', '1', 0, 'c', 1, '', 1, 0, new Number(2), new String(2), 2, '2']

console.log(unique1(arr))
console.log(unique2(arr))
console.log(unique3(arr))

</script>
</body>
</html>

0 comments on commit 6ef53a8

Please sign in to comment.