Skip to content

Instantly share code, notes, and snippets.

View wcoder's full-sized avatar
🎯
Focusing

Yauheni Pakala wcoder

🎯
Focusing
View GitHub Profile
@wcoder
wcoder / export-csv-to-json.js
Created October 16, 2023 18:56
Export CSV spreadsheets from Google docs and convert to JSON with formatting
#!/bin/bash
DOC_ID=''
SHEET_ID=0
TMP_FILE='temp.csv'
OUTPUT_FILE='result.json'
# export csv
curl -L "https://docs.google.com/spreadsheets/d/$DOC_ID/export?format=csv&gid=$SHEET_ID" -o $TMP_FILE
@wcoder
wcoder / ya.js
Last active October 10, 2024 11:19 — forked from wildcard/ya.py
Download file from Yandex.Disk through share link for large file. Pure Node.js script
#!/usr/bin/env node
// How to
// wget http://gist.github.com/...
// chmod +x ya.js
// ./ya.js download_url path/to/directory
const https = require('https');
const { URL } = require('url');
const { spawn } = require('child_process');
@wcoder
wcoder / ls_profiles.sh
Last active May 24, 2023 20:08
Show a list of all iOS provisioning profiles with decoded content
#!/bin/bash
PP="$HOME/Library/MobileDevice/Provisioning Profiles"
echo $PP
echo "All Provisioning Profiles:"
ls -al "$PP"
echo "Decoded Provisioning Profiles:"
@wcoder
wcoder / firestore.utils.ts
Last active July 31, 2022 14:18
Utility method to update more than 500 docs in Firestore using Batch. TypeScript.
import admin from 'firebase-admin';
/**
* Firestore does not accept more than 500 writes in a transaction or batch write.
*/
const MAX_TRANSACTION_WRITES = 499;
type WriteBigBatchOperationType = (batch: admin.firestore.WriteBatch) => void;
type WriteBigBatchCallbackType = (operation: WriteBigBatchOperationType) => void;
@wcoder
wcoder / extend_string_format.cs
Created August 5, 2021 13:34
The example demonstrates the use of square brackets to extend the C # string.Format ()
using System;
public static class StringExtensions
{
public static string Format(this string str, params object[] parameters)
{
return string.Format(str, parameters);
}
@wcoder
wcoder / xamarin-help.md
Last active July 14, 2021 19:37
Xamarin Q&A

Xamarin.Android

How to get Java class from C# type?

Java.Lang.Class has a special method for managed types:

Java | C# (Xamarin.Android)

@wcoder
wcoder / find-span-generic.cs
Last active July 14, 2021 15:24
Generic Xamarin.Android method to find Span in TextView for implementation custom LinkMovementMethod.OnTouchEvent
private T FindSpan<T>(TextView textView, ISpannable spannable, MotionEvent e)
where T : Java.Lang.Object
{
var x = (int)e.GetX() - textView.TotalPaddingLeft + textView.ScrollX;
var y = (int)e.GetY() - textView.TotalPaddingTop + textView.ScrollY;
var layout = textView.Layout;
int position = layout.GetOffsetForHorizontal(layout.GetLineForVertical(y), x);
var links = spannable.GetSpans(position, position, Java.Lang.Class.FromType(typeof(T)));
private void SetLeftDrawableWithBounds(Button button, int drawableResId, Size size, Android.Graphics.Color tintColor) {
var context = button.Context;
var drawable = DrawableCompat.Wrap(AppCompatDrawableManager.Get().GetDrawable(context, drawableResId)).Mutate();
drawable.SetBounds(0, 0, (int) context.ToPixels(size.Width), (int) context.ToPixels(size.Height));
if (tintColor != Android.Graphics.Color.Transparent) {
DrawableCompat.SetTint(drawable, tintColor);
}
button.SetCompoundDrawables(drawable, null, null, null);
@wcoder
wcoder / replace-projectreference-csproj.md
Created June 9, 2021 21:43
Replace .csproj old project reference format to new one.
  1. open text editor (with ability to replace text via regex)
  2. open target .csproj file
  3. start find and replace: (csproj")>\n(.*)Project>\n(.*)Name>\n(.*)ProjectReference>
  4. to $1 /&gt;
@wcoder
wcoder / firestore-document-id.js
Created February 23, 2021 12:00
Snippet to simply generate Firestore Document ID outside of Firebase SDK. (Javascript, Node.js)
const { randomBytes } = require('crypto');
// Sources: https://github.com/firebase/firebase-js-sdk/blob/4090271bb71023c3e6587d8bd8315ebf99b3ccd7/packages/firestore/src/util/misc.ts#L27-L55
const newId = () => {
// Alphanumeric characters
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
// The largest byte value that is a multiple of `char.length`.
const maxMultiple = Math.floor(256 / chars.length) * chars.length;
let autoId = '';