Skip to content

Instantly share code, notes, and snippets.

View UdaraAlwis's full-sized avatar
🙈
Monkeying!

Udara Alwis UdaraAlwis

🙈
Monkeying!
View GitHub Profile
@UdaraAlwis
UdaraAlwis / AppHashKeyGenerator.cs
Created March 5, 2019 10:41
Generate Android App Hash Key in Xamarin using Package Name and Keystore Signature
// move to the class global level
using Android.Util;
using Java.Security;
using Java.Util;
using System.Text;
// move to the class global level
private static string HASH_TYPE = "SHA-256";
private static int NUM_HASHED_BYTES = 9;
private static int NUM_BASE64_CHAR = 11;
@UdaraAlwis
UdaraAlwis / CrossCurrentActivityHelperExtension.cs
Last active July 30, 2019 07:47
Simple fix to use CrossCurrentActivity plugin in your .Net Standard based Xamarin.Forms solutions
// this goes in your shared .Net Standard project
namespace WhateveryourNamespace.SharedProject.Helpers
{
/// <summary>
/// Simple helper extension to access CrossCurrentActivity
/// plugin instance from your .NET Standard project.
/// </summary>
public static class CrossCurrentActivity
{
/// <summary>Current settings to use</summary>
@UdaraAlwis
UdaraAlwis / JsonFileHelper.cs
Last active August 20, 2019 11:46
Read the Json File content added as EmbeddedResources in your VS project
using System;
using System.IO;
using System.Reflection;
namespace WhateverYourNamespace
{
public static class JsonFileHelper
{
public static string GetJsonFileString()
{
@UdaraAlwis
UdaraAlwis / FillInTheBlanksUiXamForms.cs
Last active September 26, 2019 11:29
Fill in the blanks question form in Xamarin Forms
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace App2
{
@UdaraAlwis
UdaraAlwis / ExecuteGoogleFormsSubmitAsync.cs
Last active November 21, 2019 13:29
Execute a Google Forms data submission from their REST API.
private static async Task ExecuteGoogleFormsSubmitAsync()
{
// Init HttpClient to send the request
HttpClient client = new HttpClient();
// Build the Field Ids and Answers dictionary object
// (replace with your Google Form Ids and Answers)
var bodyValues = new Dictionary<string, string>
{
{"entry.1277095329","Orange Snails"},
@UdaraAlwis
UdaraAlwis / ScrapeOffListOfFieldIdsFromGoogleFormsAsync.cs
Last active November 24, 2019 10:37
Scrape off the list of Field IDs from Google Forms.
// Imports you might need! ;)
//using HtmlAgilityPack;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Threading.Tasks;
private static async Task<List<string>> ScrapeOffListOfFieldIdsFromGoogleFormsAsync(string yourGoogleFormsUrl)
{
HtmlWeb web = new HtmlWeb();
@UdaraAlwis
UdaraAlwis / FFMPEG_SPLITVIDEOFILE.bat
Last active December 7, 2019 12:38
Split or Cut Video files using ffmpeg
:: Make sure ffmpeg.exe and the video file is in the same folder
:: Download ffmpeg: https://www.ffmpeg.org/download.html
:: Command Line executable code
:: Split a given mp4 file using ffmpeg.exe
:: Method 1: From 00:00:00 To 00:00:15
ffmpeg -i video_file_name.mp4 -ss 00:00:00 -t 00:00:15 -vcodec copy video_file_name_output.mp4
:: Method 1: From 00:00:15 To End
@UdaraAlwis
UdaraAlwis / FFMPEG_GETVIDEOFILEDATA.bat
Last active December 7, 2019 12:38
Get Video file Playback time using ffprobe
:: Make sure ffprobe.exe and the video file is in the same folder
:: Download ffmpeg: https://www.ffmpeg.org/download.html
:: Command Line executable code
:: Get video length of a given mp4 file using ffprobe.exe
:: 0:01:01.812000
:: HOURS:MM:SS.MICROSECONDS
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 video_file_name.mp4 -sexagesimal
@UdaraAlwis
UdaraAlwis / GoogleFormsFieldTypeEnum.cs
Last active December 9, 2019 16:36
An enum model class representing a Question Field Types Google Forms...
// using System.ComponentModel;
/// <summary>
/// Found the Field type representation values with trial
/// and error try out of blood sweat and tears lol! ;)
/// </summary>
public enum GoogleFormsFieldTypeEnum
{
[Description("Short Answer Field")]
ShortAnswerField = 0,
@UdaraAlwis
UdaraAlwis / GoogleFormField.cs
Created December 16, 2019 13:16
An model class representing a Question Field in Google Forms...
// using System.Collections.Generic;
/// <summary>
/// A Question Field in a Google Form
/// </summary>
public class GoogleFormField
{
/// <summary>
/// Type of the Question Field
/// </summary>