Skip to content

Instantly share code, notes, and snippets.

View prof18's full-sized avatar

Marco Gomiero prof18

View GitHub Profile
@arunkumar9t2
arunkumar9t2 / DependantModulesTask.kt
Last active July 21, 2023 15:43
Gradle task to find reverse dependencies of a module
import com.google.common.graph.Graphs
import com.google.common.graph.MutableValueGraph
import com.google.common.graph.ValueGraphBuilder
import org.gradle.api.DefaultTask
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.options.Option
@rharter
rharter / Scoped.kt
Last active August 9, 2022 14:58
A kotlin property delegate to scope any object to an android lifecycle. Blog post at https://ryanharter.com/blog/easy-android-scopes/
import androidx.lifecycle.get
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStore
import androidx.lifecycle.ViewModelStoreOwner
/**
* Returns a property delegate to access the wrapped value, which will be retained for the
* duration of the lifecycle of this [ViewModelStoreOwner].
*
@gotev
gotev / NavigationBottomBarSectionsStateKeeperWorkaround.kt
Last active June 12, 2023 16:08
JetPack Bottom Bar Navigation with Sections State
package jetpack.navigation.workaround
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.navigation.NavController
import androidx.navigation.ui.setupActionBarWithNavController
import com.google.android.material.bottomnavigation.BottomNavigationView
import java.lang.ref.WeakReference
@danybony
danybony / screenshot_android.sh
Last active June 30, 2021 12:05
Android screenshot to current dir
#!/bin/bash
while getopts y: flag
do
case "${flag}" in
y) size=${OPTARG};;
esac
done
DEVICES=`adb devices | grep -v devices | grep device | cut -f 1`
@omarmiatello
omarmiatello / google-apps-script-slide-share-telegram-slack-multicountry.js
Last active June 4, 2021 17:44
Notification system! Add button in Google Presentation for share a single slide in a Telegram channel.
function onOpen() {
var ui = SlidesApp.getUi();
ui.createMenu('GDG Tools')
.addSubMenu(ui.createMenu('Share this slide on "GDG Italia"')
.addItem('Telegram (favorite)', 'shareItalyTelegram')
.addItem('Slack', 'shareItalySlack'))
.addSubMenu(ui.createMenu('Share this slide on "GDG Spain"')
.addItem('Telegram', 'shareSpainTelegram')
.addItem('Slack (favorite)', 'shareSpainSlack'))
.addToUi();
/*
* Copyright (C) 2016 Jeff Gilfelt.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@tezzutezzu
tezzutezzu / data.csv
Last active February 15, 2023 00:14
nomi italiani
We can't make this file beautiful and searchable because it's too large.
name,rank,year,count,gender,percent
ANDREA,1,1999,10336,m,3.914617704
FRANCESCO,2,1999,9494,m,3.595721796
ALESSANDRO,3,1999,9000,m,3.408626096
MATTEO,4,1999,8703,m,3.296141435
LUCA,5,1999,7799,m,2.953763881
LORENZO,6,1999,7499,m,2.840143011
MARCO,7,1999,7002,m,2.651911103
DAVIDE,8,1999,6418,m,2.430729143
SIMONE,9,1999,6379,m,2.41595843
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Build;
import android.text.Editable;
import android.util.AttributeSet;
import android.util.TypedValue;
@jackgris
jackgris / build.gradle
Created June 6, 2014 18:51
Example of use from Proguard, from Android Studio
buildscript {
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
classpath 'com.squareup.gradle:gradle-android-test-plugin:0.9.1-SNAPSHOT'
@miguelgrinberg
miguelgrinberg / rest-server.py
Last active March 29, 2024 09:05
The code from my article on building RESTful web services with Python and the Flask microframework. See the article here: http://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask_httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':