Skip to content

Instantly share code, notes, and snippets.

View Budincsevity's full-sized avatar

Norbert Budincsevity Budincsevity

  • Genesys
  • Hungary
View GitHub Profile
@Budincsevity
Budincsevity / EmbeddedServer.kt
Created November 20, 2017 11:48
Java lightweight embedded web-server
package io.github.budincsevity
import com.sun.net.httpserver.HttpServer
import java.io.PrintWriter
import java.net.InetSocketAddress
fun main(args: Array<String>) {
val server = HttpServer.create(InetSocketAddress(8080), 0)
server.createContext("/hello") { http ->
@Budincsevity
Budincsevity / combinations.py
Created September 8, 2017 12:32
Combinations of list items
import itertools
stuff = ['a', 'b', 'c']
for L in range(0, len(stuff)+1):
for subset in itertools.combinations(stuff, L):
print(subset)
@Budincsevity
Budincsevity / BooleanUtils.java
Last active August 28, 2017 08:15
Utility class for Java Boolean
public class BooleanUtils {
private static final Random RANDOM = new Random();
public boolean maybe() {
return RANDOM.nextBoolean();
}
}
@Budincsevity
Budincsevity / install.bat
Last active November 19, 2015 20:59
Install TensorFlow on Windows
1.) Download and install Docker Toolbox for Windows
2.) Run the folowing commands to create a Docker virtual machine in cmd:
docker-machine create vdocker -d virtualbox
FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd vdocker') DO %i
docker run -it b.gcr.io/tensorflow/tensorflow
3.) Run python
@Budincsevity
Budincsevity / WorkingWithJSON.md
Last active August 29, 2015 14:26
Working with JSON in Android

Working with JSON in Android

Create a JSONObject

JSONObject jObject = new JSONObject(string); 

To get a specific string

String aJsonString = jObject.getString("STRINGNAME"); 
@Budincsevity
Budincsevity / AndroidManifest.xml
Last active August 29, 2015 14:26 — forked from billmote/AndroidManifest.xml
When pushing code from your IDE, wake the device and show the activity.
<?xml version="1.0" encoding="utf-8"?>
<!-- Add this as a debug manifest so the permissions won't be required by your production app -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
</manifest>
@Budincsevity
Budincsevity / gist:772970ea2425d227a244
Last active August 29, 2015 14:26 — forked from JakeWharton/gist:f50f3b4d87e57d8e96e9
Rise and Shine™, unlock and wake up your device automatically when you deploy from the IDE. Put this somewhere in your `src/debug/` code and run it when the application or main activity starts. Apache 2.
/**
* Show the activity over the lockscreen and wake up the device. If you launched the app manually
* both of these conditions are already true. If you deployed from the IDE, however, this will
* save you from hundreds of power button presses and pattern swiping per day!
*/
public static void riseAndShine(Activity activity) {
activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED);
PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE);
PowerManager.WakeLock lock =
@Budincsevity
Budincsevity / Convert.java
Created July 20, 2015 10:16
Convert Date to LocalDate
Date input = new Date();
LocalDate date = input.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
@Budincsevity
Budincsevity / Main.java
Last active August 29, 2015 14:25
Migrating from JodaTime Period to ThreeTen
//JodaTime
Interval interval = new Interval(time, new Date().getTime());
Period period = interval.toPeriod();
int minutes = period.getMinutes();
int hours = period.getHours();
//ThreeTen
Instant firstInstant= Instant.ofEpochMilli(time);
Instant secondInstant = Instant.ofEpochMilli(new Date().getTime());
@Budincsevity
Budincsevity / Billing.java
Created July 16, 2015 22:12
InApp Billing on Android
final String id = "android.test.purchased";
mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder binder) {
service = IInAppBillingService.Stub.asInterface(binder);
String purchaseToken = "inapp:" + getPackageName() + ":android.test.purchased";
try {
int response = service.consumePurchase(3, getPackageName(), purchaseToken);
} catch (RemoteException e) {