Server Bug Fix: Determine the Sharpness of a Word

Original Source Link


The sharpness of a word is the sum of the sharpness of each of its letters, using the following rules:

Sharp letters

  • A, and V each have a sharpness of 1

  • N and Z each have a sharpness of 2

  • M and W each have a sharpness of 3

Dull letters

  • C and U each have a sharpness of -1

  • S has a sharpness of -2

  • O has a sharpness of -3

All other letters have a sharpness of 0.


The word SAUCE has a sharpness of -3 since the A contributes 1, the U and C each contribute -1 and the S contributes -2.

The word MAZE has a sharpness of 6 since the M contributes 3, the Z contributes 2, and the A contributes 1.


Given as input a string containing only uppercase letters*, determine the sharpness of that string.

*If you wish, you may instead take the input as a string containing only lowercase letters. Other common input formats are also acceptable (eg. a list of characters, a list of codepoints, etc.)


This is !

Test Cases

CODE => -4
GOLF => -3
SAUCE => -3
CATS => -2
MOON => -1
NAIL => 3
WAVE => 5
MAZE => 6

Extra test cases (Provided by @Surculose Sputum)


Python 2, 53 bytes

lambda s:sum(3-"MWCUNZS_AVO".find(c)/2*4%7for c in s)

Try it online!

Jelly, 21 bytes


A monadic Link accepting a list of characters which yields an integer.

Try it online!


“CSO“ANM“U“VZX”iⱮ€§ḅ- - Link: list of characters, W
“CSO“ANM“U“VZX”       - list of lists of characters = [['C','S','O'],['A','N','M'],['U'],['V','Z','X']]
                 €    - for each (L in those four lists):
                Ɱ     -   map across (c in W) with:
               i      -     first (1-based) index (of c in L) or 0 if not found
                  §   - sum each resulting list
                    - - literal minus one
                   ḅ  - convert (the list of four sums) from base (-1)

Python 2, 52 bytes

lambda s:sum(3-"MCNSAO_WUZ_V".find(c)*4%7for c in s)

Try it online!

Improvement on @xnor’s answer.

M C N S A O _ W U Z _ V ?  c
0 1 2 3 4 5 6 0 1 2 3 4 6  "...".find mod 7
0 4 1 5 2 6 3 0 4 1 5 2 3  "...".find*4 mod 7
3-1 2-2 1-3 0 3-1 2-2 1 0  (3-"...".find*4 mod 7)

*4 is to map -1 (failed find) onto 0

JavaScript (Node.js),  61  53 bytes

A lookup table based on the ASCII code of each letter.

Takes input as a list of codepoints.


Try it online!


By XOR’ing the ASCII code with 98 and applying a modulo 22, we gather the characters with a non-zero sharpness into the range [0..13]. This results in a lookup table of 14 entries.

If the result of the formula is out of range, we get undefined - 3 | 0, which is 0.

 char. | code | XOR 98 | MOD 22 | sharpness
  'A'  |  65  |   35   |   13   |    +1
  'B'  |  66  |   32   |   10   | 
  'C'  |  67  |   33   |   11   |    -1
  'D'  |  68  |   38   |   16   | 
  'E'  |  69  |   39   |   17   | 
  'F'  |  70  |   36   |   14   | 
  'G'  |  71  |   37   |   15   | 
  'H'  |  72  |   42   |   20   | 
  'I'  |  73  |   43   |   21   | 
  'J'  |  74  |   40   |   18   | 
  'K'  |  75  |   41   |   19   | 
  'L'  |  76  |   46   |    2   | 
  'M'  |  77  |   47   |    3   |    +3
  'N'  |  78  |   44   |    0   |    +2
  'O'  |  79  |   45   |    1   |    -3
  'P'  |  80  |   50   |    6   | 
  'Q'  |  81  |   51   |    7   | 
  'R'  |  82  |   48   |    4   | 
  'S'  |  83  |   49   |    5   |    -2
  'T'  |  84  |   54   |   10   | 
  'U'  |  85  |   55   |   11   |    -1
  'V'  |  86  |   52   |    8   |    +1
  'W'  |  87  |   53   |    9   |    +3
  'X'  |  88  |   58   |   14   | 
  'Y'  |  89  |   59   |   15   | 
  'Z'  |  90  |   56   |   12   |    +2

