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 / MatricsRotation.cs
Last active March 17, 2017 14:57
Rotate a matrix by 90 or 180 degrees
using System;
namespace CsharpCodeExamples
{
class Program
{
static void Main(string[] args)
{
var data = new int[,] { { 1, 1, 1, 1 },
{ 2, 2, 2, 2 },
using System;
namespace CsharpCodeExamples
{
class Program
{
public class SimpleStack<T>
{
int top;
private T[] data;
@LindaLawton
LindaLawton / BinarySearch.cs
Created March 13, 2017 13:47
binary search (or binary chop) o(log n) is a Logarithmic algorithm. Doubling the data only means it needs to do one extra chop.
using System;
using System.Linq;
namespace CsharpCodeExamples
{
class Program
{
static void Main(string[] args)
{
using System;
using System.Linq;
namespace CsharpCodeExamples
{
class Program
{
static void Main(string[] args)
{
// Quadratic Complexity the more data you have the more checks it has to make and the more time it will take to run.
@LindaLawton
LindaLawton / gist:b576d21924139902b7163d0441636a20
Created March 1, 2017 09:04 — forked from PureKrome/gist:55698e875e6c9028a09096c04691186f
Calling google api's in unit tests by providing fake responses
/*
This is a quick example of how to fake out the response for calling a Google API endpoint.
I'm using the QPX Express api as an example, but I'm _assuming_ this could apply accross the board
for other Google API's.
The reason you would want to do this, is so you don't need to hit the internet to get your results
(think, coding on a plane, no internet coverage, no hurting your API allowance, etc).
The main trick here is that we need to do two things:
1. Create a fake HttpMessageHandler
@LindaLawton
LindaLawton / BinarySearch.cs
Last active March 13, 2017 13:47
BigO Examples
using System;
using System.Linq;
namespace CsharpCodeExamples
{
class Program
{
static void Main(string[] args)
{
@LindaLawton
LindaLawton / GoogleDriveAuthentcation.cs
Created February 21, 2017 12:01
How to remove a file from the share with me folder on Google drive using the Google drive api V3 and C#
using Google.Apis.Auth.OAuth2;
using Google.Apis.Drive.v3;
using Google.Apis.Services;
using Google.Apis.Util.Store;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
internal class GoogleDriveAuthentcation
@LindaLawton
LindaLawton / GoogleAuthenticationCurl.sh
Last active August 8, 2023 14:08
Curl bash script for getting a Google Oauth2 Access token
# Tutorial https://www.daimto.com/how-to-get-a-google-access-token-with-curl/
# YouTube video https://youtu.be/hBC_tVJIx5w
# Client id from Google Developer console
# Client Secret from Google Developer console
# Scope this is a space seprated list of the scopes of access you are requesting.
# Authorization link. Place this in a browser and copy the code that is returned after you accept the scopes.
https://accounts.google.com/o/oauth2/auth?client_id=[Application Client Id]&redirect_uri=http://127.0.0.1&scope=[Scopes]&response_type=code
# Exchange Authorization code for an access token and a refresh token.
@LindaLawton
LindaLawton / GoogleDriveListAllFilesSample.cs
Created February 8, 2017 08:06
Sample for listing all of the files in google drive and displaying them in a directory structure.
using Google.Apis.Auth.OAuth2;
using Google.Apis.Drive.v3;
using Google.Apis.Services;
using Google.Apis.Util.Store;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace GoogleDriveListAllFilesSample
@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)
{