Skip to content

Instantly share code, notes, and snippets.

View introom's full-sized avatar

introom

View GitHub Profile
@introom
introom / asyncio_ssl_example.py
Created November 28, 2016 14:24 — forked from messa/asyncio_ssl_example.py
Python asyncio + SSL TCP client/server example
#!/usr/bin/env python3
import asyncio
import multiprocessing
import os
import ssl
from time import sleep
port = 9000

测试平台:DigitalOcean VPS ubuntu14.04 x64, strongswan5.2.2

运行以下命令请使用root权限

一:安装strongswan

由于ubuntu软件仓库中strongswan版本较低,因此从官网源码编译安装

apt-get install build-essential     #编译环境
aptitude install libgmp10 libgmp3-dev libssl-dev pkg-config libpcsclite-dev libpam0g-dev     #编译所需要的软件
@introom
introom / checknet.sh
Created April 2, 2016 15:24
checknet
#!/usr/bin/env bash
trap "exit" INT
while true; do
ping -t 2 google.com >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
osascript -e 'tell app "System Events" to display dialog "你网又断了"' >/dev/null 2>&1
fi
done
(message)
(find-function-setup-keys)
(featurep 'ibuffer)
@introom
introom / zshenv
Created January 10, 2015 04:36
Apple's shipped /etc/zshenv sucks. The path_helper is broken.
# system-wide environment settings for zsh(1)
#
# NB the following file is broken, per ##zsh channel.
# if [ -x /usr/libexec/path_helper ]; then
# eval `/usr/libexec/path_helper -s`
# fi
#
# custom
# ensure no duplicate
typeset -gU path
import re
import shutil
import argparse
from os import path
from sys import stderr
#
# Author: Daxda
# Date: 02.04.2014
# WTF: This is a quick tool I've hacked together to easily remove the meta
@introom
introom / change_mod.py
Created April 18, 2014 04:57
Python change all files mode to read only. (excluding hidden files)
#!/usr/bin/env python
"""
This script sets all files (excluding hidden ones)
to read-only mode.
"""
from __future__ import print_function
import sys
import os
import glob
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
Bundle 'gmarik/vundle'
Bundle 'scrooloose/nerdtree'
Bundle 'Raimondi/delimitMate'
Bundle 'SirVer/ultisnips'
Bundle 'Valloric/YouCompleteMe'
@introom
introom / gist:9502141
Created March 12, 2014 06:59
Fix this error "clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]" with ARCHFLAGS
Compiler
As of Apple LLVM compiler version 5.1 (clang-502) and later, the optimization level -O4 no longer implies link time optimization (LTO). In order to build with LTO explicitly use the -flto option in addition to the optimization level flag. (15633276)
The Apple LLVM compiler in Xcode 5.1 treats unrecognized command-line options as errors. This issue has been seen when building both Python native extensions and Ruby Gems, where some invalid compiler options are currently specified.
Projects using invalid compiler options will need to be changed to remove those options. To help ease that transition, the compiler will temporarily accept an option to downgrade the error to a warning:
-Wno-error=unused-command-line-argument-hard-error-in-future
Note: This option will not be supported in the future.
To workaround this issue, set the ARCHFLAGS environment variable to downgrade the error to a warning. For example, you can install a Python native extension with:
@introom
introom / dns.py
Created December 16, 2013 13:17 — forked from johnboxall/dns.py
# http://notmysock.org/blog/hacks/a-twisted-dns-story.html
# http://blog.inneoin.org/2009/11/i-used-twisted-to-create-dns-server.html
# twistd -y dns.py
import socket
from twisted.internet.protocol import Factory, Protocol
from twisted.internet import reactor
from twisted.names import dns
from twisted.names import client, server