This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function string2int(s) { | |
| return s.split('').map(function(c){ | |
| return c-'0' | |
| }).reduce(function(x,y){ | |
| return x*10+y; | |
| }) | |
| } | |
| // 测试: | |
| if (string2int('0') === 0 && string2int('12345') === 12345 && string2int('12300') === 12300) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict' | |
| function normalize(arr){ | |
| function CapStr(s){ | |
| var lc_s=s.split('').map(function(x){ | |
| return x.toLowerCase() | |
| }).reduce(function(x,y){ | |
| return x.concat(y) | |
| }) | |
| return lc_s.charAt(0).toUpperCase()+lc_s.slice(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict' | |
| function getPrimes(arr){ | |
| return arr.filter(function(x){ | |
| if(x<2) { | |
| return false | |
| } | |
| for(var i=2;i<=parseInt(x/2);i++){ | |
| if(x%i==0) return false; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict' | |
| function* next_ID(){ | |
| var current_id=0 | |
| var max=1000 | |
| while(current_id<max){ | |
| current_id++; | |
| yield current_id; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 作者:张洞之 | |
| 链接:https://www.zhihu.com/question/28277116/answer/40230530 | |
| 来源:知乎 | |
| 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 | |
| /* | |
| _ooOoo_ | |
| o8888888o | |
| 88" . "88 | |
| (| -_- |) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <project name="ipnet" default="deleteWar" basedir="."> | |
| <property name="build" value="${basedir}/build" /> | |
| <property name="build.class" value="${build}/classes"/> | |
| <property name="src" value="${basedir}/src" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| #coding=utf-8 | |
| #导入模块,urllib2是一个模拟浏览器HTTP方法的模块 | |
| import json | |
| import urllib2 | |
| import sys | |
| from urllib2 import Request, urlopen, URLError, HTTPError | |
| #url and url header |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import datetime | |
| import hashlib | |
| import MySQLdb | |
| conn = MySQLdb.connect (host = "localhost", user = "root", passwd = '',db = "spider",charset = 'utf8') | |
| cursor = conn.cursor () | |
| #INSERTION/UPDATE Statements | |
| sql="insert ignore into url_queue select * from something" | |
| cursor.execute(sql) | |
| conn.commit() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # versao.py – captura e mostra a versão do MySQL database server. | |
| # importe os modulos do MySQLdb e sys | |
| import MySQLdb | |
| import sys | |
| # Abra uma conexão com o banco de dados | |
| # Tenha certeza de ter trocado o IP, usuario, senha e database para os seus. | |
| connection = MySQLdb.connect (host = “192.168.1.1″, user = “username”, passwd = “password”, db = “database_name”) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " ------------------------------ | |
| " Name: vimrc for windows | |
| " Author: keelii | |
| " Email: [email protected] | |
| " ------------------------------ | |
| " Startup {{{ | |
| filetype indent plugin on | |
| augroup vimrcEx |
OlderNewer