Create a command line target in xcode either in Swift or Obj-C. add a metal file to the project and copy and paste the respective code into each file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git clone [email protected]:xxxxx/xxxx.git my-awesome-proj | |
Cloning into 'my-awesome-proj'... | |
ssh: connect to host github.com port 22: Connection timed out | |
fatal: Could not read from remote repository. | |
$ # This should also timeout | |
$ ssh -T [email protected] | |
ssh: connect to host github.com port 22: Connection timed out | |
$ # but this might work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
final class GradientLabel: UILabel { | |
private var colors: [UIColor] = [.supAzure, .supAppleFive] | |
private var startPoint: CGPoint = CGPoint(x: 0.0, y: 0.5) | |
private var endPoint: CGPoint = CGPoint(x: 1.0, y: 0.5) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Apportable version of GCDAsync.m that works around an issue with spurious EOF's. | |
// Also make this change to GCDAsyncSocket.h : | |
//--- a/GCDAsyncSocket/GCDAsyncSocket.h | |
//+++ b/GCDAsyncSocket/GCDAsyncSocket.h | |
//@@ -21,7 +21,7 @@ | |
//- #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 50000 // iOS 5.0 supported | |
//+ #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 50000) && !defined(APPORTABLE) // iOS 5.0 supported |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <CoreMedia/CoreMedia.h> | |
#import <CoreVideo/CoreVideo.h> | |
#import <UIKit/UIKit.h> | |
// https://developer.apple.com/library/content/qa/qa1702/_index.html | |
+ (UIImage * _Nullable)imageWithSampleBuffer:(CMSampleBufferRef _Nonnull)sampleBuffer { | |
UIImage *returnValue = nil; | |
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); | |
CVPixelBufferLockBaseAddress(imageBuffer, 0); { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a UIImage from sample buffer data | |
- (UIImage *) imageFromSampleBuffer:(CMSampleBufferRef) sampleBuffer | |
{ | |
// Get a CMSampleBuffer's Core Video image buffer for the media data | |
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); | |
// Lock the base address of the pixel buffer | |
CVPixelBufferLockBaseAddress(imageBuffer, 0); | |
// Get the number of bytes per row for the pixel buffer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIImage *)screenshotFromPlayer:(AVPlayer *)player atTime:(CMTime)time { | |
CMTime actualTime; | |
NSError *error; | |
int attemptNumber = 0; | |
BOOL success = NO; | |
UIImage *image; | |
while (attemptNumber < 5 && !success) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//特殊字符转码 | |
- (NSString *)encodeWithString:(NSString *)string { | |
NSString *charactersToEscape = @"?!@#$^&%*+,:;='\"`<>()[]{}/\\| "; | |
NSCharacterSet *allowedCharacters = [[NSCharacterSet characterSetWithCharactersInString:charactersToEscape] invertedSet]; | |
return [string stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacters]; | |
} | |
//URL中包含中文的连接转码 | |
NSString *escapedPath = [@"http://www.baidu.com?中文" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffprobe -v quiet -print_format json -show_format -show_streams "lolwut.mp4" > "lolwut.mp4.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* The MIT License | |
* | |
* Copyright (c) 2011 Paul Solt, [email protected] | |
* Modifications Copyright (c) 2011 Joe Osborn, [email protected] | |
* | |
* 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 |
NewerOlder