## [DBTech] DragonByte Member Map

AnimeHaxor submitted a new resource:

[DBTech] DragonByte Member Map – Geolocate your members and plot them on an interactive Google map!

Uses

Show your users’ locations can be shown on an interactive Google map after being geolocated from their IP addresses.
Also supports the ability to show all users or only those that are currently logged in.
Locations are calculated in batches to ensure smooth…

.

## dg.differential geometry – Approximating the parallel transport map on a curve with the covariant derivative

let $$X,Y:Mto TM$$ be vector fields on $$M$$. $$nabla_XY$$ is the change in $$Y$$ along the flow curves of $$X$$. so for a point $$p in M$$ let $$phi^X(t):mathbb{R}to M$$ be a flow curve of $$X$$ passing through $$p$$ :
$$(phi^X)’=X ; ; ; ; ; phi^X(0)=p$$
since I can’t measure the change in $$Y$$ at two different points directly. I’ll define a parallel transport map $$Pi_{tX}:T_pMto T_{phi^X(t)}M$$ taking a vector at $$p$$ to its equivalent at $$phi^X(t)$$. Then the derivative at $$p$$ is:
$$nabla_XY|_p=lim_{tto 0}frac{delta_XY|_{phi^X(t)}}{t}=lim_{tto 0}frac{Y_{phi^X(t)}-Pi_{tX}(Y_p)}{t}$$
I tried to do the usual approximation trick by assuming that for a “small” enough $$t$$ :
$$nabla_XY|_p approx frac{delta_XY|_{phi^X(t)}}{t}$$
but there is a problem that LHS and RHS are not at the same point.

here is what I did “correct me if i’m wrong”:

since the points $$p$$ and $$phi^X(t)$$ are so close:
$$Pi_{tX}(nabla_XY|_p) approx frac{delta_XY|_{phi^X(t)}}{t}$$
in other words:
$$Pi_{tX}(nabla_XY|_p)=frac{delta_XY|_{phi^X(t)}}{t}+vecepsilon_1$$
$$vecepsilon$$ being a really small difference vector. Another thing that follows is that the values of the vector field $$nabla_XY$$ at the two points are close so:
$$Pi_{tX}(nabla_XY|_p)=nabla_XY|_{phi^X(t)}+vecepsilon_2$$
then
$$delta_XY|_{phi^X(t)}=tnabla_XY|_{phi^X(t)}+tvecepsilon_2-tvecepsilon_1$$
since $$vecepsilon$$ errors are already small. $$tvecepsilon$$ would be even much smaller “second order error” and could be neglected:
$$delta_XY|_{phi^X(t)} approx tnabla_XY|_{phi^X(t)}$$
so:
$$Pi_{tX}(Y_p) approx (-tnabla_XY+Y)|_{phi^X(t)}$$

so is there anything wrong with this attempt?

## probability – Regularization (Baysian approach with Map estimate) intuition

As you know the regularization problem is as follows:

