Skip to content

Instantly share code, notes, and snippets.

@adow
adow / iTermVim.app
Last active November 12, 2018 14:35
Open file in iTerm vim for MacOS Mojave
on run {input, parameters}
set filename to POSIX path of input
set cmd to "clear;cd `dirname " & filename & "`;vim " & quote & filename & quote
tell application "iTerm"
create window with default profile
@adow
adow / UIImage+Tinted.swift
Created August 17, 2016 01:42
TintedImage
/// 对图片进行着色
func wxlive_imageWithTineColor(tintColor:UIColor,
blendMode:CGBlendMode = .DestinationIn) -> UIImage{
UIGraphicsBeginImageContextWithOptions(self.size, false, 0.0)
tintColor.setFill()
let bounds = CGRectMake(0.0, 0.0, self.size.width, self.size.height)
UIRectFill(bounds)
self.drawInRect(bounds, blendMode: blendMode, alpha: 1.0)
if blendMode != .DestinationIn {
@adow
adow / get_interface_bytes.c
Created August 9, 2016 08:20
获取网速
//
// NetworkInterface.c
// wxlive
//
// Created by 秦 道平 on 16/8/3.
// Copyright © 2016年 秦 道平. All rights reserved.
//
#include "NetworkInterface.h"
#include <sys/types.h>
@adow
adow / AWPromise.swift
Created May 9, 2016 08:09
Promise by Swift
//
// AWPromise.swift
// AWHttpRequest
//
// Created by 秦 道平 on 16/5/8.
// Copyright © 2016年 秦 道平. All rights reserved.
//
import Foundation
@adow
adow / fetch2.py
Created April 10, 2016 15:44
fetch2.py
# -*- coding: utf-8 -*-
import tornado.ioloop
from tornado.httpclient import AsyncHTTPClient
import functools
task_list = []
def callback(gen,task,v):
#print gen
#print task
@adow
adow / SQLiteDB.swift
Created December 7, 2015 03:34
A simple SQLite Wrapper written in Swift
//
// SQLiteDB.swift
// SQLiteDB
//
// Copyright (c) 2014 Matt Donnelly
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@adow
adow / Macros.swift
Created November 10, 2015 01:48 — forked from xmzio/Macros.swift
My aLog and dLog macros in Swift (to abbreviate NSLog)
//
// Macros.swift
//
// Created by Xavier Muñiz on 6/12/14.
import Foundation
// dLog and aLog macros to abbreviate NSLog.
// Use like this:
@adow
adow / gist:a854489b4cdbd02c7762
Last active November 29, 2015 01:48
python switch
result = {
'a': lambda x: x * 5,
'b': lambda x: x + 7,
'c': lambda x: x - 2
}.get(value,'')
@adow
adow / gist:8818017
Created February 5, 2014 05:46
取消CALayer上默认的Core Animation
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
self.transform=WKFlipCATransform3DPerspectSimpleWithRotate(rotateDegree);
...
[CATransaction commit];
@adow
adow / gist:8617377
Created January 25, 2014 14:41
计算运行时间
double startTime=CFAbsoluteTimeGetCurrent();
NSLog(@"duration:%f",CFAbsoluteTimeGetCurrent()-startTime);