Skip to content

Instantly share code, notes, and snippets.

View panw3i's full-sized avatar
🌴
On vacation

panw3i panw3i

🌴
On vacation
View GitHub Profile
@panw3i
panw3i / docker-compose-latest.sh
Last active October 9, 2024 01:08
Script to automatically download the latest version of Docker Compose
echo 'LATEST_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep '"'"'tag_name'"'"' | sed -E '"'"'s/.*"v([^"]+)".*/\1/'"'"') && \
sudo curl -L "https://github.com/docker/compose/releases/download/v$LATEST_VERSION/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \
sudo chmod +x /usr/local/bin/docker-compose' > docker-compose-latest.sh
@panw3i
panw3i / my_gist.txt
Created October 9, 2024 01:05
My First Gist using GitHub CLI
Hello, this is my Gist content!
let json = [
{
id: '1',
name: '节点1',
children: [
{
id: '1-1',
name: '节点1-1',
children: [
{
@panw3i
panw3i / stopwords.txt
Created January 7, 2020 04:58
停用词
!
"
#
$
%
&
'
(
)
*
@panw3i
panw3i / stopwords.txt
Created January 7, 2020 04:58
停用词
!
"
#
$
%
&
'
(
)
*
@panw3i
panw3i / stopwords.txt
Created January 7, 2020 04:58
停用词
!
"
#
$
%
&
'
(
)
*
@panw3i
panw3i / DeviceSerializer.py
Created January 6, 2020 02:20
SerializerMethodField 序列化指定字段,该字段可不在模型类中
class DeviceSerializer(serializers.ModelSerializer):
"""
设备序列化
"""
cabinet = serializers.SerializerMethodField()
def get_cabinet(self, obj):
cabinets = Cabinet.objects.filter(id=obj.cabinet_id)
if cabinets is not None and len(cabinets) > 0:
return CabinetSerializer(cabinets[0]).data
@panw3i
panw3i / download-file.js
Created March 4, 2019 14:36 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@panw3i
panw3i / subscribes.js
Created March 2, 2019 13:12
订阅与发布
// 两者有啥区别呢?容易看出,用时执行模式,每次在创建一个新的matchEmail2时候,都会新建一个闭包,和创建一个新的 regx
// 立即执行啥时候用呢? 一般是在封装的遍历在函数引用中都是有同一个时,如果不同情况需要使用多个,那么使用用时执行
// 很显然,我们如果想要创建一个对象系统的话,需要用用时执行模式
var Events = function() {
var handlers = {};
var subscribe = function(type, handler) {
if (!handlers[type]) {
handlers[type] = [];
}
@panw3i
panw3i / upload-flie.vue
Last active March 2, 2019 08:11
Vue上传文件
<template>
<div class="container">
<div class="large-12 medium-12 small-12 cell">
<label>File
<input type="file" id="file" ref="file" v-on:change="handleFileUpload()"/>
</label>
<button v-on:click="submitFile()">Submit</button>
</div>
</div>
</template>