Skip to content

Instantly share code, notes, and snippets.

@liunian
liunian / gist:1875119
Created February 21, 2012 08:25
use curl to get headers if get_headers is unable to use
<?php
/**
* Script to check link validity
*
* @author Satya Prakash
*
*/
$links = array();
$links[] = 'http://www.satya-weblog.com/2007/04/dynamically-populate-select-list-by.html';
@liunian
liunian / gist:1885866
Created February 22, 2012 16:24
expand t.co to realLink in twitter page when click
$('#stream-items-id').delegate('.js-tweet-text a[data-expanded-url]', 'click', function(e){
this.href = $(this).attr('data-expanded-url');
});
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import re
def filter(filePath):
f = open(filePath)
content = f.read()
#print content
@liunian
liunian / jquery.ui.intersect.js
Created November 1, 2012 02:31
calc two rectangle's position relation
$.ui.intersect = function(draggable, droppable, toleranceMode) {
if (!droppable.offset) return false;
var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
var l = droppable.offset.left, r = l + droppable.proportions.width,
t = droppable.offset.top, b = t + droppable.proportions.height;
switch (toleranceMode) {
@liunian
liunian / gist:4015978
Created November 5, 2012 08:16
detect whether the client is ie6 or not
function isIE6() {
return strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.0');
}
# ie6's UA example
# Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 6.1; QQDownload 731; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)3
@liunian
liunian / gist:4116655
Created November 20, 2012 07:57
chrome scrollbar style
/* from http://www.alloyteam.com/wp-content/themes/alloyteam/style.css */
::-webkit-scrollbar-track-piece {
background-color:#f5f5f5;
border-left:1px solid #d2d2d2;
}
::-webkit-scrollbar {
width:13px;
height:13px;
}
::-webkit-scrollbar-thumb {
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
@liunian
liunian / gist:5676234
Created May 30, 2013 07:24
jquery 和 underscore 式的构造器,有无 new 都会进行创建,传入已创建的对象会直接返回
var _ = function(obj) {
if (obj instanceof _) return obj;
if (!(this instanceof _)) return new _(obj);
this._wrapped = obj;
};
@liunian
liunian / gist:5910792
Created July 2, 2013 16:23
fix top and scroll bottom
// http://msdn.microsoft.com/zh-cn/library/ie/bg124132(v=vs.85).aspx
epx = window.epx || {}, epx.library = window.epx.library || {}, epx.library.tocFixedModule = function(w, d) {
function init() {
epx.topic && epx.topic.isPrintExperience() === !0 || ($leftNav = $("#leftNav"), $toc = $("#tocnav"), $footer = $("#ux-footer"), w && d && $leftNav.length !== 0 && $toc.length !== 0 && $footer.length !== 0) && ($(w).scroll(function() {
setPosition()
}), $(w).resize(function() {
setPosition()
}))
}
@liunian
liunian / gist:5926438
Last active April 26, 2024 03:32
javascript sort
/*
list: the array
fn: sort fn
start: the start index of the sorted range, included
end: the end index of the sorted range, excluded
means range: [start, end)
modify the array itself and return nothing
*/