Skip to content

Instantly share code, notes, and snippets.

View samzeng's full-sized avatar

Sam Zeng samzeng

View GitHub Profile
[].forEach.call(document.querySelectorAll("*"),function(a){a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16)})
@samzeng
samzeng / gray.css
Last active December 1, 2022 01:44
Make the website grey
.page--gray {
filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: grayscale(100%);
filter: gray;
}
@samzeng
samzeng / perf.js
Created April 25, 2019 09:15 — forked from scurker/perf.js
Capturing Page Load Metrics with Puppeteer
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 April 11, 2019 02:08
Vue get Window with and height
new Vue({
el: '#app',
data: {
window: { width: 0, height: 0 }
},
created() {
window.addEventListener('resize', this.handleResize)
this.handleResize();
},
destroyed() {
@samzeng
samzeng / devtools.js
Created March 24, 2018 15:33
检查用户是否打开开发者工具,并且记录打开次数
(function () {
var re = /x/;
var i = 0;
console.log(re);
re.toString = function () {
return alert('第 ' + (++i) + ' 次打开控制台');
};
})();
@samzeng
samzeng / detect-adblock.js
Created July 25, 2017 08:03
Detect AdBlock
(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 July 11, 2019 04:54
reset CSS for mobile browsers
@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 April 3, 2017 13:00
PhpStorm open current file with Gvim

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 February 22, 2017 10:04
Combining two arrays form a object
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 December 12, 2016 13:28 — forked from edwardbeckett/idea64.exe.vmoptions
Java 8 Intellij 64 JVM Options
-server
-Xms2g
-Xmx2g
-Xss16m
-XX:+UseConcMarkSweepGC
-XX:+CMSParallelRemarkEnabled
-XX:ConcGCThreads=4
-XX:ReservedCodeCacheSize=128m
-XX:+AlwaysPreTouch
-XX:+TieredCompilation