Skip to content

Instantly share code, notes, and snippets.

View AmSmart's full-sized avatar
🏠
Working from home

Emmanuel Oluwagbemiga Adebiyi (Smart) AmSmart

🏠
Working from home
View GitHub Profile
@AmSmart
AmSmart / script.py
Last active August 6, 2021 15:44
Decompress a zip file in S3 into a folder and upload it back to S3 (via SageMaker)
import boto3
import os
from zipfile import ZipFile
# When running on SageMaker, need execution role
from sagemaker import get_execution_role
role = get_execution_role()
# Declare bucket name, remote file, and destination
my_bucket = ""
@AmSmart
AmSmart / GuessingGame.c
Created June 22, 2021 22:23
EEE 376 Past Question Solutions
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int getRandomNumber();
int main(){
int guess = 0;
char playAgain = 'y';
bool wrongGuess;
# Setup the package source
wget https://packages.microsoft.com/config/ubuntu/20.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
# Install the SDK
sudo apt-get update; \
sudo apt-get install -y apt-transport-https && \
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-5.0
# This script helps to open a VS solution in VS2019, can be modified for other VS versions.
# Usage:
# 'vs2019here' --> Opens a VS solution in the current working directory, if any
# 'vs2019here .' --> Opens VS in the current working directory (folder view mode)
# 'vs2019here path' --> Opens a VS solution in the specified path(folder view mode if path is not a isn't a ".sln" file)
# 'vs2019here -p path' --> Opens a VS solution in the specified path(folder view mode if path isn't a ".sln" file)
$vs19 = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe"
$vs19WorkDir = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE"
$filesInCwd = Get-ChildItem(Get-Location)
@AmSmart
AmSmart / IThumbnailGenerator.cs
Last active September 28, 2020 23:16
Xamarin.Android dependency service to extract a thumbnail from a video
using Xamarin.Forms;
namespace YourApp.Shared.DependencyServices
{
public interface IThumbnailGenerator
{
ImageSource GenerateThumbnailImageSource(string url, long usecond);
string GenerateThumbnailAsPath(string url, long usecond, string appCachePath);
}
}
@AmSmart
AmSmart / Page.xaml
Created September 2, 2020 00:29
SelcetedItems not working properly (Xamarin.Forms CollectionView)
<?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:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="StatusSaver.Views.VideosPage">
<ContentPage.ToolbarItems>
<ToolbarItem Text="Save" Command="{Binding Save}"/>
@AmSmart
AmSmart / LengthOfLongestSubstring.cs
Last active August 21, 2020 22:17
Returns the length of the longest continuous substring of a string with no repeated character (C# &Python)
public int LengthOfLongestSubstring(string s)
{
// Dictionary to keep track of valid substrings and their length
var substringDict = new Dictionary<string, int>();
for(int i = 0; i < s.Length; i++)
{
// Dictionary to detect if any character is being repeated
// This should have been an HashSet😒 as the value in each pair is a dummy
var reptDetector = new Dictionary<char, int>();
string x = s.Substring(i);