python – How the basic structure of a simple messaging app works?

How the messaging apps works?
What is the Basic algorithm of it?
I tried the following method to make a messaging app.

  1. I enters message
  2. Message converts to a text file
  3. Text text file uploads to the ftp server
  4. My friend gets the text file from ftp and reads it

Is this method correct?
Do needed to use FTP server?
I found it is very slow and sometimes it gets timeout Error.
What is wrong here? Is my method wrong or the problem is the server?

magento2 – Error 404 when go to simple product URL of configurable product

I have a configurable product showing on frontend. There are 3 simple product link with it.

Here is my configurable product in backend:

enter image description here

The URL of my configurable product in frontend will be like this:


But if I try to access its simple product link like my URL key:




It give me error 404 page. Is it possible for me to go to simple product URL of my configurable product.

Thank you!

beginner – Simple program to print from a buffer until a newline is found

For practice, I wrote a small program that goes through a string in the data section (although, it could be easily adapted to take user input), and print out the characters in the string until it finds a newline, then stops.

This is by far the most complicated assembly program I’ve ever written. It’s the first time I’ve ever used a jump and cmp. It’s simple, but there’s likely improvements I can make, so I thought I’d try to get feedback.

I decided to write it in 32-bit because the system calls are a little easier to wrap my head around. I’ll transition to x86-64 once I know what exactly my school is going to be using; because I’ve seen both so far in slides.


global _start

section .data
    input: db `1234567890n`

section .text
        mov esi, input  ; Current head of string

            mov eax, 4
            mov ebx, 1
            mov ecx, esi
            mov edx, 1
            int 0x80

            inc esi
            cmp BYTE (esi), 10
            jne .loop  ; Stop looping once we've found the newline

        mov eax, 1
        mov ebx, 0
        int 0x80

nasm firstjmp.asm -g -f elf32 -Wall -o firstjmp.o
ld firstjmp.o -m elf_i386 -o firstjmp

└──╼ $./firstjmp 

confused about returning a value or not in this simple python function

I’m writing a few python scripts to get started. There is sometimes the assumption that most functions should return a value, but some cases are confusing to me.

The next function use *args, an equivalent to the rest operator in javascript, to put all the arguments (any number) into an array named args. If those directories do not exist, they should be created. (I know bash is probably the way to go here, but this is just an example).

def make_multidir(*args):
    # *args is like a rest operator in js, ...dirs
    for directory in args:
        if not os.path.exists(directory):
            print( "folder %s already exists" %(directory))

If you have any other recommendation here for the code, I’ll be eager to learn.

gn.general topology – Does a compact ANR have a local equiconnecting function which connects distinct points by simple paths?

It is known that if $X$ is a (metric) ANR, then $X$ is locally equiconnected, that is, there is a neighborhood $V$ of the diagonal $Delta X subseteq X times X$ and a continuous function $$f colon V times (0,1) rightarrow X$$
such that

  1. For every $(x,y) in V$, the path $f(x,y,-) colon (0,1) rightarrow X$ starts at $x$ and ends at $y$.
  2. For every $x in X$, the path $f(x,x,-) colon (0,1) rightarrow X$ is the constant path at $x$.

(Side note: Local equiconnectivity is equivalent to the diagonal map $Delta colon X rightarrow X times X$ being a Hurewicz cofibration.)

Let us also assume that $X$ is compact. My question is: Can we choose the $U$ and $f$ such that when $x neq y$ in the 1st condition, the path connecting them is a simple path?

Remark: It follows from Lemma 2.1 of the paper “A remark on simple path fields in polyhedra of characteristic zero” by Fadell that the answer is yes when $X$ is a finite simplicial complex. I am interested in a (strict) generalization of this result.

javascript – Several simple calculators on one page

For my students (I am an Austrian math teacher) I would like to provide some simple online calculators on my blog.

Let’s say there are two pages on my website(“Circle” and “Cube”) and on every page I want to have about 10 different calculators.

Here is an example of one page with two calculators:

enter image description here

My code




<h2>Calculate circumference of circle</h2>
 Radius of circle: <input type="text" id="calc1-input"> <button onclick="calc1()">Calculate</button>
Circumference of circle: <span id="calc1-output"></span>

<h2>Calculate area of circle</h2>
 Radius of circle: <input type="text" id="calc2-input"> <button onclick="calc2()">Calculate</button>
Area of circle: <span id="calc2-output"></span>


function commaToDot(number) {
    return parseFloat(number.replace(',','.').replace(' ',''));

function dotToComma(number){
    return number.toString().replace('.',',');

function calc1() {
    var input = document.getElementById("calc1-input").value;
    input = commaToDot(input);
    if (isNaN(input)) {
        document.getElementById('calc1-output').innerHTML = "<b>Please enter a number!</b>";
    } else {
      var output = 2 * Math.PI * input;
        document.getElementById('calc1-output').innerHTML = dotToComma(output);

function calc2() {
    var input = document.getElementById("calc2-input").value;
    input = commaToDot(input);
    if (isNaN(input)) {
        document.getElementById('calc2-output').innerHTML = "<b>Please enter a number!</b>";
    } else {
      var output = Math.PI * Math.pow(input,2);
        document.getElementById('calc2-output').innerHTML = dotToComma(output);


  • Input: In my country we use commas as decimal separators.
    So the students write 55,5 instead of 55.5 (see commaToDot()).
  • Output: The students expect the output to be with comma decimal separator, too (see dotToComma()).
  • Error: If the input is not a number (if (isNaN(input))) an error message will be displayed instead of the calculation result.


  • I see a lot of redundance in my code but I don’t know how to improve it.
    The only difference between calc1() and calc2() is the formula.
  • Maybe it is possible to improve the naming of the variables/functions?

postgresql – Postgres 12 create table as simple select + hash join takes 8+ hours for 100GB?

I’m using a “create table as select …” statement to create a copy of a subset of the columns in a ~100GB table (400 million records). I am also performing a hash join with another table which is only 36 records. It takes 8-9 hours to perform this copy. Does that seem reasonable, or is it indicative of a problem?

The server should have plenty of disk space, 128 GB of RAM, and 16 cores.

The source table is partitioned.

python – Using get_dummies to create a Simple Recommender System – Cold Start

Question: was using get_dummies a good choice for converting categorical strings?

I used get_dummies to convert categorical variables into dummy/indicator variables for a cold start recommender system using only category type information and some basic limited choices.

The code works and the output seems good. This is my first data science project for fun. I kind of put this together from reading documentation and searching StackOverflow.I plan on making it hybrid recommender system soon by added sentiment analysis and topic classification both of which I finished recently also.

To check another character just Input a different character name in userinput the full notebook and excel sheet for import at my github

I would be grateful if someone could comment on whether or not I was able to achieve the following goals (and of course if not, what I can improve):

Code structure, style, and readability: Is the code comprehensible? Are there any bad practices?

character’s name (must be unique)

herotype (can only have one of following choices)

  • Bard
  • Sorcerer
  • Paladin
  • Rogue
  • Druid
  • Sorcerer

weapons (can have one or multiple of following choices)

  • Dagger
  • sling
  • club
  • light crossbow
  • battleaxe
  • Greataxe

spells (can have one or multiple of following choices)

  • Transmutation
  • Enchantment
  • Necromancy
  • Abjuration
  • Conjuration
  • Evocation

Get Another Recommendation
You just input the username ‘Irv’ to another one like ‘Zed Ryley’ etc

userInput = (
            {'name':'Irv', 'rating':1} 

The results
come back formatted like this

    name    herotype    weapons     spells
28  Irv     Sorcerer    light crossbow  Conjuration
9   yac     Sorcerer    Greataxe    Conjuration, Evocation, Transmutation
18  Traubon Durthane    Sorcerer    light crossbow  Evocation, Transmutation, Necromancy
8   wuc     Sorcerer    light crossbow, battleaxe   Necromancy
1   niem    Sorcerer    light crossbow, battleaxe   Necromancy
23  Zed Ryley   Sorcerer    sling   Evocation

For comparison

here are the scores show how it ranks the results

In (5):



28    1.000000
9     0.666667
18    0.666667
8     0.666667
1     0.666667
23    0.333333
dtype: float64

import pandas as pd
import numpy as np

df = pd.read_excel('dnd-dataframe.xlsx', sheet_name=0, usecols=('name', 'weapons','herotype','spells'))

dummies1 = df('weapons').str.get_dummies(sep=',')
dummies2 = df('spells').str.get_dummies(sep=',')
dummies3 = df('herotype').str.get_dummies(sep=',')

genre_data = pd.concat((df, dummies1,dummies2, dummies3), axis=1)

userInput = (
            {'name':'Irv', 'rating':1}   #Their is no rating system is being used thus by default rating is set to 1
inputname = pd.DataFrame(userInput)

inputId = df(df('name').isin(inputname('name').tolist()))

#Then merging it so we can get the name. It's implicitly merging spells it by name.
inputname = pd.merge(inputId, inputname)

#Dropping information we won't use from the input dataframe
inputname = inputname.drop('weapons',1).drop('spells',1).drop('herotype',1)

#Filtering out the names from the input
username = genre_data(genre_data('name').isin(inputname('name').tolist()))

#Resetting the index to avoid future issues
username = username.reset_index(drop=True)

#Dropping unnecessary issues due to save memory and to avoid issues
userGenreTable = username.drop('name',1).drop('weapons',1).drop('spells',1).drop('herotype',1)

#Dot produt to get weights
userProfile = userGenreTable.transpose().dot(inputname('rating'))

genreTable = genre_data.copy()
genreTable = genreTable.drop('name',1).drop('weapons',1).drop('spells',1).drop('herotype',1)

#Multiply the genres by the weights and then take the weighted average
recommendationTable_df = ((genreTable*userProfile).sum(axis=1))/(userProfile.sum())

#Sort our recommendations in descending order
recommendationTable_df = recommendationTable_df.sort_values(ascending=False)

#df.loc(df.index.isin(recommendationTable_df.head(3).keys())) #adjust the value of 3 here

df.loc(recommendationTable_df.head(6).index, :)