Skip to content

Instantly share code, notes, and snippets.

View lukehorvat's full-sized avatar

Luke Horvat lukehorvat

View GitHub Profile
@lukehorvat
lukehorvat / sibelius_fixer.bat
Created January 15, 2013 12:25
Batch file for fixing WAVs exported from Sibelius. Uses SoX to process files.
cd %~dp0
mkdir converted
FOR %%A IN (%*) DO (
sox %%A "converted/%%~nxA" reverse trim 4.3 reverse trim 0.3 gain -n -1
lame -V7 converted/%%~nxA
)
pause
@lukehorvat
lukehorvat / decision_instructions.py
Last active December 11, 2015 03:28
[Blog post code] Genetic Programming with esec: An Introductory Example
instructions = [
DecisionInstructionWithState(lambda fitness_case: 1 if fitness_case.outlook == 'SUNNY' else (2 if fitness_case.outlook == 'OVERCAST' else 3), param_count=3, name='OUT'),
DecisionInstructionWithState(lambda fitness_case: 1 if fitness_case.humidity == 'HIGH' else 2, param_count=2, name='HUM'),
DecisionInstructionWithState(lambda fitness_case: 1 if fitness_case.windy else 2, param_count=2, name='WIND'),
]
@lukehorvat
lukehorvat / gp_decision_tree.py
Created January 15, 2013 10:42
An introduction to genetic programming with esec demonstrating decision tree induction.
from esec import esdl_eval
from esec.species.tgp import Instruction, DecisionInstructionWithState
from esec.landscape.tgp import TGPFitness
#define the attributes of a Saturday morning
OUTLOOK = ('SUNNY', 'OVERCAST', 'RAIN')
HUMIDITY = ('HIGH', 'NORMAL')
WINDY = (True, False)
#define the state object to store attributes of a Saturday morning
@lukehorvat
lukehorvat / ConcurrentImageBrightnessNormalizer.cs
Last active December 11, 2015 03:28
An example of concurrent image brightness normalization in C#.
//determine the brightness range of this thread's image strip
Tuple brightnessRange = GetImagePartBrightnessRange(image, startX, startY, finishX, finishY);
//update the global brightness range of the entire image
lock (_lock)
{
minBrightness = Math.Min(minBrightness, brightnessRange.Item1);
maxBrightness = Math.Max(maxBrightness, brightnessRange.Item2);
}
@lukehorvat
lukehorvat / SeekBarDialogPreference.java
Last active December 10, 2015 06:58
An Android preference class that provides a user with the means to select an integer from a SeekBar and persist it. (License: MIT License)
package com.lukehorvat;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.SeekBar;
@lukehorvat
lukehorvat / NumberPickerDialogPreference.java
Last active June 17, 2021 14:06
An Android preference class that provides a user with the means to select an integer from a NumberPicker and persist it. (License: MIT License)
package com.lukehorvat;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.NumberPicker;