This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createMapCircle: function(latitude, longitude){ | |
var latitudeRadius = this.getRadiusInLatitudeDegrees(this.radius); | |
var longuitudeRadius = this.getRadiusInLongitudeDegrees(this.radius, latitude); | |
for (var i = 0; i < 360; i++) { | |
var angle = i * (3.141516/180); | |
this.push('points', { | |
latitude: latitude + latitudeRadius * Math.sin(angle), | |
longitude: longitude + longuitudeRadius * Math.cos(angle), | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void initializeHardware() { | |
// Create peripheralManagerService and get GPIO list | |
PeripheralManagerService peripheralManagerService = new PeripheralManagerService(); | |
List<String> portList = peripheralManagerService.getGpioList(); | |
if (!portList.isEmpty()) { | |
try { | |
// Initialize GPIOs | |
initializeGpios(peripheralManagerService, portList, portList.size() < MAX_RELAYS ? portList.size() : MAX_RELAYS); | |
} catch (IOException e) { | |
view.showError("An error has ocurred"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Uploading relays | |
try { | |
for (Relay relay : relays) { | |
RelayDto relayDto = new RelayDto(relay.getLabel(), relay.getGpio().getValue()); | |
relayReference.child(relay.getId()).setValue(relayDto); | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void switchRelay(String key, Boolean value) { | |
try { | |
for (Relay relay : relays) { | |
if (relay.getId().equals(key)) { | |
relay.getGpio().setValue(value); | |
} | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.animation.Animator | |
import android.animation.AnimatorListenerAdapter | |
import android.annotation.TargetApi | |
import android.os.Build | |
import android.view.View | |
import android.view.ViewAnimationUtils | |
/** | |
* Animation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun String.normalize(): String { | |
val map = mutableMapOf<Char, Char>() | |
map.put('À', 'A') | |
map.put('Á', 'A') | |
map.put('Â', 'A') | |
map.put('Ã', 'A') | |
map.put('Ä', 'A') | |
map.put('È', 'E') | |
map.put('É', 'E') | |
map.put('Ê', 'E') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import IpAddress.Companion.IP_END | |
import IpAddress.Companion.IP_SEGMENT_SIZE | |
import IpAddress.Companion.IP_START | |
import kotlinx.coroutines.experimental.runBlocking | |
import java.net.URL | |
/** | |
* Ipfy | |
*/ | |
data class IpAddress(private val segment1: Int, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.util.Log | |
/** | |
* AndroidExtensions | |
*/ | |
/** | |
* Any | |
* */ | |
fun Any.info(text: String) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.support.v7.widget.RecyclerView | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
/** | |
* RootAdapter | |
*/ | |
abstract class RootAdapter<T>(protected val items: MutableList<T> = mutableListOf(), | |
private val onItemClickListener: (T) -> Unit = {}, |
OlderNewer