Skip to content

Instantly share code, notes, and snippets.

@masdude
masdude / readme.txt
Last active May 5, 2023 12:13
小容量MBP外接固态硬盘扩容解决方案
针对小容量mac book扩容的解决方案
需要购买:
1.nvme硬盘盒
2.大容量 nvme固态硬盘(推荐500G以上容量)
推荐下面这种侧插式nvme硬盘盒,完美匹配mac book,速度是10Gb/s,而且关机也不用取下。
缺点是要占用一边两个雷电接口,硬盘盒自带一个充电接口,
算下来其实还好,不充电的情况下,多占了一个雷电接口。
@masdude
masdude / gist:b4f3e2b361236c2ebfd794b5ab6d35a3
Created November 22, 2019 07:03 — forked from bryhal/gist:4129042
MYSQL: Generate Calendar Table
DROP TABLE IF EXISTS time_dimension;
CREATE TABLE time_dimension (
id INTEGER PRIMARY KEY, -- year*10000+month*100+day
db_date DATE NOT NULL,
year INTEGER NOT NULL,
month INTEGER NOT NULL, -- 1 to 12
day INTEGER NOT NULL, -- 1 to 31
quarter INTEGER NOT NULL, -- 1 to 4
week INTEGER NOT NULL, -- 1 to 52/53
day_name VARCHAR(9) NOT NULL, -- 'Monday', 'Tuesday'...
@masdude
masdude / README.md
Created June 30, 2018 03:16 — forked from billryan/README.md
DNSPod DDNS Python Script

替换上你的ID, Token, domain, sub_domain 就可以运行了。(ID,Token) 可以从 API 鉴权方式升级为 Token 获得。 脚本会在后台一直运行,初始化时会根据 sub_domain 查询是否已经创建,每隔30秒检查一遍IP,如果修改了就更新IP。

以 Archlinux 为例,按照如下步骤操作即可设置开机启动这个 DDNS 服务。

sudo wget -O /usr/local/bin/dnspod_ddns.py https://gist.github.com/billryan/239778f0821937939c8c140bdddd6840/raw/dnspod_ddns.py
sudo chmod +x /usr/local/bin/dnspod_ddns.py
sudo wget -O /etc/systemd/system/dnspod-ddns.py.service https://gist.github.com/billryan/239778f0821937939c8c140bdddd6840/raw/dnspod-ddns.service
sudo systemctl start dnspod-ddns
@masdude
masdude / README.md
Last active August 29, 2015 14:10 — forked from chuangbo/README.md

替换上你的Email,密码,域名ID,记录ID等参数,就可以运行了。 会在后台一直运行,每隔30秒检查一遍IP,如果修改了就更新IP。

获得domain_id可以用curl curl -k https://dnsapi.cn/Domain.List -d "login_email=xxx&login_password=xxx"

获得record_id类似 curl -k https://dnsapi.cn/Record.List -d "login_email=xxx&login_password=xxx&domain_id=xxx"

# Ubuntu PHP mail
# Ubuntu 12.04 LTS
# IMPORTANT : add your own data or parameters, I make use of double segments [[ your variable ]]. eg. ssh root@[[ 96.172.44.11 ]] should be replaced with ssh root@888.88.88.88 where "888.88.88.88" is your value, variable etc. I have a habit of using ":::" to indicate line ending and end of paragraph, crazy I know but be warned its just how I write ::: All notes are for my own use & should you use any it's at your own risk, it's NOT a Tutorial :::
# Resources
# https://help.ubuntu.com/12.04/serverguide/postfix.html
# http://sourcelibrary.org/2011/08/29/how-to-set-up-the-php-mail-function-on-a-ubuntu-linux-lamp-server/
# http://stackoverflow.com/questions/12083025/xampp-on-ubuntu-server-12-04-with-pear-installed-returns-errors-when-trying-to-u
# http://askubuntu.com/questions/47609/how-to-have-my-php-send-mail
# This method finds related articles using Jaccard index (optimized for PostgreSQL).
# More info: http://en.wikipedia.org/wiki/Jaccard_index
class Article < ActiveRecord::Base
def related(limit=10)
Article.find_by_sql(%Q{
SELECT
a.*,
( SELECT array_agg(t.name) FROM taggings tg, tags t
#!/usr/bin/env ruby
# Please read http://otobrglez.opalab.com for more information about this code.
class Book < Struct.new(:title)
def words
@words ||= self.title.gsub(/[a-zA-Z]{3,}/).map(&:downcase).uniq.sort
end

SAE 初体验

一直在用SAE做一些个人的小型项目,印象比较深刻的,还算成功的有两个:

一个是某品牌的现场活动,通过摄像头拍摄4张不同动作的照片,然后合成一张gif动画照片,合成完毕后会获得一个序列号,只要在微信上关注活动号,并发送序列号就能拿到gif动画,程序还自动发送微博到官方号上。利用SAE最大的好处就是其中很多组件节省了很多时间,例如存储、图片处理、任务系统等等。因为活动是阶段性的,所以活动结束后,站点就可以关闭,不像以前服务器都是一年起租。

另一个是朋友店里的微信托管,朋友的店是具有三家分店的汗蒸店,本来微信上用户就不少,之前都是用来发送一些品牌故事、优惠活动等消息。后来朋友想在微信上实现预约,由于订阅号的限制还是很大,所以申请为服务号,通过HTML5等实现了在线预约,现在刚刚开始使用,每天预约量还不大,相信经过一定的推广,会有越来越多的人使用。用户在在线预约后,如果条件不是特别特殊,会自动回复用户确认预定,如果条件比较特殊,会通过微信将消息直接发送给各分店店长,店长回复确认与否。

所以说,SAE还是大大简化的开发的流程,使得不用关心很多底层服务,把更多的心思放在了程序逻辑本身。更何况,费用上还是很低廉的。

Channel 初体验

#! /bin/env python
# -*- coding: utf-8 -*-
#
#todo:
# 使用python3
# 计算md5,不用文件名来避免重复,储存
# 存储信息:json? pickle? txt?数据库? 要包括 点赞数 记录当前状态下一次继续(可行?)
# 改善递归: 循环套递归?
# py2exe pyinstall?
# beautiful soup
@masdude
masdude / README.md
Created February 23, 2014 15:43 — forked from chuangbo/README.md

替换上你的Email,密码,域名ID,记录ID等参数,就可以运行了。 会在后台一直运行,每隔30秒检查一遍IP,如果修改了就更新IP。

获得domain_id可以用curl curl -k https://dnsapi.cn/Domain.List -d "login_email=xxx&login_password=xxx"

获得record_id类似 curl -k https://dnsapi.cn/Record.List -d "login_email=xxx&amp;login_password=xxx&amp;domain_id=xxx"