Skip to content

Instantly share code, notes, and snippets.

View venkatd's full-sized avatar

Venkat Dinavahi venkatd

View GitHub Profile
@venkatd
venkatd / auth.ex
Last active November 20, 2024 17:18
Minimal S3 lib based on Req - MIT LICENSE or do whatever you want with it plus I copiedbig chunks from ReqS3/ExAws anyway
defmodule Ex.S3.Auth do
def put_aws_sigv4(request) do
if s3_options = request.options[:s3] do
s3_options =
s3_options
|> Keyword.put_new(:region, "us-east-1")
|> Keyword.put_new(:datetime, DateTime.utc_now())
# aws_credentials returns this key so let's ignore it
|> Keyword.drop([:credential_provider, :bucket, :endpoint])
|> Keyword.put(:service, :s3)
defmodule MyApp.Billing.StripeClient do
def new(opts \\ []) do
Req.new(
base_url: "https://api.stripe.com/v1",
auth: {:bearer, Application.fetch_env!(:my_app, MyApp.Billing)[:stripe_secret_key]}
)
|> Req.merge(opts)
|> Req.Request.prepend_request_steps(encode_stripe_post: &encode_stripe_post/1)
end

Debugger

import Codex.KinoHelpers

Section

{:ok, pid} = Entrace.start_link()
import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
typedef TapOutsideCallback = void Function(BoxHitTestResult hitTestResult);
/// Allows widgets to detect when tapping outside of the bounds of the widget.
///
/// A common use case is allowing [TextField]s and other widgets to give up
/// their focus when someone taps outside of them.
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
/// This class smooths over the platform differences for a RawKeyEvent,
/// encapsulates some workarounds for Flutter keyboard handling bugs,
/// and makes it easier to match up [LogicalKeyEvent] to a keyboard shortcut
/// combo.
///
/// It accounts for edge cases & bugs such as:
void main() {
final lst1 = ["t1" , "t2" , "t3" , "t4"];
final lst2 = ["t2" , "t4" , "t5"];
final diff = lst1.whereNotIn(lst2).toList();
print(diff);
}
extension WhereNotInExt<T> on Iterable<T> {
Iterable<T> whereNotIn(Iterable<T> reject) {
final rejectSet = reject.toSet();
import 'dart:io';
import 'package:file/local.dart';
import 'package:glob/glob.dart';
import 'package:path/path.dart' as path;
void main(List<String> args) async {
assert(args.length == 1);
await updateRelativeImportsInPackage(args[0]);
}
@venkatd
venkatd / separated.dart
Created December 19, 2020 18:46
If you want to add some space in your rows/columns, can give this a try.
import 'package:flutter/widgets.dart';
class SeparatedRow extends StatelessWidget {
const SeparatedRow({
@required this.separator,
@required this.children,
this.mainAxisAlignment = MainAxisAlignment.start,
this.mainAxisSize = MainAxisSize.max,
this.crossAxisAlignment = CrossAxisAlignment.center,
}) : assert(separator != null),
import 'package:flutter/widgets.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
// adapted from https://stackoverflow.com/a/54173729/67655
class ExpandableSection extends HookWidget {
const ExpandableSection({
Key key,
this.expanded = false,
this.child,
import 'package:flutter/widgets.dart';
// original credit to https://medium.com/swlh/flutter-line-metrics-fd98ab180a64
class LineMetricsDebug extends StatelessWidget {
LineMetricsDebug({
this.text,
this.style,
this.width,
this.height,