Skip to content

Instantly share code, notes, and snippets.

@WunGCQ
WunGCQ / 0_reuse_code.js
Last active August 29, 2015 14:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@WunGCQ
WunGCQ / 进制转换
Created June 3, 2016 10:43
实现一个小的进制转换器...
function log(a,b){
return Math.log(b)/Math.log(a);
}
function convert(_input, source, target) {
var input = _input.toString();
var I_L = source.length,T_L = target.length;
var len = input.length;
var num = input.split('').reduce((res,letter,i)=>{
var index = source.indexOf(letter);
@WunGCQ
WunGCQ / launch.json
Last active April 18, 2019 12:04
VSCode OSX C++ cpp tasks.json launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch (OSX)",
"type": "lldb",
"request": "launch",
"program": "${workspaceRoot}/Debug/out.o",
"MIMode": "lldb",
"stopAtEntry": false,
@WunGCQ
WunGCQ / check_function.js
Created February 27, 2017 16:16
javascript check css in html document loaded
function check(){
setTimeout(()=>(
var len = 0, arr = [],count = 0;
arr = Array.prototype.slice.call(document.head.children).filter(el=>((el.tagName == 'LINK'&& el.href) || (el.tagName == 'SCRIPT' && el.src))),len = arr.length,arr).forEach(e=>
e.addEventListener('load',()=>console.log(`finished ${++count} of ${len}`))),0);
}
@WunGCQ
WunGCQ / antd_lib_input_Textarea.d.ts
Created August 2, 2017 09:18
fix antd/lib/input/Textarea.d.ts (version 2.12.3)
/// <reference types="react" />
import React from 'react';
import { AbstractInputProps } from './Input';
export interface AutoSizeType {
minRows?: number;
maxRows?: number;
}
export interface TextAreaProps extends AbstractInputProps {
autosize?: boolean | AutoSizeType;
onPressEnter?: React.FormEventHandler<any>;
@WunGCQ
WunGCQ / request.js
Created November 30, 2017 19:08
my axios
import Axios from 'axios';
import {
isArray
} from 'lodash';
import qs from 'qs';
const CGI_SERVER = process.env.CGI_SERVER;
export const cgiServerPath = () => CGI_SERVER;
const postConfig = {
method: 'POST',
@WunGCQ
WunGCQ / set100VH.js
Last active February 13, 2018 02:57
calculate 100vh to window.innerHeight to prevent keyboard squeeze window height on mobile
export function resetVH(){
const vh100 = window.innerHeight;
const styleContent = `
.vh-100 {
height: ${vh100}px;
}
`;
const node = document.createElement('style');
node.type = 'text/css';
node.innerHTML = styleContent;
@WunGCQ
WunGCQ / example.js
Created March 22, 2018 08:10
MYSQL: sequelize attribute alias for query JSON field
/*
when querying attributes using alias like:
attributes: [['m','n']] // to show m as n
sequelize will wrap the field word width '`'
the query will looks like `m` AS `n`
this seems simple;
but when query JSON fields:
//my data column: data, value: {name:'wungcq'}
attributes: ["data->'$.name'","name"]
@WunGCQ
WunGCQ / share.js
Last active May 31, 2018 16:37
pigee_h5_share
function initShare() {
var wx = window['wx'];
var path = 'https://pigee.tongpaostudio.com/entry' + (childrenVersion ? '1' : '') + '?v=' + Date.now();
$.post('//api.tongpaostudio.com/api/js/config', {
url: window.location.href,
origin: path,
}, function (data) {
wx && wx.config(data);
wx && wx.ready(function () {
wx.onMenuShareTimeline({
@WunGCQ
WunGCQ / not cache jump script
Created August 14, 2018 04:09
url cache jump
<script>
(function(){
function getQuery(r){var n=r||window.location.search;try{return(n?n.slice(1).split("&"):[]).reduce(function(r,n){var t=n.split("=");return r[t[0]||""]=t[1]||"",r},{})}catch(r){return{}}}
function stringifyQuery(r){var n=[];for(var t in r)n.push(t+"="+r[t]);return"?"+n.join("&")}
!function(){var o=getQuery(),n=Math.floor(Date.now()/12e4);if(o.tpv!=n){o.tpv=n;var i=window.location.origin+window.location.pathname+stringifyQuery(o)+window.location.hash;window.location.href=i}}();
})();
</script>