Skip to content

Instantly share code, notes, and snippets.

View Jokcy's full-sized avatar
🎯
Focusing

JokcyLou Jokcy

🎯
Focusing
View GitHub Profile
@Jokcy
Jokcy / Gruntfile.js
Created February 24, 2014 03:32
grunt编译less的最简单配置样例
module.exports = function (grunt) {
grunt.loadNpmTasks('assemble-less');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less: {
compileCore: {
options: {
@Jokcy
Jokcy / which-mobile
Last active August 29, 2015 14:08
js判断移动端浏览器是哪个平台
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp = sUserAgent.match(/midp/i) == "midp";
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid = sUserAgent.match(/android/i) == "android";
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
{
"scripts": {
"dev": "webpack-dev-server --devtool eval --hot --progress --colors --content-base dist --port 3000"
}
}
@Jokcy
Jokcy / .gitattributes
Created July 21, 2017 05:31
设置git提交内容时,所有文本文件的行末的模式
# Automatically normalize line endings for all text-based files
# http://git-scm.com/docs/gitattributes#_end_of_line_conversion
* text=auto
# For the following file types, normalize line endings to LF on
# checkin and prevent conversion to CRLF when they are checked out
# (this is required in order to prevent newline related issues like,
# for example, after the build script is run)
.* text eol=lf
*.css text eol=lf
@Jokcy
Jokcy / controlled-input.jsx
Created July 24, 2017 06:41
vue controlled input
export default {
props: {
value: {
type: [String, Number],
default: '',
},
},
data() {
@Jokcy
Jokcy / salt-password.js
Created May 7, 2018 08:17
nodejs salt password
import crypto from 'crypto'
const genRandomString = (length) => {
return crypto.randomBytes(Math.ceil(length / 2))
.toString('hex')
.slice(0, length)
}
const sha512 = (password, salt) => {
const hash = crypto.createHmac('sha512', salt)
@Jokcy
Jokcy / bash
Last active January 24, 2019 05:39
generate-openssl-cert
openssl req -x509 -newkey rsa:2048 -nodes -sha256 -keyout localhost-privkey.pem -out localhost-cert.pem
@Jokcy
Jokcy / useReducer.js
Created October 30, 2018 05:58
react hooks useReducer
function useReducer(reducer, initialState, initialAction) {
currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber();
workInProgressHook = createWorkInProgressHook();
var queue = workInProgressHook.queue;
if (queue !== null) {
// Already have a queue, so this is an update.
if (isReRender) {
// This is a re-render. Apply the new render phase updates to the previous
var _dispatch2 = queue.dispatch;
if (renderPhaseUpdates !== null) {
@Jokcy
Jokcy / finishHooks.js
Created October 30, 2018 06:28
react hooks finishHooks
function finishHooks(Component, props, children, refOrContext) {
// This must be called after every function component to prevent hooks from
// being used in classes.
while (didScheduleRenderPhaseUpdate) {
// Updates were scheduled during the render phase. They are stored in
// the `renderPhaseUpdates` map. Call the component again, reusing the
// work-in-progress hooks and applying the additional updates on top. Keep
// restarting until no more updates are scheduled.
didScheduleRenderPhaseUpdate = false;
@Jokcy
Jokcy / fiber-root.js
Last active November 8, 2018 04:14
React FiberRoot 中文注释版
type BaseFiberRootProperties = {|
// root节点,render方法接收的第二个参数
containerInfo: any,
// 只有在持久更新中会用到,也就是不支持增量更新的平台,react-dom不会用到
pendingChildren: any,
// 当前应用对应的Fiber对象,是Root Fiber
current: Fiber,
// 一下的优先级是用来区分
// 1) 没有提交(committed)的任务