Skip to content

Instantly share code, notes, and snippets.

Sam Zeng samzeng

Block or report user

Report or block samzeng

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@samzeng
samzeng / perf.js
Created Apr 25, 2019 — forked from scurker/perf.js
Capturing Page Load Metrics with Puppeteer
View perf.js
const puppeteer = require('puppeteer');
(async function() {
const browser = await puppeteer.launch({ devtools: true });
const page = await browser.newPage();
// Login
await page.goto('http://localhost:8080');
await page.type('#login', 'username');
@samzeng
samzeng / getWindowSize.vue
Last active Apr 11, 2019
Vue get Window with and height
View getWindowSize.vue
new Vue({
el: '#app',
data: {
window: { width: 0, height: 0 }
},
created() {
window.addEventListener('resize', this.handleResize)
this.handleResize();
},
destroyed() {
@samzeng
samzeng / devtools.js
Created Mar 24, 2018
检查用户是否打开开发者工具,并且记录打开次数
View devtools.js
(function () {
var re = /x/;
var i = 0;
console.log(re);
re.toString = function () {
return alert('' + (++i) + ' 次打开控制台');
};
})();
View detect-adblock.js
(function(){
var element = document.createElement('div');
element.className = 'adsbox';
document.body.appendChild(element);
window.setTimeout(function() {
if (element.offsetHeight === 0) {
document.body.classList.add('has-adblock');
}
element.remove();
@samzeng
samzeng / reset-mobile.css
Last active Jul 11, 2019
reset CSS for mobile browsers
View reset-mobile.css
@charset "utf-8";
html {
color: #000;
background: #fff;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%
}
html * {
outline: 0;
@samzeng
samzeng / external_tools.md
Created Apr 3, 2017
PhpStorm open current file with Gvim
View external_tools.md

PhpStrom

  1. Default Settings -> Tools -> External Tools
  2. Create Tool:
    1. Program: path\gvim.exe
    2. Parameters: +$LineNumber$ $FilePath$
    3. Working directory: $FileDir$
@samzeng
samzeng / tow_arrays_a_object.js
Created Feb 22, 2017
Combining two arrays form a object
View tow_arrays_a_object.js
var keys = ['a', 'b', 'c'];
var values = ['1', '2', '3'];
var obj = {};
var objArr = [];
for (var i = 0; i < keys.length; i ++) {
obj[keys[i]] = values[i];
}
objArr.push(obj);
@samzeng
samzeng / idea64.exe.vmoptions
Created Dec 12, 2016 — forked from edwardbeckett/idea64.exe.vmoptions
Java 8 Intellij 64 JVM Options
View idea64.exe.vmoptions
-server
-Xms2g
-Xmx2g
-Xss16m
-XX:+UseConcMarkSweepGC
-XX:+CMSParallelRemarkEnabled
-XX:ConcGCThreads=4
-XX:ReservedCodeCacheSize=128m
-XX:+AlwaysPreTouch
-XX:+TieredCompilation
@samzeng
samzeng / box-shadow.css
Created Sep 10, 2015
Smooth box shadow
View box-shadow.css
.box-shadow {
box-shadow: 0 0 1px rgba(0, 0, 0, 0.7);
}
View high-resolution-retina-displays.css
/* Use media queries for high-res CSS styles */
.demo {
background-image: url(test.png);
}
@media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
background-image: url(test-@2x.png);
}
/* image-set W3C: http://dev.w3.org/csswg/css-images/#image-set-notation */
.demo {
You can’t perform that action at this time.