Skip to content

Instantly share code, notes, and snippets.

@darklankou
darklankou / namada-32.md
Last active March 27, 2024 21:07
Namada migration 32
@henry2man
henry2man / persistence_controller.dart
Last active August 31, 2021 14:24
Flutter PersistenceController with initialization from Assets Backup and restore capabilities. Uses Floor. This is handmade, I've removed some stuff... in order to use it in your code you'll need to adapt it. My code is able to: Preload the database file with a copy that is stored in app assets. Create a backup in the SD Card Restore the databas…
import 'dart:async';
import 'dart:io';
import 'package:floor/floor.dart';
import 'package:flutter/services.dart';
import 'package:path/path.dart';
import 'package:path_provider/path_provider.dart';
import 'package:sqflite/sqflite.dart' as sqflite;
part 'persistence_controller.g.dart'; // the generated code will be there
@nikartm
nikartm / Cache.java
Last active April 26, 2024 07:40
Android. Example how to save an image file in the App cache and get Uri for it. The Image will not be saved in a device gallery, only in an internal App cache.
package com.github.example;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.core.content.FileProvider;
@Bambina-zz
Bambina-zz / index.js
Created April 30, 2019 08:19
A cloud function which sends data notification to all users stored in Firestore.
const functions = require('firebase-functions');
// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
// exports.helloWorld = functions.https.onRequest((request, response) => {
// response.send("Hello from Firebase!");
// });
// Import the Firebase SDK for Google Cloud Functions.
@koral--
koral-- / strings.xml
Created January 14, 2018 18:13
XML entity in strings.xml
<!DOCTYPE resources [
<!ENTITY foo "Foo">
]>
<resources>
<string name="app_name">&foo;</string>
<string name="busy_warning">Sorry, &foo; is working hard, please try again in a moment.</string>
<string name="trademark">&foo; is a registerd trademark, all rights reserved.</string>
</resources>
// Good
exports.sendEmail = functions.auth.user().onCreate(event => {
const mailgun = require('mailgun-js');
// ...
});
// Not As Awesome
const mailgun = require('mailgun-js');
exports.sendEmail = functions.auth.user().onCreate(event => {
@TWiStErRob
TWiStErRob / OkHttpProgressGlideModule.java
Last active January 31, 2024 13:37
Full POC for showing progress of loading in Glide v3 via OkHttp v2
// TODO add <meta-data android:value="GlideModule" android:name="....OkHttpProgressGlideModule" />
// TODO add <meta-data android:value="GlideModule" tools:node="remove" android:name="com.bumptech.glide.integration.okhttp.OkHttpGlideModule" />
// or not use 'okhttp@aar' in Gradle depdendencies
public class OkHttpProgressGlideModule implements GlideModule {
@Override public void applyOptions(Context context, GlideBuilder builder) { }
@Override public void registerComponents(Context context, Glide glide) {
OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(createInterceptor(new DispatchingProgressListener()));
glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
}
@jamescmartinez
jamescmartinez / slack_delete.rb
Last active May 28, 2024 15:00
This Ruby script will bulk remove all Slack files older than 30 days. Just add your API token from https://api.slack.com/web#authentication into the token quotes at the top of the file.
require 'net/http'
require 'json'
require 'uri'
@token = ''
def list_files
ts_to = (Time.now - 30 * 24 * 60 * 60).to_i # 30 days ago
params = {
token: @token,
@protrolium
protrolium / ffmpeg.md
Last active May 15, 2024 18:27
ffmpeg guide

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

You can get the list of installed codecs with:

@dmytrodanylyk
dmytrodanylyk / res_color_btn_flat_selector.xml
Last active March 4, 2023 07:52
Material Flat Button Style
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false"
android:color="@color/flat_disabled_text"/>
<item android:color="@color/flat_normal_text"/>
</selector>