Skip to content

Instantly share code, notes, and snippets.

View goshki's full-sized avatar
👨‍💻
Such development, much coding. 😵‍💫

Adrian K. goshki

👨‍💻
Such development, much coding. 😵‍💫
View GitHub Profile
@goshki
goshki / dupa.kt
Last active July 15, 2020 07:57
Kotlin string infix function test
infix fun String.dupa(dupa:String) = dupa
fun main(dupargs:Array<String>) {
var dupa = "dupa";
dupa = dupa dupa dupa
println("dupa: $dupa") // output: dupa: dupa
}
@goshki
goshki / LinqListShuffler.cs
Created December 30, 2015 07:20
A helper method to easily randomize the order of elements in a given list using LINQ.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class LinqListShuffler {
public List<string> Shuffle(List<string> list) {
Random random = new Random();
return list.OrderBy(x => random.Next()).ToList();
@goshki
goshki / ListToDictionary.cs
Created December 30, 2015 07:17
Convert a given list to a dictionary with subsequent letters as keys (A, B, C, etc.).
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class ListToDictionary {
// Dictionary with subsequent letters as keys (A, B, C, etc.). Count should be less than or equal 24
// to get reasonable results.
public Dictionary<string, string> ToDictionary(List<string> list) {
Dictionary<string, string> dictionary = new Dictionary<string, string>(list.Count);
@goshki
goshki / FlxSound.hx
Created March 27, 2013 18:22
This version of FlxSound works with HaxeFlixel version 1.09 on Android target. When calling FlxG.playMusic(), the game doesn't crash.
package org.flixel;
import nme.Assets;
import nme.events.Event;
import nme.media.Sound;
import nme.media.SoundChannel;
import nme.media.SoundTransform;
import nme.net.URLRequest;
/**
@goshki
goshki / MultiNestedVectorsSerializationTest.as
Created May 11, 2011 08:57
ActionScript 3 serialization of multi-nested vectors
package {
import flash.text.TextField;
import flash.utils.ByteArray;
import flash.display.Sprite;
import flash.net.registerClassAlias;
public class MultiNestedVectorsSerializationTest extends Sprite {
public function FlashTest() {
registerClassAlias( "String", String );
registerClassAlias( "XML", XML );
@goshki
goshki / MultipleButtonInstantiationTestState.as
Created May 10, 2011 19:19
Flixel state for testing instantiation of multiple buttons at once
package {
import org.flixel.FlxButton;
import org.flixel.FlxG;
import org.flixel.FlxState;
/**
* An example Flixel state that instantiates multiple buttons at once during creation. To achieve
* this, it uses an array of dynamic configuration objects that hold properties specific for each
* button.
*/
@goshki
goshki / argbOperations.as
Created April 12, 2011 10:33
ActionScript 3 basic operations on an ARGB (alpha, red, green, blue) color
package {
public static function argbDecombine( ARGB:uint ):Array {
return [ ARGB >> 24, ( ARGB >> 16 ) & 0xFF, ( ARGB >> 8 ) & 0xFF, ARGB & 0xFF ];
}
public static function argbCombine( ARGB:Array ):uint {
return argbCombine( ARGB[0], ARGB[1], ARGB[2], ARGB[3] );
}
@goshki
goshki / FlashPunkKeyholdTest.as
Created February 28, 2011 15:46
Check for how long the given key has been held in FlashPunk mitigating the key-repeat under Linux
package {
import flash.utils.getTimer;
import net.flashpunk.*;
import net.flashpunk.utils.*;
/**
* <p>
* The reason to use such test is that under Linux holding a key triggers a key-repeat functionality after
* a moment and so, key-press events are generated. Therefore the Input.pressed() method will periodically
@goshki
goshki / run-java-app-with-classpath.sh
Created September 24, 2010 09:49
Bash command to run a Java app with automatically generated classpath based on jars in 'lib' folder.
# Automatically generate Java app classpath based on jars in 'lib' folder
javac -cp `echo lib/*jar | tr ' ' :` App.java
/**
* <p>
* What's the point (if there is any) and logic behind using/non-using "final" keyword for parameters in interface method and/or
* its implementation?
*/
public class Test {
// Example 1:
public static interface I {
void perform( final Boolean b ); // final on b