Skip to content

Instantly share code, notes, and snippets.

View yourtion's full-sized avatar
🎯
Focusing

郭宇翔 yourtion

🎯
Focusing
View GitHub Profile
@yourtion
yourtion / getMobileprovisionUUID.sh
Created June 27, 2017 07:47
Get mobile uuid from mobileprovision file path
#!/bin/bash
if [ $# -ne 1 ]
then
echo "Usage: getmobileuuid the-mobileprovision-file-path"
exit 1
fi
# mobileprovision_uuid=`grep UUID -A1 -a $1 | grep -o "[-A-Z0-9]\{36\}"`
mobileprovision_uuid=`/usr/libexec/PlistBuddy -c "Print UUID" /dev/stdin <<< $(/usr/bin/security cms -D -i $1)`
echo "UUID is:"
echo ${mobileprovision_uuid}
sed 's/\x1b\[[0-9;]*m//g'
@yourtion
yourtion / NS_ENUM_To_NSString.m
Created December 23, 2015 04:40
convert NS_ENUM to NSString
typedef NS_ENUM(NSInteger, JHAlcoholCategory) {
JHAlcoholCategoryWhiteSpirit = 1,
JHAlcoholCategoryChampagne = 11,
JHAlcoholCategoryWine = 12,
JHAlcoholCategoryLiquer = 16,
JHAlcoholCategoryBeer = 17,
JHAlcoholCategoryWineset = 19,
JHAlcoholCategoryGift = 18,
JHAlcoholCategorySet = 20,
JHAlcoholCategoryOneKey = 21,
const Mocha = require("mocha");
var constants = Mocha.Runner.constants;
var EVENT_RUN_END = constants.EVENT_RUN_END;
var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
var EVENT_SUITE_END = constants.EVENT_SUITE_END;
var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
const t = new Mocha();
t.addFile("./all.spec.js");
@yourtion
yourtion / node-express-zip.js
Created August 16, 2017 09:38
Node.js create zip file with Express
const path = require('path');
const express = require('express')
const app = express()
const archiver = require('archiver')
app.get('/', function(req, res) {
const archive = archiver('zip');
archive.on('error', function(err) {
@yourtion
yourtion / BaiduBcdReader.java
Last active June 28, 2019 09:30
词库文件导出 (搜狗拼音输入法SCEL词库文件解析 、QQ拼音qpyd词库文件解析 、百度拼音输入法BCD词库文件解析 、Lingoes灵格斯电子词典LD2(LDF)文件解析)
/* 百度拼音输入法BCD词库文件解析
* Copyright (c) 2010 Xiaoyun Zhu
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@yourtion
yourtion / backup_mysql.sh
Created June 20, 2019 04:26
备份MySQL并删除旧数据
#!/bin/bash
baseDir="/data/backup/mysql";
userName="root"
password="123456"
host="127.0.0.1"
backup() {
echo "开始备份数据库: $1"
mysqldump -h$host -u$userName -p$password --default-character-set=utf8 $1 | gzip > $baseDir/$1_dump_$(date +%Y%m%d_%H%M%S).sql.tar.gz
echo "备份数据完成";
@yourtion
yourtion / dnspod-ddns.py
Created November 18, 2013 12:47
DNSPod-DDNS
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import urllib2
import urllib
import json
import time
import socket
public_dic={}
public_dic["login_email"]="" #replace your email
@yourtion
yourtion / fmp-timing.js
Created November 26, 2018 07:50
前端监控实践——FMP的智能获取算法 https://segmentfault.com/a/1190000017092752
// https://github.com/qbright/fmp-timing/blob/master/src/fmp-timing.js
const START_TIME = performance && performance.timing.responseEnd;
const IGNORE_TAG_SET = ["SCRIPT", "STYLE", "META", "HEAD", "LINK"];
const TAG_WEIGHT_MAP = {
SVG: 2,
IMG: 2,
CANVAS: 4,
@yourtion
yourtion / Let'sEncrypt.sh
Last active October 4, 2018 04:00
Docker+Nginx+Let'sEncrypt
#!/bin/sh
# https://ruby-china.org/topics/31942
# Install
yum install -y epel-release
yum install -y certbot
# 使用方法:certbot certonly --webroot -w [Web站点目录] -d [站点域名] -m [联系人email地址] --agree-tos
certbot certonly --webroot -w /opt/www/demo.mydomain.com -d demo.mydomain.com -m myname@gmail.com --agree-tos