Skip to content

Instantly share code, notes, and snippets.

View dzolnai's full-sized avatar

Dániel Zolnai dzolnai

  • Egeniq
  • Budapest
View GitHub Profile
@dzolnai
dzolnai / simplex.c
Created January 17, 2017 18:46
Simplex solver article - gist 6
for (int j = start_index; j < end_index; j++) {
float value = get_element(tableau, tableau->rows - 1, j);
rsSetElementAt_float(solution_vector, value, j - start_index);
}
rsSetElementAt_int(result_size, end_index - start_index, 0);
@dzolnai
dzolnai / SubRowsSupportFragment.kt
Last active April 22, 2020 08:06
RowsSupportFragment which also remembers position in last selected row.
@file:Suppress("PackageDirectoryMismatch")
package android.support.v17.leanback.widget
import android.os.Bundle
import android.support.v17.leanback.app.RowsSupportFragment
import android.support.v7.widget.RecyclerView
import android.view.View
/**
* RowsSupportFragment which also remembers the subposition in the rows.
@dzolnai
dzolnai / BaseGridFragment.kt
Created May 23, 2018 13:46
A BaseGridFragment contains a VerticalGridSupportFragment which is modified to allow focus to escape it.
abstract class BaseGridFragment : Fragment() {
private var lifecycleCallbacks: FragmentManager.FragmentLifecycleCallbacks? = null
/**
* If your fragment contains a VerticalGridSupportFragment, it automatically includes a search button you can disable.
* However, the focus search listener is not disabled, and it does conflict with our implementation for showing the menu.
* Don't forget to save a reference to the callbacks to unsubscribe when destroying the fragment.
*/
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@dzolnai
dzolnai / ItemFocusHighlighter.kt
Created May 23, 2018 14:48
A Leanback focus highlight helper which can delay focus changes on demand.
@file:Suppress("PackageDirectoryMismatch")
package android.support.v17.leanback.widget
import android.os.Handler
import android.os.Looper
import android.view.View
import java.lang.ref.WeakReference
/**
@dzolnai
dzolnai / AnimatingDialogFragment.kt
Created May 23, 2018 15:01
DialogFragment which can have hide animations
/**
* Dialog Fragment with hide animations
*/
class AnimatingDialogFragment : DialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(DialogFragment.STYLE_NO_FRAME, R.style.TvTheme_Dialog)
}
val recognizerIntent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM)
// Prefer dutch language for recognition
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "nl-NL")
// Display text for the user as hint until results are available (only in overlay mode)
recognizerIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speak to search...")
// Accept partial results if they come
recognizerIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true)
@dzolnai
dzolnai / AdobeLocationFramework.cs
Last active May 31, 2019 12:16
Get Adobe Analytics library working on Unity
//
// Copyright (c) 2017 eppz! mobile, Gergely Borbás (SP)
//
// http://www.twitter.com/_eppz
//
// 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 CONNECTION WITH THE SOFTWARE
@dzolnai
dzolnai / Including tau in your Tizen project
Created November 27, 2019 15:00
The journey of creating an electric meter style Tizen watchface
<head>
...
<link rel="stylesheet" href="lib/tau/wearable/theme/default/tau.css">
<link rel="stylesheet" media="all" href="lib/tau/wearable/theme/default/tau.circle.css">
</head>
<body> 
...
<script src="js/app.js"></script>
<script src="lib/tau/animation/tau.animation.min.js"></script>
</body>
@dzolnai
dzolnai / app.js
Created November 27, 2019 15:06
Running tau with an element
var t = tau.animation.target;
var digitElement = document.querySelector("#digit-element");
t(digitElement).tween({
translateY : -(finalOffset) * digitSizePx + constantOffset
}, {
duration : 1000,
ease: 'linear'
});
@dzolnai
dzolnai / MainActivity.kt
Created November 29, 2019 13:06
Creating an ExoPlayer with your own audioprocessor
private val fftAudioProcessor = FFTAudioProcessor()
val renderersFactory = object : DefaultRenderersFactory(this) {
override fun buildAudioProcessors(): Array<AudioProcessor> {
val processors = super.buildAudioProcessors()
return processors + fftAudioProcessor
}
}
player = ExoPlayerFactory.newSimpleInstance(this, renderersFactory, DefaultTrackSelector())