Skip to content

Instantly share code, notes, and snippets.

View yangjunjun's full-sized avatar
🐱
Focusing

杨军军 yangjunjun

🐱
Focusing
  • undefined
  • Xian, Shaanxi, China
View GitHub Profile
@finscn
finscn / checkSequence
Last active August 29, 2015 13:57
检测 两组任意(不限个数 不限花色) 的扑克牌, 混到一起后能否构成任意长度(大于1 小于15)的顺子.A代表1或14,小王代表1--5,大王代表1--14
/*
检测 两组任意(不限个数 不限花色) 的扑克牌, 混到一起后能否构成任意长度(大于1 小于15)的顺子.
A可表示1或14,小王可表示1--5,大王可表示1--14
说明:
1 我微博里说 小王代表 1到9有误, 我这边实际遇到的场景是 小王代表 1--5 (当然 这个无所谓)
2 牌是可以有重复的 : 例如 可以 4个小王 9个大王 等等, 可以理解为是从无数副扑克牌当中随意抽取出两组
3 组成的顺子 可以不是5张 , 其实严格说 就是 等差为1的等差数列
4 能且只能组成一组顺子, 组成顺子后, 牌没有剩余
@paranoidxc
paranoidxc / V2EX.user.js
Last active December 14, 2015 09:28
固定 V2EX 的导航栏, 双击导航栏页面回到顶部,每日自动签到。
// ==UserScript==
// @author iParanoid
// @name V2EX_User_Script
// @namespace https://zone-huangxc.rhcloud.com
// @description Position fixed the navigation , Scroll to top when double click navigation bar or Page Footer
// @include *
// @updateURL https://gist.github.com/paranoidxc/5065236/raw/10bc3ee7501b86f2e579657ef64348e642cc2a70/V2EX.user.js
// ==/UserScript==
function iparanoid_wrapper() {
@missett
missett / JS Quicksort
Created October 24, 2013 11:47
Recursive Quicksort implementation in JS
function quicksort(input) {
if(input.length === 0) return input;
var head = input[0],
tail = input.slice(1);
var less = tail.filter(function(i) {
return i < head ? true : false;
});
@dofy
dofy / ve2x.date.user.js
Last active January 26, 2016 06:43
显示 v2ex 绝对时间
// ==UserScript==
// @name v2ex 绝对时间
// @namespace http://phpz.org/
// @version 0.1.5
// @description 显示 v2ex 中的绝对时间
// @author Seven Yu
// @match *.v2ex.com/*
// @run-at document-end
// @grant none
// @updateURL https://gist.github.com/dofy/38c8d67405a5597f4e7e/raw
@wintercn
wintercn / showboxes.js
Created May 21, 2013 06:34
显示页面的盒结构
function randomColor(){
return "rgb("+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+")";
}
function showBoxes(window) {
var rects = [];
function getRects(node){
var range = window.document.createRange();
range.setStartBefore(node);
range.setEndAfter(node);
@feross
feross / gist:1936676
Created February 29, 2012 01:00
memoizer.js
var count = 0;
var memoizer = function(memo, formula) {
var recur = function(n) {
var result = memo[n];
if (typeof result !== "number") {
result = formula(n);
memo[n] = result;
}
return result;
@dexteryy
dexteryy / standards_for_webapps_on_mobile.md
Last active August 17, 2017 02:16
W3C Standards for Web Apps on Mobile (After HTML5)
@wintercn
wintercn / HTMLLexicalParser.js
Last active August 5, 2019 11:16
HTML语法分析器模型
function StartTagToken(){
}
function EndTagToken(){
}
function Attribute(){
}
@addyosmani
addyosmani / memoize.js
Created September 18, 2011 16:33
memoize.js - a faster JavaScript memoizer
/*
* memoize.js
* by @philogb and @addyosmani
* further optimizations by @mathias
* Released under an MIT license.
*/
function memoize( fn ) {
return function () {
var args = Array.prototype.slice.call(arguments),
hash = "",
@cbrammer
cbrammer / installer.js
Created October 19, 2012 22:42
NPM Sucks
var npm = require('npm')
, pack = require('./package.json')
, modules = {}
;
if(pack.dependencies) build(pack.dependencies);
if(pack.optionalDependencies) build(pack.optionalDependencies);
if(pack.devDependencies) build(pack.devDependencies);
function build(dependancies) {