Skip to content

Instantly share code, notes, and snippets.

@AluBhorta
AluBhorta / cli.sh
Created April 13, 2023 16:47
set $AWS_ACCOUNT env var dynamically from aws cli
export AWS_ACCOUNT=$(aws sts get-caller-identity --output text --query Account --output text)
@AluBhorta
AluBhorta / xpath.js
Created April 10, 2023 13:13 — forked from iimos/xpath.js
Micro function that gives xpath by element and elements by xpath.
function xpath(el) {
if (typeof el == "string") return document.evaluate(el, document, null, 0, null)
if (!el || el.nodeType != 1) return ''
if (el.id) return "//*[@id='" + el.id + "']"
var sames = [].filter.call(el.parentNode.children, function (x) { return x.tagName == el.tagName })
return xpath(el.parentNode) + '/' + el.tagName.toLowerCase() + (sames.length > 1 ? '['+([].indexOf.call(sames, el)+1)+']' : '')
}
// Usage:
@AluBhorta
AluBhorta / output.md
Created August 4, 2021 14:09
docker history output example
IMAGE          CREATED          CREATED BY                                      SIZE      COMMENT
421fe9cc45f6   2 minutes ago    CMD ["/app/my-app.sh"]                          0B        buildkit.dockerfile.v0
<missing>      2 minutes ago    COPY . /app # buildkit                          176B      buildkit.dockerfile.v0
<missing>      2 minutes ago    RUN /bin/sh -c apk update # buildkit            2.15MB    buildkit.dockerfile.v0
<missing>      7 weeks ago      /bin/sh -c #(nop)  CMD ["/bin/sh"]              0B
<missing>      7 weeks ago      /bin/sh -c #(nop) ADD file:f278386b0cef68136…   5.6MB
@AluBhorta
AluBhorta / StorageClient.dart
Last active March 13, 2021 15:56
Firebase storage client for flutter/dart
import 'dart:io';
import 'package:firebase_storage/firebase_storage.dart';
class StorageClient {
final FirebaseStorage storage = FirebaseStorage.instance;
Future<String> uploadFile(String storagePath, File file) async {
try {
await storage.ref(storagePath).putFile(file);
return storagePath;