Skip to content

Instantly share code, notes, and snippets.

View giscafer's full-sized avatar
🎯
Working hard

Nicky Lao giscafer

🎯
Working hard
View GitHub Profile
@giscafer
giscafer / bar-chart.component.ts
Last active March 15, 2017 15:57
primeng bar chart 宽度设置方式(Chart.js how to set the width for a bar chart)
/**
* Created by giscafer on 2017/3/15.
*/
import {Component} from '@angular/core';
import {UIChart} from 'primeng/primeng';
@Component({
selector: 'cool-chart',
template:`<p-chart type="bar" [data]="data" [options]="options"></p-chart>`,
@giscafer
giscafer / autocomplete.ts
Created April 18, 2017 01:22
primeng 2.2.5扩展,支持optionGroup以及支持中文输入
/**
* Created by giscafer on 2017/4/15.
* 复制源码修改覆盖
* 添加事件延迟,支持中文输入
*/
import {
NgModule,
Component,
ViewChild,
@giscafer
giscafer / uploadPic.js
Last active May 8, 2017 06:41
XMLHttpRequest + FormData图片上传
/**
* let formData = new FormData();
* for (let i = 0; i < this.files.length; i++) {
formData.append("file", this.files[i], this.files[i].name);
}
*/
uploadPic(formData){
let jwt = localStorage["jwt"];
/*let headers = new Headers({
@giscafer
giscafer / nativescript-selected-picture-and-del.js
Last active May 27, 2017 10:02
nativescript selected picture and delete picture
/**
* 删除图片
* @param args
*/
exports.onPictureDelete = function (args) {
var result = [], flag = false;
var imgId = args.object.imgId;
var imageItems = list_view.bindingContext.imageItems;
var pickImgArr = [model.UPLOAD_BTN_IMG];
if (imageItems.length == signPicNumber && maxPicture) {
@giscafer
giscafer / dataURItoBlob.ts
Created May 31, 2017 08:28
picture base64String to Blob
/**
* base64 转 二进制文件
* dataURL to blob, ref to https://gist.github.com/fupslot/5015897
* @param dataURI
* @returns {Blob}
*/
export function dataURItoBlob(dataURI) {
var byteString = atob(dataURI.split(',')[1]);
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
var ab = new ArrayBuffer(byteString.length);
@giscafer
giscafer / nativescript-imageUpload.js
Last active June 1, 2017 07:02
nativescript imageupload tools
/**
* Created by giscafer on 2017/5/6.
*/
/**
* 相册图片单选
*/
var imagepicker = require("nativescript-imagepicker");
var fs = require('file-system');
var dialogs = require("ui/dialogs");
var enums = require("ui/enums");
@giscafer
giscafer / dataToTree.ts
Last active May 26, 2018 15:41
tree data convert
/**
* 父子关系的原始数据格式化成树形结构数据
* @param {Array<Object>} data 原始数据
* @return {Array<Object>} 树形结构数据
*/
export function dataToTree(data) {
/*tslint:disable*/
let pos = {},
tree = [],
i = 0,
@giscafer
giscafer / echarts-options.js
Created November 24, 2017 03:36
数据可视化-广州迁徙
var geoCoordMap = {
'广州': [113.5107,23.2196],
'北京': [116.4551,40.2539],
'天津': [117.4219,39.4189],
'上海': [121.4648,31.2891],
'重庆': [106.557165,29.563206],
'河北': [114.508958,38.066606],
'河南': [113.673367,34.748062],
'云南': [102.721896,25.047632],
'辽宁': [123.445621,41.806698],
@giscafer
giscafer / currying.js
Last active November 27, 2017 12:54
fedemo.duapp.com.ts
var currying = function(fn) {
var _weight = 0;
var _args = [];
return function() {
if (!arguments.length) {
return fn.apply(this, _args);
} else {
Array.prototype.push.apply(_args, arguments);
return arguments.callee;
@giscafer
giscafer / Book.js
Last active January 21, 2019 09:31
原生js接口设计模式
/**
* 类的封装和信息的隐藏
*
* 本例子使用闭包来实现静态变量熟悉和方法,通过创建一个受保护的变量空间,可以实现公用、私用和特权成员,以及
* 静态成员和常量。
*
* 概念:
* 1、特权方法(privileged method) 指有权访问私有变量和私有函数的公有方法
* 2、非特权方法(non-privileged method) 指无需(或没有权限)访问私有变量和私有函数的公有方法
*