Skip to content

Instantly share code, notes, and snippets.

View LindaLawton's full-sized avatar
🎯
Focusing

Linda Lawton LindaLawton

🎯
Focusing
View GitHub Profile
@LindaLawton
LindaLawton / GenericHttp
Last active September 13, 2016 12:52
For sending Generic Http POST and Http Get calls. Works with .Net 3.5
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
namespace HttpStuff
@LindaLawton
LindaLawton / Insertion sort example C#
Created October 5, 2016 08:51
Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time https://en.wikipedia.org/wiki/Insertion_sort
/// <summary>
/// Insertion sort example
///
/// Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time
/// https://en.wikipedia.org/wiki/Insertion_sort
///
///
/// OutPut:
/// 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 ,
/// 8 , 9 , 7 , 6 , 5 , 4 , 3 , 2 , 1 ,
@LindaLawton
LindaLawton / Clone Object
Created October 27, 2016 10:18
Perform a deep Copy of the object, using Json as a serialisation method.
using Newtonsoft.Json;
using System;
using System.Globalization;
namespace HttpStuff.Util
{
public static class Extensions
{
/// <summary>
/// Perform a deep Copy of the object, using Json as a serialisation method.
@LindaLawton
LindaLawton / Delegates
Created November 16, 2016 08:03
testing out the different ways of Encapsulating a function.
private static string UppercaseString(string inputString)
{
return inputString.ToUpper();
}
delegate string ConvertMethod(string inString);
static void Main(string[] args)
{
var name = "linda";
@LindaLawton
LindaLawton / GoogleSamplecSharpSample.Methods.Drivev3
Last active July 23, 2018 03:42
Generated sample for Google Drive v3. Current issues with body, and needing to test the upload methods.
// Copyright 2016 DAIMTO : www.daimto.com
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
@LindaLawton
LindaLawton / List all files
Created December 12, 2016 13:33
Uses page streamer to eat up your quota.
/// <summary>
/// Lists or searches files.
/// Documentation https://developers.google.com/drive/v3/reference/files/list
/// Generation Note: This does not always build correctly. Google needs to standardize things I need to figure out which ones are wrong.
/// </summary>
/// <param name="service">Authenticated Drive service. </param>
/// <param name="optional">The optional parameters. </param>
/// <returns>FileListResponse</returns>
public static Google.Apis.Drive.v3.Data.FileList ListAll(DriveService service, FilesListOptionalParms optional = null)
{
@LindaLawton
LindaLawton / Upload file
Created December 12, 2016 13:34
code for uploading file to google drive v3
string filepath = @"C:\Users\linda_l\Documents\deleteme.txt";
if (System.IO.File.Exists(filepath.ToString()))
{
Google.Apis.Drive.v3.Data.File body = new Google.Apis.Drive.v3.Data.File();
body.Name = System.IO.Path.GetFileName(filepath.ToString());
body.Description = "Test Description";
body.MimeType = "text/plain";
byte[] byteArray = System.IO.File.ReadAllBytes(filepath);
System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
@LindaLawton
LindaLawton / GmailSendMail.psi
Last active December 6, 2021 05:18
Step by step guild to using power shell to get a Google access token.
clear-host;
#Remove-Variable * -ErrorAction SilentlyContinue
#get-item Variable:*
#Get-Variable | Select-Object -ExpandProperty Name
. C:\Users\linda_l\Desktop\PowerShell\GoogleOauth.ps1
Add-Type -Path "C:\Users\linda_l\Documents\visual studio 2015\Projects\TestingLibrary\packages\AE.Net.Mail.1.7.10.0\lib\net45\AE.Net.Mail.dll"
Add-Type -AssemblyName System.IO
Add-Type -AssemblyName System.Text.Encoding
@LindaLawton
LindaLawton / Google Analytics reporting
Created December 20, 2016 13:59
Powershell example using the Google analytics reporting api. Requires a refresh token to work.
Set-PSDebug -Off
Clear-Host
##########################################################################################################################
#
# Using refresh token to get new access token
# The access token is used to access an api by sending the access_token parm with any request.
# Access tokens are only valid for about an hour after that you will need to request a new one using your refresh_token
#
##########################################################################################################################
@LindaLawton
LindaLawton / BigONotation.cs
Created February 2, 2017 08:06
Big O notation shows time complexity of an algorithm.
class Program
{
delegate int del(int i);
delegate int[] delArray(int i);
delegate int[] delArray2(int[] i);
static void Main(string[] args)
{