Skip to content

Instantly share code, notes, and snippets.

View webserveis's full-sized avatar

Webserveis webserveis

View GitHub Profile
@webserveis
webserveis / SeparatorTextView.java
Created February 3, 2023 18:54 — forked from alphamu/SeparatorTextView.java
Demonstration of how to make a custom TextView which has a separator running across it. Screenshot of TextView https://raw.githubusercontent.com/alphamu/RxAndroidDemo/master/app/SeparatorTextViewSample.png
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Build;
import android.util.AttributeSet;
import android.view.Gravity;
import android.widget.TextView;
/**
* Simple version used in the article:
@webserveis
webserveis / youtube2mp3.py
Last active January 15, 2023 13:26
Script convert youtube video to MP3 in Python
import os
from sty import fg, bg, ef, rs
from pytube import YouTube
from pathlib import Path
import re
import inquirer
def cError(text): return fg.red + text + fg.rs
def cWarging(text): return fg.da_yellow + text + fg.rs
@webserveis
webserveis / EventDate.py
Last active December 27, 2022 16:20
Script EventDate TimeZone
import datetime
from dateutil.tz import gettz
class RegionTZ:
def __init__(self, name, tz, flag=None):
self.name = name
self.tz = gettz(tz.strip())
if flag is None:
flag = self.name
self.flag = flag
@webserveis
webserveis / appsales.py
Created December 26, 2022 15:43
GPlay Tools
from datetime import datetime, timedelta
from datetime import date
class AppGplay:
def __init__(self, name, startDate, endDate=None):
self.name = name
self.startDate = startDate
if endDate is None:
endDate = self.startDate + timedelta(days=7)
self.endDate = endDate
@webserveis
webserveis / aReadme.md
Last active November 3, 2022 11:41
Cercanias, procesado de datos abiertos para los horarios de trenes

Dependencias

  • Servidor Mysql
  • Instalar Python 3+
  • Instalar dependencias de python, pandaz, mysql, alive-progress $> pip install mysql-connector-python $> pip install pandas $> pip install alive-progress

Fuente de datos

@webserveis
webserveis / SingletonHolder.kt
Created October 15, 2022 18:45
SingletonHolder Kotlin Andorid
package com.kotlin.utils.singleton
/**
* What if you need pass some arguments for initialization jus like parameterized constructor?
* Since we can't use constructor with the object keyword. So, we need to find some other way of
* doing the same.
*
* We can archive this by using a SingletonHolder class.
* Also, to make it thread-safe, we need to have a way of synchronized a double check locking principle.
*/
@webserveis
webserveis / Main.swift
Created August 31, 2022 12:06
Pokemon Battle Swift
import Foundation
enum PokemonType : Int {
case Water = 0
case Fire
case Plant
case Electro
static var count: Int { return PokemonType.Electro.rawValue + 1}
@webserveis
webserveis / AuthState.kt
Last active August 30, 2022 13:50
Firebase Auth ViewModel
sealed class AuthState {
object Idle : AuthState()
object Authenticating : AuthState()
class Authenticated(val user: FirebaseUser? = null) : AuthState()
object Unauthenticated : AuthState()
class AuthError(val message: String? = null) : AuthState()
}
@webserveis
webserveis / MainActivity.kt
Created August 4, 2022 18:05
FirebaseUI para Android usando Kotlin
class MainActivity : AppCompatActivity() {
private lateinit var appBarConfiguration: AppBarConfiguration
private lateinit var binding: ActivityMainBinding
private val mViewModel by viewModels<AuthViewModel> {
AuthViewModelFactory(this.application)
}
private val auth by lazy {
FirebaseAuth.getInstance()
@webserveis
webserveis / FirstFragment.kt
Created July 7, 2022 15:59
TabLayout MVVM Kotlin
class FirstFragment : Fragment() {
private var _binding: FragmentFirstBinding? = null
private val binding get() = _binding!!
val viewModel by activityViewModels<MyViewModel>()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {