Creating a top-hat distributed random number generator

enter image description here

I have this Fortran code which generates a flat distribution as it produces a single random number centered on 0.
The function GRNDM (Geant 4 random number generator) produces equally distributed random numbers between the values of 0 and 1. RDUMMY is the name of the vector filled with the random number and the argument “1” states the length of the vector: i.e. GRNDM here will produce a single random number between 0 and 1. The second line then produces random numbers in the interval (μ−σ2,μ+σ2).

I was wondering if there was a way of changing it to produce random numbers with a top hat distribution?

Selling – Debrid Script (Link Generator + Torrent Leech) | Proxies-free

Hello People! i’m selling a complete debrid script supporting many filehosters and with many features:

Users Features:
-Login/Register system (activation key and forget pass system)
-Account Panel (change name, pass, avatar…)
-User Dashboard (User Status, User Consumption, Download History, Torrent History…)
-Payments History
-Tickets System
-Points System
-Affiliate system
-Log History

Main Features:
-Torrent Support (with torrent history and multiserver support)
-Download history
-Downloader for free and premium users (free users have limits, customizable)
-Limit download by day (free users)
-Filesize Limit (free users)
-Wait time (free users)
-Limit hosters (free users)
-Happy hours (free users)
-Streming support (video)
-Max link list
-Limit mb by filehoster (premium)
-Server balancer
-Anti-flood system
-Multiserver support (also can use separated servers for free and premium)

Hosters features:
-150 plugins available
-200 icons of filehosters (automatically shows on list)
-Live status of hosters (up or down)
-Separate hosters for free and premium

Premium Features:
-2 Package types (days and bandwidth)
-PayPal (payment)
-Points change
-Stripe (payment)
-Redeem Voucher Code

Reseller features:
-Reseller panel with credits balance
-Reseller code creator
-Reseller list code

Admin Features:
-Package Premium editor
-User Editor (status, user level, password, etc…)
-Debrid Dashboard (debrid system info, total downloads, total traffic…)
-Premium Accounts Adder (debrid system)
-Hosters editor (debrid system)
-Users Link History (debrid system)

-Users Torrents History (debrid system)
-Users Traffic (debrid system)
-Torrent Servers adder (debrid system)
-Backend Servers status (debrid system)
-Maintenance mode and Notification system
-Autoupdate script system

Core features:
-API for 3rd apps
-Multi-Language support
-Responsive design
-Web App design
-Timeout Session Expiration system
-MVC based from own framework
-Privacy, ToS, FAQ, Refund pages editable
-Bootstrap based
-JavaScript, AJAX, CSS, PHP and MySQL Based
-Many more…

The script will be updated constantly adding new features and solving minor errors.

Price: ask me via skype

Demo: ask me via skype

Skype: xandilien1


Last edited:

python – Number Base Conversion Problem Generator

A program that generates questions to train your number conversion skills. This program asks questions about octet, binary and hexadecimal. No other bases. First, the user is asked a number of questions, e.g. B. "Number of questions", "Question type" and "Basis". Then questions are generated based on the input from the user. The user can give an answer and it is informed whether they are correct. Code works perfectly.

I'm asking for a review because I feel a bad smell in my code. It feels too long, repetitive, and confusing. There must be a better way. Maybe an OOP approach? Something to reduce complexity and "if-else" repetition. However, I feel that this is partly because I have limited it to it just 3 bases. I am a late beginner, but I would not say that I am just intermediate.

My code only uses an external library baseconvert. Can be installed with pip pip install baseconvert

import random
import baseconvert

# The Start
# ---------
# Step 1: Ask whether the user wants 'Decimal > Base X' or 'Base X > Decimal' or 'Random'
# Step 2: Ask how many questions the user wants. Type the answer. Type -1 for infinite.
# Step 3: If infinite, prompt to type 'f' to stop.
# Step 4: Ask what base you want based on index. 1. Octet // 2. Hexadecimal // 3. Binary // 4. Random

def question_type_ask():
    print('Which question would you like to be asked?')
    print('1. Decimal > Base Xn2. Base X > Decimaln3. Random')
    ans = input('Input: ')
    if ans != '1' and ans != '2' and ans != '3':
        print('Invalid input')
    return ans

def amount_ask():
    print('How many questions do you want to be asked? Type -1 for infinite.')
    print('Type 'f' as answer to stop')
        ans = int(input('Input: '))
    except ValueError:
        print('Input numbers only, please.')
        return amount_ask()
    if ans >= -1:
        return ans
        return amount_ask()

def base_ask():
    print('Which base do you want to be asked?')
    print('1. Octetn2. Hexadecimaln3. Binaryn4. Random')
    ans = input('Input: ')
    if ans != '1' and ans != '2' and ans != '3' and ans != '4':
        print('Invalid input')
    return ans

