El Fubu

Welcome to a low in KB page (Except for Video Thumbnails)

Removing Javascript 2: The revenge - 2023-06-30 00:00:00

Hello! I’m still alive.

Just 2 years after our first edition of kicking out javascript here we are again, reducing the size and processing time of the website.

Yes, it was pretty light but we can go FURTHER! Also we want this to be viewable by obsolete browsers, of course. New things are not always progress when we can simplify.

The only javascript that I had at this moment was the highlight.min.js, a javascript code in charge of handling code highlights. Some time ago I discovered that Hugo has now included Chroma for syntax highlighting. This is done in compile time and colored with just a CSS file, so… I was up to try it.

Removing Javascript - 2021-06-15 19:39:47

Hello!

Probably nobody cares, but I have removed the share section (twitter + facbeook) because it required to load 300kb for the icons plus random javascripts.

We want this to be light.

On the other hand I have removed the “last posts” from the index. This is because it needed to recompile ALL the posts everytime because this list is always updated. This way… only the last post needs to be compiled!

Pyspark and UDF types problem - 2020-11-02 12:20:05

Hello!

Here is a fast note that might not be obvious. Beware with UDF types in PySpark.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from pyspark.sql.functions import udf
from pyspark.sql.types import IntegerType, FloatType


def very_fun(idk):
    return(22)
    
def floating_fun(idk):
    return(22.0)

df = sqlContext.createDataFrame(
    [
        (1, 'foo'), 
        (2, 'bar'),
    ],
    ['id', 'txt'] 
)
    
funfun_int = udf(very_fun, IntegerType())
funfun_float = udf(very_fun, FloatType())
    
floatingfun_int = udf(floating_fun, IntegerType())
floatingfun_float = udf(floating_fun, FloatType())

df = df.withColumn('funfun_int', funfun_int(df['id']))
df = df.withColumn('funfun_float', funfun_float(df['id']))

df = df.withColumn('floatingfun_int', floatingfun_int(df['id']))
df = df.withColumn('floatingfun_float', floatingfun_float(df['id']))

df.show()

And the result is not very amusing:

Z80 For Loop - 2017-07-05 08:10:27

WHILE - FOR:

We usually use B as counter. The main trick here is that DJNZ decrements the counter in B and then checks, so that you don’t need to do two operations.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
LD C, 5
LD A, 0
LD B, 100

.NEXT2:
push BC
LD B, 10
  
.NEXT:
ADD A, C
DJNZ .NEXT
pop BC
      
DJNZ .NEXT2

SparkR gapply mess - 2017-05-12 08:56:31

Hello,

Do not assume anything. Never. Ever. Specially with SparkR (Apache Spark 2.1.0).

When using the gapply function, maybe you want to return the key to mark the results in a function as follows:

countRows <- function(key, values) {
    df <- data.frame(key=key, nvalues=nrow(values))
    return(df)
}   

count <- gapplyCollect(data, "keyAttribute", countRows)
countRows <- function(key, values) {
    df <- data.frame(key=key, nvalues=nrow(values))
    return(df)
}   
count <- gapplyCollect(data, "keyAttribute", countRows)

SURPRISE. You can’t.

You should get this error:

Error in match.names(clabs, names(xi)): names do not match previous names

Well, that’s weird. Why is this happening?

asMSX bugfix 1: Ifs on .megarom - 2016-09-03 12:49:45

Hello!

Finally some improvements on asMSX. At the start of this project JamQue told me that he had issues using ifs when the “.megarom” clause is active. The issue correction can be seen here in Github.

The problem was that when generating a byte (for example, an LD instruction) it checks if it is able to generate it if the condition established for this level allows it.

Original:

guardar_byte(b)
{
if ((!conditional_level)||(conditional[conditional_level]))
if (type!=MEGAROM)
{
 ...some code...
}
if (type==MEGAROM)
{
 ...some code...
}

The first if will only affect the if(type!=MEGAROM) as it doesn’t provide brackets to define a block, therefore it will get only the next sentence. Also instead of doing if(type==MEGAROM) I just did an else.