Skip to content

Instantly share code, notes, and snippets.

View 1c7's full-sized avatar

ZhengCheng 1c7

View GitHub Profile
@1c7
1c7 / snippet_for_blog.html
Created January 8, 2019 03:35
微信小程序代码
<image class='图片position:relative' src="{{例子}}" bind:tap='click_image' mode='widthFix'>
<view catch:tap='删除标签函数' data-tag="{{i}}" class='tag_on_image' wx:key="{{i}}" wx:for='{{tag_array}}' wx:for-item='i' data-item='{{i}}' style="position:absolute; left:{{i.x}}px;top:{{i.y}}px;">
{{i.name}}
</view>
</image>
@1c7
1c7 / 1.sh
Created January 1, 2019 09:05
test Ghost+Github
echo "Hello Ghost from Github"
@1c7
1c7 / copy-your-subreddit-list.js
Last active November 30, 2018 06:48
copy your subreddit list
// Step 1: visit
// https://www.reddit.com/subreddits/
// Step 2:
// copy & past these into Chrome developer tool
var array = []
document.querySelectorAll('.subscription-box ul li').forEach(function(element) {
var subreddit = element.querySelector('a[class="title"]')
subreddit_name = subreddit.innerText
@1c7
1c7 / grap youtube playlist title.js
Created November 24, 2018 17:26
grap youtube playlist title
var original = $('#playlist tr span').text().split('\n')
original.splice(0,1)
var res = original.filter((element, index) => {
return index % 2 == 0;
})
var result = res.map(s => s.trim());
result.join('\n')
@1c7
1c7 / show_finger_real_time.js
Last active November 19, 2018 10:47
Show number of finger touch screen in Real time
$("#camera-controller").on("touchstart", (e) => {
var fingerOnScreen = e.originalEvent.targetTouches.length;
$('#finger_count').text(fingerOnScreen);
});
$("#camera-controller").on("touchend", (e) => {
var fingerOnScreen = e.originalEvent.targetTouches.length;
$('#finger_count').text(fingerOnScreen);
});
@1c7
1c7 / wechat_imgSecCheck_Demo.js
Last active November 4, 2018 14:37
微信内容安全,参考代码
// 微信小程序,内容安全示例代码
const qiniuUploader = require("../../utils/qiniuUploader.js"); // https://github.com/gpake/qiniu-wxapp-sdk
const wittcism = require('../../utils/wittcism.js') // API
Page({
data: {},
onShow() {},
change_avatar() {
qiniuUploader.upload(filePath, (res) => {
var original_qiniu_link = res.qiniu_url
<template lang='pug'>
// 社交媒体账号
.box-icon-line
.icon.wechat(@click='wechat_click')
img(src='/static/app-image/icon-wechat-color.png', alt='wechat icon')
</template>
<script>
export default {
@1c7
1c7 / wechat.vue
Last active October 31, 2018 09:16
微信桌面端二维码登录的 redirect_url 地址
<!-- 微信登录:电脑端的 redirect_uri, 接收到来自微信的 code, 然后这个页面负责做下一步操作(把 code 传给后端)-->
<template lang='pug'>
#root
.hint
h3
| {{message}}
</template>
<script>
import { mapGetters, mapActions } from 'vuex';
@1c7
1c7 / 微信小程序 wxs 头像 filter.js
Created October 15, 2018 12:08
微信小程序 wxs 头像 filter
/*
用户的头像 url 有3种可能:
1. 空
代表是默认头像
2. avatar-2018-07-24-16-26-52-Fs0NsdbSY8dPPvJjiXFKs-M8ISLG.jpg
代表是用户自定义头像,前面要加上 https://img.wittcism.com
3. https://wx.qlogo.cn/mmopen/vi_32/Da3any5kia1kePickTDzlMJTRQMFJbaebPebFlicbXF6WkT6vH325DDGcNm3zNZX1r4Wtpg7ZjUarezKPVvV8bHpw/132"
代表是微信登录的头像
avatar 这个 filter 要进行正确的处理,3种情况下都返回正确的 URL
@1c7
1c7 / nginx.conf
Created September 14, 2018 08:59
Nginx Safety Checklist
# For Safety
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header Content-Security-Policy "default-src https: data: 'unsafe-inline' 'unsafe-eval'" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Xss-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
server_tokens off;
add_header Referrer-Policy "no-referrer-when-downgrade";
add_header Feature-Policy "midi none;notifications none;push none;sync-xhr none;microphone none;camera none;magnetometer none;gyroscope none;speaker self;vibrate none;fullscreen self;payment none;";
# Sources: