Skip to content

Instantly share code, notes, and snippets.

View mollyporph's full-sized avatar

Otto Remse mollyporph

  • Forefront Consulting
  • Sweden
View GitHub Profile
defmodule Mkeon.Diceroller do
def seed do
<< a :: 32, b :: 32, c :: 32 >> = :crypto.rand_bytes(12)
:random.seed(a,b,c)
end
def add_random_number(0, list, _dicevalue) do
list
end
def add_random_number(x, list, dicevalue) do
seed
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace UnitTests.Enum
{
[TestFixture]
public class EnumFlagsTest
// INPUT: Potentiometer should be connected to 5V and GND
int potPin = A0; // Potentiometer output connected to analog pin A0
int potVal = 0; // Variable to store the input from the potentiometer
// OUTPUT: Use digital pins 3,6,5, the Pulse-width Modulation (PWM) pins
// LED's cathodes should be connected to digital GND
int redPin = 3; // Red LED, connected to digital pin 9
int grnPin = 6; // Green LED, connected to digital pin 10
int bluPin = 5; // Blue LED, connected to digital pin 11
int buttonPin = 7; // push button

Predicatebuilder är ett hjälpmedel för att kunna kedja långa LINQ-queries för att fylla ut funktionalitet som saknas av query-providern, i vårt fall TableStorage.

Predicatebuilder ser ut såhär:

public static class PredicateBuilder
{
    public static Expression<Func<T, bool>> True<T>() { return f => true; }
    public static Expression<Func<T, bool>> False<T>() { return f => false; }

    public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> expr1,
import numpy as np
import re
def next_string(s):
alpha = 'abcdefghijklmnopqrstuvwxyz'
try:
return s[0:-1] + alpha[alpha.index(s[-1]) + 1]
except IndexError:
return next_string(s[0:-1]) + 'a'
def hasAlphabetIncrement(password):
data = np.array(list(map(ord,password)))
using NUnit.Framework;
using System;
using System.Linq;
using System.Reflection;
namespace UnitTests.Enum
{
[TestFixture]
public class EnumFlagsTest
{
with open("8.txt") as f:
content = f.readlines()
res = sum([(len(x)-len(bytes(x[1:-1], "utf-8").decode("unicode_escape"))) for x in content])
print(res)
import re
import numpy as np
rowRegex = re.compile(r'(turn on|turn off|toggle)\s(\d{,3}),(\d{,3})\sthrough\s(\d{,3}),(\d{,3})')
def apply(function, light):
return {
'toggle': light +2,
'turn on': light +1,
'turn off': max(0,light-1)
}[function]
def parseRow(row):
import re
imp = """
rthkunfaakmwmush
qxlnvjguikqcyfzt
..."""
impArr = imp.split()
first = re.compile(r"(?!.*(ab|cd|pq|xy))(?=(.*[aeiou].*){3,})(?=.*(\w)\3+)")
second = re.compile(r"(?!.*(\w)\1{2,})(?=.*(\w).\2)(?=.*(\w\w).*\3)")
resFirst = len([x for x in impArr if first.match(x) is not None ])
resSecond = len([x for x in impArr if second.match(x) is not None ])
I can’t even say what’s wrong with PHP, because— okay. Imagine you have uh, a toolbox.
A set of tools. Looks okay, standard stuff in there.
You pull out a screwdriver, and you see it’s one of those weird tri-headed things.
Okay, well, that’s not very useful to you, but you guess it comes in handy sometimes.
You pull out the hammer, but to your dismay, it has the claw part on both sides.
Still serviceable though, I mean, you can hit nails with the middle of the head holding it sideways.
You pull out the pliers, but they don’t have those serrated surfaces;