Skip to content

Instantly share code, notes, and snippets.

View zonble's full-sized avatar

Weizhong Yang a.k.a zonble zonble

View GitHub Profile
import UIKit
import AVFoundation
class ZBSimpleRecorder: NSObject {
var audioEngine: AVAudioEngine?
var file: ExtAudioFileRef?
func start(fileURL:URL) {
#import <Foundation/Foundation.h>
@interface KKSimpleAirPlay2Player : NSObject
- (id)initWithURL:(NSURL *)inURL;
- (void)play;
- (void)pause;
@property (readonly, getter=isStopped) BOOL stopped;
@end
var playlistMoreAction = {
id: "com.kkbox.k2y",
title: "View Videos in the Playlist on Youtube",
type: "playlist_more",
action: function(playlist) {
var playlistID = playlist["id"]
var url = "http://k2y.herokuapp.com/playlist/" + encodeURIComponent(playlistID)
openURL(url)
}
}
import UIKit
import PlaygroundSupport
class SampleTableViewController : UITableViewController {
var selectedIndexPath: IndexPath?
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
}
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7')
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.HttpResponseException
import static groovyx.net.http.ContentType.*
import groovy.json.JsonBuilder
def post_to_slack = {
token, text, channel, domain, username, icon_emoji ->
def site = "https://${domain}.slack.com/"
println site
@import url(http://fonts.googleapis.com/earlyaccess/cwtexhei.css);
body {
font-family: Helvetica, "Noto Sans CJK TC", cwTeXHei, sans-serif !important;
font-size: 10pt !important;
}
.CodeMirror {
width: auto !important; /*override the width below*/
width: 100%;
import UIKit
import StoreKit
import MediaPlayer
class AppleProductPlayer: NSObject {
func play(productID: String) {
SKCloudServiceController.requestAuthorization { status in
let cloudServiceController = SKCloudServiceController()
cloudServiceController.requestCapabilitiesWithCompletionHandler { cloudServiceCapability, error in
if cloudServiceCapability.contains(.AddToCloudMusicLibrary) {
//
// CustomNVToolBarVC.m
// customToolBar
//
#import "CustomNVToolBarVC.h"
#import <objc/runtime.h>
@interface UIToolbar (Override)
@property (strong, nonnull, nonatomic) UIView *targetView;
@zonble
zonble / KKSimplePlayer.swift
Created April 21, 2016 16:34
Using AudioQueue and Swift to do a simple stream player
import Foundation
import AudioToolbox
class KKSimplePlayer: NSObject {
var URL: NSURL
var URLSession: NSURLSession!
var packets = [NSData]()
var audioFileStreamID: AudioFileStreamID = nil
var outputQueue: AudioQueueRef = nil
var streamDescription: AudioStreamBasicDescription?
MAP = {",": ".", "!": "?", "(": ")", "{": "}", "[": "]", "<": ">", "@": "#",
";": ":", ".": ",", "?": "!", ")": "(", "}": "{", "]": "[", ">": "<",
"#": "@", ":": ";"}
c_t = lambda x: ''.join(c.swapcase() for c in x.group(0)[::-1])
def twist(text):
import re
text = re.sub(r'[a-zA-Z]*', c_t, text)
text = re.sub(r'\s+', ' ', text)
text = re.sub(r'[0-9]', lambda x: str(9 - int(x.group(0))), text)
text = re.sub('[!#$%&()*+,-./:;<=>?@[\]^_`{|}~]',