Skip to content

Instantly share code, notes, and snippets.

View dorentus's full-sized avatar
🎲
🌎🌍🌏

ZHANG Yi dorentus

🎲
🌎🌍🌏
View GitHub Profile
@robertjpayne
robertjpayne / SwiftStaticCompile.rb
Last active April 23, 2017 15:40
A ruby function to generate a static library + clang module from a single Swift source file
require "Subprocess"
require "tmpdir"
#
# Currently will only convert a single swift code file into a static library
# and cannot include any Objective-C code.
#
# Usage: generate("/path/to/MyCode.swift", :ios)
#
def generate(file, platform, dst=nil)
@marklarr
marklarr / swiftRegex.swift
Created June 3, 2014 06:53
Ruby-esque regex in Swift
// Regex
import Foundation
operator infix =~ {}
@infix func =~ (str: String, pattern: String) -> Bool {
var error: NSError?
let regex = NSRegularExpression.regularExpressionWithPattern(pattern, options: nil, error: &error)
if (error) { return false }

测试平台: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     #编译所需要的软件
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDNvfUw8zgNbMEQmyfFhN2CGa5m+oRkUXRbzdZkyyqj8/SMTflfMRXBZOLKPGnSZv9ZazRdGUA6FS2CcrCqGzsxwDHVxvQo2RfbYMLo0181GJIFQq2WA0GfSgtPJ57agHNgMQcOeir0dexJ7z9CZRGGf4e+7ByTKROvq67ZziOIxYpquKG8+uCdIvd8QP6sXHGFL0DuLjaGzfDnj7FORC7sgGaxrcuAE8BAEAKWlTQSbSaM1hv7Vka/XxVXwA71bjb5ZZTpZkNBHskK/ffY2XCjzxGbqab6aV8eeBSzRGg32UulIhN159Zwsy6qxfXk6ceQDZLa5nSCUhww/j9947/3 [email protected]
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAIAQCdVrmIoEVyyYSRuEeC+Vzg1pzE3r/JRSLIexLsZzYHe/E+BXy49r0wOPGUyWJoeBdyGp7clz2FYFO62nFxJFQ+dZZg6lwrpBXts4d8Teau5t0x6MDn/ZRpT0ztJCYi3RyonHwDMA2zyxYVuWLtx7esKKvZOqOXzuVVyWgJCqadgL0a4286D9PJnG9K10+nDxRti99ykVLABczf9E81HJQlLoNi1zVZZzty1JWuX7NTvLJcEppSYWrxDln8SV8Mp88Yb9YDdfXZIGG7TkqWGESkxBNLI/h813Q/J+UzsDHxDW+mzQ3x5XViPIRShb1HbB9hCQ2UxCXLUPyYtXKSRziYZG9wijjHJ9CC1tuQZ1vcd/b+0XoYe782g1n4uHw8wmzlVBHaVX/h4ndek+/coo8LcUBHhfMnSUfaEu0WsYjI44yy4H7DZBRmPanc9MNYXoeUtBwG9vkb48CSWmNdqzspOKRoi/lJ26o3npyDXi4tP9/H8zyWY7DMMXi5OzKmM235ezZbgUfjx2sFLvPO7sBQ01w4v7slNQtYUpAWRLwPm9DAB10xzxul0e8Gdy0InVxgBeAkom
@dorentus
dorentus / build_config.rb
Last active August 31, 2020 01:53
Put build_config.rb into mruby root dir, make, and put build_framework.rb into build dir and run it to get a MRuby.framework, run collect_mrb_gem_archive.rb <gem_name> in build dir to get a seperate <gem_name>.framework
MRuby::Build.new do |conf|
toolchain :clang
conf.gembox 'default'
end
def crossbuild_for(name, platform, sysroot, cc_defines = [])
MRuby::CrossBuild.new(name) do |conf|
toolchain :clang
conf.gembox 'default'
@edubkendo
edubkendo / atom_opal.md
Last active April 19, 2018 05:09
Writing Atom Plugins in Opal (Ruby)

I want to write plugins for Atom's editor in Ruby. Opal makes this possible. Atom is one of several projects in recent times to combine Chromium with Node.js for a desktop app. While it utilizes chromium for it's gui, and boasts "[e]very Atom window is essentially a locally-rendered web page", writing Atom plugins is more like writing a server-side node.js app than a typical single-page client-side app (albeit with really awesome integration with Chrome Devtools). Opal development, on the other hand, has to-date been focused primarily on the browser use-case.

Because of this, I had to make a choice between using the opal-node package from npm, using Opal via Ruby w/ a compile step, or packaging up opal-parser.js, including it with the app, and writing in compilation on the fly. Each choice came with compromises. Using opal-node would have been easiest, just create a top level index.coffee that required opal-node, and then require in your ruby

@jazzsasori
jazzsasori / gist:9051537
Created February 17, 2014 14:27
BlocksKit 2.0
// 今までの書き方
#import <BlocksKit/BlocksKit.h>
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addEventHandler:^(id sender) {
// do something
} forControlEvents:UIControlEventTouchUpInside];
// 2.0の書き方
@dorentus
dorentus / ramdish.sh
Last active February 9, 2017 08:19
ramdisk.sh
#!/bin/bash
RD=ramdisk
if [ ! -e "/Volumes/$RD" ]; then
diskutil erasevolume HFS+ "$RD" `hdiutil attach -nomount ram://16777216` # 8G
# ~/Library/Developer/Xcode
mkdir -p "/Volumes/$RD/Xcode"
@steipete
steipete / UIKitLegacyDetector.m
Last active April 29, 2025 20:17
A simple way to detect at runtime if we're running in UIKit legacy mode or the new "flat" variant. Written for our PDF iOS SDK (http://pspdfkit.com), where the precompiled binary needs to detect at runtime in what variant it's running. Want more stuff like that? Follow me on Twitter: http://twitter.com/steipete
// Taken from http://PSPDFKit.com. This snippet is under public domain.
#define UIKitVersionNumber_iOS_7_0 0xB57
BOOL PSPDFIsUIKitFlatMode(void) {
static BOOL isUIKitFlatMode = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// We get the modern UIKit if system is running >= iOS 7 and we were linked with >= SDK 7.
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) {
isUIKitFlatMode = (NSVersionOfLinkTimeLibrary("UIKit") >> 16) >= UIKitVersionNumber_iOS_7_0;
}
extern uint32_t dyld_get_program_sdk_version() WEAK_IMPORT_ATTRIBUTE;
extern BOOL DZApplicationUsesLegacyUI(void)
{
static dispatch_once_t onceToken;
static BOOL legacyUI = NO;
dispatch_once(&onceToken, ^{
uint32_t sdk = __IPHONE_OS_VERSION_MIN_REQUIRED;
if (dyld_get_program_sdk_version != NULL) {
sdk = dyld_get_program_sdk_version();