Skip to content

Instantly share code, notes, and snippets.

View Partoo's full-sized avatar
💭
I may be slow to respond.

Partoo Partoo

💭
I may be slow to respond.
View GitHub Profile
The regex patterns in this gist are intended only to match web URLs -- http,
https, and naked domains like "example.com". For a pattern that attempts to
match all URLs, regardless of protocol, see: https://gist.github.com/gruber/249502
# Single-line version:
(?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|s
@Partoo
Partoo / jquery.pnotify.js
Created September 11, 2013 01:15
Use <i/>tag instead of <span>in title,so can use "text-align:center" in css file.
/*
* jQuery Pines Notify (pnotify) Plugin 1.2.2
*
* http://pinesframework.org/pnotify/
* Copyright (c) 2009-2012 Hunter Perrin
*
* Triple license under the GPL, LGPL, and MPL:
* http://www.gnu.org/licenses/gpl.html
* http://www.gnu.org/licenses/lgpl.html
* http://www.mozilla.org/MPL/MPL-1.1.html
{
// Your GitHub API token
// see: https://github.com/condemil/Gist#generating-access-token
"token": "a92f9d7fa458dead2d0a54f7d6556151e4b1eeb0",
// Show GitHub organizations
// Example: "company1", "company2"
"include_orgs": [],
// Show GitHub users
@Partoo
Partoo / general.js
Created June 30, 2013 03:40
Some common code.
//Highlight current category
$(function () {
var url = window.location.pathname,
re = /^\/\w*/;
urlRegExp=url.match(re);
urlRe = new RegExp(url.replace( /^\/\w*/));
$('ul.mainNav>li >a').each(function(){
if ($(this).attr('href').match(re).toString()==url.match(re).toString()) {
$(this).parent("li").addClass('current');
}
function BrowseServer( startupPath, functionData )
{
// You can use the "CKFinder" class to render CKFinder in a page:
var finder = new CKFinder();
// The path for the installation of CKFinder (default = "/ckfinder/").
finder.basePath = '/manage/libarary/editor/ckfinder';
//Startup path in a form: "Type:/path/to/directory/"
finder.startupPath = startupPath;
@Partoo
Partoo / image.js
Created April 18, 2013 14:42
ckeditor plugin image.js
/**
* @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.html or http://ckeditor.com/license
*/
(function() {
var imageDialog = function( editor, dialogType ) {
// Load image preview.
var IMAGE = 1,
LINK = 2,
@Partoo
Partoo / GuessGame
Last active December 15, 2015 11:28
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package guess;
import java.util.Random;
import java.util.Scanner;
/**
/*obj 概率对象数组;
luck 概率数组,即obj数组元素意义对应;
对于给定的概率对象,该函数运行相当于:
var a = ['一等奖:宝马X6', '二等奖:苹果三件套', '三等奖:威戈背包', '继续努力!'];
var b = [1, 10, 100, 500];
goodluck(a, b) {
var random = (1 + 10 + 100 + 500) * Math.random();
random <= 500 || return a[3];
random <= 600 || return a[2];