Skip to content

Instantly share code, notes, and snippets.

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

Aloïs de Gouvello aloisdg

🏠
Working from home
View GitHub Profile
@aloisdg
aloisdg / add.py
Created March 23, 2018 23:56
add kata
import unittest
# https://tio.run/##lZPBasMwDIbveQrRHRLTEtr0Nuhp63FsbIXBxjCmURozx85shbZPn9lJWrqthc43S/o//cJyvafS6Hkrq9pYgkZLInTU5liAyPNE6rqhCeSoZCUJLSwgHsfsNoJwZAFdQSpdLjeSkkMiHIvUWO0LqKew6DTsmioJqR2DwljY@bqB5WrlSceOjEXRWgnnYOWNvZCVevOA3nXukoPdNKTuhEPfv@sS7IfEG1qTOFTFibFwTT0PLS2/GqGSMOdoOmITmLKf8keN16lnQT37q35SjbseMu4w2XnMamuuxWQBM7/o5r@melvzi7ZeJZX3h@e6kppmo0mcxme4vH//35iweCUqZWBrrMrjyw3csEGe/d5L4gnEveqDHXU3sC5x/QlUCoJBA4WQysG2RO3j6Nm1sIL8fkoH2hAIcN0CHilbP/uphWchHbpkta9xaa2xpx8imB28Zaz1f4dzLSrkHBZ@OM4rITXnca84rnaIJqz9Bg
def add(input, delimiter = '+'):
if input.isdigit():
return int(input)
return sum(int(x) for x in input.split(delimiter))
class TestStringMethods(unittest.TestCase):
@aloisdg
aloisdg / weapon.py
Created March 23, 2018 23:55
Magical weapon calculator
import unittest
# https://www.reddit.com/r/Pathfinder_RPG/comments/14ibsz/need_help_with_cost_of_magical_weapons/
# https://tio.run/##vZXfb9owEMff81fcC0oCEUpCqdCkPmyMdQ@rOqmV9oBQ5IKh1hKb2c42Vu1vZ2fnZymIiIdJUeLcWZ87f3N32e70s@Cj/Z5lWyE15JxpTZV2nGVKlIIZX71zAMCdiiwTHJ6IolC41kICSVOg2TYVO0qVazYmGVGayl9Cfp8KpeEGRmFoHIr9ofj28rd6mbufGKfuAo3hcNxYP7KM8Vyzn0d8j4zv3lofMszDmqPGeEdXLM8OrV@I3BTcuDF@zkvbVWO7xY2E65xw65k0nqlIhVKkDHjtGM@KriFJGIqXJJ6i6ToAIdmGcZIG1cmrjAJ4EjxX5hABUP5M@JJmlGtjmS98K7cJhpRhBUFXtWy7S7J5tM0V3z7bjoNo7ddyG37v4VaypcGa9eHnHNR5QN9usJqY2wJ9XhEZFyrPvDbeB7Z@fViaYiWFvg/9PsQIi0Osk0ZLpWUpZa2IpDqXHNxBbwU9VV8u9MBrzh000gTgPmhKU5Tcff8jJ5otzfJWUqLJb@r6TlXmj1jyd2TDlt8o2QruVW0wNI4p1rxJwqZhsjOe@1KG1ymWOiOSSj3DkKmHInlx6BeqBjDCtXOUZEuzIw5PUVRyw706xTXV3R1re6GhTpB6/OBVG3RH141T469PimFbuju6mAAdRDYDpDvWjpuGGp2ifjCF1x1bD4KoZsenU7bw@AJ6XNMnZ@ijC@ijmh6dw48vwI9r/Dg8g581Y@WSbxDAPFp0lqoV7J5TvC4NGbSCRv8varxodcnbqF8l66AiDufD3mvx/YFrxuwgAusCO4OhHMDQmr7gMDPqOcloksAN/iIT/N8wniRuEbwew8bq@fv9Pw
# http://grpg.wikidot.com/tool:magic-weapon-cr
<div id="qunit"></div>
<div id="qunit-fixture"></div>
@aloisdg
aloisdg / ClipCard.html
Created July 13, 2017 18:57
Clip mtg image
<html><head>
<style type="text/css">
.container {
position: relative;
}
#clip {
position: absolute;
clip: rect(35px, 206px, 175px, 16px);
/* clip: shape(top, right, bottom, left); NB 'rect' is the only available option */
}
@aloisdg
aloisdg / CardGenerator.cs
Created July 2, 2017 18:50
This is a function for creating a valid-ish credit card number
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CardGenerator
{
/*
* Original instructions https://www.nerdwallet.com/blog/credit-cards/credit-card-numbers-valid-website-luhn-algorithm/
@aloisdg
aloisdg / sun.csv
Last active February 9, 2017 14:45
date Energy Generated Energy Used percent Energy Used Average Generation Lowest Generation Highest Generation CO2 Emissions Saved
08:02:17 160.380 115.861 72.24 13.888 0.000 5.890 171.607
07:02:17 158.590 110.956 69.96 13.541 0.000 4.735 169.691
06:02:17 160.008 116.775 72.98 13.521 0.000 6.076 171.209
05:02:17 161.822 111.035 68.62 13.595 0.000 5.409 173.150
04:02:17 186.182 110.707 59.46 15.572 0.000 5.720 199.214
03:02:17 186.379 118.970 63.83 15.556 0.000 5.966 199.426
02:02:17 202.393 129.718 64.09 16.878 0.000 6.339 216.560
01:02:17 172.158 128.399 74.58 14.346 0.000 6.573 184.209
31:01:17 174.347 131.268 75.29 14.452 0.000 6.617 186.551
[[projects]]
name = "County"
why = """People like to count char, letter, byte, etc.
As golfer I use byte-counter, but I want to make my own.
I need to compare differents input together."""
what = "A website and an API"
how = "Frontend in TypeScript with VueJS. No Backend"
source = [ "https://mothereff.in/byte-counter" ]
[[projects]]
module counter =
open System.Text
let countByte x = System.Text.Encoding.UTF8.GetByteCount(x : string)
let countChar x = (x : string).Length
module penelope =
let countLetter x = x |> Seq.filter (System.Char.IsLetter) |> Seq.length
let estimate x = (float (countLetter x)) * 28.5;
@aloisdg
aloisdg / Alphabet.cs
Created January 24, 2017 20:39 — forked from dgritsko/Alphabet.cs
Naive bijective function in C#. http://stackoverflow.com/questions/742013
namespace Alphabet
{
public class AlphabetTest
{
public static readonly string Alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
public static readonly int Base = Alphabet.Length;
public static string Encode(int i)
{
if (i == 0) return Alphabet[0].ToString();