Skip to content

Instantly share code, notes, and snippets.

@nealnote
nealnote / multiofflinetask.js
Last active September 2, 2017 06:10
multi offline task add for pan.baidu.com
/**
* multi offline task add for pan.baidu.com
* 执行代码前必须 点一下 **离线下载** 按钮
**/
(function () {
var R = require('function-widget-1:offlineDownload/util/newOfflineDialog.js');
var r = R.obtain();
var timer = 600;
var add = function (url) {
r.setVisible(1);
@nealnote
nealnote / mobile.base.styl
Created March 2, 2015 10:30
mobile.base.styl
/**
* base
*/
/**
* @vendor http://learnboost.github.io/stylus/docs/interpolation.html
*/
vendor(prop, args)
-webkit-{prop} args
-moz-{prop} args
{prop} args
@nealnote
nealnote / parseURL.js
Created December 25, 2014 09:24
parseURL.js
// http://james.padolsey.com/javascript/parsing-urls-with-the-dom/
// This function creates a new anchor element and uses location
// properties (inherent) to get the desired URL data. Some String
// operations are used (to normalize results across browsers).
function parseURL(url) {
var a = document.createElement('a');
a.href = url;
return {
source: url,
#!/usr/bin/python
# -*- encoding: utf-8 -*-
import os
import hashlib
import logging
_hashes = {}
def get_absolute_path(root, path):
@nealnote
nealnote / osxsetup.txt
Last active August 29, 2015 14:06
osx set up
#setting
# Enable full keyboard access for all controls
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# Disable menu bar transparency
defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false
# Allow quitting Finder via ⌘ + Q; doing so will also hide desktop icons
defaults write com.apple.finder QuitMenuItem -bool true
@nealnote
nealnote / guid.js
Created August 5, 2014 06:36
guid.js
//https://github.com/jeromegn/Backbone.localStorage/blob/master/backbone.localStorage.js#L27
// Generate four random hex digits.
function S4() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
};
// Generate a pseudo-GUID by concatenating random hexadecimal.
function guid() {
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
};
@nealnote
nealnote / requestAnimationFrame.html
Created August 1, 2014 03:36
requestAnimationFrame.html
<!DOCTYPE HTML>
<html>
<head>
<meta charset='utf-8'>
<title> requestAnimationFrame </title>
<style type="text/css">
.mover {
position: absolute;
height: 100px;
width: 100px;
@nealnote
nealnote / requestAnimationFrame.js
Created July 29, 2014 01:06
requestAnimationFrame.js
//https://github.com/gabrielecirulli/2048/blob/master/js/animframe_polyfill.js
(function () {
var lastTime = 0;
var vendors = ['webkit', 'moz'];
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] ||
window[vendors[x] + 'CancelRequestAnimationFrame'];
}
var quickSort = function(arr){
if ( arr.length <= 1 ) {
return arr;
}
var sampleIndex = Math.floor(arr.length/2),
sample = arr.splice(sampleIndex, 1)[0],
left = [],
right = [];
for (var i = 0; i < arr.length ; i++){
if ( arr[i] < sample ) {
@nealnote
nealnote / css-reset-box-sizing
Created July 21, 2014 06:49
css-reset-box-sizing
/**
* http://blog.teamtreehouse.com/box-sizing-secret-simple-css-layouts#comment-50223
*/
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}