This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
isValidURL(url) { | |
var res = url.match( | |
/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/g | |
); | |
return res !== null; | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { store } from '@/store/index' | |
const userInfo = store.getters['user/userInfo'] | |
userInfo.authorityId | |
import { mapGetters } from "vuex"; | |
computed: { | |
...mapGetters("user", ["userInfo", "token"]), | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user := User{Name: "Jinzhu", Age: 18, Birthday: time.Now()} | |
result := db.Create(&user) // 通过数据的指针来创建 | |
user.ID // 返回插入数据的主键 | |
result.Error // 返回 error | |
result.RowsAffected // 返回插入记录的条数 | |
//创建一个记录且一同忽略传递给略去的字段值。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#批量修改表字段 | |
SELECT CONCAT('alter table ',TABLE_NAME,' modify ',COLUMN_NAME,' varchar(500) ;') AS '修改语句' | |
FROM INFORMATION_SCHEMA.COLUMNS | |
WHERE TABLE_SCHEMA='scrm_wechat_1' AND COLUMN_NAME IN ('resource_url') | |
# 批量修改 rtpsystem_go中所有deleted_at字段默认值为null | |
SELECT | |
CONCAT( 'alter table ', TABLE_NAME, ' modify ', COLUMN_NAME, ' timestamp NULL DEFAULT NULL ;' ) AS '修改语句' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//普通POST请求 | |
resp, err := http.Post( | |
"http://xxxx.com", | |
"application/x-www-form-urlencoded", | |
strings.NewReader(bodyStr)) | |
if err != nil { | |
fmt.Println(err) | |
} | |
defer resp.Body.Close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//互斥锁 | |
//互斥即不可同时运行。即使用了互斥锁的两个代码片段互相排斥,只有其中一个代码片段执行完成后,另一个才能执行。 | |
//互斥锁是传统的并发程序对共享资源进行访问控制的主要手段,在 Go 中,似乎更推崇由 channel 来实现资源共享和通信。它由标准库代码包 sync 中的 Mutex 结构体类型代表。只有两个公开方法:调用 Lock()获得锁,调用 unlock()释放锁。 | |
/** | |
https://learnku.com/go/t/32513 | |
使用 Lock () 加锁后,不能再继续对其加锁(同一个 goroutine 中,即:同步调用),否则会 panic。只有在 unlock () 之后才能再次 Lock ()。异步调用 Lock (),是正当的锁竞争,当然不会有 panic 了。适用于读写不确定场景,即读写次数没有明显的区别,并且只允许只有一个读或者写的场景,所以该锁也叫做全局锁。 | |
func (m *Mutex) Unlock () 用于解锁 m,如果在使用 Unlock () 前未加锁,就会引起一个运行错误。已经锁定的 Mutex 并不与特定的 goroutine 相关联,这样可以利用一个 goroutine 对其加锁,再利用其他 goroutine 对其解锁。 | |
**/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
//需求就是 Product 的Chance越大 抽到的几率越小 | |
// 来源 https://segmentfault.com/q/1010000021810370?utm_source=tag-newest | |
// 一般抽奖设计,Chance 是表示中奖概率,你这种反向操作的其实有点变态 | |
// 特别是你给出的数据中两个 Chance = 0 ; 这想表示什么; | |
// 按照正常操作,我们都是将各个抽奖商品的中奖概率进行累加,然后随机取值在累加和范围内选中抽奖商品 | |
// OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// vim: syntax=js | |
v-on:keyup="getProd" //绑定事件 | |
v-on:click="activite(item.id,$event,'activite')" | |
:pid="['p'+ item.id]" //拼接绑定数据 | |
// 条件渲染 | |
v-if="province_status" //province_status为true则显示元素 | |
<h1 v-if="ok">Yes</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// vim: syntax=js | |
$(".class_name").html(); //样式选择器 | |
$("#id_name").html(); //ID选择器 | |
$("#name > .img").val(); //子选择器 | |
$(function () { | |
$('#box1').foucs(); //获取焦点 | |
$('#box2').blur(); //失去焦点 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// vim: syntax=css | |
/* 兼容iphone5/SE */ | |
@media (device-height:568px) and (-webkit-min-device-pixel-ratio:2){ | |
.member-info-score{ | |
float:right;width:70%;margin-top:.7rem; | |
} | |
} |
NewerOlder