Skip to content

Instantly share code, notes, and snippets.

@Ridwy
Ridwy / parseRIFF.m
Created May 19, 2012 07:19
Parsing RIFF File
/*
NSDictionary* parseRIFF(NSString* path)
parse RIFF file
General output dictionary
{
formType = {
chunkId = ... ;
@Ridwy
Ridwy / gist:3438128
Created August 23, 2012 16:11
AudioUnitCreate(), AudioUnitDispose()
#include <AudioToolbox/AudioToolbox.h>
/*
AudioUnit unit = AudioUnitCreate(kAudioUnitType_Output, kAudioUnitSubType_RemoteIO);
// set properties
AudioUnitInitialize(unit);
AudioOutputUnitStart(unit);
@Ridwy
Ridwy / gist:4704540
Created February 4, 2013 01:23
-[NSMutableData appendBytes:length:] copies specific buffer.
NSMutableData* data = [NSMutableData data];
char str[] = "foo";
[data appendBytes:str length:sizeof(str)];
NSLog(@"%s %s", [data bytes], str); // foo foo
str[0] = 0;
NSLog(@"%s %s", [data bytes], str); // foo
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Script-Type" content="text/javascript" charset="utf-8">
<title></title>
<style type="text/css">
</style>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/knockout/knockout-2.2.1.js"></script>
// extract RAW PCM
NSURL* url = [[NSBundle mainBundle] URLForResource:@"" withExtension:@"mp3"];
AVAsset* asset = [AVAsset assetWithURL:url];
NSError* err = nil;
AVAssetReader* reader = [[AVAssetReader alloc] initWithAsset:asset error:&err];
if (!err) {
AVAssetReaderAudioMixOutput* output = [[AVAssetReaderAudioMixOutput alloc]
initWithAudioTracks:[asset tracksWithMediaType:AVMediaTypeAudio]
audioSettings:nil];
[reader addOutput:output];
@Ridwy
Ridwy / gist:6290416
Last active December 21, 2015 10:09
UITextFieldがキーボードで隠れないようにスクロールアップする方法。 ViewControllerに以下のコードを実装してUITextFieldのdelegateにする
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// register for keyboard notifications
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide)
name:UIKeyboardWillHideNotification
object:nil];
}
@Ridwy
Ridwy / iOS 7 OSD Log
Created April 28, 2014 04:49
デバッガみたいに自動でスクロールアップするUITextView
@interface SomeViewController ()
@property (weak) UITextView *logView;
@end
@implementation SomeViewController
- (void)writeOSDLog:(NSString *)log
{
if (self.logView == nil) {
NSTextStorage *textStorage = [NSTextStorage new];
NSLayoutManager *layoutManager = [NSLayoutManager new];
@Ridwy
Ridwy / CNLiningUpView.swift
Last active August 29, 2015 14:17
User icon lining up view like FourSquare
//
// CNLiningUpView.swift
// CNLiningUpView
//
// Created by Chiharu Nameki on 2015/03/29.
// Copyright (c) 2015 Chiharu Nameki. All rights reserved.
//
import UIKit
//
// ScrollPageController.swift
// ScrollPageController
//
// Created by Chiharu Nameki on 2015/06/21.
// Copyright (c) 2015 Chiharu Nameki. All rights reserved.
//
import UIKit
//
// CNImageView.swift
// ImageView
//
// Created by Chiharu Nameki on 2015/08/02.
// Copyright (c) 2015 Chiharu Nameki. All rights reserved.
//
import UIKit