Skip to content

Instantly share code, notes, and snippets.

View boboboa32's full-sized avatar

Bobo Shone boboboa32

  • Xiaoman
  • China
View GitHub Profile
@boboboa32
boboboa32 / FileWebService.swift
Last active March 11, 2023 10:38
Moya file download
import Moya
import SwiftyJSON
enum FileWebService {
case download(url: String, fileName: String?)
var localLocation: URL {
switch self {
case .download(let url, let fileName):
let fileKey: String = url.MD5 // use url's md5 as local file name
@boboboa32
boboboa32 / convert_mp3.m
Created June 30, 2016 03:05
convert ios audio to mp3 file using lame
int read, write;
FILE *pcm = fopen([audioFilePath cStringUsingEncoding:1], "rb"); //source
fseek(pcm, 4*1024, SEEK_CUR); //skip file header
FILE *mp3 = fopen([mp3FilePath cStringUsingEncoding:1], "wb"); //output
const int PCM_SIZE = 8192;
const int MP3_SIZE = 8192;
short int pcm_buffer[PCM_SIZE*2];
unsigned char mp3_buffer[MP3_SIZE];
@boboboa32
boboboa32 / webview.m
Last active June 30, 2016 05:51
caculate WKWebView content height
- (void)viewDidLoad {
...
[self.webView.scrollView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:nil];
}
- (void)dealloc
{
[self.webView.scrollView removeObserver:self forKeyPath:@"contentSize" context:nil];
}
-(BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// start of your application:didFinishLaunchingWithOptions
// !!!: Use the next line only during beta
// [TestFlight setDeviceIdentifier:[[UIDevice currentDevice] uniqueIdentifier]];
[TestFlight takeOff:@"Insert your Application Token here"];
// The rest of your application:didFinishLaunchingWithOptions method
// ...
@boboboa32
boboboa32 / corona_twitter.lua
Created February 18, 2013 08:05
Using the iOS Built-In Twitter Feature
local function tweetCallback( event )
if ( event.action == "cancelled" ) then
print( "User cancelled" )
else
print( "Thanks for the tweet!" )
end
end
local options = {
message = "Hello Twitter world!",
local golden_ratio_conjugate = 0.618033988749895
local h = math.random()
h = h + golden_ratio_conjugate
h = h % 1
local r,g,b = HSVtoRGB(h, 0.5, 0.9)
function HSVtoRGB(h, s, v)
local r, g, b
local i = math.floor(h * 6)
local f = h * 6 - i
local p = v * (1 - s)
local q = v * (1 - f * s)
local t = v * (1 - (1 - f) * s)
local switch = i % 6
@property (nonatomic, strong) NSSet* cats;
- (NSMutableSet*)catsSet;
@end
@interface _People (CoreDataGeneratedAccessors)
- (void)addCats:(NSSet*)value_;
- (void)removeCats:(NSSet*)value_;
@property (nonatomic, strong) NSNumber* age;
@property int16_t ageValue;
- (int16_t)ageValue;
- (void)setAgeValue:(int16_t)value_;
// DO NOT EDIT. This file is machine-generated and constantly overwritten.
// Make changes to People.h instead.