question_type = question_type_ask()
amount = amount_ask()
base = base_ask()
is_random_question = False
is_random_base = False

if question_type == '3':
    is_random_question = True
if base == '4':
    is_random_base = True

def question_generator():
    global question_type
    global amount
    global base

    base_list = ('1', '2', '3')
    type_list = ('1', '2')

    while True:
        if is_random_base:
            base = random.choice(base_list)
        if is_random_question:
            question_type = random.choice(type_list)
        if question_type == '1':  # Decimal > Base X
            base1 = 'Base 10'
            num = random.randrange(100, 100000)
            if base == '1':  # Octet
                base2 = 'Base 8'
                correct_ans = baseconvert.base(num, 10, 8, string=True)
            elif base == '2':  # Hexa
                base2 = 'Base 16'
                correct_ans = baseconvert.base(num, 10, 16, string=True)
            elif base == '3':  # Binary
                base2 = 'Base 2'
                correct_ans = baseconvert.base(num, 10, 2, string=True)
            elif base == '4':  # Random
                base2 = random.choice(base_list)
                if base2 == base_list(0):
                    base = '1'
                elif base2 == base_list(1):
                    base = '2'
                elif base2 == base_list(2):
                    base = '3'
        elif question_type == '2':  # Base X > Decimal
            base2 = 'Base 10'
            correct_ans = str(random.randrange(100, 100000))
            if base == '1':  # Octet
                base1 = 'Base 8'
                num = baseconvert.base(correct_ans, 10, 8, string=True)
            elif base == '2':  # Hexa
                base1 = 'Base 16'
                num = baseconvert.base(correct_ans, 10, 16, string=True)
            elif base == '3':  # Binary
                base1 = 'Base 2'
                num = baseconvert.base(correct_ans, 10, 2, string=True)
            elif base == '4':  # Random
                base1 = random.choice(base_list)
                if base1 == base_list(0):
                    base = '1'
                elif base1 == base_list(1):
                    base = '2'
                elif base1 == base_list(2):
                    base = '3'

    print(f'({base1}) {num} to ({base2})')
    ans = input('Answer: ')
    if ans == correct_ans:
        print('You are correct!')
    elif ans.lower() == 'f':
        print(f'Wrong! The answer is {correct_ans}')

counter = 0
if amount == -1:
    amount = float('inf')
while counter < amount:
    counter += 1

php – How to create a code generator button using HTML

Hello, I'm still learning to work with programming. I know almost nothing, but I wanted to create a simple thing (in my head) that is a button that I can insert into my WordPress blog.

It would be a type button, if I press it a random name will be generated

Example: I enter the name of the "Generate fruit" button and the name of a fruit that I have inserted into the HTML code is generated. Every time I press it, it is spent like a different kind of fruit and I can repeat it. "Banana" and the next time I press it comes out "Orange" or "Strawberry" and so on, but only from the fruits that I put in my code

I searched and found nothing, the most similar thing I found was a name generator.

Thanks in advance if anyone can help me.

Extremely simple Python password generator

I tried to create a password generator that initially works as intended and generates a password with small, capital and special characters. However, I can only generate passwords up to 19 characters and the script sends an error if a string is too big or something.

import random

generator = "qwertyuiopasdfghjklzxcvbnm0123456789QWERTYUIOPASDFGHJKLZXCVBNM.!?*"
generatorLength = len(generator)

def Generator():
    acc = 0
    password = ''
    length = int(input("How long?n"))
    if length < 6:
        print("Can't be less than 6n")
    while acc < length:
        password += generator(random.randint(0, generatorLength))
        acc += 1
    print("Password:", password)


How is an asynchronous generator properly packaged in Python?

As of Python 3.6 and PEP 525 you can use an asynchronous generator:

import asyncio

async def asyncgen():
    yield 1
    yield 2

async def main():
    async for i in asyncgen():

I have created a function that can include any asynchronous generator, just as you would include a basic function @decorator.

def asyncgen_wrapper(generator):

    async def wrapped(*args, **kwargs):
        print("The wrapped asynchronous generator is iterated")

        gen = generator(*args, **kwargs)

            value = await gen.__anext__()
        except StopAsyncIteration:

        while True:
            to_send = yield value

                value = await gen.asend(to_send)
            except StopAsyncIteration:

    return wrapped

Enclosing an asynchronous generator appears to be quite complicated compared to enclosing a basic generator:

def gen_wrapper(generator):
    def wrapped(*args, **kwargs):
        return (yield from generator(*args, **kwargs))
    return wrapped

