Skip to content

Instantly share code, notes, and snippets.

View yourtion's full-sized avatar
🎯
Focusing

郭宇翔 yourtion

🎯
Focusing
View GitHub Profile
#!/bin/sh
# monit add : iptables -I OUTPUT -s 你的服务器IP -p tcp --sport 开放的端口
# show : iptables -n -v -L -t filter
#统计流量
flowname="/data/log/vpn/flow.log"
flownametail="/data/log/vpn/flow_tail.log"
flowregex="spt:端口起始到结尾"
@yourtion
yourtion / mount_ntfs.sh
Created March 6, 2018 06:37
Mac下NTFS可写
1、列出所有的外接存储设备
$ diskutil list external
/dev/disk2 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *15.9 GB disk2
1: Windows_NTFS DBand 15.9 GB disk2s1
2、解挂载然后重新挂载
# 解挂载
function render(template, context) {
return template.replace(/\{\{(.*?)\}\}/g, (match, key) => context[key]);
}
const template = "{{name}}很厉name害,才{{age}}岁";
const context = { name: "yourtion", age: "15" };
console.log(render(template, context));
@yourtion
yourtion / vscode.js
Last active February 5, 2018 10:07
Settings
// Place your settings in this file to overwrite the default settings
{
"editor.fontFamily": "Hack",
"templates.Author": "Yourtion Guo <yourtion@gmail.com>",
// Editor
"editor.tabSize": 2,
"editor.insertSpaces":true,
// "editor.formatOnPaste": true,
"editor.quickSuggestions": {
"other": true,
@yourtion
yourtion / master.js
Created February 2, 2018 15:38
Node.js Simple IPC Timmer Demo
const { fork } = require('child_process');
const crypto = require('crypto');
const timmer = fork('./timmer.js');
let lastTime = Date.now();
let localTime = Date.now();
timmer.on('message', (m) => {
console.log('remote: ', m.time - lastTime - 1000 + 'ms');
@yourtion
yourtion / proxy.conf
Created January 8, 2018 02:49
NginxProxyConfig
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
@yourtion
yourtion / unpack_plist.py
Last active October 19, 2017 10:33
unpack plist image
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os,sys
from xml.etree import ElementTree
from PIL import Image
import logging
DEBUG = False
# 设置默认的level为DEBUG
@yourtion
yourtion / git_log.sh
Last active July 3, 2017 07:19
Get Last Git commit log
# Simple
git log --oneline -n 1
# val
log=`git log --oneline -n 1` && echo $log
# Only Mesg
log=`git log --oneline -n 1` && $log=${log:8} && echo $log
@yourtion
yourtion / cleanMacDocker.sh
Created March 19, 2017 03:32
cleanMacDocker - 清理mac上Docker占用的磁盘空间
#!/bin/bash
# Copyright 2017 Théo Chamley
# 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:
#
# The above copyright notice and this permission notice shall be included in all copies or
@yourtion
yourtion / socketReachabilityTest.m
Created March 3, 2017 09:38
socketReachabilityTest - 服务器可达返回true
/// 服务器可达返回true
#import <arpa/inet.h>
- (BOOL)socketReachabilityTest {
// 客户端 AF_INET:ipv4 SOCK_STREAM:TCP链接
int socketNumber = socket(AF_INET, SOCK_STREAM, 0);
// 配置服务器端套接字
struct sockaddr_in serverAddress;
// 设置服务器ipv4
serverAddress.sin_family = AF_INET;
// 百度的ip