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
let response = GCDWebServerStreamedResponse(contentType: "video/mp4", asyncStreamBlock: { block in
/// Fetch data
})
let begin = request.hasByteRaange ? request.byteRange.lowerBound : 0
let end = request.hasByteRaange ? request.byteRange.higherBound : clipFileSize
var readHead = begin
let response = GCDWebServerStreamedResponse(contentType: "video/mp4", asyncStreamBlock: { block in
if readHead < end {
let data = getData(readHead, chunkSize)
block(data, nil)
readHead += data.count
} else {
block(nil, nil)
let response = GCDWebServerStreamedResponse(contentType: "video/mp4", asyncStreamBlock: { block in
 let begin = request.hasByteRaange ? request.byteRange.lowerBound : 0
 let end = request.hasByteRaange ? request.byteRange.higherBound : clipFileSize
 var readHead = begin
 while readHead < end {
 let data = getData(readHead, chunkSize)
 block(data, nil)
 readHead += data.count
 }
})
let response = GCDWebServerStreamedResponse(contentType: "video/mp4", asyncStreamBlock: { block in
 /// Fetch data 
})
webServer?.addHandler(forMethod: "GET", pathRegex: "(.*?).mp4", request: GCDWebServerRequest.self, asyncProcessBlock: { request, completion in
let filename = request.url.lastPathComponent
let clipFileSize = getClipFileSize()
let response = GCDWebServerStreamedResponse(contentType: "video/mp4", asyncStreamBlock: { block in
/// Fetch data
})
let disposition = "attachment; filename=\"\(filename)\""
response.setValue(disposition, forAdditionalHeader: "Content-Disposition")
response.setValue("video/mp4", forAdditionalHeader: "Content-Type")
import 'package:meta/meta.dart';
class CoordinatorStatus {}
class UserinfoModel {}
class _UserStatus extends CoordinatorStatus {
UserinfoModel model;
_UserStatus({this.model});
import 'package:flutter/material.dart';
import 'dart:math' as math;
import 'dart:ui';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
import UIKit
import Foundation
extension OSStatus {
var stringValue: String? {
withUnsafeBytes(of: self) {
String(bytes: $0, encoding: .ascii)
}
}
}
@zonble
zonble / main.dart
Created November 5, 2019 02:54
Menu Navigation
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'menu.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
enum Token {
case num(Int)
case op(String)
}
func tokenize(_ s: String) -> [Token] {
let scanner = Scanner(string: s)
scanner.charactersToBeSkipped = CharacterSet.whitespaces
var tokens = [Token]()
while !scanner.isAtEnd {