## 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:

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

https://domain/becks-beer-bt-330ml-24pk.html

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

https://domain/becks-beer-bt-330ml-24pk-case-24.html

or

https://domain/becks-beer-bt-330ml-24pk-each.html

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.

firstjmp.asm

``````global _start

section .data
input: db `1234567890n`

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

.loop:
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

┌─(brendon@parrot)─(~/Desktop/Classes/CompArc/Lab4/asm)
└──╼ \$./firstjmp
1234567890┌─(brendon@parrot)─(~/Desktop/Classes/CompArc/Lab4/asm)
``````

## I can do video editing in very simple and short time. for \$5

#### I can do video editing in very simple and short time.

We will give you the video editing according to the ration and your recruitment. We will make the video very honestly and in the best way. Trust us once and watch it.

Thank youThank you

.

## 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):
os.makedirs(directory)
else:
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:

My code

JSFiddle

HTML

``````<h1>Circle</h1>

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

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

Javascript

``````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);
}
}
``````

Explanation

• 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.

Questions

• 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
• 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):

Out(5):

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

``````
``````#imports
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

#Resetting the index to avoid future issues

#Dropping unnecessary issues due to save memory and to avoid issues

#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)