Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Yauheni Pakala wcoder

💭
I may be slow to respond.
View GitHub Profile
@wcoder
wcoder / firestore-document-id.js
Created Feb 23, 2021
Snippet to simply generate Firestore Document ID outside of Firebase SDK. (Javascript, Node.js)
View firestore-document-id.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 = '';
@wcoder
wcoder / stations.json
Last active Feb 17, 2021
Railway stations. For app development only
View stations.json
[
{
"id": "1",
"ru": "443 км",
"be": "443 км",
"be_lat1": "443 km",
"be_lat2": "443 km"
},
{
"id": "2",
View WKWebView-RemoveFacebookCookies.cs
public static void RemoveFacebookCookies()
{
var websiteDataTypes = WKWebsiteDataStore.AllWebsiteDataTypes;
WKWebsiteDataStore.DefaultDataStore.FetchDataRecordsOfTypes(websiteDataTypes, (NSArray records) =>
{
for (nuint i = 0; i < records.Count; i++)
{
var record = records.GetItem<WKWebsiteDataRecord>(i);
if (record.DisplayName.Contains("facebook"))
{
@wcoder
wcoder / ssl-pinning.cs
Last active Dec 12, 2019
Sample of SSL-pinning via NSUrlSession for Xamarin.iOS.
View ssl-pinning.cs
internal static class Samples
{
public static void MakeRequest()
{
var s = "https://secure-domain.org";
var request = new NSMutableUrlRequest(new NSUrl(s))
{
HttpMethod = "GET"
};
@wcoder
wcoder / jquery-1.10.2.min.js
Created Oct 22, 2019
404 Page Galaxy Sample
View jquery-1.10.2.min.js
/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
//@ sourceMappingURL=jquery-1.10.2.min.map
*/
(function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.2",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.hasOwnProperty,b=f.trim,x=function(e,t){return new x.fn.init(e,t,r)},w=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,C=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,k=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,S=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,j=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,H=function(e,t){return t.toUpperCase()},q=function(e){(a.addEventListener||"load"===e.type||"complete"===a.readyState)&&(_(),x.ready())},_=function(){a.addEventListener?(a.removeEventListener("DOMContentLoaded",q,!1),e.removeEventListener("load",q,!1)):(a.detachEvent("onreadystatechange",q),e.detachEvent("o
@wcoder
wcoder / xamarin_ios_launch_terminal.md
Created Oct 17, 2019
Snippets for launch ios app on device/simulator via terminal.
View xamarin_ios_launch_terminal.md

From VS4Mac & Rider:

/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mlaunch \
--sdkroot /Applications/Xcode.app/Contents/Developer \
--devname "<DEVICE_NAME>" \
--killdev <APP_BUNDLE_NAME> \
--launchdev <PROJECT_PATH>/bin/iPhone/Debug/<PROJECT_NAME>.app \
--wait-for-unlock \
--argument=-connection-mode\
--argument=usb -sdk 10.0 \
@wcoder
wcoder / update_version.sh
Created Apr 3, 2019
Simple bash script for update versions of Xamarin applications via terminal or CI
View update_version.sh
#!/usr/bin/env bash
# For Xamarin Android or iOS, change the package name located in AndroidManifest.xml and Info.plist.
# AN IMPORTANT THING: YOU NEED DECLARE PACKAGE_NAME, PACKAGE_VERSION ENVIRONMENT VARIABLE IN APP CENTER BUILD CONFIGURATION.
PACKAGE_NAME="com.your.name"
PACKAGE_VERSION="0.1"
ANDROID_PROJECT_PATH="ProjectName.Android"
ANDROID_MANIFEST_PATH="$ANDROID_PROJECT_PATH/Properties/AndroidManifest.xml"
@wcoder
wcoder / ColorExtensions.cs
Created Mar 19, 2019
Port of UIColorMSHashExtension from Swift to C#. Office UI Fabric iOS for Xamarin.iOS
View ColorExtensions.cs
using System;
using UIKit;
namespace XamarinOfficeUIFabric
{
public static class ColorExtensions
{
// Original MS Source:
// https://github.com/OfficeDev/office-ui-fabric-ios/blob/master/OfficeUIFabricCore/OfficeUIFabricCore/Core/Colors/UIColorMSHashExtension.swift
public static UIColor MSHashColor(this string hash)
@wcoder
wcoder / README.md
Created Jan 13, 2019
Simple script for mirror migrate a repository from Bitbucket to Github
View README.md

How to use

  1. create repo on github (from web interface)
  2. run script:
./bitbucket_to_github.sh <user_name> <repository_name>

Sample: