Skip to content

Instantly share code, notes, and snippets.

View Erichain's full-sized avatar
🎯
Focusing

Erichain Erichain

🎯
Focusing
View GitHub Profile
@Erichain
Erichain / clientController.js
Last active March 3, 2017 10:47
Use ionic and express.js to upload files
View clientController.js
app.controller(['$cordovaFileTransfer', function ( $cordovaFileTransfer ) {
// 一定要将代码放在事件监听中
// 表示设备准备好了之后才能执行里面的代码
document.addEventListener('deviceready', function () {
var uploadOptions = new FileUploadOptions(),
server = 'your_server_api',
imgPath = 'your_img_path';
// 注意此处设置的fileKey,Express服务端中也需要这个
uploadOptions.fileKey = 'file';
@Erichain
Erichain / calcDaysDiff.js
Created March 11, 2016 09:51
A function to calculate the difference between days
View calcDaysDiff.js
function calcDaysDiff( start, end ) {
var currentDate = start || new Date(),
timeDiff = end - currentDate,
timeUnit = 24 * 60 * 60 * 1000,
diff = 0;
diff = (timeDiff - currentDate % timeUnit) / timeUnit + 1;
return Math.floor(diff);
}
@Erichain
Erichain / msconvert.js
Last active December 25, 2023 19:15 — forked from remino/msconvert.js
JavaScript: Convert milliseconds to object with days, hours, minutes, and seconds
View msconvert.js
function convertMS( milliseconds ) {
var day, hour, minute, seconds;
seconds = Math.floor(milliseconds / 1000);
minute = Math.floor(seconds / 60);
seconds = seconds % 60;
hour = Math.floor(minute / 60);
minute = minute % 60;
day = Math.floor(hour / 24);
hour = hour % 24;
return {
@Erichain
Erichain / installAndroidSDKOnMac.md
Last active July 28, 2023 06:57
Mac OS下安装和配置android-sdk
View installAndroidSDKOnMac.md

##MAC OS下安装和配置android-sdk

###安装

在MAC上安装android-sdk,标准的安装方法是使用homebrew,运行如下命令:

brew update

brew install android-sdk