Skip to content

Instantly share code, notes, and snippets.

View ika18's full-sized avatar

Ika Wu ika18

View GitHub Profile
@ika18
ika18 / 01-setup-new-typescript-project.md
Created February 18, 2024 15:23 — forked from avermeulen/01-setup-new-typescript-project.md
TypeScript basics with Mocha setup - learn how to use interfaces

Setup a new TypeScript project with Mocha support

Ensure you have TypeScript installed globally using this command:

npm install -g typescript

This outlines how to setup a new TypeScript project with mocha support.

@ika18
ika18 / smiple_memo.ts
Last active July 2, 2020 05:54
React Memo的最小实现
const memo = (component, comparision) => {
let prevProps = {};
let nextProps = {};
let memoResult = null;
let initialized = false;
const comparisionFn = comparision ? comparision : (nextProps, prevProps) => {
return nextProps === prevProps;
}
@ika18
ika18 / machine.js
Last active February 8, 2020 11:49
Generated by XState Viz: https://xstate.js.org/viz
const echoMachine = Machine({
id: 'echo',
initial: 'listening',
states: {
listening: {
on: {
SPEAK: {
actions: send('ECHO')
},
ECHO: {
@ika18
ika18 / machine.js
Last active February 8, 2020 11:26
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
<div>hola</div>
@ika18
ika18 / test.js
Last active January 1, 2016 02:18
var showTimeId;
var moveTimeId;
var slideLeaveTimeId;
me.$element.on('mouseenter', '[data-action="note"], [data-action="email"], [data-action="target"], [data-action="shortlist"], [data-action="task"], [data-action="floating"]', function ($e) {
var $target = $($e.target);
var mouseenter = function (e) {
clearTimeout(moveTimeId);
$(this).off(e);
};
@ika18
ika18 / build.example.js
Last active December 23, 2015 12:49
r.js build example in Chinese
/*
* This is an example build file that demonstrates how to use the build system for
* require.js.
*/
({
// 包含你app的顶级文件夹。如果这个选项被使用了,它假定了你的脚本都在这个路径下的子文件夹种。
// 这个是非必要项。如果没有被指定,那下面的baseUrl就是找文件的锚点。
// 如果这个被指定了,那么所有的app目录的文件将被复制到这个路径:
// 输出域和baseUrl会被假定是这个目录下的相对路径。
@ika18
ika18 / README.md
Last active December 21, 2015 06:39
Use localStorage to share one comet across multiple tabs

NOTE:

  • The tab which triggers the localStorage's key/value will not fire 'storage' event. But the others will.
  • If the tab is exited with an exception, then it won't fire 'storage'.
@ika18
ika18 / log
Created July 29, 2013 06:00
an error handling in troopjs
define(['jquery',
'troopjs-core/component/service',
'config'], function RouteService($, Service, config) {
'use strict';
var URL = '/rest/data/errorlog';
function log(msg, stack) {
if (!config.debug) {
var data = {
@ika18
ika18 / gollum
Created November 13, 2012 10:23 — forked from anonymous/gollum
gollum
/*!
* Gollum - 1.0.0-2-g7afb5e9
* Copyright (c) 2012 Norman Xu <[email protected]>
* Licensed MIT
*/
/**
* @class Gollum
* Load script under sandboxed execution context to isolate unsafe code.