Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢
slow but safe..

Fritz Lin fritx

🐢
slow but safe..
View GitHub Profile
@fritx
fritx / src-core-util-env.js
Last active Mar 11, 2019
Vue.nextTick 2.4.4
View src-core-util-env.js
// ...
/**
* Defer a task to execute it asynchronously.
*/
export const nextTick = (function () {
const callbacks = []
let pending = false
let timerFunc
@fritx
fritx / 201611.md
Created Dec 6, 2016
11月项目笔记
View 201611.md

[1128] nw18 解决locale判断失效
https://github.com/nwjs/nw-builder/issues/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 Dec 6, 2016
10月项目笔记
View 201610.md

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

class EditorForm extends Component {
  componentDidUpdate () {
    const { members } = this.props
    $('#editor').atwho({ at: '@', data: members })
View electron-openWindow.js
// @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 Sep 29, 2016
Sqlite3 db migration with co
View lagancy-co.js
'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 / app-drag.js
Last active May 25, 2017
nwjs/electron window dragging implementation (replacement of -webkit-app-region: drag/no-drag)
View app-drag.js
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 / gist:2f4b7b38288657f2e394
Created Aug 9, 2014
demo of fix of showorders.php
View gist:2f4b7b38288657f2e394
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 Aug 29, 2015
demo of jsapicall.php
View jsapicall.html.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 Aug 29, 2015
run http-server
View index.js
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 Feb 15, 2014
`requireFn` with circular module loading
View requireFn.js
/**
* Created by fritz on 2/15/14.
*/
var Module = require('module'),
path = require('path');
/**
* easy way for circular module loading
*/
function requireFn(request) {