duangsues.is_a? SaltedFish
60 subscribers
609 photos
6 videos
91 files
562 links
🌶🐔🐟 duangsuse 的日常
尤其喜欢发些奇奇怪怪的东西
和转载别人的东西
Download Telegram
本来还有一张以前一起去漓江的相片呢,找不到了。
顺便发现了一个曾经帮助创造体外透析血桥握力器,不用再去买了。
#life 接下来就会回去见一个转学前的老朋友
Forwarded from duangsuse::Echo
转眼间我买的第一个一年的域名已经过期了,我离开酷安入 Telegram 也快一年了,第一次接触 Java 大概也有两年了呢。这两年收获巨大。当然主要都是我自己看书学的((但是也感谢大家的科普,愿大家以后都能成为优秀的工程师,能够游刃有余的处理各种复杂的分布式、并发处理和同步、异步、底层、计算机网络、信息安全、机器学习、CG、算法、优雅函数库 DSL、解释器、逆向工程/二进制相关、函数式逻辑式等问题
This media is not supported in your browser
VIEW IN TELEGRAM
待会要安装一下某台打印机和准备出去玩一会(
This media is not supported in your browser
VIEW IN TELEGRAM
安装好了不过没 A4 纸张...
Forwarded from duangsuse Throws
MinB64 是 2017 年 2 月 8 日(6 日开始 8 日结束更新)的 Android 应用
今天是 2018 年 10 月 27 日。离「正式开始」已经一年又一个多月过去了。 #tech #dev #life
const fs = require('fs')
const util = require('util')
const glob = util.promisify(require('glob'))
const request = require('request-promise')
const version = require('../package.json').version

module.exports = {

VERSION: version,

api: {
upload: 'https://sm.ms/api/upload',
history: 'https://sm.ms/api/list',
clear: 'https://sm.ms/api/clear',
delete: 'https://sm.ms/delete/'
},

headers: {
'User-Agent': request/smms-cli ${version}
},

/**
* Upload an image file
* @param {string} filename - path to a binary image file
* @returns {promise}
*/
upload(filename) {
return glob(filename)
.then(file => {
if (!file.length) {
throw new Error(Invalid filename)
}
let formData = {
smfile: fs.createReadStream(filename),
ssl: 1,
format: 'json'
}
return request
.post({
url: this.api.upload,
headers: this.headers,
formData,
json: true
})
.then((json) => {
if (json.code !== 'success') {
throw new Error(json.msg)
}
return json
})
})
.catch(err => {
throw err
})
},

history() {
return request.get({
url: this.api.history,
headers: this.headers,
json: true
})
},

clear() {
return request.get({
url: this.api.clear,
headers: this.headers,
json: true
})
},

delete(hash) {
return request
.get({
url: this.api.delete + hash,
headers: this.headers,
qs: {
format: 'json'
},
json: true
})
.then((json) => {
if (json.code !== 'success') {
throw new Error(json.msg)
}
return json
})
}

}
#!/usr/bin/env node

const fs = require('fs')
const util = require('util')
const glob = util.promisify(require('glob'))
const Table = require('cli-table3')
const commander = require('commander')
const smms = require('../')

// preload smms-cli history
const HOME_PATH = process.platform === 'win32' ? 'USERPROFILE' : 'HOME'
const DEFAULT_HISTORY_PATH = ${process.env[HOME_PATH]}/.smms-cli

// utils
let loadHistory = () => {
try {
let data = fs.readFileSync(DEFAULT_HISTORY_PATH, 'utf8')
data = data.trim()
if (data.length) {
return data.split("\n").map(x => x.split("\t"))
} else {
return []
}
} catch (e) {
return []
}
}

let saveHistory = (smms_history) => {
let data = smms_history.map(x => x.join("\t")).join("\n")
fs.writeFileSync(DEFAULT_HISTORY_PATH, data, 'utf8')
}

let collect = (val, arr) => {
return arr.concat(val)
}

let ts2date = (ts) => {
return new Date(ts * 1000).toLocaleString()
}

let parseGlob = async (files) => {
let result = []
for (let file of files) {
let t = await glob(file)
result.push(...t)
}
return result
}

let smms_history = loadHistory()

commander
.version(smms.VERSION)
.option('-f, --file [file ...]', 'Upload binary image files', collect, [])
.option('-d, --delete [url/hash]', 'Delete image files')
.option('-l --list', 'Show upload history (local)')
.option('--history', 'Show upload history (remote)')
.option('--clear', 'Clear history (both local and romote)')
.parse(process.argv)

if (commander.history) {
smms.history()
.then(result => {
let table = new Table({
head: ['datetime', 'filename', 'url']
})
table.push(...result.data.map(x => {
return [ts2date(x.timestamp), x.filename, x.url]
}))
console.log(table.toString())
})
return
}

if (commander.list) {
let table = new Table({
head: ['datetime', 'filename', 'url']
})
table.push(...smms_history.map(x => {
return [ts2date(x[0]), x[1], x[2]]
}))
console.log(table.toString())
return
}

if (commander.clear) {
smms.clear()
saveHistory([])
return;
}

if (commander.delete) {
let data = smms_history.find(x => {
return x[2] === commander.delete || x[3] === commander.delete
})
if (data === undefined) {
console.error(Sorry, url or hash not found!)
return
}
smms
.delete(data[3])
.then((json) => {
console.log(json.msg)
})
.catch(err => {
console.error(err.msg || err.message)
})
return
}

if (commander.file.length || commander.args.length) {
const args = commander.file.concat(commander.args)

parseGlob(args).then(files => {
let promises = [], output = []
files.forEach((file) => {
promises.push(
smms.upload(file)
.then((json) => {
output.push([json.data.filename, json.data.url])
smms_history.push([json.data.timestamp, json.data.filename, json.data.url, json.data.hash])
})
.catch(err => {
output.push([file, err.msg || err.message])
})
)
})

Promise.all(promises).then(() => {
let table = new Table({
head: ['filename', 'url']
})
table.push(...output)
console.log(table.toString())
saveHistory(smms_history)
})
})
}
#task
我准备先花 20 分钟左右开发个在 Android 上自动启用 USB Tethering (USB 绑定网络)的应用

然后补充一下 Gekyll 的设计,有时间时写
然后给 InScript 添加新特性,假期结束前出总文档

这是上周没有完成的... 😶
Forwarded from Deleted Account
有人用过View自带的playSoundEffect吗?isSoundEffectsEnabled我已经设置成true了,但Play还是没有效果。网上也没找到有效的办法。