Skip to content

Instantly share code, notes, and snippets.

View kerryChen95's full-sized avatar

kerryChen95 kerryChen95

  • AutoX
  • Beijing, China
View GitHub Profile
@kerryChen95
kerryChen95 / currentStackAndLine.js
Last active September 28, 2022 03:17
Get current stack and line number in JavaScript
// For V8:
// Define global variable `__stack__` and `__line`
// for current stack and line
(function(global){
Object.defineProperty(global, '__stack__', {
get: function(){
var orig = Error.prepareStackTrace;
Error.prepareStackTrace = function(_, stack){ return stack; };
var err = new Error;
Error.captureStackTrace(err, arguments.callee);
@kerryChen95
kerryChen95 / dabblet.css
Last active June 18, 2018 08:54
scroll inside on rotate 90deg
/**
* The first commented line is your dabblet’s title
*/
html, body {
background: #f06;
height: 100%;
}
#ctn {
.hd, .ft {
height: 20px;
background-color: red;
}
.bd::after {
content: '';
clear: both;
height: 0;
line-height: 0;
visibility: hidden;
.hd, .ft {
height: 20px;
background-color: red;
}
.bd::after {
content: '';
clear: both;
height: 0;
line-height: 0;
visibility: hidden;
@kerryChen95
kerryChen95 / gist:8591272
Created January 24, 2014 02:50
`JSON.parse()` cannot parse string...Notice when parse network response in JSON
JSON.parse('')
// SyntaxError: Unexpected end of input
JSON.parse('vds')
// SyntaxError: Unexpected token v
@kerryChen95
kerryChen95 / uniqueId.js
Created December 6, 2013 15:43
create unique id and check duplication.
function check() {
var hash = {},
key,
times = Math.pow(10, 9),
i = 1;
do {
key = create3();
if (hash[key]) {
git checkout topic-branch
git rebase master
git checkout master
git merge topic-branch
@kerryChen95
kerryChen95 / regexp.js
Created December 2, 2013 11:14
RegExp for English & Chinese usual sentence. It was written when I change my fucking annotation style.
// RegExp for English & Chinese usual sentence, which is reuseable
[\s\w\。\,\、\`\:\~\`\!\@\#\$\%\^\&\*\(\)\-\_\+\=\{\}\[\]\|\;\:\"\'\<\>\,\.\/\?]*?\n
// Whole RegExp for change my fucking annotation style, which is:
// /**
// * balabala
// * foo
// **/
// search via it and replace with $1$3 **twice**, and than there is a new annotation style:
@kerryChen95
kerryChen95 / evaluateTeaching.js
Last active December 29, 2015 02:39
UESTC evaluate teaching script
(function evaluate(){
var ifr = document.querySelector('#iframeautoheight'),
ifrDoc = ifr.contentDocument,
selects = ifrDoc.querySelector('#DataGrid1').querySelectorAll('.select'),
i, l,
options,
submitBtn = ifrDoc.querySelector('#Button2');
if( submitBtn.value.search(/提\s*交/) === -1 ){
for(i = 0, l = selects.length; i < l; ++i){
.wrapper {
width:90%;
margin: auto;
overflow: hidden;
zoom: 1;
background: beige;
}
.nav {
float: left;