Skip to content

Instantly share code, notes, and snippets.

View fritx's full-sized avatar
🐢
slow but safe..

Fritz Lin fritx

🐢
slow but safe..
View GitHub Profile
@fritx
fritx / src-core-util-env.js
Last active March 11, 2019 03:11
Vue.nextTick 2.4.4
// ...
/**
* Defer a task to execute it asynchronously.
*/
export const nextTick = (function () {
const callbacks = []
let pending = false
let timerFunc
@fritx
fritx / app-drag.js
Last active May 25, 2017 11:00
nwjs/electron window dragging implementation (replacement of -webkit-app-region: drag/no-drag)
var remote = require('remote')
var $ = require('./lib/jquery')
var win = remote.getCurrentWindow()
var isDragging = false
var winPos
var dX, dY // screen - win
$(document).on('mousedown', '.app-drag', function(e) {
e = e.originalEvent || e
@fritx
fritx / 201611.md
Created December 6, 2016 10:20
11月项目笔记

[1128] nw18 解决locale判断失效
nwutils/nw-builder#357
12升18 应用打包后 navigator.language(s)始终返回en
(1) 可以确保nw Resources/下的*.lproj语言文件 cp到打包后的app内
language(s)重新生效 像nw12一样

nw.build()
.then(() => {
  // mac
@fritx
fritx / 201610.md
Last active December 6, 2016 10:16
10月项目笔记

[1027] 如何在webpack/react环境中引入at.js
ichord/At.js#411
要在react中加jquery本就别扭 更何况加的是jquery插件
一时无法摆脱jq 只能注意解决摩擦之处

class EditorForm extends Component {
  componentDidUpdate () {
    const { members } = this.props
    $('#editor').atwho({ at: '@', data: members })
// @private
function openWindow (key, opts = {}) {
const dontShow = opts.show === false
opts = Object.assign({
show: false,
resizable: false
}, opts)
opts.webPreferences = Object.assign({
nodeIntegration: false,
preload
@fritx
fritx / lagancy-co.js
Last active September 29, 2016 14:26
Sqlite3 db migration with co
'use strict'
const co = require('co')
const fs = require('mz/fs')
const sqlite3 = require('../node-sqlite3') // custom version sqlite3
co(function* () {
try {
yield fs.unlink('old.db')
yield fs.unlink('new.db')
} catch (e) {}
@fritx
fritx / gist:2f4b7b38288657f2e394
Created August 9, 2014 06:21
demo of fix of showorders.php
function agreeReturnMoneyAfterSent($id,$agree,$s){
if(confirm('确认'+$s+'?')==false){
//window.event.returnValue=false;
return;
}
$returnValue=false;
$.get("<?php echo WXPAY_REFUND_SELLER_AGREE_URL; ?>",{id:$id,flag:$agree},function(data,textStatus,jhr){
if(data=="<?php echo WX_SUCCESS_STATUS; ?>"){
alert("成功");
//$returnValue=true;
@fritx
fritx / jsapicall.html.php
Last active August 29, 2015 14:05
demo of jsapicall.php
<!DOCTYPE html>
<html>
<head>
<base href="../s/">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="keywords" content="月饼, 邮政, 江门, 商城, 订单, 微信">
<meta name="description" content="江门邮政月饼商城">
<title>邮政商城</title>
<link rel="stylesheet" href="css/_deps.css">
@fritx
fritx / index.js
Last active August 29, 2015 13:57
run http-server
var spawn = require('child_process').spawn;
var port = 8077;
var server = spawn('./node_modules/.bin/http-server', ['-p', port]);
server.stderr.pipe(process.stderr);
server.stdout.pipe(process.stdout);
server.on('close', function () {
process.exit();
});
@fritx
fritx / requireFn.js
Created February 15, 2014 06:24
`requireFn` with circular module loading
/**
* Created by fritz on 2/15/14.
*/
var Module = require('module'),
path = require('path');
/**
* easy way for circular module loading
*/
function requireFn(request) {