Skip to content

Instantly share code, notes, and snippets.

View zhoukekestar's full-sized avatar
🎄
Focusing

keke zhoukekestar

🎄
Focusing
View GitHub Profile
@zhoukekestar
zhoukekestar / hello-world.html
Created October 27, 2016 05:35
html5 hello-world.html
<!-- Defines element markup -->
<template>
<p>Hello <strong></strong> :)</p>
</template>
<script>
(function(window, document, undefined) {
// Refers to the "importer", which is index.html
var thatDoc = document;
// Refers to the "importee", which is src/hello-world.html
@zhoukekestar
zhoukekestar / export-single-file.js
Created October 30, 2016 12:34
Export Single File from Vue
// ------------------------
// npm install rollup rollup-plugin-flow-no-whitespace rollup-plugin-buble rollup-plugin-alias he de-indent
// -------------------------
// Edit rollup-plugin-alias.js
// if (!/js$/.test(updatedId)) {
// console.log(updatedId + ' ----> ' + updatedId + '.js');
// updatedId += '.js';
// }
// -------------------------
@zhoukekestar
zhoukekestar / note
Last active November 24, 2017 05:19
openvpn on aliyun
# Aliyun OpenVPN: https://help.aliyun.com/knowledge_detail/42521.html
# sudo bash update_source.sh // usa can't visit mirrors.aliyun.com
yum install -y lzo lzo-devel openssl openssl-devel pam pam-devel pkcs11-helper pkcs11-helper-devel
rpm -qa lzo lzo-devel openssl openssl-devel pam pam-devel pkcs11-helper pkcs11-helper-devel
wget http://oss.aliyuncs.com/aliyunecs/openvpn-2.2.2.tar.gz
yum install -y rpm-build gcc gcc-c++
rpmbuild -tb openvpn-2.2.2.tar.gz
# rpm -ivh openvpn-2.2.2-1.x86_64.rpm
rpm -ivh ./rpmbuild/RPMS/x86_64/openvpn-2.2.2-1.x86_64.rpm
cd /usr/share/doc/openvpn-2.2.2/easy-rsa/2.0
@zhoukekestar
zhoukekestar / DevWarningPatch.bat
Created November 14, 2016 03:51
Disabled "disabled developer mode extensions" pop up.
<# :
@echo off
copy/b "%~f0" "%temp%\%~n0.ps1" >nul
powershell -Version 2 -ExecutionPolicy bypass -noprofile "%temp%\%~n0.ps1" "%cd% " "%~1"
del "%temp%\%~n0.ps1"
pause
exit /b
#>
param([string]$cwd='.', [string]$dll)
@zhoukekestar
zhoukekestar / findmac.js
Created December 23, 2016 06:29
Find MAC address by IP
// node findmac.js 10.10.2.255 c4-01-7c-3d-b8-40
const exec = require('child_process').exec;
// http://thebackroomtech.com/2010/08/22/determine-ip-address-from-a-mac-address/
var broadcast = process.argv[2]
, mac = process.argv[3]
, targetIP = '';
if (!broadcast) {
@zhoukekestar
zhoukekestar / atom-eslint.js
Last active March 6, 2017 03:39
ESlint any files (include: pug, jade, html, js, weex file, we, jsx etc) for Atom.
const { BufferedProcess, Point } = require('atom');
const fs = require('fs')
const DEBUG_ESLINT = false;
// execute shell command
const executeCommand = function executeCommand (command, callback) {
command = command.split(' ');
const args = command.slice(1);
@zhoukekestar
zhoukekestar / utils.js
Created February 17, 2017 06:45
encodeURIComponent & decodeURIComponent
const s1 = '\\[ \\{ \\} \\] , / \\? : @ & = \\+ \\$ # " \\\\'.split(' '); // '[{}],/\?:@&=\+$#"\ '
const s2 = '%5B%7B%7D%5D%2C%2F%3F%3A%40%26%3D%2B%24%23%22%5C%20'.match(/.{3}/g); // encodeURIComponent('[{,/\?:@&=\+$#"\\ ')
const s3 = '[{}],/\?:@&=\+$#"\\ '.split('');
s1.push(' ');
module.exports.encodeURIComponent = function encodeURIComponent(str) {
let res = `${str}`;
for (let i = 0; i < s1.length; i += 1) {
res = res.replace(new RegExp(s1[i], 'g'), s2[i]);
@zhoukekestar
zhoukekestar / atom-autorun.js
Last active February 23, 2017 06:31
auto-run for atom on windows.
const {executeCommand, getCurrentEditorProjectHome, isFileExist} = require('./atom-utils.js');
const fs = require('fs')
const portMap = {}
const autorunIfNeeded = function autorunIfNeeded(editor = atom.workspace.getActiveTextEditor()) {
const project = getCurrentEditorProjectHome(editor);
if (isFileExist(`${project}/Dockerfile`)) {
const content = fs.readFileSync(`${project}/Dockerfile`);
@zhoukekestar
zhoukekestar / atom-close-big-file.js
Last active March 6, 2017 03:41
Close big file before atom crash!
const fs = require('fs');
module.exports = function(atom, windows) {
console.log('close big file')
atom.workspace.onDidOpen(editor => {
try {
const file = editor.uri;
const stats = fs.statSync(file);
if (stats.size > 2e4) { // Bigger than 20KB
@zhoukekestar
zhoukekestar / index.js
Created March 28, 2017 03:43
Fastest IP for you!
const exec = require('child_process').exec;
const ping = (ip) => {
return new Promise((resolve, reject) => {
exec(`ping ${ip}`, (err, stdout, stderr) => {
if (err) {
reject(err);
return;
}
resolve({ip, stdout});