Skip to content

Instantly share code, notes, and snippets.

View remylavergne's full-sized avatar
🏠
Working from home

Rémy LAVERGNE-PRUDENCE remylavergne

🏠
Working from home
View GitHub Profile
@remylavergne
remylavergne / download-file.go
Last active June 21, 2021 20:35
[Go] [Golang] How to download file
func downloadFile(fullUrl string) {
// Extract filename from path
fileURL, err := url.Parse(fullUrl)
if err != nil {
check(err)
}
path := fileURL.Path
segments := strings.Split(path, "/")
fileName := segments[len(segments)-1]
@remylavergne
remylavergne / copy-files.kts
Last active March 3, 2021 09:37
[Kotlin - Coroutines - KScript] Script to copy local files / folders
@file:DependsOnMaven("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2")
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.runBlocking
import java.io.File
import kotlin.system.exitProcess
import kotlin.system.measureTimeMillis
@remylavergne
remylavergne / Main.kt
Last active October 29, 2020 07:51
Kotlin - Composition with Delegation / Reflection - Two ways
import kotlin.reflect.KMutableProperty
import kotlin.reflect.KProperty
import kotlin.reflect.full.memberProperties
fun main() {
// Create Sup
val spiderman: SuperHeroe = SuperHeroe(Person(firstname = "Peter", lastname = "Parker", age = 28), "SpiderMan")
println("Spiderman firstname: ${spiderman.firstname}")
@remylavergne
remylavergne / main.dart
Created September 26, 2020 09:19
shuffle_dart
void main() {
// On crée / reçoit la liste des questions
List<Question> questions = [
new Question("Quel temps fait-il ?"),
new Question("Que manges-tu ?"),
new Question("Quelle est cette couleur ?"),
new Question("Quel fruit est-ce ?"),
new Question("Quelle est ta voiture préférée ?"),
new Question("Quel film regardes-tu ?"),
new Question("Où habites-tu ?")
@remylavergne
remylavergne / android-apk-signature.md
Last active November 29, 2021 11:29
[Android ] Verify APK Signature >26 with apksigner

Android APK Signature verification (>26)

Tool

Apksigner can be used to verify APK signature. It's a part of build-tools since version 26.

Where to find it ? (e.g.)

  • macOS : ~/Users/<your_user_name>/Library/Android/sdk/build-tools/<build-tools-version>/lib/
  • Windows : ?
@remylavergne
remylavergne / main.dart
Created May 7, 2020 18:13
[Flutter] YouTube videos list simple
import 'package:flutter/material.dart';
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
final List<String> urls = [
'UvBiN3BAxw4', // Aquafrolics
@remylavergne
remylavergne / main.dart
Last active May 6, 2020 18:06
[Flutter] ListView Builder example
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
final List<String> urls = [
@remylavergne
remylavergne / disney-cars-2-fix.md
Last active July 13, 2022 10:32
[Windows 10] Disney Pixar Cars 2 game crash fix

Disney Pixar Cars 2 (2011) crash fix

Problems

  • Black screen
  • Music loop stuck
  • Computer freeze (needs a full reboot to work again)
  • Can't play more than one mission

Tested & fixed on Windows 10

@remylavergne
remylavergne / InternetConnectivity.kt
Created March 18, 2020 20:49
[Android] Internet connectivity
fun isInternetAvailable() {
try {
val command = "ping -c 1 google.com"
if (Runtime.getRuntime().exec(command).waitFor() == 0) {
viewAction.onNext(LauncherAction.InternetAvailable)
} else {
viewAction.onNext(
LauncherAction.NoNetwork(
R.string.launcher_error_no_network_title,
R.string.launcher_error_no_network_message
@remylavergne
remylavergne / ServiceManager.kt
Created March 18, 2020 15:15
[Android] WorkManager snippets
class ServiceManager(private val context: Context) {
private val globalsConstraints =
Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build()
// Add new jobs here
private val allServicesAvailables =
listOf(
Service(IncidentsSynchronizationWorker::class.java, IncidentsSynchronizationWorker.TAG),
Service(AttachmentsCleaningWorker::class.java, AttachmentsCleaningWorker.TAG)