APL (Dyalog Unicode), 31 bytes

-/1⊥¨4|(↓4 3⍴'ANMCSOVZWU  ')⍳¨⊂

Try it online!

Tacit function.

How it works

-/1⊥¨4|(↓4 3⍴'ANMCSOVZWU  ')⍳¨⊂  ⍝ Input: string S
       (↓4 3⍴'ANMCSOVZWU  ')     ⍝ 'ANM' 'CSO' 'VZW' 'U  '
                            ⍳¨⊂  ⍝ Find the index of each char in S in each of above
                                 ⍝ Index is 1-based, not found gives 4
     4|  ⍝ Modulo 4; convert 4 to 0
  1⊥¨    ⍝ Sum of each row
-/       ⍝ Alternating sum; (ANM score)-(CSO score)+(VZW score)-(U score)

C(GCC) 84 73 72 bytes

-11 bytes thanks to ceilingcat


(note that StackExchange strips some non-printing characters)

Try it online!

APL+WIN, 42 38 bytes.

Prompts for string:

   +/(2/¯3+⍎¨'4562103')['AVNZMWCUS O '⍳⎕]

Try it online! Courtesy of Dyalog Classic


⍎¨'4562103' Split number as a string into individual digits and convert to integers

2/¯3+ Subtract 3 to give the non-zero letter values and double up each value 

['AVNZMWCUS O '⍳⎕] Find the index position of non-zero letters that occur in the input. 
If a letter is not in list it is given an index of length of list + 1

+/ Sum the values corresponding to the indices of non-zero letters in string

Python 2, 62 60 bytes

-2 bytes thanks to @Neil!

lambda w:sum('AVNZMW'.find(c)/2-'CUS_O'.find(c)/2for c in w)

Try it online!

Python 3, 61 bytes

Input is taken as a byte-string $ s $.

lambda s:sum(b''[c-65]-4for c in s)

Try it online!

We use a lookup table, where each element maps to the sharpness of a given letter. Note the -4, to display the negative sharpness.

Retina 0.8.2, 61 60 bytes



Try it online! Link includes test cases. Edit: Saved 1 byte thanks to @mathjunkie. Explanation:


Turn sharp letters into the appropriate number of # (sharp… geddit? any non-word non-magic non-- character would have worked) signs and dull letters into the appropriate number of - (because they have negative sharpness) signs.


Delete other letters and all matching pairs of # and - signs.


Output the number of signs remaining, prefixed by the first one if it’s a -. Since the regex matches a zero-length string, I have to ensure it only matches once.

Javascript (Node.js), 115 bytes

let s=0;for(let b='w'+w,c=a=>Math.ceil(10*3**(4/~'OSCUAVNZMW'.indexOf(a[0])))-4||-1;b=b.slice(1);s+=9>c(b)?c(b):0);

Try it online!

This puts all the characters in a string, ‘OSCUAVNZMW’, and uses a formula to map the character index to the “sharpness” of each letter. The formula is:


Where $f(x)$ is the sharpness, and $x$ is the negative index of the character + 1. Sounds convoluted, but there’s a reason: the index is modified to make Javascript’s string.indexOf() return 0 instead of -1.

This formula does result in 0 instead of -1 for U. However, using Javascript’s || functionality in variable assignment, we can just default zero values to -1 instead.

Also, this is my first code golf, advice appreciated!

Java (JDK), 56 bytes


Try it online!

Javascript (Babel Node), 131 bytes


Try it online!

This is my first code golfing. I hope I’m doing it right.

I’ll be glad to get some js golfing tips (before exploring new golfing languages) and overall golfing tips.

Javascript (ES6), 65 characters


Javascript (ES6), 67 characters


Takes an array of lowercase characters as input.

Stax, 20 19 bytes


Run and debug it

Keg, 42 bytes


Unfortunately, TIO doesn’t have the latest version of the interpreter on its servers, so y’all can’t try it online.

Quite literally, this maps over each character in the input, assigns it a value based on the sharpness table, and sums the stack.

Zsh, 73 bytes

a=(O S CU : AV NZ MW)
for c (${(s[])1})(((x=a[(I)*$c*])&&(r+=x-4)))

Try it online!

Get the last (I)ndex of the glob *$char* (with (I), it is zero if not found). If it is non-zero, add to $r.

