Skip to content

Instantly share code, notes, and snippets.

View knappador's full-sized avatar
💭
First posty toasty

knappador

💭
First posty toasty
View GitHub Profile
@knappador
knappador / pulse_audio_record.rs
Created March 21, 2019 15:13
MIT Licensed Pulse Audio Recording
// Copyright 2019 Brian Knapp<knappador@gmail.com>
//
// 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 copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTIO
@knappador
knappador / gist:b8c1a9d0290a8c37ce8f
Last active August 29, 2015 14:22
How It Paralleled It
Log.i("BackgroundRealmActivity", "MainThread Id: " + Thread.currentThread().getId());
PublishSubject<Integer> intSubject = PublishSubject.create();
Observable<Integer> ints = intSubject.asObservable();
intSubject.subscribe((Integer i) -> {
Log.i("BackgroundRealmActivity emitted", Integer.toString(i));
});
ints.flatMap((Integer i) -> {
@knappador
knappador / gist:1c7824979e1b21061b0b
Created June 8, 2015 05:25
Enabling Minify after adding Espresso test throws a ton of warnings. Build will not complete with --dontwarn and --dontnote
...
:app:compileFullDebugAndroidTestSources UP-TO-DATE
:app:proguardFullDebugAndroidTest
Note: there were 12 duplicate class definitions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
Warning: org.hamcrest.integration.EasyMock2Adapter: can't find superclass or interface org.easymock.IArgumentMatcher
Warning: org.hamcrest.integration.JMock1Adapter: can't find superclass or interface org.jmock.core.Constraint
Warning: library class android.test.AndroidTestCase extends or implements program class junit.framework.TestCase
Warning: library class android.test.AndroidTestRunner extends or implements program class junit.runner.BaseTestRunner
Warning: library class android.test.InstrumentationTestCase extends or implements program class junit.framework.TestCase
@knappador
knappador / gist:d48a4aff8765eabec271
Created September 4, 2014 01:47
Property Multiplexer Example
class PropertyMultiplexer(EventDispatcher):
select = ListProperty()
def __init__(self, rule_sets, **kwargs):
super(PropertyMultiplexer, self).__init__(**kwargs)
self.rule_sets = rule_sets
default = rule_sets.default
# there must be a default in rule_sets and it
# must define a default for each possible property
@knappador
knappador / gist:fda4ec6d0145322435fa
Created June 11, 2014 03:51
An Example of More Complicated Dimensions Definition
''' This module contains a list of all "styles" where each more specific
style will override the more general one all the way to the default. Any
attribute type can be used and will be available on the DimensionController
instance, d_ctl inside the kv file. Importing the d_ctl into the kv
namespace allows the entire kv file to recieve any property updates
resulting from UI rotation or resizeing dynamically.'''
''' currently this implementation has no support for nesting
so the namespace could become cluttered on complex UI's. What is the
@knappador
knappador / gist:8395143
Created January 13, 2014 05:21
Just an example of some kv used in practice
# meanwhile in some widget tree I create an instance and
# set the property in that specific tree for the specific ColorSel instance
ColorSel:
title: 'high color'
# passing in the attribute that will be bound inside kv
bind_color: 'ebbh'
<ColorSel@RelativeLayout>:
@knappador
knappador / RecallMyProperty.py
Created August 21, 2013 23:46
Storing the old value for future use...lol. I still ended up needing to check if the old_value was None. You have to re-define your do_stuff function in order to truly get rid of the if statement. This of course uses more memory than just checking every time. Possibly as much as perhaps 15 machine words, or more...gasp!
from kivy.event import EventDispatcher
from kivy.properties import NumericProperty
class Eoo(EventDispatcher):
new_value = NumericProperty()
def __init__(self, **kwargs):
self.old_value = None
super(Eoo, self).__init__(**kwargs)
self.bind(new_value=self.recall)
[INFO ] [Window ] using <pygame> as window provider
[INFO ] [GL ] OpenGL version <4.3.0 NVIDIA 319.23>
[INFO ] [GL ] OpenGL vendor <NVIDIA Corporation>
[INFO ] [GL ] OpenGL renderer <GeForce GTX 660M/PCIe/SSE2>
[INFO ] [GL ] Shading version <4.30 NVIDIA via Cg compiler>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <32>
@knappador
knappador / gist:5565304
Last active December 17, 2015 06:28
example.c segfault
Reading symbols from /home/knapper/projects/libCello/demos/a.out...done.
(gdb) run
Starting program: /home/knapper/projects/libCello/demos/a.out
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
Type: 'Int'
Type: 'Real'
Type: 'String'
Price of a 'Pear' is 55
Price of "Apple" is 12