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 / OAuthClient.java
Last active August 18, 2021 07:23
Retrofit OAuth2 refreshing tokens without modifying all requests.
package com.example.yourapp;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.example.yourapp.AuthenticationModel;
import retrofit.client.Header;
import retrofit.client.OkClient;
@dzolnai
dzolnai / AutoHotKey.ahk
Last active November 19, 2015 18:12
AutoHotKey for remapping Windows + 1, 2, 3... to Windows + Q, W, E...
; Windows + Q calls Windows + 1
#q::
Send {LWin Down}1
Sleep 200
While GetKeyState("LWin","P")
{
KeyWait, q, D T0.3
If !ErrorLevel ; if you do press q
{
Send {Blind}1
@dzolnai
dzolnai / AnimatableInsetDrawable
Created January 24, 2016 14:30
A modified copy of the original Android InsetDrawable which allows setting the insets from a public method
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@dzolnai
dzolnai / cadvisor
Last active February 26, 2016 14:41
cAdvisor init.d service
#!/bin/sh
### BEGIN INIT INFO
# Provides: cadvisor
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
public class PracticalInfoFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_practical_info, container, false);
TextView practicalInfo = (TextView)view.findViewById(R.id.practical_info);
practicalInfo.setMovementMethod(LinkMovementMethod.getInstance());
String infoString = _readStringFromAssets(); // Not detailed here, content can be seen in the other file below
_setTextViewLinks(practicalInfo, infoString);
return view;
@dzolnai
dzolnai / SimplexRS.java
Last active January 17, 2017 18:17
Simplex solver article - gist 2
ScriptC_simplex script = new ScriptC_simplex(renderScript);
ScriptField_Tableau tableau = new ScriptField_Tableau(renderScript, 1);
int rowCount = data.length;
int columnCount = data[0].length;
tableau.set_rows(0, rowCount, false);
tableau.set_columns(0, columnCount, false);
tableau.set_dual_program(0, minimize, false);
tableau.set_matrix(0, data, false);
// Copy all values at once to the allocated memory of the struct.
tableau.copyAll();
@dzolnai
dzolnai / simplex.h
Created January 17, 2017 18:16
Simplex solver article - gist 1
typedef struct __attribute__((packed)) Tableau {
int rows, columns;
float matrix[MAX_ROWS * MAX_COLS];
bool dual_program;
} Tableau_t;
Tableau_t *tableau;
@dzolnai
dzolnai / SimplexRS.java
Created January 17, 2017 18:27
Simplex solver article - gist 3
Type solutionVectorType = new Type.Builder(renderScript, Element.F32(renderScript)).setX(script.get_MAX_COLS()).create();
Type resultSizeType = new Type.Builder(renderScript, Element.I32(renderScript)).create();
script.set_solution_vector(arrayAllocation);
script.set_result_size(resultSizeAllocation);
script.invoke_solve();
float[] solutionVector = new float[script.get_MAX_COLS()];
arrayAllocation.copyTo(solutionVector);
int[] resultSizeVector = new int[1];
resultSizeAllocation.copyTo(resultSizeVector);
@dzolnai
dzolnai / simplex.c
Last active January 17, 2017 18:32
Simples solver article - gist 4
#pragma version(1)
#pragma rs java_package_name(com.egeniq.lpsolver.renderscript)
#pragma rs_fp_full
#include "simplex.rsh"
@dzolnai
dzolnai / simplex.h
Created January 17, 2017 18:42
Simplex solver article - gist 5
#define DEBUG true
#if DEBUG
#define LOG(msg, param) rsDebug(msg, param)
#else
#define LOG(msg, param)
#endif