I mainly dealt with it accuracy my packaging. I want the wrapper to be as transparent as possible about the wrapper generator. Which leads me to two questions:

  • Is there an easier way to implement a decorator for asynchronous generators?
  • My implementation covers all possible marginal cases (think asend() for example)?

Java – ASCII-Art Generator – Code Review Stack Exchange

Enter the image description here


To learn how to work with images in Java, I created an ASCII art generator. The program can do two things:

  1. Convert images to ASCII type
  2. Convert text to ASCII style

I divided the task into several steps:

  1. Convert text to image
  2. Read the picture and its height and width
  3. Save the data of each pixel
  4. Convert pixel data to ASCII characters
  5. To press


This class is responsible for user interaction and creating an instance of the required class (-es).

import java.util.InputMismatchException;
import java.util.Scanner;

public class Control {

    public static void main(String() args) {
        System.out.println("Picture to ASCII (1) or text to ASCII (2)?");
        Scanner scan = new Scanner(;
        int decision;
        while(true) {
            try {
                decision = scan.nextInt();
                if(decision > 2 || decision < 1) {
                    throw new InputMismatchException();
            catch(InputMismatchException e) {   //User enters not a number or a number > 2 or < 1
                System.out.println("Enter (1) or (2):");
                scan.nextLine();    //Clear Scanner

        scan.nextLine(); //To clear scanner

        switch(decision) {
                System.out.println("Want to reverse brightness? (yes = 1, no = 2)");
                int reverse;
                while(true) {
                    try {
                        reverse = scan.nextInt();
                        if(reverse > 2 || reverse < 1) {
                            throw new InputMismatchException();
                    catch(InputMismatchException e) {   //User enters not a number or a number > 2 or < 1
                        System.out.println("Enter (1) or (2):");
                boolean reverseBrightness;
                reverseBrightness = reverse == 1 ? true : false; //if(reserve == 1) {reverseBrightness = true} else {reverseBrightness = false};

                System.out.println("Enter filename:");
                String filename;
                while(true) {
                    try {
                        filename = scan.nextLine();
                        Picture picture = new Picture(filename, reverseBrightness);
                    catch(IOException e) {  //IIOException occurs when file not found
                        System.out.println("File not found. Enter filename:");

                System.out.println("Enter text:");
                String str = scan.nextLine();
                try {
                    AsciiText text = new AsciiText(str);
                catch(IOException e) {

                System.out.println("An Error occured!");    //Impossible to happen, just to adhere to best practice

Responsible for converting images into ASCII art.

import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

public class Picture {
    private BufferedImage img;
    private int height;
    private int width;
    private Triplet()() array;
    private int()() brightness;
    private final int MAX_BRIGHTNESS = 255;
    private char()() ascii;
    private final String str = "$@B%8&MW#*oahkbdpqwmZ0OQLCJUYXzcvunxrjft/\\(|)1{})(?-_+~i!Il:;,"\^`"; //ASCII-chars

    public Picture(String filename, boolean reverse) throws IOException {
        img = File(filename));
        this.height = img.getHeight();
        this.width = img.getWidth();

        if(reverse) {


    //Saving the proportion of red, green and blue of each pixel
    private void fillArray() {
        array = new Triplet(height)(width);
        for(int i = 0; i < height; i++) {
            for(int j = 0; j < width; j++) {
                int getRGB = img.getRGB(j, i);
                int red = (getRGB>>16) & 0xff;
                int green = (getRGB>>8) & 0xff;
                int blue = getRGB & 0xff;
                array(i)(j) = new Triplet(red, green, blue);

    //Calculating the brightness of each pixel
    private void fillBrightnessArray() {
        brightness = new int(height)(width);
        for(int i = 0; i < height; i++) {
            for(int j = 0; j < width; j++) {
                brightness(i)(j) = (array(i)(j).getFirst() + array(i)(j).getSecond() + array(i)(j).getThird()) / 3;

    //Reversing the brightness-values
    private void reverseBrightness() {
        for(int i = 0; i < height; i++) {
            for(int j = 0; j < width; j++) {
                brightness(i)(j) = MAX_BRIGHTNESS - brightness(i)(j);
                if(brightness(i)(j) < 0) {
                    brightness(i)(j) *= -1;

    //Converting brightness into appropriate ASCII-char
    private void fillAscii() {
        ascii = new char(height)(width);
        for(int i = 0; i < height; i++) {
            for(int j = 0; j < width; j++) {
                ascii(i)(j) = str.charAt(brightness(i)(j) / 4);

    //print completed ASCII-art to file
    private void printAscii() {
        try {
            FileWriter writer = new FileWriter("ascii.txt");
            for(int i = 0; i < height; i++) {
                for(int j = 0; j < width; j++) {
                    writer.write(ascii(i)(j) + "" + ascii(i)(j) + "" + ascii(i)(j));
        catch(IOException e) {


Responsible for the second task: converting text.

import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

import javax.imageio.ImageIO;

public class AsciiText {
    private final String filename = "text.jpg";

    public AsciiText(String text) throws IOException {
        int width = 200;
        int height = 40;
        int imageType = BufferedImage.TYPE_INT_RGB;

        //Creating image with text
        BufferedImage image = new BufferedImage(width, height, imageType);

        Graphics graphic = image.getGraphics();
        int fontSize = 15;
        graphic.setFont(new Font("Arial", Font.PLAIN, fontSize));

        Graphics2D graphics = (Graphics2D) graphic;
        int xCoordinate = 5;
        int yCoordinate = 25;
        graphics.drawString(text, xCoordinate, yCoordinate);

        ImageIO.write(image, "jpg", new File(filename));

        //Converting created image to ASCII-art
        Picture picture = new Picture(filename, true);

public class Triplet {
    private int first;
    private int second;
    private int third;

    public Triplet(int first, int second, int third) {
        this.first = first;
        this.second = second;
        this.third = third;

    public int getFirst() {
        return first;

    public int getSecond() {
        return second;

    public int getThird() {
        return third;


 * Attribution:
 * The code in this question was created with the help of the following question(s) and their answer(s). 
 * These come from the Stack Exchange network, where content is licensed under CC-BY-SA (
 * Question by Jeel Shah (
 * Answer by Peter Lawrey (
 * Question by aneuryzm (
 * Answer by Bala R (


An example of the text for ASCII art conversion is the message "Hello world!" At the beginning of this question.

To demonstrate the conversion of images, I used the well-known poison symbol, which you can find here:

Enter the image description here


How can I improve the code? What about the general code structure? Did I miss something important?

I would appreciate suggestions.

Automation – is there a number sequence generator that skips the count?

I am trying to make a list of numbers that follow a certain sequence number up to 18, skip 23 integers and continue counting so the sequence is 01-18 41-58 81-98 21-38 61-78

Is there a program or online service that does it for me? I searched for hours and only developed a tool to generate a list of numbers, but they only do incremental numbering

and I need the numbers line by line like





How much more detail do you need? I work with an ID numbering sequence for an RC file with tens of thousands of sprites so I can add more without having to manually write down thousands of numbers

Is it better for me to press 12 characters on the keyboard or use my password manager generator?

The password generator is better. A system is used that is only used to generate random characters. Your brain is not designed for that.

If you crush the keyboard a hundred times and create a heat map of the entered keys, the most frequently used keys will be the central and the peripheral less.

Open your text editor and generate more than 30 passwords with your method. Then run this script:

awk -vFS="" '{for(i=1;i<=NF;i++)w($i)++}END{for(i in w) print i,w(i)}' file-you-saved | sort -g -k2

All characters are taken, counted and sorted by frequency. For your method to beat the password generator, the letters should have more or less the same frequency.

If the site you're signing in to allows more characters, do so. I use 64 if allowed, or the maximum if it is less.

python 3.x – A standalone implementation of the parser generator

This is a leisure project. I tried to create a parser generator with a grammar inspired by

Unfortunately, it was much more difficult than I expected to understand the syntax of a certain grammar (meta-grammar?) Than I expected.

I call it KiloGrammar (sorry for the bad pun).

It was very different from what I had planned, but it seems to do the job.
It actually describes a batch machine and is probably Turing complete, although I haven't had the time to implement something like Rule 110 to check it out.

Here is an excerpt from a grammar to analyze simple mathematical expressions:

# this grammar parses simple math expressions like: a + 10 * (8 + 5)

token var "(A-Za-z)+"
token int "-?(0-9)+"
token float "-?(0-9+)+.(0-9)+"
token whitespace "( s)+"
keyword "("
keyword ")"
keyword "+"
keyword "-"
keyword "*"
keyword "/"

shorthand "NUMBER" "int|float|var"
shorthand "operation" "+|-|*|/"

rule ignore_whitespace (whitespace)

rule math_priority (ADD|SUB, *|/, EXPRESSION)
    pop(3); push((0)(1), (0)(0), (0)(2), (1), (2))

rule math (EXPRESSION, operation, EXPRESSION)

rule parenthesis ("(", EXPRESSION, ")")
    pop(3); push((1))

You can find the complete implementation here:

You can do it with: python some_input_grammar.txt -compile >

To easily test your new parser python some_input.txt -color It should print a syntax tree.

or to see how the syntax tree is built: python some_input.txt -interactive -color

it also works for the parser generator itself: python some_input_grammar.txt -interactive -color

Although I thought it was a toy project and I had no idea what I was doing, I would like to know your thoughts about the usability and quality of the project, especially the meta-grammar (?) It uses.