Skip to content

Instantly share code, notes, and snippets.

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

ZHANG Yi dorentus

🎲
🌎🌍🌏
View GitHub Profile
@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

@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'
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

测试平台: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     #编译所需要的软件
@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 }
@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)
@lucholaf
lucholaf / gist:e37f4d26e406250a156a
Last active September 5, 2016 15:06
Xcode pre-action: generate Swift FAT file to reduce compilation time, since it's faster to recompile the whole source code in a single file
> $PROJECT_DIR/merge.swift; find $PROJECT_DIR/ -iname *.swift -not -name merge.swift -exec cat {} >> $PROJECT_DIR/merge.swift \;
@soffchen
soffchen / Surge.md
Last active April 25, 2025 12:25
Surge

Feature

  • 替代 PAC,实现根据规则区分选择代理线路
  • 支持 SOCKS5 和 Shadowsocks 协议
  • 完整支持所有的 Shadowsocks 加密方式 (table, rc4-md5, salsa20, chacha20, aes-256-cfb, aes-192-cfb, aes-128-cfb, bf-cfb, cast5-cfb, des-cfb, rc2-cfb, rc4, seed-cfb)
  • 全面支持双向 HTTP Keep-Alvie
  • 快,各种黑科技加速
  • 直接临时修改某个域名的访问规则 (暂时仅 Mac 版本)
  • 支持使用 GeoIP 规则决定线路

Usage

@sharplet
sharplet / trap.swift
Created November 23, 2015 03:46
Simple signal handling in Swift
import Darwin
enum Signal: Int32 {
case HUP = 1
case INT = 2
case QUIT = 3
case ABRT = 6
case KILL = 9
case ALRM = 14
case TERM = 15
@steipete
steipete / PSPDFBlockAssert.m
Created January 12, 2016 21:56
Check if object is a block - nice for assertions.
PSPDF_EXTERN BOOL PSPDFIsBlock(id _Nullable block) {
static Class blockClass;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
blockClass = [^{} class];
while ([blockClass superclass] != NSObject.class) {
blockClass = [blockClass superclass];
}
});