Skip to content

Instantly share code, notes, and snippets.

View lexrus's full-sized avatar
🏠
Working from home

Lex Tang lexrus

🏠
Working from home
View GitHub Profile
@lexrus
lexrus / auto-run.swift
Last active March 11, 2023 15:27 — forked from mikeash/auto-run.swift
把这个 swift 文件复制到 /usr/local/bin/ 下,chmod +x /usr/local/bin/auto-run.swift 。然后每次执行 auto-run.swift 都会检查是否需要重新编译,最后会执行编译后的 auto-run.swiftc。需要 Xcode 6.0+,亲测 bash 和 zsh 下可用,fish 下会报错。
/*/../usr/bin/true
source="$0"
compiled="$0"c
if [[ "$source" -nt "$compiled" ]]; then
DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer xcrun swiftc -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -g "$source" -o "$compiled" || exit
fi
"$compiled"
// Public domain - https://gist.github.com/nolanw/dff7cc5d5570b030d6ba385698348b7c
import Foundation
extension URLRequest {
/**
Configures the URL request for `multipart/form-data`. The request's `httpBody` is set, and a value is set for the HTTP header field `Content-Type`.
- Parameter parameters: The form data to set.
@lexrus
lexrus / vpn.sh
Last active December 21, 2015 02:49 — forked from alvinl/vpn.sh
#!/bin/bash
#apt-get update
apt-get install pptpd -y --force-yes
echo localip 192.168.240.1 >> /etc/pptpd.conf
echo remoteip 192.168.240.2-200 >> /etc/pptpd.conf
echo ms-dns 8.8.8.8 >> /etc/ppp/pptpd-options
echo ms-dns 8.8.4.4 >> /etc/ppp/pptpd-options
echo "lex pptpd lexrusontwitter *" | tee -a /etc/ppp/chap-secrets
/etc/init.d/pptpd restart
@lexrus
lexrus / vim.rb
Last active December 14, 2015 01:59 — forked from uasi/vim.rb
require 'formula'
class Vim < Formula
homepage 'http://www.vim.org/'
url 'ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2'
head 'https://vim.googlecode.com/hg/'
sha256 '5c5d5d6e07f1bbc49b6fe3906ff8a7e39b049928b68195b38e3e3d347100221d'
version '7.3.682'
def features; %w(tiny small normal big huge) end
@lexrus
lexrus / build.py
Last active October 13, 2015 07:08 — forked from rjyo/build.py
OTA builder
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import json
import getopt
import urllib2
import commands
import string
@lexrus
lexrus / Makefile
Created March 30, 2012 08:59 — forked from hiroshi/Makefile
Makefile for Testflight upload
# Testflight web interface doesn't allow input non-ASCII characters (e.g. Japanese) with Safari!
BROWSER = Safari
TESTFLIGHT_TEAM_TOKEN_FILE = ./.testflight_team_token
TESTFLIGHT_TEAM_TOKEN_URL = https://testflightapp.com/dashboard/team/edit/?next=/api/doc/
TESTFLIGHT_TEAM_TOKEN = $(shell cat $(TESTFLIGHT_TEAM_TOKEN_FILE))
TESTFLIGHT_API_TOKEN_FILE = ~/.testflight_api_token
TESTFLIGHT_API_TOKEN_URL = https://testflightapp.com/account/\#api-token
TESTFLIGHT_API_TOKEN = $(shell cat $(TESTFLIGHT_API_TOKEN_FILE))
TESTFLIGHT_NOTES = 'This build was uploaded via the upload API'
#TESTFLIGHT_OTHER_OPTIONS = -F replace=True