Ein(sample error) + $$lambda/n$$ $$||theta||$$. Thus, when $$lambda$$ -> $$inf$$, $$||theta||$$ approches zero. However, Given that the prior distribution of the parameters p($$theta$$) ~ N(0 , $$b^2$$ I) acting as regularizer/bias. the MAP estimate tells us the opposite as I understand. As $$b^2$$ or $$lambda$$ approaches infinity – $$theta$$ becomes uniformly distributed – which doesn’t restrict our $$theta$$ to be around the zero mean (unbiased choice of $$b^2$$), the regularization term in MAP estimate will diminish and this leaves us with the MLE estimate which we know it causes overfitting. However, in our case (where $$b^2$$ approaches infinity, we expect $$||theta||$$ = 0. That means we encounter underfitting which contradicts that MLE causes overfitting! What am I missing here?

## hash map – Is there a more idiomatic way to process these strings?

New Scala dev here:

Is there a more idiomatic or efficient way to accomplish this in Scala?

Given a list of the following strings, I need to obtain the unique ‘main parts’ once any parts including and after a “-” have been removed.

The output should be a list of sorted strings. Also note both “;” and “,” have been used as separators.

Input:

``````val data: List(String) = List(
"W22; O21; B112-WX00BK; G211; B112-WI00BK; G11",
"W22; K122l; B112-WI00BK; O21; B112-WX00BK; G211",
"W21, V32",
"W21, N722",
"S133-VU3150; S133-SU3150; R22-VK3150; R123-VH3"
)
``````

Desired Output:

``````List(
B112 G11 G211 O21 W22,
B112 G211 K122l O21 W22,
V32 W21,
N722 W21,
R123 R22 S133
)
``````

My solution:

``````def process(input: String): String =
input.split(" ").map(word => {
if (word contains "-")
word.take(word.indexOf("-"))
else word
.replace(";", "").replace(",","")}).toSet.toList.sorted.mkString(" ")

val result: List(String) = data.map(process(_))
``````

## performance – Map implementation in C++

I always wondered how maps work in programming languages, so I decided to write my own class for them in C++. My implementation does not sort data and uses CRC as a hashing algorithm.

## Features

`put(key, value)` – Puts a new element into the map.

`get(key)` – Gets an element based on its key.

`remove(key)` – Removes an element based on its key.

`clear()` – Removes all elements.

## Code

``````template<typename K, typename V>
class Map {
private:
struct Element {
K key;
unsigned int hash;
V value;
};

Element* data;
unsigned long length = 0;

unsigned int getCRC(unsigned char *message) {
int i, j;

i = 0;
crc = 0xFFFFFFFF;
while (message(i) != 0) {
byte = message(i);
crc = crc ^ byte;
for (j = 7; j >= 0; j--) {
crc = (crc >> 1) ^ (0xEDB88320 & mask);
}
i = i + 1;
}
return ~crc;
}
public:
~Map() {
free(data);

data = nullptr;
}

Map() {
data = (Element*) malloc(0);
}

void put(K key, V value) {
Element element = {key, getCRC((unsigned char*) &key), value};

data = (Element*) realloc(data, (length+1)*sizeof(Element));
data(length) = element;
length++;
}

V get(K key) {
unsigned int hash = getCRC((unsigned char*) &key);

for(unsigned long i = 0; i < length; i++) {
if(data(i).hash == hash) {
return data(i).value;
}
}

return (V) 0;
}

void remove(K key) {
unsigned int hash = getCRC((unsigned char*) &key);

for(unsigned long i = 0; i < length; i++) {
if(data(i).hash == hash) {
length--;

for(unsigned int j = i; j < length; j++) {
data(j) = data(i + 1);
}

data = (Element*) realloc(data, length*sizeof(Element));
}
}
}

void clear() {
data = (Element*) realloc(data, 0);
length = 0;
}
};
``````

## What I would like to know

Like everyone, I want to know if there are any bugs or if I could optimize something. But I also wonder if the CRC32 algorithm is suitable for maps at all or if my class can be even classified as a map. Also missing features would be interesting for me.

## representation theory – Constructing a surjective intertwining map onto Verma module

I want to prove the following result:

Theorem: Let $$mathfrak{g}$$ be a semi-simple Lie algebra, $$mathfrak{h}$$ be a Cartan subalgebra, $$mu in mathfrak{h}$$, and $$W_{mu} = mathfrak{U}_{mathfrak{g}}/I_{mu}$$ be the Verma module with highest weight $$mu$$. Suppose that $$sigma_{mu}: mathfrak{g} rightarrow mathfrak{gl} left( W_{mu} right)$$ be a highest weight cyclic representation with highest weight $$mu$$. Then, there is a surjective intertwining map $$phi: V_{mu} rightarrow W_{mu}$$.

Here, $$mathfrak{U}_{mathfrak{g}}$$ is the universal enveloping algebra of $$mathfrak{g}$$, and $$I_{mu}$$ is a left-ideal in $$mathfrak{U}_{mathfrak{g}}$$ generated by elements of the form $$H – langle mu, H rangle cdot 1$$, where $$H in mathfrak{h}$$, and $$X in mathfrak{g}_{alpha}$$, where $$alpha$$ is a positive root. Also, $$V_{mu} = W_{mu}/U_{mu}$$, where $$U_{mu}$$ is the space of all elements $$v$$ of $$W_{mu}$$ which do not have a $$v_0$$-component (where $$v_0$$ is a highest weight vector for $$W_{mu}$$), and for any collection $$X_1, X_2, cdots, X_l$$ of root vectors with positive roots, the vector $$pi_{mu} left( X_1 right) pi_{mu} left( X_2 right) cdots pi_{mu} left( X_l right)v$$ also does not have a $$v_0$$-component.

The representation $$pi_{mu}: mathfrak{U}_{mathfrak{g}} rightarrow W_{mu}$$ is given by $$pi_{mu} left( t right) left( left( v right) right) = left( tv right)$$, where $$left( cdot right)$$ denotes the equivalence class of an element in $$W_{mu}$$. This representation can be restricted to $$mathfrak{g}$$ (through the inclusion) to give a representation of $$mathfrak{g}$$.

To prove the result, I have tried the following:

Firstly, using the universal property of universal enveloping algebra $$mathfrak{U}_{mathfrak{g}}$$, we get an associative algebra homomorphism $$tilde{sigma}_{mu}: mathfrak{U}_{mathfrak{g}} rightarrow mathfrak{gl} left( W_{mu} right)$$ which satisfies $$tilde{sigma}_{mu} left( 1 right) = I$$ and $$tilde{sigma}_{mu} left( Z right) = sigma{mu} left( Z right)$$, for $$Z in mathfrak{g}$$.

Then, we define $$psi: mathfrak{U}_{mathfrak{g}} rightarrow W_{mu}$$ as

$$psi left( t right) = tilde{sigma}_{mu} left( t right) w_0,$$

where $$w_0$$ is a highest weight vector for the representation $$sigma_{mu}$$ of $$mathfrak{g}$$. Since $$tilde{sigma}_{mu}$$ is an associative algebra homomorphism, $$psi$$ is a linear map between vector spaces. Now, for $$H in mathfrak{h}$$, we see that

$$psi left( H – langle mu, H rangle cdot 1 right) = tilde{sigma}_{mu} left( H – langle mu, H rangle cdot 1 right) w_0 = sigma_{mu} left( H – langle mu, H rangle cdot 1 right) w_0 = 0.$$

Also, for any $$X in mathfrak{g}_{alpha}$$, where $$alpha$$ is a positive root, we have

$$psi left( X right) = tilde{sigma}_{mu} left( x right) w_0 = sigma_{mu} left( X right) w_0 = 0,$$

since $$w_0$$ is a highest weight vector for $$sigma_{mu}$$. That is, we see that $$I_{mu} subseteq ker psi$$. Hence, this map descends to a linear map $$tilde{psi}: W_{mu} = mathfrak{U}_{mathfrak{g}}/I_{mu} rightarrow W_{mu}$$.

Now, I want to prove that $$U_{mu} subseteq ker tilde{psi}$$ so that it can descend to a map $$phi: V_{mu} rightarrow W_{mu}$$. However, I cannot prove it! If we start with any $$v in U_{mu}$$, then it does not have a $$v_0$$-component. We want that $$tilde{psi} left( v right) = 0$$. This would mean that $$tilde{sigma}_{mu} left( v right) w_0 = 0$$. However, I cannot see why this should happen?

Is there something wrong in this attempt? Any help will be appreciated!

## Displaying a “map” with curses and python

I started making a game in curses, but I feel like I am displaying the map inefficiently and ineffectively.

Here’s the code (only the relevant parts):

``````import curses

world_map = (
'00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
'00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
'00000000000000000011111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
'00000000000000011111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
'00000000000111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
'00000000000011111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
'00000000000000111111111111111111110000000000000000000000000000000001111111111111111111111111000000000000000000000000000',
'00000000000000000111111111111111111111000000000000000000000000000001111111111111111111111111000000000000000000000000000',
'00000000000000000011111111111111111000000000000000000000000000000001111133333111111111111111000000000000000000000000000',
'00000000000000000000011111111111100000000000000000000000000000000001111133333111111111111111000000000000000000000000000',
'00000000000000000000000000000000000000000000000000000000000000000001111133333111111111222211000000000000000000000000000',
'00000000000000000000000000000000000000000000000000000000000000000001111133333111111111222211000000000000000000000000000',
'00000000000000000000000000000000000000000000000000000000000000000001111133333111111111222211000000000000000000000000000',
'00000000000000000000000000000000000000000000000000000011111111111111111133333111111111222211000000000000000000000000000',
'00000000000000000000000000000000000000000000000000000011111111111111111133333111111111222211000000000000000000000000000',
'00000000000000000000000000000000000000000000000000000011111111111111111111111111111111222211000000000000000000000000000',
'00000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111000000000000000000000000000',
'00000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111000000000000000000000000000',
'00000000000000001111111111111111111111111000000000000011111111111110000000000000000000000000000000000000000000000000000',
'00000000000000001111111111111111111111111000000000000011111111111110000000000000000000000000000000000000000000000000000',
'00000000000000001114444411111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000',
'00000000000000001114444411111115555555111000000000000000000000000000000000000000000000000000000000000000000000000000000',
'00000000000000001114444411111115555555111000000000000000000000000000000000000000000000000000000000000000000000000000000',
'00000000000000001114444411111115555555111000000000000000000000000000000000000000000000000000000000000000000000000000000',
'00000000000000001111111111111115555555111000000000000000000000000000000000000000000000000000000000000000000000000000000',
'00000000000000001111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000',
'00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
'00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
'00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
'00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000')

def win(stdscr):
curses.init_color(255, 0, 0x64 * 1000 // 0xff, 0)
curses.init_color(254, 0xff * 1000 // 0xff, 0xff * 1000 // 0xff, 0xff * 1000 // 0xff)
curses.init_color(253, 0x82 * 1000 // 0xff, 0x8c * 1000 // 0xff, 0x51 * 1000 // 0xff)
curses.init_color(252, 0xff * 1000 // 0xff, 0xe4 * 1000 // 0xff, 0xb5 * 1000 // 0xff)
curses.init_color(251, 0xc0 * 1000 // 0xff, 0xc0 * 1000 // 0xff, 0xc0 * 1000 // 0xff)

curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLUE)  # water
curses.init_pair(2, curses.COLOR_RED, curses.COLOR_GREEN)  # grass
curses.init_pair(3, curses.COLOR_RED, 255)  # trees
curses.init_pair(4, curses.COLOR_RED, 254)  # mountains
curses.init_pair(5, curses.COLOR_RED, 253)  # swamp
curses.init_pair(6, curses.COLOR_RED, 252)  # desert
curses.init_pair(7, curses.COLOR_RED, 251)  # village

colors = (curses.color_pair(1), curses.color_pair(2), curses.color_pair(3), curses.color_pair(4), curses.color_pair(5), curses.color_pair(6), curses.color_pair(7))

while True:

for i in range(30):
for j in range(119):

stdscr.refresh()

def main():
curses.wrapper(win)

if __name__ == '__main__':
main()

``````

Running this produces this window: Is there a better way I could be doing this?

## sql server – Error in SQL 2018 Custom Map

Good day.
I am trying to create a stored procedure where the MEMBER ID is custom auto-incremented as follows

“AP202170001”
“AP202170002”
“AP202170003”

and so on as it goes by registering data in the affiliate table.

I have the following query that shows me what I want

``````SELECT 'AP' + DATENAME(YEAR,GETDATE())+ CONVERT(VARCHAR(2),MONTH(GETDATE()))+ RIGHT(CAST((POWER(10, 6) +
CAST(ISNULL(MAX(IDAFILIADO), 0) + 1 AS VARCHAR(5))) AS VARCHAR(7)), 6)
`````` But when I run the query again, it throws me the following error message It is not adding the correlative or in which part I am making a mistake, the data type of the IDAFILIADO field is char (13)

## javascript – React / typescript: como usar a key do .map para definir a URL do meu fetch com metodo patch

Estou tentando fazer um patch para uma lista de componentes,onde eu aprovo ou rejeito cada item, estou listando com um map e cada map tem um botão com minha função para fazer o patch porem minha api tem definido cada item com uma URL diferente, e essa URL é condizente com meu ID, que é minha key do map.

``````const AnalystN2: React.FC = () => {
const url = "http://localhost:3001/api";
const p = useAuth();
const (users, setUsers) = useState<any()>(());
const ids = "1001"

useEffect(() => {
fetch(`\${url}/users`)
.then(function (users) {
return users.json();
})
.then(setUsers);
}, ());

const (cards, setCards) = useState<any()>(());

useEffect(() => {
fetch(`\${url}/cards`)
.then(function (cards) {
return cards.json();
})
.then(setCards);
}, (url));

const aprove = () => {

fetch(`\${url}/cards/\${ids}`,{
method: "PATCH",
body: JSON.stringify({

status:"aproved"

}),
})
.then(function(cards) {
return cards.json();
})
.then((data) => console.log(data, 'aaaaaaaaaaaaaaaaaaaaa'));
}

const rejected = ()=>{

fetch(`\${url}/cards/\${ids}`,{
method: "PATCH",
body: JSON.stringify({

status:"rejected"

}),
})
.then(function(cards) {
return cards.json();
})
.then((data) => console.log(data, 'aaaaaaaaaaaaaa'));
}

if (!users.length){
return (
<div>
carregando
</div>
)
}

return (
<>

<button onClick={(e)=> {
p.signOut()
e.preventDefault()
}}>
LogOutt
</button>

{
cards.map((card, cards) => {

return <li key={card.id}>
<h4> status: {card.status} </h4>

<button onClick={(e)=> { aprove()
}} > Aprovar </button>

<button onClick={(e)=> { rejected()
}} > Rejeitar </button>

</li>

})
}
``````

Quando eu “seto” meu “id” com o correspondente, ele faz o que eu necessito, agora gostaria de saber como faço para deixar isso para cada objeto listado no map, aceito criticas quanto ao código, estou querendo aprender.

## 2D side-scroller : how to place structures in a noise generated map?

I’m creating a little terraria-like 2D side-scroller game with TypeScript. The map is generated by a 1D noise which indicates the height of the ground at each block.

I am looking for the best way to implement natural structures, generated at the same time as the terrain (for example houses, trees …), in places that allow it. For example, if a tree is placed on a slope that is too steep, its leaves could interfere with the cliff, which would not be very aesthetic. Another example, houses should appear where there is enough floor space.

One method would be to have a loop that searches for the right places but isn’t there a more optimized way of doing this?