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 / AppHashKeyHelper.cs
Last active July 21, 2020 10:14
Generate Android App Hash Key in Xamarin
using System;
using System.Linq;
using System.Text;
using Android.Content;
using Android.Content.PM;
using Android.Util;
using Java.Security;
using Java.Util;
namespace WhateverNameSpace.Droid.Util
@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_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 / 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_GENERATEVIDEOFROMIMAGES.bat
Last active March 17, 2023 11:03
Generate a slideshow video from images in a folder using ffmpeg
:: Generate a Video Slideshow from images in a folder on Windows
:: that's optimized for current system's screen resolution
:: Make sure your Images, ffmpeg executables, and this batch file are in the same folder
:: The images should be ".jpg" format, or you may change in the script below
:: Make sure to download ffmpeg: https://www.ffmpeg.org/download.html
:: Command Line executable code
:: Begin by getting the framerate. ex: 1/2
:: This determines time span for each image to display
:: And load the images in the current directory