├── SimpleMailForwarderDkim
├── Dockerfile
│ ├── TrustedHosts
│ ├── supervisord.conf
│ ├── opendkim.conf
│ └── Dockerfile
└── docker-compose.yml
├── WordPressDocker
├── php-uploads.ini
├── nginx.conf
└── docker-compose.yml
├── Common.Wpf
├── Common.Wpf.csproj
├── ViewModel
│ └── ViewModelBase.cs
└── Command
│ ├── CommandBase.cs
│ └── GenericCommand.cs
├── InterviewPrep
├── Codility
│ └── Palladium2020
│ │ ├── Palladium2020.csproj
│ │ ├── Palladium2020.sln
│ │ └── Program.cs
└── LeetCode
│ ├── find-the-town-judge.py
│ ├── reorganize-string.py
│ ├── remove-linked-list-elements.py
│ └── find-and-replace-in-string.py
├── ReflectionEmitClassGeneration
├── ViewModel
│ ├── ItemViewModelBase.cs
│ └── MainWindowViewModel.cs
├── App.xaml
├── ReflectionEmitClassGeneration.csproj
├── App.xaml.cs
├── View
│ ├── MainWindow.xaml.cs
│ └── MainWindow.xaml
├── ReflectionEmitClassGeneration.sln
└── Types
│ └── TypeGenerator.cs
├── TPLDataflowProcessing
├── App.xaml.cs
├── App.xaml
├── TPLDataflowProcessing.csproj
├── View
│ ├── MainWindow.xaml.cs
│ └── MainWindow.xaml
├── TPLDataflowProcessing.sln
├── Model
│ └── MockPriceFeed.cs
└── ViewModel
│ ├── PriceEventViewModel.cs
│ └── MainWindowViewModel.cs
├── README.md
├── react-native-firebase-socialauth
├── GoogleProvider.js
├── TwitterProvider.js
├── FacebookProvider.js
├── LoginFunctions.js
└── EmailProvider.js
├── .gitignore
└── LICENSE
/SimpleMailForwarderDkim/Dockerfile/TrustedHosts:
--------------------------------------------------------------------------------
1 | 127.0.0.1
2 | localhost
3 | 192.168.0.1/24
4 |
--------------------------------------------------------------------------------
/WordPressDocker/php-uploads.ini:
--------------------------------------------------------------------------------
1 |
2 | #
3 | # Allow larger file uploads
4 | #
5 | file_uploads = On
6 | memory_limit = 64M
7 | upload_max_filesize = 64M
8 | post_max_size = 64M
9 | max_execution_time = 600
10 |
11 |
--------------------------------------------------------------------------------
/Common.Wpf/Common.Wpf.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.0
5 | true
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/InterviewPrep/Codility/Palladium2020/Palladium2020.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.1
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ReflectionEmitClassGeneration/ViewModel/ItemViewModelBase.cs:
--------------------------------------------------------------------------------
1 | using Common.Wpf.ViewModel;
2 |
3 | namespace ReflectionEmitClassGeneration.ViewModel
4 | {
5 | public class ItemViewModelBase: ViewModelBase
6 | {
7 | public ItemViewModelBase()
8 | {
9 |
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ReflectionEmitClassGeneration/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ReflectionEmitClassGeneration/ReflectionEmitClassGeneration.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | netcoreapp3.0
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/SimpleMailForwarderDkim/Dockerfile/supervisord.conf:
--------------------------------------------------------------------------------
1 | [supervisord]
2 | nodaemon=true
3 |
4 | [program:smf]
5 | command=/entrypoint.sh
6 | autostart = true
7 | autorestart = true
8 | stdout_logfile=/dev/stdout
9 | stdout_logfile_maxbytes=0
10 | [program:smfopendkim]
11 | command=/usr/sbin/opendkim -f -x /etc/opendkim/opendkim.conf
12 |
13 | autostart = true
14 | stdout_logfile=/dev/stdout
15 | stdout_logfile_maxbytes=0
--------------------------------------------------------------------------------
/TPLDataflowProcessing/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace TPLDataflowProcessing
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/TPLDataflowProcessing/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ReflectionEmitClassGeneration/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace ReflectionEmitClassGeneration
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ReflectionEmitClassGeneration/View/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using ReflectionEmitClassGeneration.ViewModel;
2 | using System.Collections.ObjectModel;
3 | using System.ComponentModel;
4 | using System.Windows;
5 |
6 | namespace ReflectionEmitClassGeneration.View
7 | {
8 | ///
9 | /// Interaction logic for MainWindow.xaml
10 | ///
11 | public partial class MainWindow : Window
12 | {
13 | public MainWindow()
14 | {
15 | InitializeComponent();
16 |
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Common.Wpf/ViewModel/ViewModelBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Runtime.CompilerServices;
4 |
5 | namespace Common.Wpf.ViewModel
6 | {
7 | public abstract class ViewModelBase : INotifyPropertyChanged
8 | {
9 | public event PropertyChangedEventHandler PropertyChanged;
10 |
11 | public void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
12 | {
13 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
14 | }
15 |
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Common.Wpf/Command/CommandBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Input;
3 |
4 | namespace Common.Wpf.Command
5 | {
6 | public abstract class CommandBase : ICommand
7 | {
8 | public virtual bool CanExecute(object parameter)
9 | {
10 | return true;
11 | }
12 |
13 | public abstract void Execute(object parameter);
14 |
15 | public event EventHandler CanExecuteChanged
16 | {
17 | add { CommandManager.RequerySuggested += value; }
18 | remove { CommandManager.RequerySuggested -= value; }
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/TPLDataflowProcessing/TPLDataflowProcessing.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | netcoreapp3.0
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/SimpleMailForwarderDkim/Dockerfile/opendkim.conf:
--------------------------------------------------------------------------------
1 | AutoRestart Yes
2 | AutoRestartRate 10/1h
3 | UMask 002
4 | Syslog yes
5 | SyslogSuccess Yes
6 | LogWhy Yes
7 | Canonicalization relaxed/simple
8 | ExternalIgnoreList refile:/etc/opendkim/TrustedHosts
9 | InternalHosts refile:/etc/opendkim/TrustedHosts
10 | KeyTable refile:/etc/opendkim/KeyTable
11 | SigningTable refile:/etc/opendkim/SigningTable
12 | Mode sv
13 | PidFile /var/run/opendkim/opendkim.pid
14 | SignatureAlgorithm rsa-sha256
15 | UserID opendkim:opendkim
16 | Socket inet:8891@localhost
17 |
--------------------------------------------------------------------------------
/SimpleMailForwarderDkim/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.7'
2 |
3 | services:
4 | mail:
5 | build:
6 | context: Dockerfile
7 | dockerfile: Dockerfile
8 | args:
9 | SMF_EMAILDOMAIN: 'yourdomain.com'
10 | container_name: mail
11 | ports:
12 | - 25:25
13 | - 110:110
14 | - 995:995
15 | - 993:993
16 | - 143:143
17 | - 465:465
18 | - 587:587
19 | - 4190:4190
20 | restart: always
21 | volumes:
22 | - ./ssl_certs/smtp.key:/etc/postfix/cert/smtp.key
23 | - ./ssl_certs/smtp.cert:/etc/postfix/cert/smtp.cert
24 | - ./dkim/:/etc/opendkim/keys/
25 | environment:
26 | SMF_CONFIG: 'yourdomain.com:your@email.com'
27 | SMF_DOMAIN: 'yourdomain.com'
28 |
--------------------------------------------------------------------------------
/TPLDataflowProcessing/View/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace TPLDataflowProcessing
17 | {
18 | ///
19 | /// Interaction logic for MainWindow.xaml
20 | ///
21 | public partial class MainWindow : Window
22 | {
23 | public MainWindow()
24 | {
25 | InitializeComponent();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/InterviewPrep/LeetCode/find-the-town-judge.py:
--------------------------------------------------------------------------------
1 | from typing import List
2 | class Solution:
3 | def findJudge(self, N: int, trust: List[List[int]]) -> int:
4 | trustCount = {}
5 | for i in range(N):
6 | trustCount[i+1] = {"trusts": 0, "trusted": 0}
7 | for entry in trust:
8 | trustCount[entry[0]]["trusts"] += 1
9 | trustCount[entry[1]]["trusted"] += 1
10 | couldBeJudge = None
11 | for i in range(N):
12 | entry = trustCount[i + 1]
13 | if entry["trusts"] == 0 and entry["trusted"] == N -1:
14 | if couldBeJudge is not None:
15 | return -1
16 | couldBeJudge = i + 1
17 | if couldBeJudge is None:
18 | return -1
19 | return couldBeJudge
20 |
21 | sol = Solution()
22 | result = sol.findJudge(2, [[1,2]])
23 | print(result)
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Public Samples
2 | You can find various snippets available for educational purposes in this repo:
3 | ### WordPress Docker
4 | Docker-compose files to allow you to spin up a wordpress site with https
5 | ### Simple Mail Forwarder DKIM
6 | Attempt at using docker-compose to spin up Zixia's Simple Mail Forwarder with added DKIM signing on top
7 | ### React Native Firebase Social Auth
8 | React Native samples on how to sign up users using Firebase's social auth and email/password signup
9 | ### Reflection.Emit Class Generation
10 | C# .NET Core code and sample WPF app showing how to generate a new type at runtime using Reflection.Emit
11 | ### TPL Dataflow Processing Pipeline
12 | C# .NET Core app to demo functionality of the TPL Dataflow library for parallel data processing
13 | ### Interview Prep
14 | Code snippets for various Codility and LeetCode questions in Python and C#
15 |
16 |
--------------------------------------------------------------------------------
/Common.Wpf/Command/GenericCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Common.Wpf.Command
4 | {
5 | public class GenericCommand : CommandBase
6 | {
7 | private readonly Action _commandAction;
8 | private readonly Func