Skip to content

Instantly share code, notes, and snippets.

@Laiteux
Laiteux / ValidateTelegramUsername.cs
Last active May 12, 2024 08:52
C# method to validate a Telegram username using RegEx
using System;
using System.Text.RegularExpressions;
// NOTE: Change min length to 4 (instead of 5) in the RegEx if you want to include/allow NFT/Fragment usernames
bool ValidateTelegramUsername(string username)
=> Regex.IsMatch(username.TrimStart('@'),
@"^(?=.{5,32}$)(?!.*__)(?!^(telegram|admin|support))[a-z][a-z0-9_]*[a-z0-9]$",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
Console.WriteLine(ValidateTelegramUsername("Laiteux1")); // True
@richlander
richlander / modernizing-csharp9.md
Last active April 26, 2024 17:14
Modernizing a codebase for C# 9

Modernizing a codebase for C# 9

There are lots of cases that you can improve. The examples use nullable reference types, but only the WhenNotNull example requires it.

Use the property pattern to replace IsNullorEmpty

Consider adopting the new property pattern, wherever you use IsNullOrEmpty.

string? hello = "hello world";
@kontoulis
kontoulis / plugin.freezone.php
Created October 8, 2019 19:53
Overrides freezone in trackamnia
<?php
/**
* ManiaLive - Freezone Plugin
*
* @copyright Copyright (c) 2009-2011 NADEO (http://www.nadeo.com)
* @version $Revision: 3705 $:
* @author $Author: philippe $:
* @date $Date: 2011-05-09 13:04:04 +0200 (lun., 09 mai 2011) $:
*/
@mraaroncruz
mraaroncruz / steps.md
Last active June 9, 2024 06:31
Get the Telegram channel ID

To get the channel id

  1. Create your bot with botfather
  2. Make you bot an admin of your channel

Simplest way (via @anhtuank7c)

Go to Telegram web and open a channel, get the ID from -[channel id] from hash in the path

https://web.telegram.org/k/#-9999999999999

@Rand0mB0t
Rand0mB0t / asciiFlipper.py
Last active April 18, 2024 17:40
Simple Python script for flipping an ASCII- art
__author__ = 'Rand0mb0t'
# Code for ASCII-ART Flipper
img_file = str(input("select an input file : "))
save_file = str(input("Select an output file : "))
with open(img_file,"r") as file: # Open art- file
lines = file.read().split('\n')
while '' in lines: # Remove any empty lines from file
lines.remove('')
@thesadoo
thesadoo / getTelegramAvatar.php
Created July 21, 2017 19:34
Get user's Telegram avatar with a simple function using their Telegram usernames
<?php
function getTelegramAvatar($username='')
{
$username = $username;
$username = str_replace('@', '', $username);
$baseURL = 'https://telegram.me/';
$pageURL = $baseURL . $username;
@71
71 / ExampleAsync.cs
Last active January 25, 2023 20:34
A file I used to understand how async / await works behind-the-scenes in C#.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Tests
{
/// <summary>