Skip to content

Instantly share code, notes, and snippets.

View ThanosFisherman's full-sized avatar

Thanos Psaridis ThanosFisherman

View GitHub Profile
@ThanosFisherman
ThanosFisherman / gpu.cpp
Created October 30, 2024 22:06 — forked from statico/gpu.cpp
Trick to tell AMD and Nvidia drivers to use the most powerful GPU instead of a lower-performance (such as integrated) GPU
#ifdef _WIN32
// Use discrete GPU by default.
extern "C" {
// http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
// http://developer.amd.com/community/blog/2015/10/02/amd-enduro-system-for-developers/
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
#endif
@ThanosFisherman
ThanosFisherman / evaluateGuess.kt
Last active August 8, 2019 12:58
From Coursera course "Kotlin for Java developers" week 2 - Mastermind game solution
package mastermind
data class Evaluation(val rightPosition: Int, val wrongPosition: Int)
fun evaluateGuess(secret: String, guess: String): Evaluation {
var rightPos = 0
var wrongPos = 0
if (secret == guess) {
return Evaluation(4, 0)
@ThanosFisherman
ThanosFisherman / CheckableImageButton.java
Last active February 4, 2023 19:18
It's a checkable ImageButton that respects xml selector state changes
/**
* Created by thanos on 12/8/17.
* It's a checkable ImageButton that respects xml selector state changes
*/
public final class CheckableImageButton extends AppCompatImageButton implements Checkable
{
private static final int[] DRAWABLE_STATE_CHECKED = new int[]{android.R.attr.state_checked};
private boolean mChecked;
@ThanosFisherman
ThanosFisherman / CheckableLinearLayout.java
Created December 7, 2017 22:32
Checkable LinearLayout
public class CheckableLinearLayout extends LinearLayout implements Checkable {
private static final int[] CHECKED_STATE_SET = {android.R.attr.state_checked};
private boolean mChecked;
public CheckableLinearLayout(Context context) {
super(context);
}
public CheckableLinearLayout(Context context, AttributeSet attrs) {
@ThanosFisherman
ThanosFisherman / RetainedAsyncTask.java
Last active November 7, 2016 18:10
Asynctask wrapped in a retained fragment
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
public abstract class RetainedAsyncTask<Params, Progress, Result> extends Fragment
{
private AsyncCustom asyncCustom;