Skip to content

Instantly share code, notes, and snippets.

View sorashi's full-sized avatar

Dennis Pražák sorashi

View GitHub Profile
@sorashi
sorashi / UserDecision.cs
Last active June 9, 2021 03:23
A method that asks user for an answer, validates if the answer is right and returns the desired value. If the answer is invalid, it asks the user again.
private static object GetUserDecision(string question, Type typeToReturn, Func<object, bool> validator)
{
string answer;
if (typeToReturn == typeof(bool))
{
do
{
Write(question + " (y/n) ");
answer = Console.ReadLine();
answer = answer.ToLower().Trim();
@sorashi
sorashi / 1000-7.py
Created January 19, 2016 17:49
Tokyo Ghoul reference
import time
now=time.time()
c=1000
while c>0:
print c
c-=7
print "Hello, Tokyo! It took me "+str(round((time.time()-now)*1000,3))+"ms to count down from 1000, decreasing by 7."
@sorashi
sorashi / kana.txt
Last active March 7, 2024 07:59 — forked from Cybuster/kana
Kana and kanji list for development purposes
Katakana Codes
ァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶヷヸヹヺ・
Basic Katakana
アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲン
Punctuation and Symbols
゛゜ーヽヾ
Phonetic Extensions for Ainu
@sorashi
sorashi / twitch-irc-recieved-message.regex
Created March 4, 2016 19:27
RegEx for pulling out information from Twitch IRC messages recieved in a channel
^:(?<user>[a-zA-Z0-9_]{4,25})!\1@\1\.tmi\.twitch\.tv PRIVMSG #(?<channel>[a-zA-Z0-9_]{4,25}) :(?<message>.+)$
@sorashi
sorashi / czechia.md
Last active August 2, 2017 08:14
Czechia, the short name of the Czech Republic

Czechia (Czech Republic)

The geographical name Czechia was officially announced when the state started to exist on its own in 1993. The reason why it is not known is because the Czech state and its institutions have not used it. A short country name that is not used by the state itself and by its institutions cannot become well known and recognized abroad.

Czechia is listed in UNTERM.

Some examples to make the difference between a political and a geographical name clear

Keybase proof

I hereby claim:

  • I am sorashi on github.
  • I am sorashi (https://keybase.io/sorashi) on keybase.
  • I have a public key ASBwT6rSA3IN9ucBeb8lFArMNi-s_EyVCmw3_U013Ulv9wo

To claim this, I am signing this object:

@sorashi
sorashi / Fraction.cs
Last active June 9, 2021 03:23
The base for a fraction class. Can be used to represent rational numbers precisely.
using System;
using System.Text.RegularExpressions;
public class Fraction
{
private int denominator = 1;
private int nominator = 0;
public Fraction() {
}
@sorashi
sorashi / primalityTest.cs
Last active June 9, 2021 03:22
Prime number utilities
public static bool IsPrime(int candidate) {
if ((candidate & 1) == 0)
return candidate == 2;
for (int i = 3; (i * i) <= candidate; i += 2)
if ((candidate % i) == 0)
return false;
return candidate != 1;
}
@sorashi
sorashi / problem54.csx
Last active May 25, 2017 15:46
This is the solution to problem 54 of Project Euler. Don't look at this if you don't want to see spoilers. The hand ranking uses a lot of LINQ, enjoy 😄
#r "System.Numerics"
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.IO;
using System.Diagnostics;
/*
@sorashi
sorashi / color_names.txt
Created August 1, 2017 14:30
Color dictionary, taken from Name that Color http://chir.ag/projects/ntc/
000000|Black
000080|Navy Blue
0000C8|Dark Blue
0000FF|Blue
000741|Stratos
001B1C|Swamp
002387|Resolution Blue
002900|Deep Fir
002E20|Burnham
002FA7|International Klein Blue