Skip to content

Instantly share code, notes, and snippets.

View Lxxyx's full-sized avatar

Lxxyx Lxxyx

  • China Hangzhou (UTC+8)
  • 09:38 (UTC +08:00)
View GitHub Profile
@Lxxyx
Lxxyx / Hello.js
Created November 22, 2015 13:33
Js
var detail_s = "平时会有什么非常重要的事情,要这么严肃以公告的形式发布出来呢?我也不知到,但是估计下来这里也可以放下很多的字吧,万一不够还可以省略掉是不是。但是居然不能用sketch还得用上PS不过也就这样吧..."
var HeaderTitle = React.createClass({
render: function () {
return (
<span className="card-title-h1">
{this.props.title}
</span>
);
}
@Lxxyx
Lxxyx / OnlineEdu.js
Created March 14, 2016 12:23
OnlineEdu
import 'babel-polyfill'
const rp = require('request-promise');
var request = require('request');
const fsp = require('fs-promise');
const cheerio = require('cheerio');
var iconv = require('iconv-lite');
var firPage = 'http://online.ncu.edu.cn/eol/homepage/common/'
var loginPage = 'http://online.ncu.edu.cn/eol/homepage/common/login.jsp'
@Lxxyx
Lxxyx / debounce2.js
Created June 27, 2016 00:51
debounce
/**
* 在指定的时间内,若函数被多次触发
* 则只会调用最新的一次,避免不必要的性能开销
* 调用时间: 最后一次触发 + 设定的等待时间
*
* @param {Function} func 要延时的函数
* @param {Number} wait 延迟时间/ms
* @return {Function} 延迟后的函数
*/
const debounce = (func, wait) => {
@Lxxyx
Lxxyx / throttle.js
Created October 31, 2016 03:41
debuonce
// 1000内,只触发一次
const throttle = (cb, time = 1000, ctx = null) => {
let timer = null
return (...args) => {
if (timer) {
return
}
timer = setTimeout(() => {
cb.apply(ctx, args)
timer = null
@Lxxyx
Lxxyx / SortSchedule.js
Last active November 3, 2016 11:51
SortSchedule
function sortWeek (schedules) {
schedules = schedules.map(s => sortDay(s))
}
function sortDay (schedule) {
const sorted = []
const hasSort = []
let base = schedule[0]
for (let i = 0; i < schedule.length; i++) {
if (base === null) {
@Lxxyx
Lxxyx / SimpleRouter.ts
Created December 30, 2016 08:19
SimpleRouter
interface IRoutes {
path: string,
content: string
}
class Router {
routes: Array<IRoutes> = []
view: HTMLDivElement = null
register (route: IRoutes) :void {
@Lxxyx
Lxxyx / index.ios.js
Created January 20, 2017 16:21
RN点击时,只有最里面会收到通知。
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
@Lxxyx
Lxxyx / package.json
Created January 22, 2017 07:57
ts-jest package.json
{
"jest": {
"preset": "react-native",
"setupFiles": [
"<rootDir>/jest-setup.js"
],
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
@Lxxyx
Lxxyx / tsconfig.json
Created January 22, 2017 08:00
tsconfig.json
{
"compilerOptions": {
"target": "es2015",
"module": "es2015",
"moduleResolution": "node",
"pretty": true,
"jsx": "react",
"outDir": "build",
"allowSyntheticDefaultImports": true,
"noImplicitAny": false,
@Lxxyx
Lxxyx / ajax_demo.js
Created February 1, 2017 04:43
ajax demo
// XMLHttpRequest
var xhr = new XMLHttpRequest()
xhr.open('GET', 'https://httpbin.org/ip')
xhr.onload = function () {
console.log('responseText: ', xhr.responseText)
console.log('responseText type: ', typeof xhr.responseText)
console.log('JSONData: ', JSON.parse(xhr.responseText))
console.log('JSON type:', typeof JSON.parse(xhr.responseText))
}
xhr.send()