Skip to content

Instantly share code, notes, and snippets.

View cesarferreira's full-sized avatar

César Ferreira cesarferreira

View GitHub Profile
@davidteren
davidteren / nerd_fonts.md
Last active March 22, 2024 10:57
Install Nerd Fonts via Homebrew [updated & fixed]
<?
# MIT license, do whatever you want with it
#
# This is my invoice.php page which I use to make invoices that customers want,
# with their address on it and which are easily printable. I love Stripe but
# their invoices and receipts were too wild for my customers on Remote OK
#
require_once(__DIR__.'/../vendor/autoload.php');
@flutter-clutter
flutter-clutter / overlay_with_hole.dart
Created June 27, 2020 12:08
Flutter overlay with a hole
import 'package:flutter/material.dart';
class OverlayWithHole extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Flutterclutter: Holes")),
body: _getExperimentOne()
);
}
@bessarabov
bessarabov / gist:674ea13c77fc8128f24b5e3f53b7f094
Last active March 27, 2024 07:46
One-liner to generate data shown in post 'At what time of day does famous programmers work?' — https://ivan.bessarabov.com/blog/famous-programmers-work-time
git log --author="Linus Torvalds" --date=iso | perl -nalE 'if (/^Date:\s+[\d-]{10}\s(\d{2})/) { say $1+0 }' | sort | uniq -c|perl -MList::Util=max -nalE '$h{$F[1]} = $F[0]; }{ $m = max values %h; foreach (0..23) { $h{$_} = 0 if not exists $h{$_} } foreach (sort {$a <=> $b } keys %h) { say sprintf "%02d - %4d %s", $_, $h{$_}, "*"x ($h{$_} / $m * 50); }'
@zulhfreelancer
zulhfreelancer / fix-bundle-install-network-error.md
Last active October 30, 2023 05:34
How to fix bundle install 'network error while fetching' issue on Mac OSX?

If you get something like this when running bundle install...

Network error while fetching https://rubygems.org/quick/Marshal.4.8/xxx-x.x.x.gemspec.rz (execution expired)

...this solution might work for you.

First, make sure you have tried all the troubleshoot solutions here.

@igeligel
igeligel / get-medium-stats.js
Last active December 1, 2022 13:02
medium-get-totals
const totalTypes = {
VIEWS: 2,
READS: 3,
FANS: 5
};
const getTotal = tableColumn =>
[
...document.querySelectorAll(
`td:nth-child(${tableColumn}) > span.sortableTable-number`
@cesarferreira
cesarferreira / MyRecyclerViewAdapter.kt
Last active July 1, 2021 04:24
DiffUtils kotlin extension
class DeliveryWindowsAdapter : RecyclerView.Adapter<DeliveryWindowsAdapter.ViewHolder>() {
var items: List<DeliveryWindowUiModel> by Delegates.observable(emptyList()) { _, oldList, newList ->
autoNotify(oldList, newList) { o, n -> o.id == n.id }
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val deliveryWindow = items[position]
holder.title.text = deliveryWindow.title
holder.price.text = deliveryWindow.friendlyPrice
@ferrerojosh
ferrerojosh / AndroidWorkerInjection.kt
Created May 30, 2018 06:40
androidx workmanager injector temporary impl
import androidx.work.Worker
object AndroidWorkerInjection {
fun inject(worker: Worker) {
checkNotNull(worker, { "worker" })
val application = worker.applicationContext
if (application !is HasWorkerInjector) {
throw RuntimeException("${application.javaClass.canonicalName} does not implement ${HasWorkerInjector::class.java.canonicalName}")
}
@daniellAlgar
daniellAlgar / Logger.kt
Last active March 28, 2020 10:36
This is a safe way to do logging in your Android apps without running the risk of having Log() statements in your production code. It reduces garbage collection and eliminates the need for a log tag.
package com.?
import android.os.Build
import android.util.Log
import com.varvet.shipgaz.BuildConfig
import java.util.regex.Pattern
/**
* A logger to avoid logging in production. It will check if [BuildConfig.DEBUG] is true or not.
* If true then allow logging, otherwise don't.
@PrashamTrivedi
PrashamTrivedi / DownloadRequest.kt
Last active February 25, 2023 12:43
Download File with progress indicator, written in Kotlin with Co-routines
suspend fun downloadFile(url: String,
downloadFile: File,
downloadProgressFun: (bytesRead: Long, contentLength: Long, isDone: Boolean) -> Unit) {
async(CommonPool) {
val request = with(Request.Builder()) {
url(url)
}.build()
val client = with(OkHttpClient.Builder()) {
addNetworkInterceptor { chain ->