Skip to content

Instantly share code, notes, and snippets.

@jeevan-vj
jeevan-vj / deploy-static.ps1
Created December 3, 2017 14:39 — forked from chardcastle/deploy-static.ps1
Upload files (recursive) via powershell
## Automate FTP uploads
## Go to destination
cd C:\Test
$location = Get-Location
"We are here: $location"
## Get files
$files = Get-ChildItem -recurse
## Get ftp object
$ftp_client = New-Object System.Net.WebClient
$ftp_address = "ftp://user:pass@adress:/home/chardcastle/test"
@jeevan-vj
jeevan-vj / deepcopy.ts
Created January 4, 2018 02:25
typescript function for object deep copy
deepCopy(obj) {
let copy;
// Handle the 3 simple types, and null or undefined
if (null == obj || "object" != typeof obj) return obj;
// Handle Date
if (obj instanceof Date) {
copy = new Date();
copy.setTime(obj.getTime());
@jeevan-vj
jeevan-vj / ListFilesInZip.ps1
Last active February 13, 2018 09:39
list files in zip file using powershell
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')
$files = [IO.Compression.ZipFile]::OpenRead($sourceFile).Entries
Write-Host $files
@jeevan-vj
jeevan-vj / ArrayContainsInAnotherArray.ps1
Created February 13, 2018 09:48
array element exists in another array checking in powershell
$requiredFruit= @("apple","pear","nectarine","grape")
$someFruit= @("apple","banana","pear","nectarine","orange","grape")
$moreFruit= @("apple","banana","nectarine","grape")
-not @($requiredFruit| where {$someFruit -notcontains $_}).Count
-not @($requiredFruit| where {$moreFruit -notcontains $_}).Count
-not @($requiredFruit| where {$moreFruit -notcontains $_}| select -first 1).Count
# https://docs.microsoft.com/en-gb/powershell/module/Microsoft.PowerShell.Archive/Expand-Archive?view=powershell-5.1
Expand-Archive c:\a.zip -DestinationPath c:\a
@jeevan-vj
jeevan-vj / isBase64.js
Created February 20, 2018 08:14 — forked from RyanNutt/isBase64.js
Check if a String is base64 encoded using JavaScript - from https://stackoverflow.com/a/34068497/1561431
function isBase64(str) {
try {
return btoa(atob(str)) == str;
} catch (err) {
return false;
}
}
@jeevan-vj
jeevan-vj / IToastMessageService.cs
Created February 24, 2018 14:38
IToastMessageService.cs
public interface IToastMessageService
{
void ShowToastMessage(string message);
}
@jeevan-vj
jeevan-vj / ToastMessageService.cs
Created February 24, 2018 14:41
ToastMessageService.cs
[assembly: Xamarin.Forms.Dependency(typeof(ToastMessageService))]
namespace ToastTestXamarin.Droid
{
public class ToastMessageService : IToastMessageService
{
public void ShowToastMessage(string message)
{
Toast.MakeText(Android.App.Application.Context, message, ToastLength.Long).Show();
}
}
@jeevan-vj
jeevan-vj / MainPage.xaml
Created February 24, 2018 14:43
MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:ToastTestXamarin"
x:Class="ToastTestXamarin.MainPage">
<Button x:Name="BtnToastMessage" Text="Show Toast" Clicked="ShowToast"></Button>
</ContentPage>
@jeevan-vj
jeevan-vj / MainActivity.cs
Created March 15, 2018 13:05
Double tap to exit xamarin android
private bool doubleBackToExitPressedOnce = false;
public override void OnBackPressed()
{
if (doubleBackToExitPressedOnce)
{
base.OnBackPressed();
Java.Lang.JavaSystem.Exit(0);
return;
}