Perl 5 -p, 48 bytes


Try it online!

Charcoal, 25 24 bytes


Try it online! Link is to verbose version of code. Edit: Saved 1 byte by porting @ovs’ answer. Explanation:

   S                        Input string
  E                         Map over characters
             ι              Current character
      ⌕                     Find position in
       AVNZMW               Literal string `AVNZMW`
     ÷        ²             Integer divide by literal `2`
    ⁻                       Minus
                      ι     Current character
                ⌕           Find position in
                 UCSSO      Literal string `UCSSO`
               ÷       ²    Integer divide by literal `2`
 Σ                          Take the sum
I                           Cast to string
                            Implicitly print

The halved Find results in one less than the sharpness/dullness, but the other find returns -1 in that case, thus correcting the value.

05AB1E, 39 38 36 34 33 28 bytes


Try it online! or Verify all test cases (as arranged by @sporeball)

-5 thanks to @Kevin


Original: lε.•3и½:∍äaŠ•sk>4%„ݧuyåi(]O
Uncompressed: lε"anm vzw cso u"sk>4%"cosu"yåi(]O

l               | Take the implicit input and lowercase it.
ε               | Map the following to this input to find the sharpness of each letter:
"anm vzw cso u" |   Push the string "anm vzw cso u", representing the sharpness of each
                |   letter. They are arranged in a way such the index of the character
                |   is retrivable via mathematical caluclation.
sk              |   Swap this string, and the mapping item, and find the index of the
                |   item within the big string
>4%             |   Increment the value, and then modulo 4 it in order to find the "raw"
                |   sharpness of the string. The result will be in the range [0, 3]
"cosu"          |   Now comes the part where we determine if the sharpness needs to be
                |   negated or not. First, we push a string containing all letters that
                |   have negative sharpness
yå              |   We now push the letter being mapped, and test to see if it is in the
                |   aforementioned string
i(]             |   If it is in the string, negate the sharpness value. After that,
                |   close the if-statement and the loop
O               | Summate the stack and implicitly output the total sharpness.

05AB1E, 22 bytes


Try it online!

A port of the Jelly answer suggested by @Kevin.

Pyth, 28 bytes

J"MNA CSOWZV U"sm-3%[email protected]#JQ

Try it online!

Ruby, 70 bytes


Try it online! (3 bytes longer because TIO doesn’t suppoort ruby 2.7 _1 syntax)

C (gcc), 88 87 bytes

Saved a byte thanks to ceilingcat!!!


Try it online!

Bash + GNU utilities, 100 $cdots$ 92 91 bytes

sed 's/[AV]/+1/g

Try it online!

Java (OpenJDK 8), 205 bytes

int u(String s){if(s.length()>0){int n=0;switch(s.charAt(0)){case'M':case'W':n++;case'N':case'Z':n++;case'A':case'V':n+=4;case'O':n--;case'S':n--;case'C':case'U':n--;}return n+u(s.substring(1));}return 0;}

Try it online!

T-SQL, 133 bytes

Added some line changes to make it readable

FROM spt_values

Try it online

Add++, 49 bytes


Try it online!

An implementation of xnor’s formula, go upvote that.

How it works

The second line defines the main function which runs the helper function k over ach character in the input, then sums the result.

k works as follows:

D,k,@,"MCNSAO_WUZ_V"$€=12Rz€¦*bM-1+4*7%3$_ ; Monadic function, takes a single character s
					   ;    and returns the sharpness of s
					   ; For example, s = 'C'		 		STACK = ['C']
      "MCNSAO_WUZ_V"			   ; Push this string 			 		STACK = ['C' 'MCNSAO_WUZ_V']
                    $€=			   ; Check each character for equality with s		STACK = [[0 1 0 0 0 0 0 0 0 0 0 0]]
		       12R		   ; Push [1 2 3 4 5 6 7 8 9 10 11 12]			STACK = [[0 1 0 0 0 0 0 0 0 0 0 0] [1 2 3 4 5 6 7 8 9 10 11 12]]
			  z		   ; Zip arrays						STACK = [[[0 1] [1 2] [0 3] [0 4] [0 5] [0 6] [0 7] [0 8] [0 9] [0 10] [0 11] [0 12]]]
			   €¦*		   ; Product of each					STACK = [[0 2 0 0 0 0 0 0 0 0 0 0]]
			      bM	   ; Maximum (call the result r)			STACK = [2]
				-1+4*7%3$_ ; Push 3 - ((r - 1) * 4 % 7)				STACK = [-1]

