Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
I may be slow to fuck.

hustcc hustcc

:octocat:
I may be slow to fuck.
View GitHub Profile
@hustcc
hustcc / jsdom-iframe-test.js
Created Jan 15, 2018 — forked from dijs/jsdom-iframe-test.js
Example of testing iframe messaging using jsdom
View jsdom-iframe-test.js
import { expect } from 'chai';
import jsdom from 'jsdom';
describe('JSDOM', () => {
it('should communicate with inner iframes', done => {
jsdom.env({
url: "http://bar.com/",
done (err, window) {
var frame = window.document.createElement('iframe');
window.document.body.appendChild(frame);
@hustcc
hustcc / ChangeToBig.js
Created Jan 19, 2017
金额大小写自动转换(代码来源于农行网银)
View ChangeToBig.js
// 金额大小写自动转换
function ChangeToBig(value) {
if (value == null || value == "") {
//return "错误金额";
return "";
}
value = "" + value;
var intFen, i;
View Text2Img.js
var canvas = document.getElementById('canv'),
ctx = canvas.getContext('2d'),
img = document.getElementById('image');
function grow(el) {
el.style.height = "10rem";
el.style.height = (el.scrollHeight)+"px";
}
var generate = function() {
View parseDate.js
parse = function(input) {
if (input instanceof Date) {
return input;
} else if (!isNaN(input)) {
return new Date(input);
} else if (/^\d+$/.test(input)) {
return new Date(parseInt(input, 10));
} else {
var s = (input || '').trim();
s = s.replace(/\.\d+/, ''); // remove milliseconds
@hustcc
hustcc / htmlEntities.js
Created May 11, 2016
javascript 转义
View htmlEntities.js
function htmlEntities(str) {
return String(str)
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
}
@hustcc
hustcc / file_input.css
Created May 11, 2016
重写 file 控件样式
View file_input.css
input[type="file"]{
-webkit-appearance: none;
text-align: left;
-webkit-rtl-ordering: left;
}
input[type="file"]::-webkit-file-upload-button{
-webkit-appearance: none;
float: right;
margin: 0 0 0 10px;
border: 1px solid #aaaaaa;
@hustcc
hustcc / emoji.md
Created May 11, 2016
emoji-preview
View emoji.md

Emoji表情

将对应emoji表情的符号码复制后输入你的markdown文本即可显示emoji表情。 如:blush:,显示为😊

人物

syntax preview syntax preview syntax preview
:bowtie: :bowtie: :smile: 😄 :laughing: 😆
@hustcc
hustcc / headless browsers.md
Created Apr 20, 2016 — forked from evandrix/README.md
Headless web browsers
View headless browsers.md

Here are a list of headless browsers that I know about:

  • [HtmlUnit][1] - Java. Custom browser engine. JavaScript support/DOM emulated. Open source.
  • [Ghost][2] - Python only. WebKit-based. Full JavaScript support. Open source.
  • [Twill][3] - Python/command line. Custom browser engine. No JavaScript. Open source.
  • [PhantomJS][4] - Command line/all platforms. WebKit-based. Full JavaScript support. Open source.
  • [Awesomium][5] - C++/.Net/all platforms. Chromium-based. Full JavaScript support. Commercial/free.
  • [SimpleBrowser][6] - .Net 4/C#. Custom browser engine. No JavaScript support. Open source.
  • [ZombieJS][7] - Node.js. Custom browser engine. JavaScript support/emulated DOM. Open source.
  • [EnvJS][8] - JavaScript via Java/Rhino. Custom browser engine. JavaScript support/emulated DOM. Open source.
View GradualColor.js
// 颜色#FF00FF格式转为Array(255,0,255)
function color2rgb(color) {
var r = parseInt(color.substr(1, 2), 16);
var g = parseInt(color.substr(3, 2), 16);
var b = parseInt(color.substr(5, 2), 16);
return new Array(r, g, b);
}
// 颜色Array(255,0,255)格式转为#FF00FF
function rgb2color(rgb) {
@hustcc
hustcc / AnimationFrame.js
Last active May 23, 2016
AnimationFrame can be used to do tasks.
View AnimationFrame.js
var frame_func = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(func) {
window.setTimeout(func, 1000 / 60);
};
//帧动画,做定时任务
//动画循环
if (!window.requestAnimationFrame) {
window.requestAnimationFrame = (window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.oRequestAnimationFrame ||