Skip to content

Instantly share code, notes, and snippets.

@homleen
homleen / wdj_top.py
Created December 2, 2013 10:43
豌豆荚 TOP 排行
# encoding=utf8
import urllib2
from bs4 import BeautifulSoup
url = 'http://www.wandoujia.com/top'
opener = urllib2.build_opener()
content = opener.open(url).read()
@homleen
homleen / solr.xml
Last active December 25, 2015 08:39
Install Solr
<Context docBase="/usr/share/tomcat6/webapps/solr.war" debug="0" crossContext="true" >
<Environment name="solr/home" type="java.lang.String" value="/root/solr" override="true" />
</Context>
@homleen
homleen / init.js
Created September 25, 2013 10:51
underscore init
'use strict';
var _ = function(obj) {
console.log('heading');
if (obj instanceof _) return obj;
console.log('body');
if (!(this instanceof _)) return new _(obj);
@homleen
homleen / 500px.user.js
Created September 25, 2013 08:48
Show 500px photo url.
// ==UserScript==
// @match http://500px.com/photo/*
// ==/Userscript==
'use strict';
(function(){
var imgPlaceHolder = document.querySelector('.nude_placeholder');
var imgUrl = imgPlaceHolder.nextSibling.src;
@homleen
homleen / code-01.js
Last active December 21, 2015 02:59
有趣的淘宝校招题
var url = 'http://ued.campus.alibaba.com/quiz3/index.php?t=OTEyNzQ1MjRMY3ZEdktWd1ZSRGxZQlZWUUFVazhH';
var msg = [];
var start = 10;
function get(room) {
$.get(url + '&room=' + room, function(response){
var t = null;
msg.push($(response).find('#message').html());
t = $(response).find('#next-room').html();
@homleen
homleen / datesBetween.php
Created August 12, 2013 09:01
Get dates between two dates.
<?php
function datesBetween($start, $end, $format = 'Ymd')
{
$output = array();
$startDate = date($format, strtotime($start));
$endDate = date($format, strtotime($end));
$output[] = $startDate;
@homleen
homleen / variable.js
Created August 11, 2013 09:45
vals in for block.
var list = ['test', 'for', 'var', 'in', 'for', 'block'];
for(var i = 0, l = list.length; i < l; i++) {
var forBlockVal = i;
}
console.log(i);
console.log(forBlockVal);
@homleen
homleen / gen-array.js
Last active December 20, 2015 19:19
生成2013年所有的日期,并随即生成一个对应的值
'use strict';
var start = new Date(2013, 0, 1);
var end = new Date(2014, 0, 1);
var data = [];
while (start < end) {
data.push( [start.getTime() / 1000, Math.floor( Math.random() * 6) ] );
start = new Date(start.setDate(
@homleen
homleen / download.php
Created August 8, 2013 03:50
PHP下载文件名乱码不完全解决方案。
<?php
$ua = $_SERVER['HTTP_USER_AGENT'];
$name = "+ 孙_燕-姿 &✺☞& 繁體字&2013.doc";
header('Content-Type: application/octet-stream');
if (preg_match("/MSIE/", $ua)) {
header('Content-Disposition: attachment; filename="' . rawurlencode($name) . '"');
@homleen
homleen / boilerplate.js
Last active December 20, 2015 17:48
jQuery Boilerplate
$(function(){
'use strict';
var App = {
init: function() {
this.cacheElements();
this.bindEvents();
},
cacheElements: function() {