Perl 5 + -pF, 39 bytes

$+=y/OSUBANMCBVZW/0-62-6/&&[email protected]}{

Try it online!


For each character in the input (stored in @F via -F) we add to $ (defaults to '', implicitly output as the last argument for calls to print, which is triggered as part of -p) the value of $_-3, if we have translated (y/// is a synonym for tr///) any char in $_ (the current char taken from [email protected]) using OSUBANM to 0-6 and CBVZW to 2-6.

SimpleTemplate, 118 bytes

Yes, not short at all. 🙁
My language has absolutely no way what-so-ever of creating an array with keys and values defined, so, everything has to be generated.

{@setA 1,1,2,2,3,3,-1,-1,-2,-3}{@setL"AVNZMWCUSO"}{@eachL}{@setA.[_]A.[__]}{@/}{@eachargv.0}{@incbyA.[_]R}{@/}{@echoR}

This simply outputs the sharpness of the word.


The code above is just a mess! Here’s a readable version:

{@set rates 1,1,2,2,3,3,-1,-1,-2,-3}
{@set letters "AVNZMWCUSO"}
{@each letters as letter key i}
    {@set rates.[letter] rates.[i]}

{@set result 0}

{@each argv.0 as char}
    {@inc by rates.[char] result}
{@echo result}

Should be fairly easy to understand.

The {@inc by rates.[char] result} will increment the result by rates.[char] (similar to result += rates[char] on other languages).

You can try this on
There you have the golfed version, ungolfed and a function implementation (the {@echo result} is replaced with {@return result}).

Tagged : /

Math Genius: Prove or disprove that R is an equivalence relation

Original Source Link

A relation R is defined on Z by xRy if x · y ≥ 0. Prove or disprove the following:

(a) R is reflexive

(b) R is symmetric

(c) R is transitive

(a) If xRx then x*x >= 0 for all x in Z. This is true because (-a)(-a) = a, for all a in Z.

(b) If xRy then we want yRx for all x,y in Z. This is true because ab = ba for all a, b in Z.

(c) Now I am stuck because I know that “If xRy and yRz we want that xRz. This is true because …” but how do I say that multiplication is transitive.

Suppose $x*y ge 0$ and $y*zge 0$.

Case 1: $x < 0$. $x*y ge0 implies $frac 1x x*y le frac 1x *0$ so $y le 0$.

Case 1a: $y < 0$ then $y*z ge 0 implies z le 0$. So $x < 0$ and $zle 0$ so $x*z le 0$. So far so good.

Case 1b: $y = 0$ then $y*z ge 0$ means $y*z=0$ and $z$… could be anything.

If $zle 0$ we would have $x*z le 0$.

But if $z > 0$ we would have $x< 0$ and $z > 0$ so $x*z < 0$ and that fails transitivity.

Counter example:

Let $- 1 R 0$ because $-1*0 ge 0$. And $0 R 1$ because $0*1 ge 0$. But $-1 not R 1$ because $-1*1 < 0$.

So not transitive.

HINT: Is $-1,R,0$? Is $0,R,1$? Is … ?

Tagged : / / /

Code Bug Fix: Randomize Audio Played in HTML

Original Source Link

hoping to get a little help here. I have this HTML code that plays an audio file from a local folder. I want to add a couple more audio files and have it a play a random file from the array. I have been searching a lot and trying different things but I haven’t found anything that works exactly for my application.

Below is the code I am currently using for one audio file which works just fine. I really apologize for sloppy script, HTML is not my specialty and I took this from somewhere else:


   <audio id='music' volume='0.1' autoplay controls>

       <source src="myfile.mp3" type="audio/mpeg">
       Your browser does not support the audio element.    


               var audio = document.getElementById("music");
               audio.volume = 0.4;


I have an idea of what I am trying to do based on what I have found for loading random images, I just cannot figure out how to incorporate the same method into my audio file. I know I am asking for someone to basically write this for me but is there a way to use the method below but for audio in my HTML file?

    <script type="text/javascript">
    ImageArray = new Array();
    ImageArray[0] = 'image1.jpg';
    ImageArray[1] = 'iamge2.jpg';
    ImageArray[2] = 'iamge3.jpg';
    ImageArray[3] = 'iamge4.jpg';

function getRandomImage() {
    var num = Math.floor( Math.random() * 11);
    var img = ImageArray[num];
    document.getElementById("randImage").innerHTML = ('<img src="' + 'images/random/' + img + '" 


I hope I’ve been helpful

<audio id="music" volume="0.1" autoplay controls>

<script type="text/javascript">
    function addAudio() {
        fileArray = ["file1.mp3", "file2.mp3", "file3.mp3"]
        var num = Math.floor(Math.random() * fileArray.length);
        var x = document.getElementById("music");
        x.innerHTML = "";
        x.innerHTML += '<source src="audio/' + fileArray[num] + '" type="audio/mpeg">';; 

Before the browser does something automatically, it requires the user to take some action! My advice is to make the first screen which after interaction calls the next one to start the music. Here I gave you an example.

<!DOCTYPE html>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <div id="screen" onclick="addAudio();secondScreen();" style="position: absolute; top:0px; right: 0px; bottom: 0px; left: 0px;">
        Some Firts Screen (click)

    <audio id="music" volume="1">

    <script type="text/javascript">
        function addAudio() {
            fileArray = ["file1.mp3", "file2.mp3", "file3.mp3"]
            var num = Math.floor(Math.random() * fileArray.length);
            var x = document.getElementById("music");
            x.innerHTML = "";
            x.innerHTML += '<source src="audio/' + fileArray[num] + '" type="audio/mpeg">';


        function secondScreen() {
            document.getElementById("screen").innerHTML = "Second Screen"


This is the exact code that ended up working for me, again this HTML file is loaded in a game server as a loading screen so it wont auto play in a browser unless you do the things mentioned by 54ka above.

<audio id='music' controls autoplay>

  <source src="" type="audio/mpeg">


    function myFunction() {
       fileArray = ["song1.mp3", "song2.mp3", "song3.mp3"];
       var num = Math.floor(Math.random() * fileArray.length);
       var x = document.getElementById("music");
       x.src = fileArray[num]; 

       var audio = document.getElementById("music");
       audio.volume = 0.2;
       audio.autoplay = true;



Tagged : / / /

Server Bug Fix: Regarding CentOS 6.10 to CentOS 7 upgrade

Original Source Link

I have servers in VMWARE, trying to upgrade the OS from CentOS 6.10 to CentOS 7,
1) redhat upgrade tool installed but could not find any proper base url to download the package from online.
2) Tried to upgrade via CentOS 7 iso, but it is failing due to dependency issues. The list is quite large and I am not sure why is it giving this error because I continued to keep this server updated with latest updates from its own repo and still I am getting these errors.

It would be great if any one can help me on this.

The Red Hat upgrade tool is for Red Hat Enterprise Linux and requires a subscription so that you can add the Red Hat repo and install the package from it. You are running
CentOS so this isn’t possible.

As others have stated, it isn’t best practice to upgrade across major versions as things are likely to not work. This is why you are seeing the errors. The reliable method is to install RHEL 7 or RHEL 8 on another machine and then install the software and put the needed configurations in place. This way, you can test everything as you put it in place and make sure that everything is working. This is the best way if it’s a production system.

Tagged : / / /

Ubuntu HowTo: Prevent Nautilus / Nemo from creating .Trash-1000 folder in mounted devices

Original Source Link

Both Nautilus and Nemo create hidden folders called .Trash-1000 in any mounted device, apparently to manage their Trash folder. This is mighty confusing in network drives that are mounted by other users, that may be using other operating systems or programmes that do not recognise this folder as a trash bin.

Moreover, this folder expands with the number of files deleted and can not be erased from Ubuntu:

$ sudo rm -rf ./.Trash-1000
rm: cannot remove './.Trash-1000/files': Directory not empty

To free space in such mounted volumes the .Trash-1000 folder must be deleted from a different system.

Is there any way to prevent Nemo or Nautilus from creating this folder in network drives? I can naturally simply not use them, but they are handy in many situations.

After looking at Nautilus’s source code and Michael Stumpfl’s answer it becomes clear that trash folder creation, is something hard-coded in Nautilus’s source code itself and is part of how libgio works – the library behind file manipulations in Gtk/GNOME applications. Therefore disabling such behavior is currently not possible without recompiling either the file manager itself or altering source code of the library ( which I wouldn’t recommend doing, since other applications rely on it, so changes may affect other applications’ behavior ).

Probably the best solution is to propose a feature request to Nautilus developers and wait until it is fixed. One could also resort to permanent deletion of files via Shift+Delete short cut or using command-line utilities such as mv (move to user’s trash folder on / filesystem) or rm. Otherwise – switch to using different file manager for the time being.

This doesn’t prevent the creation of the .Trash folder but it’s a simple way of dealing with your stated problem.

This may seem overly simple but just use globbing.
As in: rm -rf .Trash-1000/*

the pattern (*) is expanded by the shell and rm will descend into and remove any files and directories whose name matches that pattern. It will not attempt to delete the .Trash-1000 folder but will remove ‘./.Trash-1000/files’. Of course normal permissions apply.


Tagged : / / /

Making Game: Outlook 2013: Can I increase the number of recent “move to folder” folders list?

Original Source Link

Well, as described in the subject, I’d like to have more recent folders in the “move to folder” menu. Can it be achieved?

Can I increase the number of recent “move to folder” in the folders list?

No it is not possible.

There are some alternatives:

The “Move to folder” MRU list is limited to 10 lists, and it can’t be
expanded. We can either use Quick Steps or macros to move emails to
predefined folders.

To use Quick Steps:

To use macros:

Source Making “Move to Folder” List Longer in Outlook 2013

The answer is: Use a different software

The background is:
Its May 2020 and it is still not addressed by Microsoft.
This unbelievable annoying “feature” is still limited to 10 entries and it blocks the way of working big time.
It shows exactly that Microsoft does not care in any way for the paying customer.

Thousands of complaints, years of posting in all microsoft-forums, webpages, social media and absolutely no reaction whatsoever.

We are going to avoid microsofts office in the future – 7000 desktop-pcs. It is just too expensive to work with MS-Office because of the time you loose when using crappy software.

(We have 76 open complaints/feature-requests/bug-reports and not one is addressed)

Tagged : / /

Code Bug Fix: Unresolved reference: method of extended class in Kotlin

Original Source Link

I have a variable in my class that extends BroadcastReceiver and implements one additional method called isNetworkAvailable. When I call the method within the class it works but it results in “Unresolved reference” when called from outside. The preexisting methods of the class are also accessible.

Any ideas?

class MainActivity : AppCompatActivity() {

    private var connectivityReceiver: BroadcastReceiver = object: BroadcastReceiver(){

        override fun onReceive(context: Context, arg1: Intent) {
            if ( isNetworkAvailable([email protected]) ) { // Works just as it's supposed to.
                // ...

        fun isNetworkAvailable(context: Context?): Boolean {
            // ...

    override fun onCreate(savedInstanceState: Bundle?) {
        // ...
        connectivityReceiver.onReceive() // Accessible if arguments are provided 
        connectivityReceiver.isNetworkAvailable([email protected]) // ERROR: Unresolved reference

@Fred answer is correct, it is because compiler don’t know that the BroadcastReceiver has the function called isNetworkAvailable.

Kotlin is strong in type interference, you don’t need to specify explicitly that the variable is of type BroadcastReceiver it tells the compiler that the object is of type BroadcastReceiver which does not have any function called isNetworkAvailable().

Just remove the explicit type declaration from the variable

private var connectivityReceiver = object: BroadcastReceiver() {...}

Kotlin will automatically assign the correct type using its inferred type of anonymous object.

You’re variable connectivityReceiver is of type BroadcastReceiver, which has no method isNetworkAvailable. Unfortunately, it’s not as simple as this because for Kotlin connectivityReceiver is nothing but a BroadcastReceiver.

To make your method available you can create a specific class and not an anonymous object.

class MyBroadcaseReceiver : BroadcastReceiver(){

    override fun onReceive(context: Context, arg1: Intent) {
        if ( isNetworkAvailable([email protected]) ) { // Works just as it's supposed to.
            // ...

    fun isNetworkAvailable(context: Context?): Boolean {
        // ...

Then in the activity just use

private var connectivityReceiver: MyBroadcaseReceiver = MyBroadcaseReceiver()

Note that if you do something like

private var connectivityReceiver: BroadcaseReceiver = MyBroadcaseReceiver()

you’ll end up in the same issue since connectivityReceiver will be a BroadcastReceiver and not the class where isNetworkAvailable is defined.

There’s also the possibility of just removing the explicit type:

private var connectivityReceiver = object: BroadcastReceiver(){

    override fun onReceive(context: Context, arg1: Intent) {
        if ( isNetworkAvailable([email protected]) ) { // Works just as it's supposed to.
            // ...

    fun isNetworkAvailable(context: Context?): Boolean {
        // ...

Kotlin’s inference should be able to pick up the method then. The reason why I think this is not a great approach is because it only works if you want to keep this object expression private – see object expressions

Note that anonymous objects can be used as types only in local and private declarations. If you use an anonymous object as a return type of a public function or the type of a public property, the actual type of that function or property will be the declared supertype of the anonymous object, or Any if you didn’t declare any supertype. Members added in the anonymous object will not be accessible.

Basically means in your case if you remove private the member isNetworkAvailable won’t be accessible anymore. I believe code is meant to change a lot and especially a class like that eventually should go to its own place as it becomes more complex and makes it easier to test. This is of course just a personal opinion.

Tagged : /

Ubuntu HowTo: Docker images exit immediately exit code 126

Original Source Link

I have just installed Ubuntu 20.0 and installed docker using snap. I’m trying to run some different Docker images for hbase and rabbitmq but anytime I startup an image it immediately exists with 126 status

$ sudo docker ps -a
CONTAINER ID        IMAGE               COMMAND               CREATED              STATUS                            PORTS               NAMES
4d58720fce3a        dajobe/hbase        "/opt/hbase-server"   5 seconds ago        Exited (126) 4 seconds ago                            hbase-docker
b7a84731a05b        harisekhon/hbase    "/"      About a minute ago   Exited (126) 59 seconds ago                           optimistic_goldwasser
294b95ef081a        harisekhon/hbase    "/"      About a minute ago   Exited (126) About a minute ago                       goofy_tu

I have tried everything and tried to use docker inspect on the seperate images, but nothing gives away, why the containers exit out immediately. Any suggestions?

Tagged : / /

Math Genius: Transcendence degree of $mathcal{M}(x)$ in $mathbb{C}$, and $mathcal{M}(X)$ is finitely generated over $mathbb{C}$

Original Source Link

I have been reading about Riemann surfaces from Rick Miranda’s Book and now the term transcendent degree has come in to play, but I have no knowledge of field theory so I dont quite understand it I have some intuition behind it but I might be wrong.

So when proving that $mathcal{M}(X)$ has transcendent degree one over $mathbb{C}$ when $X$ is an algebraic curve there a few steps that I don’t completely understand, when he says let $f$ and $g$ be two algebraically independent elements of $mathcal{M}(X)$ do we mean that there is no combination of $g$ with elements of $mathcal{M}(X)$ that can give us $f$? Is that why latter we will have that $dim(L(nD))geq (n^2+3n+2)/2$? New edit : Ok I think I already understood this part because we consider $L(D)$ as vector space over $mathbb{C}$ and that will give us that number.

Now this is still something I dont understand:
Also another thing thats is making me confusion due to my lack of knoweledge of field theory , but the author says that in order to prove that $mathcal{M}(X)$ is finitetely generated extension field of $mathbb{C}$ it suffices to see that $mathcal{M}(X)$ is a finite algebraic extension of $mathbb{C}(f)$, now this is making me a bit of cofusion because if $mathbb{C}(f)$ is isomorphic to $mathbb{C}(t)$,
wouldn’t this have infinite dimension as a vector space over $mathbb{C}$? I am probably confusing definitions because maybe the algebraic extension dimension is not the same one as this but I really don’t know, so any help would be appreciated.

Thanks in advance.

I assume you are asking about Prop. 1.17 on pp.174-176.

The notion of transcendence degree is analogous to dimension. The dimension of a vector space $E$ over a field $F$ is the maximum number of linearly independent elements, where $v_1,ldots,v_n$ are linearly independent if there is no non-trivial linear relation
among them. (If $E$ is an extension field of $F$, then $E$ is a fortiori a vector space over $F$.) Analogously, the transcendence degree of an extension field $E$ of $F$ is the maximum number of algebraically independent elements, where $v_1,ldots,v_n$ are algebraically independent if there is no non-trivial polynomial relation
where $P$ is a non-zero polynomial in $n$ variables. For example, the field
$mathbb{Q}(sqrt{e},pi,sqrt[3]{epi})$ has transcendence degree at most 2 over $mathbb{Q}$, since we have the polynomial relation $x^2y-z^3=0$ when $x=sqrt{e}$, $y=pi$, and $z=sqrt[3]{epi}$. (Also just about everybody believes it has transcendence degree exactly 2, but nobody’s proven that yet.)

If $f$ and $g$ are algebraically independent, then the set of all monomials $f^ig^j$, $i,jgeq0$ is linearly independent, since a non-trivial linear relation among these monomials (with coefficients in $F$) is the same thing as a non-zero polynomial relation between $f$ and $g$. So the monomials belonging to $L(nD)$ are also linearly independent, and since there are more of them (for large $n$) than the bound on the dimension of $L(nD)$, we have a contradiction.

As for your second question, $mathbb{C}(t)$ indeed has infinite dimension over $mathbb{C}$, and so does $mathcal{M}(X)$. But for finite dimension, we need to be able to express all the elements of the extension field linearly in terms of a finite number of basis elements. For finite generation, we allow rational expressions. Precisely, $E=F(v_1,ldots,v_n)$ if for every element $zin E$, there are polynomials (in $n$ variables) $P$, $Q$, with coefficients in $F$, such that
As a famous example, an elliptic function field $mathcal{M}(X)$ is generated by its Weierstrass function and its derivative, $wp$ and $wp’$. There is a cubic equation relating $wp$ and $wp’$, which is why the transcendence degree isn’t 2. Nonetheless, you can’t express either one as a rational function of the other.

Hope this helps.

Tagged : / /

Server Bug Fix: PMTA Timeout Centos 7

Original Source Link

I have an issue with PMTA which not sending any emails from my server and all connections with others are timeout!

Timed out, status = ETIMEDOUT while connecting from subdomain. myserver.tld (My_Server_Ip) to (

I have pinged my server from my computer and its working!

I have pinged from my server and its working!

My server is using VestaPanel as a control panel and I wonder if its firewall might be blocking the connections!

What do you think about this?

Below is my config file :

#smtp-port 25
smtp-listener SERVER_IP:25
<source 0/0>
    log-connections yes
    log-commands    yes      # WARNING: verbose!
  allow-unencrypted-plain-auth yes
sync-msg-create false
sync-msg-update false
run-as-root no
log-file /var/log/pmta/log        # logrotate is used for rotation

<acct-file /var/log/pmta/acct.csv>
#    move-to /opt/myapp/pmta-acct   # configure as fit for your application
#    move-interval 5m

    max-size 50M

# transient errors (soft bounces)
<acct-file /var/log/pmta/diag.csv>
  move-interval 1d
  delete-after never
  records t

# spool directories

spool /var/spool/pmta

http-mgmt-port 1983
http-access admin
http-access 0/0 monitor
http-access SERVER_IP admin


#<spool /var/spool/pmta>
<smtp-user xxxx>
    password xxxxx
    source {smtpuser-auth}
<smtp-user xxxxx>
    password xxxxx
    source {smtpuser-auth}
<source {smtpuser-auth}>
    smtp-service yes
    always-allow-relaying yes
    require-auth true
    process-x-virtual-mta yes
    default-virtual-mta pmta-pool
    remove-received-headers true
    add-received-header false
    hide-message-source true
<virtual-mta pmta-vmta1>
smtp-source-host SERVER_IP subdomain.myserver.tld
domain-key dkim,*,/home/admin/conf/mail/subdomain.myserver.tld/dkim.pem
<domain *>
max-msg-rate 400/h
</virtual-mta> <domain myserver.tld>
route []:25

<virtual-mta-pool pmta-pool>
virtual-mta pmta-vmta1


    always-allow-api-submission yes
    add-message-id-header yes
    retain-x-job yes
    retain-x-virtual-mta yes
    verp-default yes
    process-x-envid yes
    process-x-job yes
    jobid-header X-Mailer-RecptId
    process-x-virtual-mta yes

<domain myserver.tld>
route []:25

Tagged : / / /