Skip to content

Instantly share code, notes, and snippets.

ShuYu Wang andelf

Block or report user

Report or block andelf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@andelf
andelf / wait_for_pid.py
Created Dec 27, 2016
Ansible task: wait for pid and threads
View wait_for_pid.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import binascii
import datetime
import math
import re
import select
import socket
import sys
@andelf
andelf / install_swift_snapshot_to.sh
Created Apr 28, 2016
Swift Development Snapshot Install Script
View install_swift_snapshot_to.sh
#!/bin/sh
# FileName : install_swift_to.sh
# Author : ShuYu Wang <andelf@gmail.com>
# Created : Thu Apr 28 12:21:46 2016 by ShuYu Wang
# Copyright : Feather Workshop (c) 2016
# Description : Swift Snapshot Installing Script
# Time-stamp: <2016-04-28 12:22:51 andelf>
OLDPWD=$(pwd)
@andelf
andelf / racer-auto-complete.el
Last active Oct 4, 2015
Racer Auto-Complete Mode
View racer-auto-complete.el
;; FileName : racer-autocomplete.el
;; Author : ShuYu Wang <andelf@gmail.com>
;; Created : Wed May 20 10:08:03 2015 by ShuYu Wang
;; Copyright : Feather Workshop (c) 2015
;; Description : racer auto-complete source
;; Time-stamp: <2015-05-20 10:08:18 andelf>
;;; copy this to your load-path and add following to your ~/.emacs
;; (setq racer-cmd "/your/path/to/bin/racer")
@andelf
andelf / Optional-ext.swift
Last active Nov 21, 2018
Swift Optional Extension
View Optional-ext.swift
protocol Index {
typealias IndexType
typealias Result
subscript (i: IndexType) -> Result { get }
}
protocol IndexMut: Index {
typealias IndexType
typealias Result
@andelf
andelf / EasyJSON.swift
Last active Aug 29, 2015
Swift JSON Helper
View EasyJSON.swift
import Foundation
//let raw = String.stringWithContentsOfURL(NSURL(string: "http://www.weather.com.cn/data/sk/101010100.html"))
struct EasyJSON {
var _obj: AnyObject!
init(_ obj: AnyObject) {
//assert(NSJSONSerialization.isValidJSONObject(obj), "must be valid json object")
_obj = obj
@andelf
andelf / Monad.swift
Last active Feb 18, 2017
Monad in Swift
View Monad.swift
// Monad
operator infix >>= {
precedence 10
associativity left
}
struct _MReturn {
}
@transparent func _mreturn<Args>(a: Args) -> (_MReturn, Args) {
return (_MReturn(), a)
@andelf
andelf / Swift.text
Created Jun 20, 2014
Swift Standard Library .swiftmodule Dump
View Swift.text
Swift
LLVM 3.5svn
/SourceCache/compiler_KLONDIKE/compiler_KLONDIKE-600.0.34.4.8/src/tools/swift/stdlib/core/Algorithm.swift
/SourceCache/compiler_KLONDIKE/compiler_KLONDIKE-600.0.34.4.8/src/tools/swift/stdlib/core/ArrayBody.swift
/SourceCache/compiler_KLONDIKE/compiler_KLONDIKE-600.0.34.4.8/src/tools/swift/stdlib/core/ArrayBuffer.swift
/SourceCache/compiler_KLONDIKE/compiler_KLONDIKE-600.0.34.4.8/src/tools/swift/stdlib/core/ArrayBufferType.swift
/SourceCache/compiler_KLONDIKE/compiler_KLONDIKE-600.0.34.4.8/src/tools/swift/stdlib/core/ArrayType.swift
/BinaryCache/compiler_KLONDIKE/compiler_KLONDIKE-600.0.34.4.8~2/Objects/stdlib/macosx-10.9-internal-x86_64/stdlib/core/Arrays.swift
/SourceCache/compiler_KLONDIKE/compiler_KLONDIKE-600.0.34.4.8/src/tools/swift/stdlib/core/Assert.swift
/SourceCache/compiler_KLONDIKE/compiler_KLONDIKE-600.0.34.4.8/src/tools/swift/stdlib/core/AssertCommon.swift
@andelf
andelf / HashSet.swift
Last active Aug 29, 2015
Generic Hash Set in Swift
View HashSet.swift
struct HashSet<T : Hashable> {
typealias Element = T
var _map: Dictionary<T, ()> = [:]
var count: Int {
return _map.count
}
var isEmpty: Bool {
@andelf
andelf / proc_diff.py
Last active Aug 29, 2015
Monitor Process Creation and Quiting
View proc_diff.py
import os
import commands
import time
def get_process():
procs = set()
for line in commands.getoutput("ps aux").split('\n'):
if not line: # or '%CPU' in line:
continue
proc = ' '.join(line.split()[10:])
View ast_extractor.rs
// copied from rustdoc
/// Parses, resolves, and typechecks the given crate
fn get_ast_and_resolve(cpath: &Path, libs: HashSet<Path>, cfgs: Vec<~str>) -> (ast::Crate, CrateAnalysis) {
use syntax::codemap::dummy_spanned;
use rustc::driver::driver::{FileInput, build_configuration,
phase_1_parse_input,
phase_2_configure_and_expand,
phase_3_run_analysis_passes};
let input = FileInput(cpath.clone());
You can’t perform that action at this time.