Skip to content

Instantly share code, notes, and snippets.

@jeevan90
jeevan90 / deploy-static.ps1
Created Dec 3, 2017 — forked from chardcastle/deploy-static.ps1
Upload files (recursive) via powershell
View deploy-static.ps1
## 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"
@jeevan90
jeevan90 / deepcopy.ts
Created Jan 4, 2018
typescript function for object deep copy
View deepcopy.ts
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());
@jeevan90
jeevan90 / ListFilesInZip.ps1
Last active Feb 13, 2018
list files in zip file using powershell
View ListFilesInZip.ps1
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')
$files = [IO.Compression.ZipFile]::OpenRead($sourceFile).Entries
Write-Host $files
@jeevan90
jeevan90 / ArrayContainsInAnotherArray.ps1
Created Feb 13, 2018
array element exists in another array checking in powershell
View ArrayContainsInAnotherArray.ps1
$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
View Expand-Archive.ps1
# 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
@jeevan90
jeevan90 / isBase64.js
Created Feb 20, 2018 — forked from RyanNutt/isBase64.js
Check if a String is base64 encoded using JavaScript - from https://stackoverflow.com/a/34068497/1561431
View isBase64.js
function isBase64(str) {
try {
return btoa(atob(str)) == str;
} catch (err) {
return false;
}
}
@jeevan90
jeevan90 / IToastMessageService.cs
Created Feb 24, 2018
IToastMessageService.cs
View IToastMessageService.cs
public interface IToastMessageService
{
void ShowToastMessage(string message);
}
View 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();
}
}
View 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>
@jeevan90
jeevan90 / MainActivity.cs
Created Mar 15, 2018
Double tap to exit xamarin android
View MainActivity.cs
private bool doubleBackToExitPressedOnce = false;
public override void OnBackPressed()
{
if (doubleBackToExitPressedOnce)
{
base.OnBackPressed();
Java.Lang.JavaSystem.Exit(0);
return;
}