Skip to content

Instantly share code, notes, and snippets.

View tiwiz's full-sized avatar

Roberto Orgiu tiwiz

View GitHub Profile
dependencies {
  compile "org.jetbrains.kotlinx:kotlinx-coroutines-android:0.22.5"
}
kotlin.coroutines=enable
fun launch(block: suspend () -> Unit): Job
suspend fun delay(
time: Long, 
unit: TimeUnit) {
  …
}
launch { 
 delay(1000L) 
 println("World!") 
}
@tiwiz
tiwiz / coroutines_example.kt
Last active July 2, 2018 12:05
Coroutines Introduction
launch { 
 delay(1000L) 
 println("World!") 
}
println("Hello,") 
Thread.sleep(2000L)
@tiwiz
tiwiz / password.sh
Created October 21, 2017 12:03
This Gist contains the way to get current wifi SSID and Password from a Mac OS X terminal
#!/bin/bash
# Usage ./password Name_Of_The_Wi-Fi_Network
# This script returns the password of the wireless SSID in input
echo "Wi-Fi SSID: $1"
ESCAPED=$(echo $1 | sed "s/'/\\\'/g" | sed "s/[ ]/\\\\ /g")
sudo security find-generic-password -ga ${ESCAPED} | sed -n -e 's/^.password: //p'
@tiwiz
tiwiz / RotationTestUtils.kt
Last active August 30, 2017 14:32
RotationTestUtils.kt
@file:JvmName("RotationTestUtils")
package com.your.package.
import android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
import android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
import android.content.res.Configuration
import android.content.res.Configuration.ORIENTATION_PORTRAIT
import android.support.test.InstrumentationRegistry
import android.support.test.rule.ActivityTestRule
@tiwiz
tiwiz / AddWifiNetwork.java
Last active October 27, 2018 23:14
Add your Wi-Fi Network to Android Things
String networkSSID = "Your Network SSID here";
String networkPasskey = "YourNetworkPasswordHere";
WifiConfiguration wifiConfiguration = new WifiConfiguration();
wifiConfiguration.SSID = "\"" + networkSSID + "\"";
wifiConfiguration.preSharedKey = "\"" + networkPasskey + "\"";
WifiManager manager = (WifiManager) getSystemService(WIFI_SERVICE);
manager.addNetwork(wifiConfiguration);
@Module
public class AuthenticationModule {
@Provides
@Singleton
public AuthenticationService provideAuthenticationService(UserRepository userRepository) {
return new AuthenticationController(userRepository);
}
}