Skip to content

Instantly share code, notes, and snippets.

@mwise
mwise / Rakefile
Created February 22, 2015 18:41
motion-env warning with some arrays of at least four hashes
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project/template/ios'
require "bundler/gem_tasks"
require "bundler/setup"
begin
require 'bundler'
@mwise
mwise / gist:0e5cf73774310fde7dcf
Last active August 29, 2015 14:12
Window a buffer for sampling
@implementation SamplerKit
+ (void) windowBuffer: (AVAudioPCMBuffer*)buffer rampFrames:(AVAudioFrameCount)_rampFrames{
int frames = [buffer frameLength];
float* _windowBuffer = (float*) malloc(sizeof(float) * frames);
float min = 0.0f;
float max = 1.0f;
@mwise
mwise / gist:d8d801511b1357cbad7c
Created December 30, 2014 16:38
Audiobus CocoaPods install error
rake pod:install [14/496]
Could not find json-1.8.1 in any of the sources
Run `bundle install` to install missing gems.
Updating spec repo `master`
Already up-to-date.
CocoaPods 0.36.0.beta.1 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
=ERROR REPORT==== 23-Oct-2014::19:00:57 ===
Error in process <0.254.0> with exit value: {[{reason,undef},{mfa,{'Elixir.Shelob.WebSocketHandler',init,2}},{stacktrace,[{'Elixir.Shelob.WebSocketHandler',init,[{http_req,#Port<0.5428>,ranch_tcp,keepalive,<0.254.0>,<<3 bytes>>,'HTTP/1.1',{{127,0,0,1},57844},<<9 bytes>>,undefined,8080,<<3 bytes>>,undefined,<<0 bytes>>,[],[{<<4 bytes>>,<<14 bytes>>},{<<6 bytes>>,<<22 bytes>>},{<<17 bytes>>,<<24 bytes>>},{<<7 bytes>>,<<9 bytes>>},{<<10 bytes>>,<<7 bytes>>},...
=ERROR REPORT==== 23-Oct-2014::19:00:57 ===
Ranch listener http had connection process started with cowboy_protocol:start_link/4 at <0.254.0> exit with reason: {[{reason,undef},{mfa,{'Elixir.Shelob.WebSocketHandler',init,2}},{stacktrace,[{'Elixir.Shelob.WebSocketHandler',init,[{http_req,#Port<0.5428>,ranch_tcp,keepalive,<0.254.0>,<<"GET">>,'HTTP/1.1',{{127,0,0,1},57844},<<"127.0.0.1">>,undefined,8080,<<"/ws">>,undefined,<<>>,[],[{<<"host">>,<<"127.0.0.1:8080">>},{<<"origin">>,<<"http://127.0.0.1:8080/">>},{<<
@mwise
mwise / implementation.rb
Created September 10, 2014 00:36
Bug using AudioUnitParameterEvent
event = AudioUnitParameterEvent.new
event.scope = KAudioUnitScope_Global
event.element = 0
event.parameter = parameter
event.eventType = KParameterEvent_Ramped
event.eventValues.ramp.startBufferOffset = offset
event.eventValues.ramp.durationInFrames = frames
event.eventValues.ramp.startValue = get_parameter(parameter)
event.eventValues.ramp.endValue = value
@mwise
mwise / implementation.rb
Created September 10, 2014 00:36
Bug using AudioUnitParameterEvent
event = AudioUnitParameterEvent.new
event.scope = KAudioUnitScope_Global
event.element = 0
event.parameter = parameter
event.eventType = KParameterEvent_Ramped
event.eventValues.ramp.startBufferOffset = offset
event.eventValues.ramp.durationInFrames = frames
event.eventValues.ramp.startValue = get_parameter(parameter)
event.eventValues.ramp.endValue = value
@mwise
mwise / implementation.rb
Created September 10, 2014 00:36
Bug using AudioUnitParameterEvent
event = AudioUnitParameterEvent.new
event.scope = KAudioUnitScope_Global
event.element = 0
event.parameter = parameter
event.eventType = KParameterEvent_Ramped
event.eventValues.ramp.startBufferOffset = offset
event.eventValues.ramp.durationInFrames = frames
event.eventValues.ramp.startValue = get_parameter(parameter)
event.eventValues.ramp.endValue = value
@mwise
mwise / gist:b6154f942ce566471983
Last active August 29, 2015 14:04
Vim function to open spec in split
fun! OpenFilesInSplit(left, right)
if a:left == a:right
return
endif
only
exec "edit " . a:left
exec "vs " . a:right
execute "normal! \<c-w>t"
endfun
@mwise
mwise / README.md
Last active July 14, 2023 14:11
Git hook to prevent merging staging branch into master branch

To use this hook:

  • add the prepare-commit-msg file at .git/hooks/prepare-commit-msg and edit as needed
  • make it executable: chmod +x .git/hooks/prepare-commit-msg
  • disable fast-forward merges: git config branch.master.mergeoptions "--no-ff"
  • that's it!

NOTE: after a failed merge from a forbidden branch, the working tree will still be in a MERGING state. To discard the local working copy state, run: git reset --merge

@mwise
mwise / gist:bab66be2682c1c9792f9
Created July 5, 2014 14:36
searchable_table.rb
module RMExtensions
module SearchableTable
def setup_search_controller(opts)
$self = self
@search_bar = UISearchBar.alloc.initWithFrame(
CGRectMake(0, 0, frame.size.width, 44))
@search_controller = UISearchDisplayController.alloc
.initWithSearchBar(@search_bar, contentsController: rmq.view_controller)