Skip to content

Instantly share code, notes, and snippets.

View welbesw's full-sized avatar
💭
Swifting

William Welbes welbesw

💭
Swifting
View GitHub Profile
@welbesw
welbesw / Podfile
Created May 1, 2015 22:01
Parse with Extensions Podfile
platform:ios, '8.0'
use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'
link_with 'AppName', 'AppName WatchKit Extension'
def shared_pods
pod 'Parse', '~> 1.7.2'
end
@welbesw
welbesw / FFT.m
Last active March 18, 2016 14:38
FFT on the audio buffer in the AURenderCallback method:
static void performFFT(float* data, UInt32 numberOfFrames, SoundBufferPtr soundBuffer, UInt32 inBusNumber) {
int bufferLog2 = round(log2(numberOfFrames));
float fftNormFactor = 1.0/( 2 * numberOfFrames);
FFTSetup fftSetup = vDSP_create_fftsetup(bufferLog2, kFFTRadix2);
int numberOfFramesOver2 = numberOfFrames / 2;
float outReal[numberOfFramesOver2];
float outImaginary[numberOfFramesOver2];
@welbesw
welbesw / timerTick.swift
Created March 18, 2016 14:37
Method called by NSTimer to update frequency values from FFT
func timerTick(sender:NSTimer?) {
if audioManager.isPlaying() {
//Get the frequency data from the audio manager and show on horizontal bar graph
var size:UInt32 = 0
let frequencyData = audioManager.guitarFrequencyDataOfLength(&size)
let frequencyValuesArray = Array<Float32>(UnsafeBufferPointer(start: UnsafePointer(frequencyData), count: Int(size)))
//Sanity check for expected 256 length
if frequencyValuesArray.count == 256 {
frequencyView.frequncyValues = frequencyValuesArray
// UITableView data source delegate methods
// These are the methods that UITableView calls on the controller to
// setup the table view with the number of items and a reusable cell
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// return the number of sections
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
@welbesw
welbesw / ItemHolder.java
Created May 31, 2016 14:16
Item RecyclerView.ViewHolder
/**
* A simple view holder to be used for a list of items. To
* keep things simple, just one TextView will be used.
*/
public class ItemHolder extends RecyclerView.ViewHolder {
public TextView mTextView;
public ItemHolder(View itemView) {
super(itemView);
@welbesw
welbesw / ItemAdapter.java
Last active May 31, 2016 14:44
RecyclerView.Adapter
/**
* A simple RecyclerView.Adapter class that manages items.
*/
public class ItemAdapter extends RecyclerView.Adapter<ItemHolder> {
private List<String> mItems;
public ItemAdapter(List<String> items) {
mItems = items;
}
/**
* A simple {@link Fragment} subclass.
* Use the {@link RecyclerFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class RecyclerFragment extends Fragment {
private RecyclerView mRecyclerView;
private List<String> items = new ArrayList<String>();
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
tools:context="layout.RecyclerFragment">
</android.support.v7.widget.RecyclerView>
@welbesw
welbesw / Podfile
Created June 7, 2016 15:58
Salesforce SDK Podfile
#define the source locations. The Salesforce SDK is not a published cocoapod
source 'https://github.com/forcedotcom/SalesforceMobileSDK-iOS-Specs.git' # needs to be first
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
target 'ContactsForce' do
pod 'SalesforceSDKCore'
@welbesw
welbesw / SalesforceManager.swift
Created June 7, 2016 17:26
SalesforceManager singleton class
import SalesforceSDKCore
import SalesforceRestAPI
public class SalesforceManager : NSObject {
//Define a shared instance for singleton
static let sharedInstance = SalesforceManager()
let errorDomain = "com.centare.contactforce.salesforcemanager"