Skip to content

Instantly share code, notes, and snippets.

@MrFant
MrFant / README.md
Last active October 9, 2019 14:01
JS的函数节流和函数防抖

JS的函数节流和函数防抖

debounce 函数防抖

个人理解 函数防抖就是法师发技能的时候要吟唱,技能吟唱没完再按技能就会重新读吟唱。

throttle 函数节流

个人理解 函数节流就是fps游戏的射速,就算一直按着鼠标射击,也只会在规定射速内射出子弹。

结合应用场景

@MrFant
MrFant / Hello.java
Created December 19, 2018 14:56
java代理模式之静态代理和动态代理
/**
* java 静态代理,基于接口实现
*/
public interface Hello {
String sayHello(String str);
}
class HelloImp implements Hello{
// 目标对象
public String sayHello(String str) {
@MrFant
MrFant / jdbc.java
Last active November 20, 2019 05:59
仅用jdbc连接数据库的demo
// 依赖jdbc
import java.sql.*;
public class jdbc{
public static void main(String[] args) throws Exception{
//1、注册驱动,什么是驱动?能够让java连接数据库,也就是实现jdbc接口规范就是驱动
Class.forName("com.mysql.jdbc.Driver");//硬编码
/*
* 2、通过驱动管理者获取数据库连接
* DriverManager是驱动实现类的管理者。
* url:连接数据库的位置,端口号,数据库名
@MrFant
MrFant / my.cnf
Created August 6, 2018 01:30
mysql configuration file template in Mac OS
#
# yii fant configuration file template for MySQL, Galera Cluster, MariaDB and Percona Server
# Location: /etc/my.cnf or /etc/mysql/my.cnf
# This template is intended to work with MySQL 5.6 and newer and MariaDB 10.0 and newer
# Get most recent updated from here:
# 本配置文件将所有character set都设置为utf8
#
[client]
@MrFant
MrFant / bookstore.sql
Created July 1, 2018 13:54
SQL code set
/*
SQLyog Ultimate v8.32
MySQL - 5.5.40 : Database - itcaststore
*********************************************************************
*/
CREATE DATABASE /*!32312 IF NOT EXISTS*/`itcaststore` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `itcaststore`;
@MrFant
MrFant / index.js
Last active June 16, 2018 02:32
command-line fileBrowser base on nodeJS
/**
* nodejs的标准输入输出流实现命令行程序,实现文件的读取和显示,类似于*nix系统里的ls,cat,cd等命令
*Module dependencies
*/
// "use strict";
var fs = require('fs'),
stdin = process.stdin,
stdout = process.stdout,
@MrFant
MrFant / index.js
Last active June 14, 2018 13:56
a tcp server base on nodejs
/**
* a tcp server base on nodejs
* come from <<nodejs: javascript everywhere>>
*
*/
// "use strict";
var net = require('net'),
count=0,
users={};
@MrFant
MrFant / h5_file_demo.html
Last active June 14, 2018 13:35
html5 file api demo
<html>
<head>
<meta charset="UTF-8">
<title>File API</title>
</head>
<body>
<article>
<div id="holder"></div>
<p id="status">File API & FileReader API not supported</p>
@MrFant
MrFant / ChineseServlet.java
Last active September 3, 2018 12:36
Servlet response and request interface
package cn.itcast.chapter04.response;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ChineseServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)throws ServletException, IOException {
//response.setCharacterEncoding("utf-8");
// response.setHeader("Content-Type","text/html;charset=utf-8");
//设置字符编码
@MrFant
MrFant / index.html
Last active May 18, 2018 02:30
Use execCommands to edit HTML content in your browser
<div class="container">
<div class="jumbotron">
<div class="container">
<h2>execCommands supported in your browser</h2>
<div class="row">
<div class="col-md-6">The <small class="btn btn-success btn-xs">Green</small> commands are supported by your browser, where as the <small class="btn btn-error btn-xs">Grey</small> ones.. You guessed it! :-) <br />Anyway try to select contents below and click <small class="btn btn-success btn-xs">commands</small> to execute the commands on it. <br />I use the HTML attribute <code>contenteditable=true</code> to allow modifications to the content. <code>Updated</code>: Added <a href="https://fortawesome.github.io/Font-Awesome/icons/">font awesome icons</a>. <br /> <br />Inspired by <a href="https://css-tricks.com/cut-and-copy-from-javascript/">Cut and Copy (from JavaScript)</a></div>
<div class="col-md-6">
<code>2017-06-04 updated:</code><br>
<em>As pointed out by <a href="https://twitter.com/Robvanhe">@Robvanhe</a> the pen did not