Skip to content

Instantly share code, notes, and snippets.

📚
Diving into Xamarin docs

Mohamed Elshawaf mshwf

📚
Diving into Xamarin docs
Block or report user

Report or block mshwf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mshwf
mshwf / SLinkedList.cs
Last active Sep 8, 2019
Singly linked list implementation in C#
View SLinkedList.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
namespace ExtendedCollection
{
[DebuggerDisplay("{Value}")]
public class SNode<T>
{
@mshwf
mshwf / occurrences.cs
Created Jun 23, 2019
finds occurrences of a sub-string in a string
View occurrences.cs
List<Kmer> kmers = new List<Kmer>();
string message = "gjhcebfu71uevkkvhjv,yjvykku71jrbirbgerngtgntteu71agg6g79htu718eay8hibioay+8eru71ohob8vy89egyhoih89vu71oyhbigr89yhrrvoaeoghau71e8ryg98ergh.oaeryl9g7rv7g7iytg643483gi@$#t32@#2R23r213ri4tyg2ti.88oichu71tp9hg";
for (int i = 0; i <= message.Length - 3; i++)
{
string substring = message.Substring(i, 3);
int occurences = Regex.Matches(message, Regex.Escape(substring)).Count;
kmers.Add(new Kmer { Text = substring, Occ = occurences });
}
View image-optimizer.cs
class Program
{
static void Main(string[] args)
{
var img = Image.FromFile(@"C:\Users\Mohamed.Elshawaf\Desktop\imageTests\original.png");
var ratio = .75;
var height = img.Height;
var width = img.Width;
int newHeight = (int)(height * ratio);
int newWidth = (int)(width * ratio);
@mshwf
mshwf / proxy.cs
Created May 22, 2019
implementing DynamicProxy in .NET
View proxy.cs
using ConsoleTest.Repos;
using Goodreads;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Proxies;
using System.Security.Principal;
using System.Text;
@mshwf
mshwf / boiler_flutter.dart
Last active May 11, 2019
The auto-generated code in main.dart file by >flutter create
View boiler_flutter.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
View TextSwitch.cs
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
//Created by Mshwf, Jan 2019
namespace OudAuction.Controls
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public class TextSwitch : Grid
View AgeCalculator.cs
public static string ToAgeString(DateTime dob)
{
DateTime today = DateTime.Today;
int months = today.Month - dob.Month;
int years = today.Year - dob.Year;
if (today.Day < dob.Day)
{
months--;
View AgeCalculator.cs
public static string ToAgeString(DateTime dob)
{
DateTime today = DateTime.Today;
int months = today.Month - dob.Month;
int years = today.Year - dob.Year;
if (today.Day < dob.Day)
{
months--;
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex">
<link rel="shortcut icon" href="https://www.paytabs.com/images/favicon.png" />
<title>PayTabs - موثوقة و طريقة دفع سهلة</title>
@mshwf
mshwf / LINQchallenges1.cs
Last active Jul 19, 2018
My attempt to solve Lunchtime LINQ Challenge part1 https://www.markheath.net/post/lunchtime-linq-challenge
View LINQchallenges1.cs
//challeng 1
string names = "Davis, Clyne, Fonte, Hooiveld, Shaw, Davis, Schneiderlin, Cork, Lallana, Rodriguez, Lambert";
var team = names.Split(',').Select((player, index) => (index + 1) + ". " + player.Trim()).Aggregate((curr, next) => curr + ", " + next);
//challenge 2 (see answer)
string playersData = "Jason Puncheon, 26/06/1986; Jos Hooiveld, 22/04/1983; Kelvin Davis, 29/09/1976; Luke Shaw, 12/07/1995; " +
"Gaston Ramirez, 02/12/1990; Adam Lallana, 10/05/1988";
var players = playersData.Split(';').Select(player => (Name: player.Trim().Substring(0, player.IndexOf(',') - 1), DoB: DateTime.ParseExact(player.Substring(player.IndexOf(',') + 1).Trim(), "dd/MM/yyyy", CultureInfo.InvariantCulture))).Select(x => new { x.Name, x.DoB, Age = DateTime.Now.Year - x.Item2.Year }).OrderBy(x => x.Age).ToList();
You can’t perform that action at this time.