Skip to content

Instantly share code, notes, and snippets.

@frestoinc
frestoinc / CC.md
Created September 10, 2024 05:02 — forked from mvandermeulen/CC.md
(ISC)2 Flashcards for CC (Certified in Cybersecurity)
  1. Security commensurate with the risk and the magnitude of harm resulting from the loss, misuse or unauthorized access to or modification of information.

Adequate Security

  1. Controls implemented through policy and procedures. Examples include access control processes and requiring multiple personnel to conduct a specific operation. Administrative controls in modern environments are often enforced in conjunction with physical and/or technical controls, such as an access-granting policy for new users that requires login and approval by the hiring manager.

Administrative Controls

  1. The ability of computers and robots to simulate human intelligence and behavior. > Artificial Intelligence
@frestoinc
frestoinc / AndroidManifest.xml
Created March 10, 2022 03:02
BLE Permission helper supporting Android 12
<uses-permission
android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
@frestoinc
frestoinc / PermissionActivity.md
Created April 2, 2021 18:08 — forked from mmoczkowski/PermissionActivity.md
Async permissions with Kotlin coroutines
package io.stanwood.bitrise

import android.annotation.SuppressLint
import android.content.pm.PackageManager
import android.support.v4.app.ActivityCompat
import android.support.v4.content.ContextCompat
import android.support.v7.app.AppCompatActivity
import kotlinx.coroutines.experimental.CancellableContinuation
import kotlinx.coroutines.experimental.suspendCancellableCoroutine
@frestoinc
frestoinc / ConfigGson.kt
Created October 27, 2020 09:13 — forked from vorobeij/ConfigGson.kt
Gson interface adapter for "Register an InstanceCreator with Gson for this type may fix this problem"
object ConfigGson {
fun getGson() = GsonBuilder().apply {
registerTypeAdapter(Launchable::class.java, InterfaceAdapter<Launchable>())
registerTypeAdapter(Trigger::class.java, InterfaceAdapter<Trigger>())
}.create()
}
@frestoinc
frestoinc / SharedPreferencesSingletonEnumKeyTemplate.java
Created September 14, 2020 01:26 — forked from alphamu/SharedPreferencesSingletonEnumKeyTemplate.java
A SharedPreferences singleton that can be used to centralise and simplify reading and writing of SharedPerferences in your Android app. There are 2 versions, one that uses static String for Keys and an other that uses enums. Which one you use comes down to your preference, enums I feel provides better control when you have multiple programmers w…
#if (${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import android.content.Context;
import android.content.SharedPreferences;
/*
* A Singleton for managing your SharedPreferences.
*
* You should make sure to change the SETTINGS_NAME to what you want
* and choose the operating made that suits your needs, the default is
@frestoinc
frestoinc / AdbCommands
Created August 11, 2020 05:27 — forked from Pulimet/AdbCommands
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="root"
CORRECT_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
private fun hasInternetConnection(): Boolean {
val connectivityManager = getApplication<NewsApplication>().getSystemService(
Context.CONNECTIVITY_SERVICE
) as ConnectivityManager
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val activeNetwork = connectivityManager.activeNetwork ?: return false
val capabilities = connectivityManager.getNetworkCapabilities(activeNetwork) ?: return false
return when {
capabilities.hasTransport(TRANSPORT_WIFI) -> true
capabilities.hasTransport(TRANSPORT_CELLULAR) -> true
@frestoinc
frestoinc / NestedConverter
Created March 4, 2020 01:33
Converter for room conversion in kotlin
class NestedConverter {
companion object {
@TypeConverter
@JvmStatic //needed
fun stringToList(data: String?): List<NestedRepo> {
if (data == null) {
return emptyList()
}
val type = object : TypeToken<List<NestedRepo>>() {}.type
@frestoinc
frestoinc / UnitTestsSuite.kt
Created March 4, 2020 01:32
Suite classes
import com.github.shchurov.gitterclient.unit_tests.tests.*
import org.junit.runner.RunWith
import org.junit.runners.Suite
@RunWith(Suite::class)
@Suite.SuiteClasses(
GetRoomMessagesInteractorTest::class,
GetRoomsInteractorTest::class
class UnitTestsSuite