Skip to content

Instantly share code, notes, and snippets.

View yanqiw's full-sized avatar

Frank(Wang.Yan.Qi) yanqiw

View GitHub Profile
@yanqiw
yanqiw / tmux.md
Created September 20, 2021 04:04 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@yanqiw
yanqiw / scrollTo.js
Created February 10, 2019 07:59 — forked from joshcanhelp/scrollTo.js
Animated scrollTo for specific element or top of page
//
// Smooth scroll-to inspired by:
// http://stackoverflow.com/a/24559613/728480
//
module.exports = function (scrollTo, scrollDuration) {
//
// Set a default for where we're scrolling to
//
@yanqiw
yanqiw / detect-js-framework.js
Created May 3, 2018 11:23 — forked from rambabusaravanan/detect-js-framework.js
Detect JS Framework used in a Website
// Pase these lines into website's console ( Ctrl/Cmd + Shift + I )
if(!!window.React ||
!!document.querySelector('[data-reactroot], [data-reactid]'))
console.log('React.js');
if(!!window.angular ||
!!document.querySelector('.ng-binding, [ng-app], [data-ng-app], [ng-controller], [data-ng-controller], [ng-repeat], [data-ng-repeat]') ||
!!document.querySelector('script[src*="angular.js"], script[src*="angular.min.js"]'))
console.log('Angular.js');
@yanqiw
yanqiw / RCTScrollView.m
Created October 5, 2016 06:50
React Native adopt to xcode 8
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "RCTScrollView.h"
@yanqiw
yanqiw / byjQuery
Created September 9, 2016 05:49
javascript async
function asyncEvent(){
    var dfd = jQuery.Deferred();
    setTimeout(function () {
      dfd.resolve();
    }, 500);
    return dfd.promise();
  }
function resovleCallback(){
console.log('resolved');
@yanqiw
yanqiw / react-native-router-flux-android-back-button.js
Created July 15, 2016 09:31
react-native-router-flux, handle android back button event.
import { BackAndroid } from 'react-native';
import {Reducer} from 'react-native-router-flux';
backButtonPressedOnceToExit = false;
let currentSceneName = null;
const reducerCreate = params=>{
const defaultReducer = Reducer(params);
return (state, action)=>{
console.info("reducerCreate.{state,action}", state, action);
#!/usr/local/bin/python
import os, re, sqlite3
from bs4 import BeautifulSoup, NavigableString, Tag
db = sqlite3.connect('loopback.docset/Contents/Resources/docSet.dsidx')
cur = db.cursor()
try: cur.execute('DROP TABLE searchIndex;')
except: pass
@yanqiw
yanqiw / git-auto-add.py
Last active January 20, 2016 09:23
this code is used to watch folder, after file changes, add and commit the git
#!/usr/bin/python
'''
this script is used watch the folder. after file changes, auto add and commit the git
run python git-auto-add.py [commit comments]
'''
import time
import sys
import os
from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler
@yanqiw
yanqiw / gen_uid.js
Last active December 14, 2015 10:19 — forked from cyjake/gen_uid.js
// 还需要了解的:
// - 什么是 UID
// - 这四种方式优劣
function getId() {
return "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".replace(/x/g, function() {
return Math.floor(Math.random()*16).toString(16).toUpperCase();
});
}