Skip to content

Instantly share code, notes, and snippets.

View tiwiz's full-sized avatar

Roberto Orgiu tiwiz

View GitHub Profile

Keybase proof

I hereby claim:

  • I am tiwiz on github.
  • I am tiwiz (https://keybase.io/tiwiz) on keybase.
  • I have a public key whose fingerprint is EE83 0A02 F863 BF6C AE5D FA37 A3AC 13C1 7DE5 62DF

To claim this, I am signing this object:

@tiwiz
tiwiz / debug_layout.sh
Created July 11, 2016 13:59
This script is a faster way to enable and disable debug layout. Just run it and it will toggle the debug layout.
#!/bin/bash
adb shell setprop debug.layout true
adb shell am start com.android.settings/.DevelopmentSettings
adb shell input keyevent 4
@tiwiz
tiwiz / ChangeLocale.java
Created August 23, 2016 10:29
Change locale of the app
private void setLocale(String language, String country) {
Locale locale = buildLocaleWith(language, country);
Resources res = InstrumentationRegistry.getContext().getResources();
Configuration config = res.getConfiguration();
setLocaleInto(config, locale);
res.updateConfiguration(config, res.getDisplayMetrics());
}
@NonNull
private Locale buildLocaleWith(String language, String country) {
@Module
public class AuthenticationModule {
@Provides
@Singleton
public AuthenticationService provideAuthenticationService(UserRepository userRepository) {
return new AuthenticationController(userRepository);
}
}
@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);
@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 / 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 / coroutines_example.kt
Last active July 2, 2018 12:05
Coroutines Introduction
launch { 
 delay(1000L) 
 println("World!") 
}
println("Hello,") 
Thread.sleep(2000L)
launch { 
 delay(1000L) 
 println("World!") 
}
suspend fun delay(
time: Long, 
unit: TimeUnit) {
  …
}